![JAR search and dependency download from the Maven repository](/logo.png)
com.healthy.common.security.userdetails.ClientPrincipal Maven / Gradle / Ivy
The newest version!
package com.healthy.common.security.userdetails;
import org.springframework.lang.NonNull;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal;
import java.io.Serializable;
import java.util.*;
/**
* OAuth2 Client 实体封装对象
*
* @author xm.z
*/
public class ClientPrincipal implements OAuth2AuthenticatedPrincipal, Serializable {
private final String clientId;
private final Map attributes;
private final Collection extends GrantedAuthority> authorities;
private Set scope = new HashSet<>();
public ClientPrincipal(String clientId, Map attributes,
Collection extends GrantedAuthority> authorities) {
this.clientId = clientId;
this.attributes = attributes;
this.authorities = (authorities != null) ? Collections.unmodifiableCollection(authorities)
: AuthorityUtils.NO_AUTHORITIES;
}
@NonNull
public Set getScope() {
return scope;
}
public void setScope(Collection scope) {
this.scope = Collections.unmodifiableSet(scope == null ? new LinkedHashSet<>() : new LinkedHashSet<>(scope));
}
@Override
public Map getAttributes() {
return attributes;
}
@Override
public Collection extends GrantedAuthority> getAuthorities() {
return authorities;
}
@Override
public String getName() {
return clientId;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy