com.fivefaces.structureclient.config.security.UserAuthenticationToken Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-structure-client Show documentation
Show all versions of common-structure-client Show documentation
structure Client for Five Faces
The newest version!
package com.fivefaces.structureclient.config.security;
import lombok.Getter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import java.util.stream.Collectors;
@Getter
public class UserAuthenticationToken extends AbstractAuthenticationToken {
private final String apiToken;
private final User user;
public UserAuthenticationToken(String apiToken, User user) {
super(user.getRoles().stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList()));
this.apiToken = apiToken;
this.user = user;
}
@Override
public Object getCredentials() {
return null;
}
@Override
public Object getPrincipal() {
return user;
}
}