[java-identity-provider COMMIT] in /trunk/idp-authn-impl/src: main/java/net/shibboleth/idp/authn/impl/ExtractUsername...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Jul 29 22:54:13 EDT 2013
Author: scantor
Date: Mon Jul 29 22:54:13 2013
New Revision: 4630
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4630&view=rev
Log:
IDP-228: extract credentials from form submission
Added:
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequestTest.java (with props)
Modified:
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequest.java
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequest.java?rev=4630&r1=4629&r2=4630&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequest.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequest.java Mon Jul 29 22:54:13 2013
@@ -20,56 +20,113 @@
import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletRequest;
-import net.shibboleth.ext.spring.webflow.Event;
-import net.shibboleth.ext.spring.webflow.Events;
import net.shibboleth.idp.authn.AbstractAuthenticationAction;
import net.shibboleth.idp.authn.AuthenticationException;
import net.shibboleth.idp.authn.AuthnEventIds;
import net.shibboleth.idp.authn.context.AuthenticationContext;
import net.shibboleth.idp.authn.context.UsernamePasswordContext;
-import net.shibboleth.idp.profile.ActionSupport;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
-import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.action.ActionSupport;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.webflow.execution.RequestContext;
/**
- * A stage that extracts a username/password from the request. This stage is expected to be used in conjunction with
- * {@link DisplayUsernamePasswordPage} but will work with any stage that properly passes in the username and password.
+ * An action that extracts a username and password from an HTTP form body or query string,
+ * creates a {@link UsernamePasswordContext}, and attaches it to the {@link AuthenticationContext}.
+ *
+ * @event {@link org.opensaml.profile.action.EventIds#PROCEED_EVENT_ID}
+ * @event {@link AuthnEventIds#NO_CREDENTIALS}
+ * @pre <pre>ProfileRequestContext.getSubcontext(AuthenticationContext.class, false) != null</pre>
+ * @post If ProfileRequestContext.getHttpRequest() != null, a pair of form or query parameters is
+ * extracted to populate a {@link UsernamePasswordContext}.
*/
- at Events({@Event(id = EventIds.PROCEED_EVENT_ID),
- @Event(id = AuthnEventIds.NO_CREDENTIALS, description = "request does not contain username or password")})
public class ExtractUsernamePasswordFromFormRequest extends AbstractAuthenticationAction {
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(ExtractUsernamePasswordFromFormRequest.class);
+ /** Parameter name for username. */
+ @Nonnull @NotEmpty private String usernameFieldName;
+
+ /** Parameter name for password. */
+ @Nonnull @NotEmpty private String passwordFieldName;
+
+ /** Constructor. */
+ ExtractUsernamePasswordFromFormRequest() {
+ usernameFieldName = "username";
+ passwordFieldName = "password";
+ }
+
+ /**
+ * Get the username parameter name, defaults to "username".
+ *
+ * @return the username parameter name
+ */
+ @Nonnull @NotEmpty public String getUsernameFieldName() {
+ return usernameFieldName;
+ }
+
+ /**
+ * Set the username parameter name.
+ *
+ * @param fieldName the username parameter name
+ */
+ public void setUsernameFieldName(@Nonnull @NotEmpty final String fieldName) {
+ usernameFieldName = Constraint.isNotNull(
+ StringSupport.trimOrNull(fieldName), "Username field name cannot be null or empty.");
+ }
+
+ /**
+ * Get the password parameter name, defaults to "password".
+ *
+ * @return the password parameter name
+ */
+ @Nonnull @NotEmpty public String getPasswordFieldName() {
+ return passwordFieldName;
+ }
+
+ /**
+ * Set the password parameter name.
+ *
+ * @param fieldName the password parameter name
+ */
+ public void setPasswordFieldName(@Nonnull @NotEmpty final String fieldName) {
+ passwordFieldName = Constraint.isNotNull(
+ StringSupport.trimOrNull(fieldName), "Password field name cannot be null or empty.");
+ }
+
/** {@inheritDoc} */
[... 44 lines stripped ...]
More information about the commits
mailing list