Spring security Custom userdetails not working -


i'm attempting customise userdetails, , assembler , register in security xml.

 @service("customuserdetailsservice")  public class customuserdetailsservice implements userdetailsservice{      @autowired     private userservice userservice;      @autowired     private assembler assembler;           @override     @transactional(readonly = true)     public userdetails loaduserbyusername(string username)         throws usernamenotfoundexception {     // todo auto-generated method stub     userdetails userdetails = null;      userentity userentity = userservice.getuserbyname(username);       if (userentity == null)      throw new usernamenotfoundexception("user not found");      return assembler.builduserfromuser(userentity);   } 

assembler

@service("assembler") public class assembler {     @transactional   public userdetails builduserfromuser(userentity userentity) {       string username = userentity.getusername();      string password = userentity.getpassword();      string name = userentity.getname();      boolean enabled = userentity.getactive();      boolean accountnonexpired = enabled;      boolean credentialsnonexpired = enabled;      boolean accountnonlocked = enabled;       collection<grantedauthority> authorities = new arraylist<grantedauthority>();      for(role role : userentity.getroles()) {              authorities.add(new simplegrantedauthority(role.getname()));      }        return new customuser(username, password, enabled, accountnonexpired,        credentialsnonexpired, accountnonlocked, authorities, name);   }} 

security xml 2

    <authentication-manager>     <authentication-provider user-service-ref='customuserdetailsservice'>     <password-encoder hash='md5' />     </authentication-provider> </authentication-manager>    <beans:bean id='customuserdetailsservice'       class='com.user.application.service.customuserdetailsservice'></beans:bean>      <context:component-scan base-package='com.user.application' />   

the problem customuserdetailsservice class not being recognised or being called. when attempting login, application keeps returning login page back.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -