[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl...
noreply at shibboleth.net
noreply at shibboleth.net
Sun Jan 18 14:26:48 EST 2015
Author: scantor
Date: Sun Jan 18 14:26:48 2015
New Revision: 7256
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7256&view=rev
Log:
IDP-573 - trim source values and prevent all-whitespace
Modified:
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/SAML1NameIdentifierAttributeDefinition.java
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/SAML2NameIDAttributeDefinition.java
Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/SAML1NameIdentifierAttributeDefinition.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/SAML1NameIdentifierAttributeDefinition.java?rev=7256&r1=7255&r2=7256&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/SAML1NameIdentifierAttributeDefinition.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/SAML1NameIdentifierAttributeDefinition.java Sun Jan 18 14:26:48 2015
@@ -17,6 +17,7 @@
package net.shibboleth.idp.saml.attribute.resolver.impl;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -32,6 +33,7 @@
import net.shibboleth.idp.attribute.resolver.ResolutionException;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -41,13 +43,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Lists;
-
/**
- * An attribute definition the creates attributes whose values are {@link NameIdentifier}. <br/>
- * When building the NameIdentifier the textual content of the NameIdentifier is the value of the source attribute. If a
- * {@link #nameIdQualifier} is provided that value is used as the NameIdentifier's name qualifier otherwise the
- * attribute issuer's entity ID is used.
+ * An attribute definition the creates attributes whose values are {@link NameIdentifier}.
+ *
+ * <p>When building the NameIdentifier the textual content of the NameIdentifier is the value of the source attribute.
+ * If a {@link #nameIdQualifier} is provided that value is used as the NameIdentifier's NameQualifier otherwise the
+ * attribute issuer's entity ID is used.</p>
*/
public class SAML1NameIdentifierAttributeDefinition extends AbstractAttributeDefinition {
@@ -123,7 +124,7 @@
* @return the constructed NameIdentifier
* @throws ResolutionException if the IdP Name is empty.
*/
- protected NameIdentifier buildNameId(@Nonnull final String nameIdValue,
+ protected NameIdentifier buildNameId(@Nonnull @NotEmpty final String nameIdValue,
@Nonnull final AttributeResolutionContext resolutionContext) throws ResolutionException {
log.debug("{} building a SAML1 NameIdentifier with value of '{}'", getLogPrefix(), nameIdValue);
@@ -163,12 +164,16 @@
@Nonnull final AttributeResolutionContext resolutionContext) throws ResolutionException {
if (theValue instanceof StringAttributeValue) {
- final StringAttributeValue value = (StringAttributeValue) theValue;
- final NameIdentifier nid = buildNameId(value.getValue(), resolutionContext);
+ final String value = StringSupport.trimOrNull(((StringAttributeValue) theValue).getValue());
+ if (value == null) {
+ log.warn("{} Value was all whitespace", getLogPrefix());
+ return null;
+ }
+ final NameIdentifier nid = buildNameId(value, resolutionContext);
final XMLObjectAttributeValue val = new XMLObjectAttributeValue(nid);
return val;
}
- log.warn("{} Value {} is not a string", getLogPrefix(), theValue.toString());
+ log.warn("{} Unsupported value type: {}", getLogPrefix(), theValue.getClass().getName());
return null;
}
@@ -186,7 +191,6 @@
inputValues = PluginDependencySupport.getMergedAttributeValues(workContext, getDependencies());
if (null != inputValues && !inputValues.isEmpty()) {
-
if (1 == inputValues.size()) {
final IdPAttributeValue<?> val = encodeOneValue(inputValues.iterator().next(), resolutionContext);
if (null != val) {
@@ -195,7 +199,7 @@
} else {
// TODO(rdw) Fix typing
// Intermediate to solve typing issues.
- final List<XMLObjectAttributeValue> xmlVals = Lists.newArrayListWithExpectedSize(inputValues.size());
+ final List<XMLObjectAttributeValue> xmlVals = new ArrayList<>(inputValues.size());
[... 74 lines stripped ...]
More information about the commits
mailing list