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

com.fivefaces.structureclient.config.security.UserAuthenticationToken Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy