AbstractAuthenticationToken
package com.lee.security.springsecurity;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import java.util.Collection;
public class MyAuthenticationToken extends AbstractAuthenticationToken {
private static final long serialVersionUID = -3493689242937151984L;
private String username;
//手机验证码的登录
private String code;
private String phone;
//身份证的登录
private String idCard;
//当前登陆的用户信息
private SpringSecurityUserInfo springSecurityUserInfo;
public MyAuthenticationToken(Collection<? extends GrantedAuthority> authorities) {
super(authorities);
}
public MyAuthenticationToken(String username) {
super(null);
this.username=username;
}
@Override
public Object getCredentials() {
return this.username;
}
@Override
public Object getPrincipal() {
return null;
}
@Override
public void eraseCredentials() {
super.eraseCredentials();
}
@Override
public String toString() {
return "MyAuthenticationToken{" +
"username='" + username + '\'' +
", code='" + code + '\'' +
", phone='" + phone + '\'' +
", idCard='" + idCard + '\'' +
", springSecurityUserInfo=" + springSecurityUserInfo +
'}';
}
public MyAuthenticationToken(String username, SpringSecurityUserInfo springSecurityUserInfo) {
super(null);
this.username = username;
this.springSecurityUserInfo = springSecurityUserInfo;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
public SpringSecurityUserInfo getSpringSecurityUserInfo() {
return springSecurityUserInfo;
}
public void setSpringSecurityUserInfo(SpringSecurityUserInfo springSecurityUserInfo) {
this.springSecurityUserInfo = springSecurityUserInfo;
}
}