use of com.varsql.core.auth.Authority in project varsql by varsqlinfo.
the class SecurityUtil method loginRole.
public static String loginRole(Authentication auth) {
if (auth == null)
return null;
if (auth instanceof AnonymousAuthenticationToken) {
return User.ANONYMOUS_USERNAME;
}
User user = (User) auth.getPrincipal();
java.util.Iterator<? extends GrantedAuthority> iter = user.getAuthorities().iterator();
while (iter.hasNext()) {
return ((Authority) iter.next()).getName();
}
return "";
}
use of com.varsql.core.auth.Authority in project varsql by varsqlinfo.
the class AuthDAO method loadUserByUsername.
public User loadUserByUsername(String username, String password, boolean remembermeFlag) {
try {
UserEntity userModel = userRepository.findByUid(username);
if (userModel == null) {
return null;
// throw new UsernameNotFoundException("Wrong username or password ");
}
if (remembermeFlag == false) {
if (!passwordEncoder.matches(password, userModel.getUpw())) {
return null;
// throw new UsernameNotFoundException("Wrong username or password ");
}
}
User user = new User();
user.setLoginRememberMe(remembermeFlag);
user.setViewid(userModel.getViewid());
user.setUsername(userModel.getUid());
user.setPassword("");
user.setFullname(userModel.getUname());
if (userModel.isBlockYn()) {
// 차단된 사용자 체크.
user.setBlockYn(true);
return user;
}
user.setUserLocale(LocaleConstants.parseLocaleString(userModel.getLang()));
user.setOrgNm(userModel.getOrgNm());
user.setDeptNm(userModel.getDeptNm());
user.setEmail(userModel.getUemail());
user.setAcceptYn(userModel.isAcceptYn());
String userRole = userModel.getUserRole();
List<Authority> roles = new ArrayList<Authority>();
Authority r = new Authority();
AuthorityType authType = AuthorityType.valueOf(userRole);
r = new Authority();
r.setName(userRole);
r.setPriority(authType.getPriority());
roles.add(r);
user.setTopAuthority(authType);
user.setAuthorities(roles);
return user;
} catch (Exception e) {
logger.error(this.getClass().getName(), e);
throw new UsernameNotFoundException(new StringBuilder().append("Wrong username or password :").append(username).append(" ").append(e.getMessage()).toString());
}
}
Aggregations