use of org.apache.shiro.authc.SimpleAuthenticationInfo in project zeppelin by apache.
the class ZeppelinHubRealm method doGetAuthenticationInfo.
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authToken) throws AuthenticationException {
UsernamePasswordToken token = (UsernamePasswordToken) authToken;
if (StringUtils.isBlank(token.getUsername())) {
throw new AccountException("Empty usernames are not allowed by this realm.");
}
String loginPayload = createLoginPayload(token.getUsername(), token.getPassword());
User user = authenticateUser(loginPayload);
LOG.debug("{} successfully login via ZeppelinHub", user.login);
return new SimpleAuthenticationInfo(user.login, token.getPassword(), name);
}
use of org.apache.shiro.authc.SimpleAuthenticationInfo in project tesla by linking12.
the class TeslaUserRealm method doGetAuthenticationInfo.
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) {
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
if (username == null) {
throw new AccountException("Null usernames are not allowed by this realm.");
}
Users user = userDao.findByUserNamed(username);
Long userId = user.userId();
String password = user.password();
int status = user.status();
if (password == null) {
throw new UnknownAccountException("No account found for " + username);
}
if (!password.equals(new String((char[]) token.getCredentials()))) {
throw new IncorrectCredentialsException("Password is not right for " + username);
}
if (status == 0) {
throw new LockedAccountException("account is locked for user " + username);
}
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(userId, password.toCharArray(), username);
info.setCredentialsSalt(ByteSource.Util.bytes(username));
return info;
}
use of org.apache.shiro.authc.SimpleAuthenticationInfo in project BlogSystem by DuanJiaNing.
the class MyAuthorizingRealm method doGetAuthenticationInfo.
/**
* 首先执行登录验证
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
// 获取用户账号
String username = token.getPrincipal().toString();
BloggerAccount account = accountService.getAccount(username);
if (account != null) {
// 将查询到的用户账号和密码存放到 authenticationInfo用于后面的权限判断。第三个参数随便放一个就行了。
return new SimpleAuthenticationInfo(account.getUsername(), account.getPassword(), "");
} else {
return null;
}
}
use of org.apache.shiro.authc.SimpleAuthenticationInfo in project fruit-manage by liuzhaozhao.
the class ShiroDbRealm method doGetAuthenticationInfo.
// @Override
// public void setCacheManager(CacheManager cacheManager) {
// super.setCacheManager(cacheManager);
// // ShiroCache.setCacheManager(cacheManager);
// }
/**
* 身份证认证
*
* @param authenticationToken
* @return
* @throws AuthenticationException
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) authenticationToken;
String username = usernamePasswordToken.getUsername();
User user = User.dao.getUser(username);
SimpleAuthenticationInfo authenticationInfo = null;
if (user != null) {
authenticationInfo = new SimpleAuthenticationInfo(user, user.getPass(), getName());
// authenticationInfo.setCredentialsSalt(ByteSource.Util.bytes(name
// + user.get("salt")));
}
return authenticationInfo;
}
use of org.apache.shiro.authc.SimpleAuthenticationInfo in project vip by guangdada.
the class ShiroFactroy method info.
@Override
public SimpleAuthenticationInfo info(ShiroUser shiroUser, User user, String realmName) {
String credentials = user.getPassword();
// 密码加盐处理
String source = user.getSalt();
ByteSource credentialsSalt = new Md5Hash(source);
return new SimpleAuthenticationInfo(shiroUser, credentials, credentialsSalt, realmName);
}
Aggregations