[java-identity-provider COMMIT] in /trunk: idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractUsernamePassw...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Feb 18 21:40:01 EST 2016
Author: scantor
Date: Thu Feb 18 21:40:00 2016
New Revision: 8096
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8096&view=rev
Log:
IDP-914 - Validate usernames based on regex
https://issues.shibboleth.net/jira/browse/IDP-914
Add matchExpression feature to the username-based validation actions.
Modified:
trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractUsernamePasswordValidationAction.java
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstJAASTest.java
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java
trunk/idp-conf/src/main/resources/conf/authn/external-authn-config.xml
trunk/idp-conf/src/main/resources/conf/authn/password-authn-config.xml
trunk/idp-conf/src/main/resources/conf/authn/remoteuser-authn-config.xml
trunk/idp-conf/src/main/resources/conf/authn/spnego-authn-config.xml
trunk/idp-conf/src/main/resources/system/flows/authn/external-authn-beans.xml
trunk/idp-conf/src/main/resources/system/flows/authn/password-authn-beans.xml
trunk/idp-conf/src/main/resources/system/flows/authn/remoteuser-authn-beans.xml
trunk/idp-conf/src/main/resources/system/flows/authn/spnego-authn-beans.xml
Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractUsernamePasswordValidationAction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractUsernamePasswordValidationAction.java?rev=8096&r1=8095&r2=8096&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractUsernamePasswordValidationAction.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractUsernamePasswordValidationAction.java Thu Feb 18 21:40:00 2016
@@ -16,6 +16,8 @@
*/
package net.shibboleth.idp.authn;
+
+import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -53,6 +55,9 @@
/** Whether to save the password in the Java Subject's private credentials. */
private boolean savePasswordToCredentialSet;
+ /** A regular expression to apply for acceptance testing. */
+ @Nullable private Pattern matchExpression;
+
/** UsernamePasswordContext containing the credentials to validate. */
@Nullable private UsernamePasswordContext upContext;
@@ -74,6 +79,17 @@
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
savePasswordToCredentialSet = flag;
+ }
+
+ /**
+ * Set a matching expression to apply to the username for acceptance.
+ *
+ * @param expression a matching expression
+ */
+ public void setMatchExpression(@Nullable final Pattern expression) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ matchExpression = expression;
}
/**
@@ -110,6 +126,13 @@
return false;
}
+ if (matchExpression != null && !matchExpression.matcher(upContext.getUsername()).matches()) {
+ log.debug("{} Username '{}' did not match expression", getLogPrefix(), upContext.getUsername());
+ handleError(profileRequestContext, authenticationContext, "InvalidCredentials",
+ AuthnEventIds.INVALID_CREDENTIALS);
+ return false;
+ }
+
return true;
}
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java?rev=8096&r1=8095&r2=8096&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java Thu Feb 18 21:40:00 2016
@@ -18,6 +18,8 @@
package net.shibboleth.idp.authn.impl;
import java.util.Collections;
+import java.util.Set;
+import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -28,6 +30,7 @@
import net.shibboleth.idp.authn.context.AuthenticationContext;
import net.shibboleth.idp.authn.context.ExternalAuthenticationContext;
import net.shibboleth.idp.authn.principal.UsernamePrincipal;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
import org.opensaml.profile.action.ActionSupport;
import org.opensaml.profile.action.EventIds;
@@ -57,8 +60,22 @@
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(ValidateExternalAuthentication.class);
[... 686 lines stripped ...]
More information about the commits
mailing list