Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
d9d8af53
Commit
d9d8af53
authored
Apr 05, 2010
by
Srikanth Chikkulapelly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified credential parsing, adding extensions and signing to support the extensions.
parent
6f270600
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
protogeni/lib/GeniCredential.pm.in
protogeni/lib/GeniCredential.pm.in
+21
-17
No files found.
protogeni/lib/GeniCredential.pm.in
View file @
d9d8af53
...
...
@@ -32,7 +32,7 @@ use Time::Local;
use
overload
(
'""'
=>
'Stringify'
);
#
Exported
variables
use
vars
qw
(@
EXPORT_OK
$
LOCALSA_FLAG
$
LOCALCM_FLAG
$
LOCALMA_FLAG
);
use
vars
qw
(@
EXPORT_OK
$
LOCALSA_FLAG
$
LOCALCM_FLAG
$
LOCALMA_FLAG
$
EXTENSIONS_NS
EXTENSIONS_PREFIX
);
#
Configure
variables
my
$
TB
=
"@prefix@"
;
...
...
@@ -46,6 +46,11 @@ my $VERIFYCRED = "$TB/sbin/verifygenicred";
my
$
NFREE
=
"$TB/bin/nfree"
;
my
$
OPENSSL
=
"/usr/bin/openssl"
;
#
Extensions
namespace
URI
.
#
TODO
:
pick
the
right
NS
URI
,
prefix
and
update
here
.
$
EXTENSIONS_NS
=
""
;
$
EXTENSIONS_PREFIX
=
""
;
#
Signing
flags
$
LOCALSA_FLAG
=
1
;
$
LOCALCM_FLAG
=
2
;
...
...
@@ -123,7 +128,7 @@ sub Create($$$)
$
self
->{
'owner_cert'
}
=
$
owner
->
GetCertificate
();
$
self
->{
'string'
}
=
undef
;
$
self
->{
'capabilities'
}
=
undef
;
$
self
->{
'extensions'
}
=
XML
::
LibXML
::
NodeList
->
new
()
;
$
self
->{
'extensions'
}
=
"<extensions></extensions>"
;
$
self
->{
'idx'
}
=
undef
;
#
Only
set
when
stored
to
DB
.
bless
($
self
,
$
class
);
...
...
@@ -177,16 +182,18 @@ sub AddCapability($$$)
}
#
#
Add
an
entension
.
Key
/
Value
pairs
#
sub
AddExtension
($$$)
#
Add
an
extension
.
Each
extension
is
an
xml
element
.
#
If
the
element
is
in
a
different
namespace
it
has
to
be
specified
#
during
element
construction
.
sub
AddExtension
($$)
{
my
($
self
,
$
key
,
$
value
)
=
@
_
;
my
($
self
,
$
elem
)
=
@
_
;
return
-
1
if
(
!ref($self));
my
$
newNode
=
XML
::
LibXML
::
Element
->
new
($
key
);
$
newNode
->
appendText
($
value
);
my
$
root
=
GeniXML
::
Parse
($
self
->{
'extensions'
});
$
root
->
appendChild
($
elem
);
$
self
->{
'extensions'
}
=
GeniXML
::
Serialize
($
root
);
return
0
;
}
...
...
@@ -260,8 +267,11 @@ sub CreateFromSigned($$;$)
my
$
root
=
$
doc
->
documentElement
();
#
Dig
out
the
extensions
my
$
extensions
=
GeniXML
::
FindNodes
(
'//n:extensions/*'
,
$
root
);
#
now
extensions
is
an
xml
element
.
my
($
extensions
)
=
GeniXML
::
FindNodes
(
'//n:extensions'
,
$
root
)->
get_nodelist
;
return
undef
if
(
!defined($extensions));
#
UUID
of
the
credential
.
my
($
uuid_node
)
=
$
doc
->
getElementsByTagName
(
"uuid"
);
return
undef
...
...
@@ -428,13 +438,7 @@ sub Sign($$)
}
$
cap_xml
.=
"</privileges>
\n
"
;
if
($
self
->
extensions
()->
size
()
>
0
)
{
$
cap_xml
.=
"<extensions>
\n
"
;
foreach
my
$
node
($
self
->
extensions
()->
get_nodelist
())
{
$
cap_xml
.=
GeniXML
::
Serialize
($
node
);
}
$
cap_xml
.=
"</extensions>
\n
"
;
}
$
cap_xml
.=
GeniXML
::
Serialize
($
self
->{
'extensions'
});
#
Every
one
gets
a
new
unique
index
,
which
is
used
in
the
xml
:
id
below
.
my
$
idx
=
TBGetUniqueIndex
(
'next_ticket'
,
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment