🌸🌸 pig token令牌解析器过程 🌸🌸
pig后端源码
一、解析请求中的令牌值。
二、验证令牌
- 内省并验证给定的令牌,返回其属性。
- 返回映射表示令牌有效。
/**
* @author lengleng
* @date 2019/2/1 扩展用户信息
*/
public class PigUser extends User implements OAuth2AuthenticatedPrincipal {
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
/**
* 扩展属性,方便存放oauth 上下文相关信息
*/
private final Map<String, Object> attributes = new HashMap<>();
@Getter
@JsonSerialize(using = ToStringSerializer.class)
private final Long id;
@Getter
@JsonSerialize(using = ToStringSerializer.class)
private final Long deptId;
@Getter
private final String phone;
public PigUser(Long id, Long deptId, String username, String password, String phone, boolean enabled,
boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked,
Collection<? extends GrantedAuthority> authorities) {
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
this.id = id;
this.deptId = deptId;
this.phone = phone;
}
@Override
public Map<String, Object> getAttributes() {
return this.attributes;
}
@Override
public String getName() {
return this.getUsername();
}
}
三、在此次调用中获取信息
- 使用
SecurityUtils
获取登录信息