0 Replies Latest reply on Oct 20, 2012 3:12 AM by iabughosh

    Programmatic authentication with JBoss 7.1.1

    iabughosh Master

      Dears,

      I've already created a discussion about this at AS7 forum, i've used a code like this but it doesn't work :

       

      SecurityContext securityContext = SecurityFactory.establishSecurityContext("java:/jaas/MyRealm");

      AuthenticationManager authManager = securityContext.getAuthenticationManager();

      Principal principal = new SimplePrincipal(credentials.getUsername());

      Subject subject = new Subject();

       

      if(authManager.isValid(principal, credentials.getPassword().toCharArray(), subject)) {

           securityContext.getUtil().createSubjectInfo(principal, credentials.getPassword().toCharArray(), subject);

      }

       

      note : isValid returns true when credentials is correct but user is not authenticated at application level.

       

      regards.