[java-identity-provider COMMIT] in /trunk: idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/Saml...

noreply at shibboleth.net noreply at shibboleth.net
Mon Jan 21 06:34:49 EST 2013


Author: rdw
Date: Mon Jan 21 06:34:48 2013
New Revision: 4272

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4272&view=rev
Log:
https://issues.shibboleth.net/jira/browse/IDP-260 Posrt SAML1 scoped Attribute encoder to V3 APIs.

This included adding scoping support (and tests) to SamlEncoderSupport (in idp-saml-api) which in turn meant inlining the ScopedValue providers (from impl) to avoid dependency circularity.

Added:
    trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/attribute/encoding/Saml1ScopedStringAttributeEncoder.java   (with props)
    trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/attribute/encoding/Saml1ScopedStringAttributeEncoderTest.java   (with props)
Modified:
    trunk/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SamlEncoderSupport.java
    trunk/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/SamlEncoderSupportTest.java

Modified: trunk/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SamlEncoderSupport.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SamlEncoderSupport.java?rev=4272&r1=4271&r2=4272&view=diff
==============================================================================
--- trunk/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SamlEncoderSupport.java (original)
+++ trunk/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SamlEncoderSupport.java Mon Jan 21 06:34:48 2013
@@ -22,6 +22,9 @@
 import javax.xml.namespace.QName;
 
 import net.shibboleth.idp.attribute.Attribute;
+import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
+import net.shibboleth.idp.saml.xmlobject.ScopedValue;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.codec.Base64Support;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
@@ -127,4 +130,68 @@
 
         return samlAttributeValue;
     }
+
+    /**
+     * Encode a {@link ScopedStringAttributeValue} value in to an SAML attribute value element using the "attribute"
+     * (Shibboleth) sytnax.
+     * 
+     * @param attribute attribute to be encoded, never null
+     * @param attributeValueElementName the SAML 1 or SAML 1 attribute name
+     * @param value value to encoded
+     * @param scopeAttributeName the name that the attribute will be given
+     * @return a {@link ShibbolethScopedValue}
+     */
+    public static XMLObject encodeScopedStringValueAttribute(@Nonnull final Attribute attribute,
+            @Nonnull final QName attributeValueElementName, @Nullable final ScopedStringAttributeValue value,
+            @Nonnull @NotEmpty final String scopeAttributeName) {
+
+
+        Constraint.isNotNull(attribute, "Attribute can not be null");
+        Constraint.isNotNull(attributeValueElementName, "Attribute Element Name resolution context can not be null");
+        Constraint.isNotNull(scopeAttributeName, "Scope Attribute Name can not be null");
+
+        if (null == value || Strings.isNullOrEmpty(value.getScope()) || Strings.isNullOrEmpty(value.getValue())) {
+            LOG.debug("Skipping empty value (or contents) for attribute {}", attribute.getId());
+            return null;
+        }
+        
+        final XMLObjectBuilder<ScopedValue> scopedValueBuilder =
+                XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(ScopedValue.TYPE_NAME);
+        final ScopedValue scopedValue = scopedValueBuilder.buildObject(attributeValueElementName);
+
+        scopedValue.setScopeAttributeName(scopeAttributeName);
+        scopedValue.setScope(value.getScope());
+        scopedValue.setValue(value.getValue());
+
+        return scopedValue;
+    }
+
+    /**
+     * Encode a {@link ScopedStringAttributeValue} value in to an {@link XSString} SAML attribute value element using
+     * the "inline" syntax.
+     * 
+     * @param attribute attribute to be encoded, never null
+     * @param attributeValueElementName the SAML 1 or SAML 1 attribute name
+     * @param value value to encoded
+     * @param scopeDelimiter the delimiter to put between the value and the scope
+     * @return a {@link ShibbolethScopedValue}
+     */
+    public static XMLObject encodeScopedStringValueInline(@Nonnull final Attribute attribute,
+            @Nonnull final QName attributeValueElementName, @Nullable final ScopedStringAttributeValue value,
+            @Nonnull String scopeDelimiter) {
+
+        Constraint.isNotNull(attribute, "Attribute can not be null");
+        Constraint.isNotNull(attributeValueElementName, "Attribute Element Name resolution context can not be null");
+        Constraint.isNotNull(scopeDelimiter, "Scope delimiter can not be null");
+
+        if (null == value || Strings.isNullOrEmpty(value.getScope()) || Strings.isNullOrEmpty(value.getValue())) {
+            LOG.debug("Skipping empty value (or contents) for attribute {}", attribute.getId());
+            return null;
+        }
+

[... 250 lines stripped ...]


More information about the commits mailing list