1 Reply Latest reply on Jan 23, 2007 2:10 PM by gavin.king

    SeamTest & Form based authentication

    eiswind

      I try to write a SeamTest. Our application uses container authentication via Form based login. The tested bean accesses the logged in Principal via

      FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal().getName();

      So the test needs to login anyhow. Following is what I found through googling:
      UsernamePasswordHandler handler = null;
       handler = new UsernamePasswordHandler("JU_benutzer1", "JU_benutzer1#");
       System.setProperty("java.security.auth.login.config", "I:/work/asd/asd-biz/classes/test/jaas.config");
       try {
       LoginContext lc = new LoginContext("example", handler);
       lc.login();
      
       }

      with jaas.config looks like
      example { org.jboss.security.ClientLoginModule required;};

      but the principal I get from the FacesContext is always named "gavin". The CallBackHandler is invoked and gives my correct identification. What can I do to get the principal right ? Any ideas ?