[java-identity-provider COMMIT] /trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePass...
noreply at shibboleth.net
noreply at shibboleth.net
Tue Jul 30 14:19:51 EDT 2013
Author: scantor
Date: Tue Jul 30 14:19:51 2013
New Revision: 4637
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4637&view=rev
Log:
Some recfactoring, leaving the rest for later.
Modified:
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromWssToken.java
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromWssToken.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromWssToken.java?rev=4637&r1=4636&r2=4637&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromWssToken.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromWssToken.java Tue Jul 30 14:19:51 2013
@@ -28,8 +28,9 @@
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 org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.action.ActionSupport;
import org.opensaml.profile.context.ProfileRequestContext;
import net.shibboleth.utilities.java.support.collection.Pair;
@@ -43,7 +44,6 @@
import org.opensaml.soap.wssecurity.UsernameToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.webflow.execution.RequestContext;
//TODO(lajoie) should we support nonce and created checks? probably
@@ -54,26 +54,39 @@
public class ExtractUsernamePasswordFromWssToken extends AbstractAuthenticationAction {
/** Class logger. */
- private final Logger log = LoggerFactory.getLogger(ExtractUsernamePasswordFromWssToken.class);
+ @Nonnull private final Logger log = LoggerFactory.getLogger(ExtractUsernamePasswordFromWssToken.class);
+
+ /** Inbound message to operate on. */
+ @Nullable private Envelope inboundMessage;
/** {@inheritDoc} */
- protected org.springframework.webflow.execution.Event doExecute(@Nonnull final RequestContext springRequestContext,
- @Nonnull final ProfileRequestContext profileRequestContext,
+ protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext,
@Nonnull final AuthenticationContext authenticationContext) throws AuthenticationException {
-
- // TODO(lajoie) get the envelope from the inbound message context
- final Envelope inboundMessage = null;
-
+
+ final MessageContext inCtx = profileRequestContext.getInboundMessageContext();
+ if (inCtx == null || !(inCtx.getMessage() instanceof Envelope)) {
+ log.debug("{} inbound message context missing or doesn't contain a SOAP Envelope", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.NO_CREDENTIALS);
+ return false;
+ }
+
+ inboundMessage = (Envelope) inCtx.getMessage();
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
+ @Nonnull final AuthenticationContext authenticationContext) throws AuthenticationException {
+
final Pair<String, String> usernamePassword = extractUsernamePassword(inboundMessage);
if (usernamePassword == null) {
- log.debug("Action {}: inbound message does not contain a username and password", getId());
- return ActionSupport.buildEvent(this, AuthnEventIds.NO_CREDENTIALS);
+ log.debug("{} inbound message does not contain a username and password", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.NO_CREDENTIALS);
+ return;
}
authenticationContext.getSubcontext(UsernamePasswordContext.class, true)
.setUsername(usernamePassword.getFirst()).setPassword(usernamePassword.getSecond());
-
- return ActionSupport.buildProceedEvent(this);
}
/**
@@ -83,7 +96,7 @@
*
* @return the username and password
*/
- @Nullable protected Pair<String, String> extractUsernamePassword(@Nonnull final Envelope message) {
+ @Nullable private Pair<String, String> extractUsernamePassword(@Nonnull final Envelope message) {
final UsernameToken usernameToken = getUsernameToken(message);
if (usernameToken == null) {
return null;
@@ -91,13 +104,13 @@
final Username username = usernameToken.getUsername();
if (username == null) {
- log.debug("Action {}: <UsernameToken> does not contain a <Username>", getId());
+ log.debug("{} <UsernameToken> does not contain a <Username>", getLogPrefix());
return null;
}
[... 47 lines stripped ...]
More information about the commits
mailing list