Skip to content

Commit

Permalink
WFLY-3514 Make sure JASPIAuthenticationMechanism only wraps the reque…
Browse files Browse the repository at this point in the history
…st once
  • Loading branch information
stuartwdouglas committed Jun 17, 2014
1 parent 04ef9e8 commit e713a36
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -73,6 +73,7 @@ public class JASPIAuthenticationMechanism implements AuthenticationMechanism {

public static final AttachmentKey<HttpServerExchange> HTTP_SERVER_EXCHANGE_ATTACHMENT_KEY = AttachmentKey.create(HttpServerExchange.class);
public static final AttachmentKey<SecurityContext> SECURITY_CONTEXT_ATTACHMENT_KEY = AttachmentKey.create(SecurityContext.class);
private static final AttachmentKey<Boolean> ALREADY_WRAPPED = AttachmentKey.create(Boolean.class);

private final String securityDomain;
private final String configuredAuthMethod;
Expand Down Expand Up @@ -220,6 +221,10 @@ private Account createAccount(final Account cachedAccount, final org.jboss.secur
}

private void secureResponse(final HttpServerExchange exchange, final SecurityContext securityContext, final JASPIServerAuthenticationManager sam, final GenericMessageInfo messageInfo, final JASPICallbackHandler cbh) {
if(exchange.getAttachment(ALREADY_WRAPPED) != null || exchange.isResponseStarted()) {
return;
}
exchange.putAttachment(ALREADY_WRAPPED, true);
// we add a response wrapper to properly invoke the secureResponse, after processing the destination
exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() {
@Override
Expand Down

0 comments on commit e713a36

Please sign in to comment.