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

io.github.dengchen2020.security.principal.Authentication Maven / Gradle / Ivy

package io.github.dengchen2020.security.principal;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.security.Principal;
import java.util.Set;

/**
 * 基础认证信息
 * @author dengchen
 * @since 2024/4/28
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Authentication implements Principal, Serializable {

    public Authentication() {}

    public Authentication(String userId) {
        this.userId = userId;
    }

    private String userId;

    private Set permissions;

    public String getUserId() {
        return userId;
    }

    public Authentication setUserId(String userId) {
        this.userId = userId;
        return this;
    }

    public Set getPermissions() {
        return permissions;
    }

    public Authentication setPermissions(Set permissions) {
        this.permissions = permissions;
        return this;
    }

    /**
     * 返回用户的唯一标识
     * @return 用户的唯一标识
     */
    @JsonIgnore
    @Override
    public String getName() {
        return userId;
    }

    @Override
    public String toString() {
        return "Authentication{" +
                "userId='" + userId + '\'' +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy