public UserDetails loadUserByUsername(String token) throws UsernameNotFoundException {
if (token == null) {
log.error("UserDetailsServiceImpl.loadUserByUsername(): User not found with null token");
throw new UsernameNotFoundException("UserDetailsServiceImpl.loadUserByUsername(): User not found with null token");
}
Accountprofile accountProfile = null;
try {
accountProfile = tradingServiceFacade.findAccountprofileByAuthtoken(token);
} catch (AuthenticationException ae) {
throw new UsernameNotFoundException("UserDetailsServiceImpl.loadUserByUsername(): User not found with token:" + token);
}
@SuppressWarnings("rawtypes")
List<Map> accounts = accountProfile.getAccounts();
Integer accountId = null;
for(Map<?, ?> account: accounts ) {
accountId = (Integer)account.get("accountid");
}
User user = new CustomUser(accountProfile.getUserid(), accountProfile.getPasswd(), getAuthorities(accountProfile.getUserid()), accountId, accountProfile.getProfileid(), token);
if (log.isDebugEnabled()) {
log.debug("UserDetailsServiceImpl.loadUserByUsername(): user=" + user + " username::token" + token);
}
return user;