package ervu_dashboard.security.model.jwt.authentication;

import java.util.Collection;

import ervu_dashboard.security.model.jwt.UserSession;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

public class JwtTokenAuthentication implements Authentication {

  private final UserSession userSession;

  public JwtTokenAuthentication(UserSession userSession) {
    this.userSession = userSession;
  }

  public UserSession getUserSession() {
    return userSession;
  }

  @Override
  public Collection<? extends GrantedAuthority> getAuthorities() {
    return userSession.roles();
  }

  @Override
  public Object getCredentials() {
    return null;
  }

  @Override
  public Object getDetails() {
    return null;
  }

  @Override
  public Object getPrincipal() {
    return null;
  }

  @Override
  public boolean isAuthenticated() {
    return true;
  }

  @Override
  public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {

  }

  @Override
  public String getName() {
    return userSession.name();
  }
}
