[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAM...

noreply at shibboleth.net noreply at shibboleth.net
Fri Jan 31 18:54:46 EST 2014


Author: tzeller
Date: Fri Jan 31 18:54:45 2014
New Revision: 5291

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5291&view=rev
Log:
IDP 219 : The AttributeContext is a child of the RelyingPartyContext, not the ProfileRequestContext.

Modified:
    trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGenerator.java
    trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGeneratorTest.java

Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGenerator.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGenerator.java?rev=5291&r1=5290&r2=5291&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGenerator.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGenerator.java Fri Jan 31 18:54:45 2014
@@ -66,7 +66,7 @@
     @Nonnull private Function<ProfileRequestContext, RelyingPartyContext> relyingPartyContextLookupStrategy;
 
     /** Strategy function to lookup AttributeContext. */
-    @Nonnull private Function<ProfileRequestContext, AttributeContext> attributeContextLookupStrategy;
+    @Nonnull private Function<RelyingPartyContext, AttributeContext> attributeContextLookupStrategy;
     
     /** Attribute(s) to use as an identifier source. */
     @Nonnull @NonnullElements private List<String> attributeSourceIds;
@@ -97,7 +97,7 @@
      * @param strategy lookup function to use
      */
     public synchronized void setAttributeContextLookupStrategy(
-            @Nonnull final Function<ProfileRequestContext, AttributeContext> strategy) {
+            @Nonnull final Function<RelyingPartyContext, AttributeContext> strategy) {
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
         
         attributeContextLookupStrategy = Constraint.isNotNull(strategy,
@@ -132,8 +132,14 @@
             throws ProfileException {
         
         // Check for a natively generated NameIdentifier attribute value.
-
-        final AttributeContext attributeCtx = attributeContextLookupStrategy.apply(profileRequestContext);
+        
+        final RelyingPartyContext rpCtx = relyingPartyContextLookupStrategy.apply(profileRequestContext);
+        if (rpCtx == null) {
+            log.warn("Unable to locate RelyingPartContext.");
+            return null;
+        }
+
+        final AttributeContext attributeCtx = attributeContextLookupStrategy.apply(rpCtx);
         if (attributeCtx == null) {
             log.warn("Unable to locate AttributeContext");
             return null;
@@ -170,8 +176,11 @@
     @Override
     @Nullable protected String getIdentifier(@Nonnull final ProfileRequestContext profileRequestContext)
             throws ProfileException {
-        
-        final AttributeContext attributeCtx = attributeContextLookupStrategy.apply(profileRequestContext);
+
+        // TODO null check rpCtx ?
+        final RelyingPartyContext rpCtx = relyingPartyContextLookupStrategy.apply(profileRequestContext);
+        
+        final AttributeContext attributeCtx = attributeContextLookupStrategy.apply(rpCtx);
         
         final Map<String, IdPAttribute> attributes = attributeCtx.getIdPAttributes();
         for (final String sourceId : attributeSourceIds) {

Modified: trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGeneratorTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGeneratorTest.java?rev=5291&r1=5290&r2=5291&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGeneratorTest.java (original)
+++ trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/nameid/DefaultSAML1NameIdentifierGeneratorTest.java Fri Jan 31 18:54:45 2014
@@ -112,7 +112,8 @@
 
         final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
         inputAttribute.setValues(values);
-        prc.getSubcontext(AttributeContext.class, true).setIdPAttributes(Collections.singleton(inputAttribute));
+        prc.getSubcontext(RelyingPartyContext.class, false).getSubcontext(AttributeContext.class, true)
+                .setIdPAttributes(Collections.singleton(inputAttribute));
 
         generator.setAttributeSourceIds(Collections.singletonList(ATTR_NAME));
         generator.initialize();
@@ -124,7 +125,8 @@
         final Collection<? extends IdPAttributeValue<?>> values = Collections.singletonList(saml1NameIdFor(NAME_1));
         final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
         inputAttribute.setValues(values);

[... 47 lines stripped ...]


More information about the commits mailing list