[java-identity-provider COMMIT] in /trunk/idp-attribute-resolver-impl/src: main/java/net/shibboleth/idp/attribute/res...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Apr 22 11:32:04 EDT 2013
Author: rdw
Date: Mon Apr 22 11:32:04 2013
New Revision: 4418
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4418&view=rev
Log:
IDP-7 Annotations, tests and constraints.
Modified:
trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/SourceValue.java
trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/ValueMap.java
trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/MappedAttributeTest.java
Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/SourceValue.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/SourceValue.java?rev=4418&r1=4417&r2=4418&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/SourceValue.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/SourceValue.java Mon Apr 22 11:32:04 2013
@@ -16,6 +16,8 @@
*/
package net.shibboleth.idp.attribute.resolver.impl.ad.mapped;
+
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
import com.google.common.base.Objects;
@@ -47,7 +49,7 @@
* @param thePartialMatch whether partial matches should be allowed
*/
public SourceValue(String theValue, boolean theIgnoreCase, boolean thePartialMatch) {
- value = theValue;
+ value = StringSupport.trimOrNull(theValue);
ignoreCase = theIgnoreCase;
partialMatch = thePartialMatch;
}
Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/ValueMap.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/ValueMap.java?rev=4418&r1=4417&r2=4418&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/ValueMap.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/ad/mapped/ValueMap.java Mon Apr 22 11:32:04 2013
@@ -18,16 +18,21 @@
package net.shibboleth.idp.attribute.resolver.impl.ad.mapped;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.shibboleth.idp.attribute.StringAttributeValue;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +46,7 @@
* Performs many to one mapping of source values to a return value. SourceValue strings may include regular expressions
* and the ReturnValue may include back references to capturing groups as supported by {@link java.util.regex.Pattern}.
*/
-public class ValueMap implements Function<String, Set<StringAttributeValue>>{
+public class ValueMap implements Function<String, Set<StringAttributeValue>> {
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(ValueMap.class);
@@ -50,7 +55,7 @@
private String returnValue;
/** Source values. */
- private Collection<SourceValue> sourceValues;
+ @Nonnull @NonnullElements private Collection<SourceValue> sourceValues = Collections.EMPTY_SET;
/** Constructor. */
public ValueMap() {
@@ -71,10 +76,11 @@
*
* @param newReturnValue the return value
*/
- public void setReturnValue(String newReturnValue) {
- returnValue = newReturnValue;
+ public void setReturnValue(@Nonnull String newReturnValue) {
+ returnValue =
+ Constraint.isNotNull(StringSupport.trimOrNull(newReturnValue), "ReturnValue must be non null or empty");
}
-
+
/**
* Sets the Source values for the mapping.
*
@@ -84,7 +90,6 @@
sourceValues = ImmutableSet.copyOf(Iterables.filter(newValues, Predicates.notNull()));
}
-
/**
* Gets the collection of source values.
@@ -114,7 +119,7 @@
log.debug("Performing partial match comparison.");
if (attributeValue.contains(sourceValue.getValue())) {
[... 22 lines stripped ...]
More information about the commits
mailing list