[java-identity-provider COMMIT] in /trunk: idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUserAge...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Oct 17 11:30:12 EDT 2013
Author: scantor
Date: Thu Oct 17 11:30:11 2013
New Revision: 4870
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4870&view=rev
Log:
Improve address-based login config.
Modified:
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUserAgentAddress.java
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUserAgentAddressTest.java
trunk/idp-conf/src/main/resources/flows/authn/ipaddress-authn-beans.xml
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUserAgentAddress.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUserAgentAddress.java?rev=4870&r1=4869&r2=4870&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUserAgentAddress.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUserAgentAddress.java Thu Oct 17 11:30:11 2013
@@ -18,8 +18,11 @@
package net.shibboleth.idp.authn.impl;
import java.net.InetAddress;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -36,22 +39,16 @@
import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.net.IPRange;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
+import com.google.common.base.Strings;
+import com.google.common.collect.Collections2;
/**
* An action that ensures that a user-agent address found within a {@link UserAgentContext}
@@ -71,68 +68,36 @@
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(ValidateUserAgentAddress.class);
- /** The ID of the subject to treat as authenticated by this action. */
- @NonnullAfterInit @NotEmpty private String principalName;
-
- /** List of designated IP ranges. */
- @Nonnull @NonnullElements private Collection<IPRange> designatedRanges;
+ /** Map of IP ranges to principal names. */
+ @Nonnull @NonnullElements private Map<String,Collection<IPRange>> mappings;
/** User Agent context containing address to evaluate. */
@Nullable private UserAgentContext uaContext;
+ /** The principal name established by the action, if any. */
+ @Nullable private String principalName;
+
/** Constructor. */
public ValidateUserAgentAddress() {
- designatedRanges = Collections.emptyList();
+ mappings = Collections.emptyMap();
}
/**
- * Get the name of the subject to use.
+ * Set the IP range(s) to authenticate as particular principals.
*
- * @return the name of the subject to use
+ * @param newMappings the IP range(s) to authenticate as particular principals
*/
- @NonnullAfterInit @NotEmpty public String getPrincipalName() {
- return principalName;
+ public void setMappings(@Nonnull @NonnullElements Map<String,Collection<IPRange>> newMappings) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ mappings = new HashMap(newMappings.size());
+ for (Map.Entry<String,Collection<IPRange>> e : newMappings.entrySet()) {
+ if (!Strings.isNullOrEmpty(e.getKey())) {
+ mappings.put(e.getKey(), new ArrayList(Collections2.filter(e.getValue(), Predicates.notNull())));
+ }
+ }
}
- /**
- * Set the name to use to identify a successfully evaluated address, by means of a simple username,
- * by attaching a {@link UsernamePrincipal}.
- *
- * @param name the principal name to use
- */
- public void setPrincipalName(@Nonnull @NotEmpty final String name) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- principalName = Constraint.isNotNull(StringSupport.trimOrNull(name), "Principal name cannot be null or empty");
- }
-
- /**
- * Get the IP range(s) to authenticate.
- *
- * @return the IP range(s) to authenticate
- */
[... 162 lines stripped ...]
More information about the commits
mailing list