Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SFA credential use of strip on refid in issue #890 #894

Merged
merged 2 commits into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

gcf 2.11:
* Remove bogus check for rspec tag (#885)
* Properly remove prefix from signature refid in SFA credentials. (#890)

gcf 2.10:
* Changed references to trac.gpolab.bbn.com to point to Github.
Expand Down
12 changes: 9 additions & 3 deletions src/gcf/sfa/trust/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,26 @@ def set_issuer_gid(self, gid):
self.gid = gid

def decode(self):
# Helper function to pull characters off the front of a string if present
def remove_prefix(text, prefix):
if text and prefix and text.startswith(prefix):
return text[len(prefix):]
return text

try:
doc = parseString(self.xml)
except ExpatError,e:
logger.log_exc ("Failed to parse credential, %s"%self.xml)
raise
sig = doc.getElementsByTagName("Signature")[0]
ref_id = sig.getAttribute("xml:id").strip().strip("Sig_")
ref_id = remove_prefix(sig.getAttribute("xml:id").strip(), "Sig_")
# The xml:id tag is optional, and could be in a
# Reference xml:id or Reference UID sub element instead
if not ref_id or ref_id == '':
reference = sig.getElementsByTagName('Reference')[0]
ref_id = reference.getAttribute('xml:id').strip().strip('Sig_')
ref_id = remove_prefix(reference.getAttribute('xml:id').strip(), 'Sig_')
if not ref_id or ref_id == '':
ref_id = reference.getAttribute('URI').strip().strip('#')
ref_id = remove_prefix(reference.getAttribute('URI').strip(), '#')
self.set_refid(ref_id)
keyinfos = sig.getElementsByTagName("X509Data")
gids = None
Expand Down