Commit 69369c3b authored by Leigh Stoller's avatar Leigh Stoller

Add urn() method to return nonlocal_id, or generate a local urn if not a

nonlocal project/user.
parent f698c8c4
......@@ -49,6 +49,8 @@ my $TBAPPROVAL = "@TBAPPROVALEMAIL@";
my $TBAUDIT = "@TBAUDITEMAIL@";
my $TBBASE = "@TBBASE@";
my $TBWWW = "@TBWWW@";
my $OURDOMAIN = "@OURDOMAIN@";
my $PGENISUPPORT= @PROTOGENI_SUPPORT@;
my $WIKISUPPORT = @WIKISUPPORT@;
my $WITHZFS = @WITHZFS@;
my $WITHAMD = @WITHAMD@;
......@@ -590,6 +592,25 @@ sub GetProjectGroup($)
return $self->{'GROUP'};
}
#
# Generate a URN.
#
sub urn($)
{
my ($self) = @_;
my $pid = $self->pid();
return undef
if (!$PGENISUPPORT);
if ($self->IsNonLocal()) {
return $self->nonlocal_id();
}
require GeniHRN;
my $domain = "${OURDOMAIN}:${pid}";
return GeniHRN::Generate($domain, "project", $pid);
}
#
# Return membership for user in the default group
#
......
......@@ -59,6 +59,7 @@ my $WITHAMD = @WITHAMD@;
my $BOSSNODE = "@BOSSNODE@";
my $CONTROL = "@USERNODE@";
my $OURDOMAIN = "@OURDOMAIN@";
my $PGENISUPPORT = @PROTOGENI_SUPPORT@;
my $MIN_UNIX_UID = @MIN_UNIX_UID@;
my $MIN_UNIX_GID = @MIN_UNIX_GID@;
my $tbacct = "$TB/sbin/tbacct";
......@@ -250,6 +251,24 @@ sub SetTempData($$) {
return 0;
}
#
# Generate a URN.
#
sub urn($)
{
my ($self) = @_;
my $uid = $self->uid();
return undef
if (!$PGENISUPPORT);
require GeniHRN;
my $urn = ($self->IsNonLocal() ? $self->nonlocal_id() :
GeniHRN::Generate($OURDOMAIN, "user", $uid));
return GeniHRN->new($urn);
}
#
# Lookup user given a plain uid. For backwards compat.
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment