DATACMNS-1403 - Fixed example source in reference documentation.

Changed to example source for changed specifications.

Original pull request: #321.
This commit is contained in:
heowc
2018-10-10 22:04:14 +09:00
committed by Mark Paluch
parent a30eb236f0
commit f404aefec3

View File

@@ -47,15 +47,16 @@ The following example shows an implementation of the interface that uses Spring
----
class SpringSecurityAuditorAware implements AuditorAware<User> {
public User getCurrentAuditor() {
public Optional<User> getCurrentAuditor() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || !authentication.isAuthenticated()) {
return null;
return Optional.empty();
}
return ((MyUserDetails) authentication.getPrincipal()).getUser();
MyUserDetails myUserDetails = ((MyUserDetails) authentication.getPrincipal()).getUser();
return Optional.of(myUserDetails);
}
}
----