com.pannoniaexpertise.audit.usernameProviders.impl.ClientDetailsUsernameProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of audit-starter Show documentation
Show all versions of audit-starter Show documentation
Starter project considering the audit mechanism
The newest version!
package com.pannoniaexpertise.audit.usernameProviders.impl;
import com.pannoniaexpertise.audit.usernameProviders.UsernameProvider;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.stereotype.Component;
/**
* Username provider class for {@link ClientDetails}
*/
@Component
public class ClientDetailsUsernameProvider implements UsernameProvider {
@Override
public boolean support(Object principal) {
if (principal == null) {
return false;
}
return principal instanceof ClientDetails;
}
@Override
public String getUsername(Object principal) {
return ((ClientDetails) principal).getClientId();
}
}