[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/saml1/profile/impl/Add...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Aug 10 15:27:21 EDT 2015
Author: scantor
Date: Mon Aug 10 15:27:21 2015
New Revision: 7670
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7670&view=rev
Log:
IDP-785 - Behavior with multiple attribute-encoders on an attribute inconsistent with v2
Modified:
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java
trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertionTest.java
trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertionTest.java
Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java?rev=7670&r1=7669&r2=7670&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java Mon Aug 10 15:27:21 2015
@@ -35,6 +35,7 @@
import net.shibboleth.idp.saml.attribute.encoding.SAML1AttributeEncoder;
import net.shibboleth.idp.saml.profile.impl.BaseAddAttributeStatementToAssertion;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -138,10 +139,7 @@
final ArrayList<Attribute> encodedAttributes = new ArrayList<>(attributes.size());
for (final IdPAttribute attribute : Collections2.filter(attributes, Predicates.notNull())) {
- final Attribute encodedAttribute = encodeAttribute(profileRequestContext, attribute);
- if (encodedAttribute != null) {
- encodedAttributes.add(encodedAttribute);
- }
+ encodeAttribute(profileRequestContext, attribute, encodedAttributes);
}
if (encodedAttributes.isEmpty()) {
@@ -159,32 +157,36 @@
}
/**
- * Encodes a {@link IdPAttribute} into a {@link Attribute} if a proper encoder is available.
+ * Encodes a {@link IdPAttribute} into zero or more {@link Attribute} objects if a proper encoder is available.
*
* @param profileRequestContext current profile request context
* @param attribute the attribute to be encoded
- *
- * @return the encoded attribute, or null if the attribute could not be encoded
+ * @param results collection to add the encoded SAML attributes to
+ *
* @throws AttributeEncodingException thrown if there is a problem encoding an attribute
*/
- @Nullable private Attribute encodeAttribute(@Nonnull final ProfileRequestContext profileRequestContext,
- @Nonnull final IdPAttribute attribute) throws AttributeEncodingException {
+ private void encodeAttribute(@Nonnull final ProfileRequestContext profileRequestContext,
+ @Nonnull final IdPAttribute attribute, @Nonnull @NonnullElements final Collection<Attribute> results)
+ throws AttributeEncodingException {
log.debug("{} Attempting to encode attribute {} as a SAML 1 Attribute", getLogPrefix(), attribute.getId());
final Set<AttributeEncoder<?>> encoders = attribute.getEncoders();
if (encoders.isEmpty()) {
log.debug("{} Attribute {} does not have any encoders, nothing to do", getLogPrefix(), attribute.getId());
- return null;
- }
-
+ return;
+ }
+
+ boolean added = false;
+
for (final AttributeEncoder<?> encoder : encoders) {
if (SAMLConstants.SAML11P_NS.equals(encoder.getProtocol())
&& encoder instanceof SAML1AttributeEncoder
&& encoder.getActivationCondition().apply(profileRequestContext)) {
log.debug("{} Encoding attribute {} as a SAML 1 Attribute", getLogPrefix(), attribute.getId());
try {
- return (Attribute) encoder.encode(attribute);
+ added = true;
+ results.add((Attribute) encoder.encode(attribute));
} catch (final AttributeEncodingException e) {
if (isIgnoringUnencodableAttributes()) {
log.debug("{} Unable to encode attribute {} as SAML 1 attribute", getLogPrefix(),
@@ -196,9 +198,11 @@
}
}
- log.debug("{} Attribute {} did not have a usable SAML 1 Attribute encoder associated with it, nothing to do",
[... 231 lines stripped ...]
More information about the commits
mailing list