View Javadoc
1   package org.oxerr.spring.security.otp.authentication;
2   
3   import java.util.Collection;
4   
5   import org.springframework.security.core.Authentication;
6   import org.springframework.security.core.GrantedAuthority;
7   
8   public class OTPAuthenticationToken implements Authentication {
9   
10  	private static final long serialVersionUID = 2019011001L;
11  
12  	private String oneTimePassword;
13  
14  	private Authentication authentication;
15  
16  	public OTPAuthenticationToken(String oneTimePassword) {
17  		this.oneTimePassword = oneTimePassword;
18  	}
19  
20  	public OTPAuthenticationToken(Authentication authentication) {
21  		this.authentication = authentication;
22  	}
23  
24  	public String getOneTimePassword() {
25  		return oneTimePassword;
26  	}
27  
28  	public void setOneTimePassword(String oneTimePassword) {
29  		this.oneTimePassword = oneTimePassword;
30  	}
31  
32  	@Override
33  	public String getName() {
34  		return authentication.getName();
35  	}
36  
37  	@Override
38  	public Collection<? extends GrantedAuthority> getAuthorities() {
39  		return authentication.getAuthorities();
40  	}
41  
42  	@Override
43  	public Object getCredentials() {
44  		return authentication.getCredentials();
45  	}
46  
47  	@Override
48  	public Object getDetails() {
49  		return authentication.getDetails();
50  	}
51  
52  	@Override
53  	public Object getPrincipal() {
54  		return authentication.getPrincipal();
55  	}
56  
57  	@Override
58  	public boolean isAuthenticated() {
59  		return authentication.isAuthenticated();
60  	}
61  
62  	@Override
63  	public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
64  		this.authentication.setAuthenticated(isAuthenticated);
65  	}
66  
67  }