[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
Tue Jan 14 12:40:24 EST 2014
Author: rdw
Date: Tue Jan 14 12:40:24 2014
New Revision: 5194
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5194&view=rev
Log:
IDP-310 compile regexp on setting if apposite.
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/SourceValueTest.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=5194&r1=5193&r2=5194&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 Tue Jan 14 12:40:24 2014
@@ -17,8 +17,12 @@
package net.shibboleth.idp.attribute.resolver.impl.ad.mapped;
+import java.util.regex.Pattern;
+
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import com.google.common.base.Objects;
@@ -38,6 +42,9 @@
*/
private final boolean ignoreCase;
+ /** In the regexp case this contains the compiled pattern. */
+ private final Pattern pattern;
+
/**
* Whether partial matches should be allowed.
*/
@@ -54,6 +61,15 @@
value = StringSupport.trimOrNull(theValue);
ignoreCase = theIgnoreCase;
partialMatch = thePartialMatch;
+ if (!partialMatch) {
+ int flags = 0;
+ if (ignoreCase) {
+ flags = Pattern.CASE_INSENSITIVE;
+ }
+ pattern = Pattern.compile(value, flags);
+ } else {
+ pattern = null;
+ }
}
/**
@@ -80,11 +96,22 @@
* @return the value string.
*/
@Nullable public String getValue() {
+ Constraint.isTrue(isPartialMatch(), "getValue is only meaningful for a partialMatch");
return value;
}
+ /**
+ * get the compiled pattern.
+ *
+ * @return Returns the pattern.
+ */
+ @Nonnull public Pattern getPattern() {
+ Constraint.isFalse(isPartialMatch(), "getPattern is only meaningful for a non partial Match");
+ return pattern;
+ }
+
/** {@inheritDoc} */
- public String toString() {
+ @Override public String toString() {
return Objects.toStringHelper(this).add("value", value).add("IsIgnoreCase", isIgnoreCase())
.add("isPartialMatch", isPartialMatch()).toString();
}
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=5194&r1=5193&r2=5194&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 Tue Jan 14 12:40:24 2014
@@ -22,7 +22,6 @@
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;
@@ -65,7 +64,7 @@
/**
* Gets the return value.
- *
+ *
* @return the return value
*/
@Nullable public String getReturnValue() {
@@ -74,7 +73,7 @@
/**
* Sets the return value.
- *
+ *
* @param newReturnValue the return value
*/
public void setReturnValue(@Nonnull @NotEmpty String newReturnValue) {
@@ -84,7 +83,7 @@
/**
* Sets the Source values for the mapping.
- *
+ *
* @param newValues functions used to map an input value to an output value
*/
public synchronized void setSourceValues(@Nullable @NullableElements final Collection<SourceValue> newValues) {
@@ -94,7 +93,7 @@
/**
* Gets the collection of source values.
- *
+ *
* @return the collection of source values
*/
@Nonnull @NonnullElements @Unmodifiable public Collection<SourceValue> getSourceValues() {
@@ -103,11 +102,12 @@
/**
[... 59 lines stripped ...]
More information about the commits
mailing list