[java-identity-provider COMMIT] in /trunk/idp-attribute-resolver-impl/src: main/java/net/shibboleth/idp/attribute/res...
noreply at shibboleth.net
noreply at shibboleth.net
Sun Nov 17 12:48:33 EST 2013
Author: rdw
Date: Sun Nov 17 12:48:33 2013
New Revision: 4951
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4951&view=rev
Log:
IDP-18 use JSON rather than hacky '!' delimiting to code up the transient. Makes for a nicer "getter" experience too.
Added:
trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdParameters.java (with props)
Modified:
trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinition.java
trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinitionTest.java
Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinition.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinition.java?rev=4951&r1=4950&r2=4951&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinition.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinition.java Sun Nov 17 12:48:33 2013
@@ -54,15 +54,6 @@
/** Context label for storage of IDs. */
public static final String CONTEXT = "TransientId";
- /** Delimiter for storage of ID-associated data. */
- public static final String DELIMITER = "!";
-
- /** Index into delimited field storage of relying party identifier. */
- public static final int RELYING_PARTY_ID_INDEX = 0;
-
- /** Index into delimited field storage of principal name. */
- public static final int PRINCIPAL_NAME_INDEX = 1;
-
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(TransientIdAttributeDefinition.class);
@@ -187,7 +178,7 @@
}
return principalName;
}
-
+
/** {@inheritDoc} */
@Nonnull protected IdPAttribute doAttributeDefinitionResolve(@Nonnull AttributeResolutionContext resolutionContext)
throws ResolutionException {
@@ -208,10 +199,13 @@
final IdPAttribute result = new IdPAttribute(getId());
- StringBuilder principalTokenIdBuilder = new StringBuilder();
- principalTokenIdBuilder.append(attributeRecipientID).append("!").append(principalName);
- String principalTokenId = principalTokenIdBuilder.toString();
-
+ final String principalTokenId;
+ try {
+ principalTokenId = new TransientIdParameters(attributeRecipientID, principalName).encode();
+ } catch (IOException except) {
+ throw new ResolutionException(except);
+ }
+
// This code used to store the entries keyed by the ID *and* the value, which I think
// was used to prevent generation of multiple IDs if the resolver runs multiple times.
// This is the source of the current V2 bug that causes the same transient to be reused
Modified: trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinitionTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinitionTest.java?rev=4951&r1=4950&r2=4951&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinitionTest.java (original)
+++ trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/TransientIdAttributeDefinitionTest.java Sun Nov 17 12:48:33 2013
@@ -81,13 +81,12 @@
Assert.assertNotNull(record);
Assert.assertTrue(val.length() >= defn.getIdSize());
+
+ TransientIdParameters parms = new TransientIdParameters(record.getValue());
- String[] fields = record.getValue().split(TransientIdAttributeDefinition.DELIMITER);
-
- Assert.assertNotNull(fields);
- Assert.assertEquals(fields.length, 2);
- Assert.assertEquals(fields[TransientIdAttributeDefinition.RELYING_PARTY_ID_INDEX], TestSources.SP_ENTITY_ID);
- Assert.assertEquals(fields[TransientIdAttributeDefinition.PRINCIPAL_NAME_INDEX], TestSources.PRINCIPAL_ID);
+ Assert.assertNotNull(parms);
+ Assert.assertEquals(parms.getAttributeRecipient(), TestSources.SP_ENTITY_ID);
+ Assert.assertEquals(parms.getPrincipal(), TestSources.PRINCIPAL_ID);
defn.destroy();
store.destroy();
More information about the commits
mailing list