use of org.springframework.security.core.userdetails.UserDetails in project OpenClinica by OpenClinica.
the class StudySubjectEndpoint method getUserAccount.
/**
* Helper Method to get the user account
*
* @return UserAccountBean
*/
private UserAccountBean getUserAccount() {
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String username = null;
if (principal instanceof UserDetails) {
username = ((UserDetails) principal).getUsername();
} else {
username = principal.toString();
}
UserAccountDAO userAccountDao = new UserAccountDAO(dataSource);
return (UserAccountBean) userAccountDao.findByUserName(username);
}
use of org.springframework.security.core.userdetails.UserDetails in project OpenClinica by OpenClinica.
the class DataEndpoint method getUserAccount.
/**
* Helper Method to get the user account
*
* @return UserAccountBean
*/
private UserAccountBean getUserAccount() {
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String username = null;
if (principal instanceof UserDetails) {
username = ((UserDetails) principal).getUsername();
} else {
username = principal.toString();
}
UserAccountDAO userAccountDao = new UserAccountDAO(dataSource);
return (UserAccountBean) userAccountDao.findByUserName(username);
}
use of org.springframework.security.core.userdetails.UserDetails in project OpenClinica by OpenClinica.
the class EventEndpoint method getUserAccount.
/**
* Helper Method to get the user account
*
* @return UserAccountBean
*/
private UserAccountBean getUserAccount() {
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String username = null;
if (principal instanceof UserDetails) {
username = ((UserDetails) principal).getUsername();
} else {
username = principal.toString();
}
UserAccountDAO userAccountDao = new UserAccountDAO(dataSource);
return (UserAccountBean) userAccountDao.findByUserName(username);
}
use of org.springframework.security.core.userdetails.UserDetails in project motan by weibocom.
the class UserController method authenticate.
@RequestMapping(value = "/authenticate", method = RequestMethod.POST)
public TokenTransfer authenticate(@RequestParam("username") String username, @RequestParam("password") String password) {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
Authentication authentication = authManager.authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
return new TokenTransfer(TokenUtils.createToken(userDetails));
}
use of org.springframework.security.core.userdetails.UserDetails in project incubator-atlas by apache.
the class AtlasAbstractAuthenticationProvider method getAuthenticationWithGrantedAuthorityFromUGI.
public Authentication getAuthenticationWithGrantedAuthorityFromUGI(Authentication authentication) {
UsernamePasswordAuthenticationToken result = null;
if (authentication != null && authentication.isAuthenticated()) {
List<GrantedAuthority> grantedAuthsUGI = getAuthoritiesFromUGI(authentication.getName());
final UserDetails userDetails = new User(authentication.getName(), authentication.getCredentials().toString(), grantedAuthsUGI);
result = new UsernamePasswordAuthenticationToken(userDetails, authentication.getCredentials(), grantedAuthsUGI);
result.setDetails(authentication.getDetails());
return result;
}
return authentication;
}
Aggregations