1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.providers;
17
18 import org.acegisecurity.GrantedAuthority;
19
20
21 /***
22 * An {@link org.acegisecurity.Authentication} implementation that is
23 * designed for use whilst unit testing.
24 *
25 * <p>
26 * The corresponding authentication provider is {@link
27 * TestingAuthenticationProvider}.
28 * </p>
29 *
30 * @author Ben Alex
31 * @version $Id: TestingAuthenticationToken.java,v 1.4 2005/11/17 00:55:49 benalex Exp $
32 */
33 public class TestingAuthenticationToken extends AbstractAuthenticationToken {
34
35
36 private Object credentials;
37 private Object principal;
38 private GrantedAuthority[] authorities;
39 private boolean authenticated = false;
40
41
42
43 public TestingAuthenticationToken(Object principal, Object credentials,
44 GrantedAuthority[] authorities) {
45 this.principal = principal;
46 this.credentials = credentials;
47 this.authorities = authorities;
48 }
49
50 protected TestingAuthenticationToken() {
51 throw new IllegalArgumentException("Cannot use default constructor");
52 }
53
54
55
56 public void setAuthenticated(boolean isAuthenticated) {
57 this.authenticated = isAuthenticated;
58 }
59
60 public boolean isAuthenticated() {
61 return this.authenticated;
62 }
63
64 public GrantedAuthority[] getAuthorities() {
65 return this.authorities;
66 }
67
68 public Object getCredentials() {
69 return this.credentials;
70 }
71
72 public Object getPrincipal() {
73 return this.principal;
74 }
75 }