All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.data.domain.AuditorAwareName Maven / Gradle / Ivy

package org.springframework.data.domain;

import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class AuditorAwareName implements AuditorAware {
  @Override
  public String getCurrentAuditor() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication != null && authentication.isAuthenticated() && !(authentication instanceof AnonymousAuthenticationToken)) {
      return authentication.getName();
    }
    return null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy