com.xlrit.gears.server.security.internal.InternalAuthentication Maven / Gradle / Ivy
package com.xlrit.gears.server.security.internal;
import java.util.List;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.xlrit.gears.engine.security.RoleAuthority;
public class InternalAuthentication extends AbstractAuthenticationToken {
private final DecodedJWT decodedJwt;
public InternalAuthentication(DecodedJWT decodedJwt, List roleNames) {
super(RoleAuthority.fromRoleNames(roleNames));
this.decodedJwt = decodedJwt;
setAuthenticated(true);
}
@Override
public Object getPrincipal() {
return decodedJwt.getSubject();
}
@Override
public Object getCredentials() {
return decodedJwt;
}
}