- header = '<?xml version="1.0" encoding="UTF-8"?>'
- reference = "ref0"
- signature_block = \
- '<signatures>\n' + \
- signature_template + \
- '</signatures>'
- template = header + '\n' + \
- '<signed-credential '
- template += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.geni.net/resources/credential/2/credential.xsd" xsi:schemaLocation="http://www.protogeni.net/resources/credential/ext/policy/1 http://www.protogeni.net/resources/credential/ext/policy/1/policy.xsd"'
- template += '>\n' + \
- '<credential xml:id="%s">\n' + \
- '<type>abac</type>\n' + \
- '<serial/>\n' +\
- '<owner_gid/>\n' + \
- '<owner_urn/>\n' + \
- '<target_gid/>\n' + \
- '<target_urn/>\n' + \
- '<uuid/>\n' + \
- '<expires>%s</expires>' +\
- '<abac>\n' + \
- '<rt0>\n' + \
- '<version>%s</version>\n' + \
- '<head>\n' + \
- '<ABACprincipal><keyid>%s</keyid><mnemonic>%s</mnemonic></ABACprincipal>\n' +\
- '<role>speaks_for_%s</role>\n' + \
- '</head>\n' + \
- '<tail>\n' +\
- '<ABACprincipal><keyid>%s</keyid><mnemonic>%s</mnemonic></ABACprincipal>\n' +\
- '</tail>\n' +\
- '</rt0>\n' + \
- '</abac>\n' + \
- '</credential>\n' + \
- signature_block + \
- '</signed-credential>\n'
-
+ refid = "ref0"
+
+ credential_format = """\
+<?xml version="1.0" encoding="UTF-8"?>
+<signed-credential xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.geni.net/resources/credential/2/credential.xsd" xsi:schemaLocation="http://www.protogeni.net/resources/credential/ext/policy/1 http://www.protogeni.net/resources/credential/ext/policy/1/policy.xsd">
+ <credential xml:id="{refid}">
+ <type>abac</type>
+ <serial/>
+ <owner_gid/>
+ <owner_urn/>
+ <target_gid/>
+ <target_urn/>
+ <uuid/>
+ <expires>{expiration_str}</expires>
+ <abac>
+ <rt0>
+ <version>{version}</version>
+ <head>
+ <ABACprincipal><keyid>{user_keyid}</keyid><mnemonic>{user_urn}</mnemonic></ABACprincipal>
+ <role>speaks_for_{user_keyid}</role>
+ </head>
+ <tail>
+ <ABACprincipal><keyid>{tool_keyid}/keyid><mnemonic>{tool_urn}</mnemonic></ABACprincipal>
+ </tail>
+ </rt0>
+ </abac>
+ </credential>
+ <signatures>""" + signature_format + """\
+ </signatures>
+</signed-credential>\
+"""