use of io.github.tesla.authz.domain.Users 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 io.github.tesla.authz.domain.Users in project tesla by linking12.
the class AuthzUserDao method findByUserNamed.
public Users findByUserNamed(String userName) {
String sql = "select u.user_id,u.username,u.password,u.status from sys_user u where u.username = ?";
final List<Users> list = this.jdbcTemplate.query(sql, usersRowMapper, userName);
Users user = list.isEmpty() ? null : list.get(0);
if (user != null) {
List<String> roles = this.findRoleByUserId(user.userId());
user.roles(roles);
}
return user;
}
use of io.github.tesla.authz.domain.Users in project tesla by linking12.
the class AuthzUserDao method findByUserId.
public Users findByUserId(Long userId) {
String sql = "select u.user_id,u.username,u.password from sys_user u where u.user_id = ?";
final List<Users> list = this.jdbcTemplate.query(sql, usersRowMapper, userId);
Users user = list.isEmpty() ? null : list.get(0);
if (user != null) {
List<String> roles = this.findRoleByUserId(user.userId());
user.roles(roles);
}
return user;
}
Aggregations