3 Replies Latest reply on Jun 18, 2008 10:43 AM by Filip Majernik

    Custom credential object and cache

    Piotr Koper Newbie

      Hi all.

      I'd like to use my own credential object in my login module. Everything works perfectly, but there is no cache and every logging lasts almost 2 seconds. Earlier, when i used PasswordCallback and simply String password as credential - cache was working normally and I was very, very happy. I'd like to know is there any possibility to enable cache with my custom credential object? If yes - how, If not... at least i will know that is a feature.

      What i have/use is:
      * jboss-4.2.1.GA on Windows XP Professional SP2
      * my own login module:

      public class MyLoginModule extends AbstractServerLoginModule
      {
      
       // my login method
       public boolean login() throws LoginException
       {
       super.loginOk = false;
      
       NameCallback nameCallback = new NameCallback("login: ");
       ObjectCallback objectCallback = new ObjectCallback("ObjectCallback");
       try
       {
       callbackHandler.handle(new Callback[]{ nameCallback, objectCallback});
       identity = new SimplePrincipal(nameCallback.getName());
       credential = (MyCredential) objectCallback.getCredential();
      
       SecurityAssociation.setPrincipal(identity);
       SecurityAssociation.setCredential(credential);
       }
       catch (IOException e)
       {
       e.printStackTrace();
       }
       catch (UnsupportedCallbackException e)
       {
       e.printStackTrace();
       }
      
       // now i use other some class to verify data
       super.loginOk = true;
       }
      
       // more code here, but it's not important here
      
      }
      

      * I don't use cache-controll file jboss-service.xml
      * In my secured ejb:
      @EJB
      @SecurityDomain("sec-domain")
      public class HelloBean implements HelloLocal, HelloRemote
      {
       // implementations of Local and Remote interfaces
      }


      * In my servlet:
      LoginContext lc = new LoginContext("sec-domain", instanceOfCallbackHandler);
      lc.login();


      Thanks for any help or suggestions
      piotr.koper