1 Reply Latest reply on May 16, 2013 10:44 AM by ktorp

    Seam Authentication with RESTEasy

    vata2999

      Hi,

       

      I need to create a REST service to enable users to login into my seam application. does anyone have experience regarding this issue ?

       

      I've created a service as follow but it still wants username and password when I request a secure page

       

      @Name()
      @Path()
      public class LoginResource {
      
         @In
         Identity identity;
      
         @In 
         Credentials credentials;
      
         @In
         IdentityManager identityManager;
      
         public void doLogin(@QueryParam("uname") String uname, @QueryParam String pass){
               identity.setusername(uname);
               identity.setpassword(pass);
              //the rest is the same as my Authenticator Bean 
        }
      
      
      }
      
        • 1. Re: Seam Authentication with RESTEasy
          ktorp

          This is how we do it:

          Identity identity = Identity.instance();
          Credentials credentials = identity.getCredentials();
          
          credentials.setUsername(loginName);
          credentials.setPassword(password);
          
          String result = identity.login();
          
          if (!identity.isLoggedIn()) {     
               throw new InvalidAccessException();
          }

          Also, we have @BypassInterceptorsin on almost every class and don't use @In.

          I hole this helps.