List of usage examples for org.springframework.security.core.token Token getExtendedInformation
String getExtendedInformation();
From source file:org.ihtsdo.otf.refset.security.RefsetIdentityService.java
/** * Gets a minimal {@link Authentication} object from {@link Token}. * It is only possible if that Token exist. At the moment ROLE_USER is defaulted * @return/*from ww w.jav a2 s .c o m*/ */ protected Authentication getPrincipal(Token token) { String info = token.getExtendedInformation(); String[] details = StringUtils.split(info, ":"); User user = new User(); user.setPassword(details[1]); user.setUsername(details[0]); user.setAuthenticated(true); user.setEnabled(true); Collection<RefsetRole> roles = new ArrayList<RefsetRole>(); RefsetRole role = new RefsetRole(); role.setAuthority(ROLE_USER); roles.add(role); user.setAuthorities(roles); Authentication auth = new UsernamePasswordAuthenticationToken(user, details[1], roles); return auth; }