[java-identity-provider] branch master updated: IDP-1543 - Change in behavior for scoped values when encodeType enabled

Scott Cantor cantor.2 at osu.edu
Wed Feb 5 18:58:40 EST 2020


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=2643d8d3b97335744eb66b352340b82f19892639

The following commit(s) were added to refs/heads/master by this push:
       new  2643d8d   IDP-1543 - Change in behavior for scoped values when encodeType enabled
2643d8d is described below

commit 2643d8d3b97335744eb66b352340b82f19892639
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Feb 5 18:58:34 2020 -0500

    IDP-1543 - Change in behavior for scoped values when encodeType enabled
    
    https://issues.shibboleth.net/jira/browse/IDP-1543
    
    Adjust default when not inlining Scope.
    Bake in appropriate defaults into default rules.
---
 idp-conf/src/main/resources/conf/attributes/default-rules.xml        | 4 ++++
 .../transcoding/impl/SAML1ScopedStringAttributeTranscoder.java       | 4 ++--
 .../transcoding/impl/SAML2ScopedStringAttributeTranscoder.java       | 4 ++--
 .../transcoding/impl/SAML1ScopedStringAttributeTranscoderTest.java   | 5 +++--
 .../transcoding/impl/SAML2ScopedStringAttributeTranscoderTest.java   | 4 +++-
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/idp-conf/src/main/resources/conf/attributes/default-rules.xml b/idp-conf/src/main/resources/conf/attributes/default-rules.xml
index b6289fe..cbf03e1 100644
--- a/idp-conf/src/main/resources/conf/attributes/default-rules.xml
+++ b/idp-conf/src/main/resources/conf/attributes/default-rules.xml
@@ -653,6 +653,7 @@
                     <prop key="transcoder">SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder CASScopedStringTranscoder</prop>
                     <prop key="saml2.name">urn:oid:1.3.6.1.4.1.5923.1.1.1.6</prop>
                     <prop key="saml1.name">urn:mace:dir:attribute-def:eduPersonPrincipalName</prop>
+                    <prop key="saml1.encodeType">false</prop>
                     <prop key="displayName.en">Principal Name</prop>
                     <prop key="displayName.de">Persönliche ID</prop>
                     <prop key="displayName.fr">Principal Name</prop>
@@ -675,6 +676,7 @@
                     <prop key="transcoder">SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder CASScopedStringTranscoder</prop>
                     <prop key="saml2.name">urn:oid:1.3.6.1.4.1.5923.1.1.1.12</prop>
                     <prop key="saml1.name">urn:oid:1.3.6.1.4.1.5923.1.1.1.12</prop>
+                    <prop key="saml1.encodeType">false</prop>
                     <prop key="displayName.en">Prior Principal Name</prop>
                     <prop key="description.en">eduPersonPrincipalName value that was previously associated with the entry.</prop>
                 </props>
@@ -688,6 +690,7 @@
                     <prop key="transcoder">SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder CASScopedStringTranscoder</prop>
                     <prop key="saml2.name">urn:oid:1.3.6.1.4.1.5923.1.1.1.9</prop>
                     <prop key="saml1.name">urn:mace:dir:attribute-def:eduPersonScopedAffiliation</prop>
+                    <prop key="saml1.encodeType">false</prop>
                     <prop key="displayName.en">Scoped Affiliation</prop>
                     <prop key="displayName.de">Zugehörigkeit</prop>
                     <prop key="displayName.fr">Affiliation</prop>
@@ -733,6 +736,7 @@
                     <prop key="transcoder">SAML2ScopedStringTranscoder SAML1ScopedStringTranscoder CASScopedStringTranscoder</prop>
                     <prop key="saml2.name">urn:oid:1.3.6.1.4.1.5923.1.1.1.13</prop>
                     <prop key="saml1.name">urn:oid:1.3.6.1.4.1.5923.1.1.1.13</prop>
+                    <prop key="saml1.encodeType">false</prop>
                     <prop key="displayName.en">Unique ID</prop>
                     <prop key="displayName.de">Eindeutige ID</prop>
                     <prop key="displayName.fr">ID unique</prop>
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoder.java
index 656fd61..e4ce6ff 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoder.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoder.java
@@ -67,15 +67,15 @@ public class SAML1ScopedStringAttributeTranscoder extends AbstractSAML1Attribute
             @Nonnull final IdPAttribute attribute, @Nonnull final TranscodingRule rule,
             @Nonnull final ScopedStringAttributeValue value) throws AttributeEncodingException {
                 
-        final Boolean encodeType = rule.getOrDefault(PROP_ENCODE_TYPE, Boolean.class, Boolean.TRUE);
-
         final String scopeType = rule.getOrDefault(PROP_SCOPE_TYPE, String.class, "attribute");
         
         if ("attribute".equals(scopeType)) {
+            final Boolean encodeType = rule.getOrDefault(PROP_ENCODE_TYPE, Boolean.class, Boolean.FALSE);
             final String scopeAttributeName = rule.getOrDefault(PROP_SCOPE_ATTR_NAME, String.class, "Scope");
             return SAMLEncoderSupport.encodeScopedStringValueAttribute(attribute,
                     AttributeValue.DEFAULT_ELEMENT_NAME, value, scopeAttributeName, encodeType);
         } else if ("inline".equals(scopeType)) {
+            final Boolean encodeType = rule.getOrDefault(PROP_ENCODE_TYPE, Boolean.class, Boolean.TRUE);
             final String scopeDelimiter = rule.getOrDefault(PROP_SCOPE_DELIMITER, String.class, "@");
             return SAMLEncoderSupport.encodeScopedStringValueInline(
                     attribute, AttributeValue.DEFAULT_ELEMENT_NAME, value, scopeDelimiter, encodeType);
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoder.java
index 3d8f72d..9be904b 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoder.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoder.java
@@ -67,15 +67,15 @@ public class SAML2ScopedStringAttributeTranscoder extends AbstractSAML2Attribute
             @Nonnull final IdPAttribute attribute, @Nonnull final TranscodingRule rule,
             @Nonnull final ScopedStringAttributeValue value) throws AttributeEncodingException {
                 
-        final Boolean encodeType = rule.getOrDefault(PROP_ENCODE_TYPE, Boolean.class, Boolean.TRUE);
-
         final String scopeType = rule.getOrDefault(PROP_SCOPE_TYPE, String.class, "inline");
         
         if ("attribute".equals(scopeType)) {
+            final Boolean encodeType = rule.getOrDefault(PROP_ENCODE_TYPE, Boolean.class, Boolean.FALSE);
             final String scopeAttributeName = rule.getOrDefault(PROP_SCOPE_ATTR_NAME, String.class, "Scope");
             return SAMLEncoderSupport.encodeScopedStringValueAttribute(attribute,
                     AttributeValue.DEFAULT_ELEMENT_NAME, value, scopeAttributeName, encodeType);
         } else if ("inline".equals(scopeType)) {
+            final Boolean encodeType = rule.getOrDefault(PROP_ENCODE_TYPE, Boolean.class, Boolean.TRUE);
             final String scopeDelimiter = rule.getOrDefault(PROP_SCOPE_DELIMITER, String.class, "@");
             return SAMLEncoderSupport.encodeScopedStringValueInline(
                     attribute, AttributeValue.DEFAULT_ELEMENT_NAME, value, scopeDelimiter, encodeType);
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoderTest.java
index 8d02070..bb93fec 100644
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoderTest.java
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1ScopedStringAttributeTranscoderTest.java
@@ -103,7 +103,6 @@ public class SAML1ScopedStringAttributeTranscoderTest extends OpenSAMLInitBaseTe
         final Map<String,Object> ruleset1 = new HashMap<>();
         ruleset1.put(AttributeTranscoderRegistry.PROP_ID, ATTR_NAME);
         ruleset1.put(AttributeTranscoderRegistry.PROP_TRANSCODER, transcoder);
-        ruleset1.put(SAML1AttributeTranscoder.PROP_ENCODE_TYPE, true);
         ruleset1.put(SAML1AttributeTranscoder.PROP_NAME, ATTR_NAME);
         ruleset1.put(SAML1AttributeTranscoder.PROP_NAMESPACE, ATTR_NAMESPACE);
         ruleset1.put(SAML1ScopedStringAttributeTranscoder.PROP_SCOPE_DELIMITER, DELIMITER);
@@ -219,7 +218,9 @@ public class SAML1ScopedStringAttributeTranscoderTest extends OpenSAMLInitBaseTe
         Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
                 "Attribute Value not inside <AttributeValue/>");
 
-        Assert.assertTrue(child instanceof ScopedValue, "Child of result attribute should be a string");
+        Assert.assertTrue(child instanceof ScopedValue, "Child of result attribute should be a ScopedValue");
+        // xsi:type should be absent because encodeType should default off for attribute-syntax scope
+        Assert.assertNull(child.getSchemaType(), "xsi:type was set");
 
         final ScopedValue childAsScopedValue = (ScopedValue) child;
 
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoderTest.java
index 40c2eb8..acd5cc1 100644
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoderTest.java
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2ScopedStringAttributeTranscoderTest.java
@@ -97,7 +97,6 @@ public class SAML2ScopedStringAttributeTranscoderTest extends OpenSAMLInitBaseTe
         final Map<String,Object> ruleset1 = new HashMap<>();
         ruleset1.put(AttributeTranscoderRegistry.PROP_ID, ATTR_NAME);
         ruleset1.put(AttributeTranscoderRegistry.PROP_TRANSCODER, transcoder);
-        ruleset1.put(SAML2AttributeTranscoder.PROP_ENCODE_TYPE, true);
         ruleset1.put(SAML2AttributeTranscoder.PROP_NAME, ATTR_NAME);
         ruleset1.put(SAML2AttributeTranscoder.PROP_NAME_FORMAT, ATTR_NAMEFORMAT);
         ruleset1.put(SAML2AttributeTranscoder.PROP_FRIENDLY_NAME, ATTR_FRIENDLYNAME);
@@ -224,6 +223,9 @@ public class SAML2ScopedStringAttributeTranscoderTest extends OpenSAMLInitBaseTe
 
         Assert.assertTrue(child instanceof XSString, "Child of result attribute should be a string");
 
+        // xsi:type should be present because encodeType should default on for inline-syntax scope
+        Assert.assertEquals(child.getSchemaType(), XSString.TYPE_NAME, "xsi:type was wrong");
+
         final XSString childAsString = (XSString) child;
 
         Assert.assertEquals(childAsString.getValue(), STRING_1 + DELIMITER + SCOPE_1);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list