保誠-保戶業務員媒合平台
wayne
2022-03-02 fb89f2f58fa36b61970af65b93c292720417e753
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.pollex.pam.security.token;
 
import com.pollex.pam.business.web.vm.OtpAccount;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.util.Assert;
 
public class OtpAuthenticationToken extends AbstractAuthenticationToken {
 
    private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
 
    private final OtpAccount principle;
    private String credentials;
 
    public OtpAuthenticationToken(OtpAccount principle, String credentials) {
        super(null);
        this.principle = principle;
        this.credentials = credentials;
        setAuthenticated(false);
    }
 
    @Override
    public String getCredentials() {
        return this.credentials;
    }
 
    @Override
    public OtpAccount getPrincipal() {
        return this.principle;
    }
 
    @Override
    public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
        Assert.isTrue(!isAuthenticated,
            "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");
        super.setAuthenticated(false);
    }
 
    @Override
    public void eraseCredentials() {
        super.eraseCredentials();
        this.credentials = null;
    }
}