0 Replies Latest reply on Feb 8, 2009 10:07 PM by Brian Hiles

    IdentityManager method issues

    Brian Hiles Newbie

      I'm having issues with using the IdentityManager methods. I was wanting to use the userExists method in a method to use a a quick/clean check to see if a userID was taken or not.


      So I use the following:


      public boolean userIdTaken(final String userName) {
             identityManager = IdentityManager.instance();
             return identityManager.userExists(userName);   
      } 



      This gives me a org.jboss.seam.security.NotLoggedInException


      So I've searched and the only solution I can find so far is to use the RunAsOperation to run as an 'admin'. Problem with that is that since there is no return on the execute method in that class, I can't get the result out of that call because the variable exists cannot be marked final (since it needs to be modified to be returned).



      public boolean userIdTaken(final String userName) {
           identityManager = IdentityManager.instance();
           boolean exists;
                
           new RunAsOperation() {
                public void execute() {
                   exists = identityManager.userExists(userName);   //won't compile      
                   }    
                     
           }.addRole("admin")
           .run();
           return exists;
      }



      Anyone got a solution?


      Thanks