Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Use the correct attachment key.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmcwhirter committed Dec 11, 2015
1 parent 355ac29 commit 72015d2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@
import io.undertow.servlet.api.ThreadSetupAction;
import org.keycloak.KeycloakSecurityContext;
import org.keycloak.adapters.undertow.OIDCServletUndertowHttpFacade;
import org.keycloak.adapters.undertow.OIDCUndertowHttpFacade;

/**
* @author Bob McWhirter
*/
public class SecurityContextServletExtension implements ServletExtension {
@Override
public void handleDeployment(DeploymentInfo info, ServletContext context) {
System.err.println( "HANDLE DEPLOYMENT FOR SECURITY CONTEXT" );
info.addThreadSetupAction(new ThreadSetupAction() {
@Override
public Handle setup(HttpServerExchange exchange) {
if (exchange == null) {
return null;
}
KeycloakSecurityContext c = exchange.getAttachment(OIDCServletUndertowHttpFacade.KEYCLOAK_SECURITY_CONTEXT_KEY);
KeycloakSecurityContext c = exchange.getAttachment(OIDCUndertowHttpFacade.KEYCLOAK_SECURITY_CONTEXT_KEY);
KeycloakSecurityContextAssociation.associate(c);
return new Handle() {
@Override
Expand All @@ -55,7 +57,7 @@ public HttpHandler wrap(HttpHandler next) {
return new HttpHandler() {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
KeycloakSecurityContext c = exchange.getAttachment(OIDCServletUndertowHttpFacade.KEYCLOAK_SECURITY_CONTEXT_KEY);
KeycloakSecurityContext c = exchange.getAttachment(OIDCUndertowHttpFacade.KEYCLOAK_SECURITY_CONTEXT_KEY);
if ( c != null ) {
KeycloakSecurityContextAssociation.associate(c);
}
Expand Down

0 comments on commit 72015d2

Please sign in to comment.