use of org.springframework.security.core.userdetails.UserDetails in project dhis2-core by dhis2.
the class GhostAutomaticAccessProvider method initialise.
// -------------------------------------------------------------------------
// AdminAccessManager implementation
// -------------------------------------------------------------------------
@Override
public void initialise() {
String username = "ghost_admin";
String password = "";
UserDetails user = new User(username, password, true, true, true, true, getGrantedAuthorities());
authentication = new UsernamePasswordAuthenticationToken(user, user.getPassword(), user.getAuthorities());
}
use of org.springframework.security.core.userdetails.UserDetails in project dhis2-core by dhis2.
the class DefaultCurrentUserService method getCurrentUserInfo.
@Override
public UserInfo getCurrentUserInfo() {
UserDetails userDetails = getCurrentUserDetails();
if (userDetails == null) {
return null;
}
Integer userId = USERNAME_ID_CACHE.get(userDetails.getUsername(), un -> getUserId(un));
if (userId == null) {
return null;
}
Set<String> authorities = userDetails.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toSet());
return new UserInfo(userId, userDetails.getUsername(), authorities);
}
Aggregations