0 Replies Latest reply on Dec 8, 2015 4:39 AM by Vineeth V Nair

    Issue with the form authentication mechanism

    Vineeth V Nair Newbie

      Hi,
      I need to do some extra authentication on top of FormAuthenticationMechaism(reason mentioned here : How can I add more than one security domain for a project ?). So I developed the code like below.

       

      public class MyAuthenticaor extends FormAuthenticationMechanism{

        static FormParserFactory formParserFactory = FormParserFactory.builder().build();

         public MyAuthenticaor(String name, String loginPage, String errorPage) {

        super(formParserFactory,name, loginPage, errorPage);

        }

        @Override

        public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange,

        SecurityContext securityContext) {

        System.out.println("Authenticated using new mechanism");

        AuthenticationMechanismOutcome superResult = super.authenticate(exchange, securityContext);

        return superResult;

        }

      }

       

      Also I have added the servlet extension like

       

      public class MyServletExtentionClass implements ServletExtension{

        @Override

        public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext arg1) {

        deploymentInfo.addLastAuthenticationMechanism("test", new MyAuthenticaor("form","/login","/error"));

         }

      }

       

      The Problem now I am getting is when i enter url the login page is coming and control is going to my authenticate method, now once i enter the credentials the control is not coming to this authenticate method. Also for every request am getting the below exception in the code.

       

       

       

      java.lang.IllegalStateException: UT000012: Session manager was not attached to the request. Make sure that the SessionAttachmentHander is installed in the handler chain

        at io.undertow.util.Sessions.getOrCreateSession(Sessions.java:57) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.FormAuthenticationMechanism.storeInitialLocation(FormAuthenticationMechanism.java:163) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.FormAuthenticationMechanism.sendChallenge(FormAuthenticationMechanism.java:154) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.transition(SecurityContextImpl.java:332) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.transition(SecurityContextImpl.java:351) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.transition(SecurityContextImpl.java:351) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.transition(SecurityContextImpl.java:351) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.access$300(SecurityContextImpl.java:316) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl.sendChallenges(SecurityContextImpl.java:137) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl.authTransition(SecurityContextImpl.java:111) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl.authTransition(SecurityContextImpl.java:116) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.impl.SecurityContextImpl.authenticate(SecurityContextImpl.java:101) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:55) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761) [undertow-core-1.1.8.Final.jar:1.1.8.Final]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_65]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_65]

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_65]