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

com.pannoniaexpertise.audit.usernameProviders.impl.UserDetailsUsernameProvider Maven / Gradle / Ivy

The newest version!
package com.pannoniaexpertise.audit.usernameProviders.impl;

import com.pannoniaexpertise.audit.usernameProviders.UsernameProvider;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

/**
 * Username provider class {@link UserDetails}
 */
@Component
public class UserDetailsUsernameProvider implements UsernameProvider {

  @Override
  public boolean support(Object principal) {
    if (principal == null) {
      return false;
    }
    return principal instanceof UserDetails;
  }

  @Override
  public String getUsername(Object principal) {
    return ((UserDetails) principal).getUsername();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy