Package org.nutz.integration.shiro.realm.bean

Examples of org.nutz.integration.shiro.realm.bean.User


 
  protected Dao dao;

  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
    String username = principalCollection.getPrimaryPrincipal().toString();
    User user = dao().fetch(User.class, Cnd.where("name", "=", username));
        if (user == null)
            return null;
        if (user.isLocked())
            throw new LockedAccountException("Account [" + username + "] is locked.");
       
        SimpleAuthorizationInfo auth = new SimpleAuthorizationInfo();
        auth.setRoles(user.getRoleStrSet());
        auth.addStringPermissions(user.getPermissionStrSet());
       
        return auth;
  }
View Full Code Here


        return auth;
  }

  protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    UsernamePasswordToken upToken = (UsernamePasswordToken) token;
    User user = dao().fetch(User.class, Cnd.where("name", "=", upToken.getUsername()));
        if (user == null)
            return null;
        if (user.isLocked())
            throw new LockedAccountException("Account [" + upToken.getUsername() + "] is locked.");
        dao().fetchLinks(user, null);
        SimpleAccount account = new SimpleAccount(upToken.getUsername(), user.getPasswd(), name);
        if (user.getSalt() != null)
            account.setCredentialsSalt(ByteSource.Util.bytes(user.getSalt()));
        return account;
  }
View Full Code Here

TOP

Related Classes of org.nutz.integration.shiro.realm.bean.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.