List of usage examples for org.springframework.security.ldap.userdetails LdapUserDetails getUsername
String getUsername();
From source file:org.musicrecital.service.UserSecurityAdvice.java
private User getCurrentUser(Authentication auth, UserManager userManager) { User currentUser;// w ww.j av a 2s.c om if (auth.getPrincipal() instanceof LdapUserDetails) { LdapUserDetails ldapDetails = (LdapUserDetails) auth.getPrincipal(); String username = ldapDetails.getUsername(); currentUser = userManager.getUserByUsername(username); } else if (auth.getPrincipal() instanceof UserDetails) { currentUser = (User) auth.getPrincipal(); } else if (auth.getDetails() instanceof UserDetails) { currentUser = (User) auth.getDetails(); } else { throw new AccessDeniedException("User not properly authenticated."); } return currentUser; }