com.icthh.xm.commons.security.internal.XmAuthenticationDetails Maven / Gradle / Ivy
package com.icthh.xm.commons.security.internal;
import io.jsonwebtoken.Claims;
import jakarta.servlet.http.HttpServletRequest;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.http.server.reactive.ServerHttpRequest;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
@Getter
public class XmAuthenticationDetails {
private final Long createTokenTime;
private final String userName;
private final Set scope;
private final String roleKey;
private final String userKey;
private final List logins;
private final Set authorities;
private final String clientId;
private final String remoteAddress;
private final String sessionId;
private final String tokenValue;
private final String tokenType;
private final Map decodedDetails;
public XmAuthenticationDetails(Claims claims, String remoteAddress, String sessionId, String token) {
this.createTokenTime = claims.get("createTokenTime", Long.class);
this.userName = claims.get("user_name", String.class);
this.roleKey = claims.get("role_key", String.class);
this.userKey = claims.get("user_key", String.class);
this.clientId = claims.get("client_id", String.class);
this.authorities = toSet(claims.get("authorities", List.class));
this.scope = toSet(claims.get("scope", List.class));
List