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

be.looorent.security.jwt.AuthenticatedToken Maven / Gradle / Ivy

package be.looorent.security.jwt;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * A JWT that has been authenticated by an AuthenticationProvider.
 * @author Lorent Lempereur - [email protected]
 */
class AuthenticatedToken extends Jwt {

    private final UserDetails principal;

    AuthenticatedToken(String jwt, UserDetails principal) {
        super(jwt);
        this.principal = principal;
        setDetails(principal);
        setAuthenticated(true);
    }

    @Override
    @SuppressWarnings("unchecked")
    public Collection getAuthorities() {
        return (Collection) principal.getAuthorities();
    }


    @Override
    public UserDetails getPrincipal() {
        return principal;
    }

    @Override
    AuthenticatedToken authenticate(UserDetails principal) {
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy