01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15: package org.acegisecurity.providers.openid;
16:
17: import org.acegisecurity.GrantedAuthority;
18:
19: import org.acegisecurity.providers.AbstractAuthenticationToken;
20:
21: /**
22: * OpenID Authentication Token
23: *
24: * @author Robin Bramley, Opsera Ltd
25: */
26: public class OpenIDAuthenticationToken extends
27: AbstractAuthenticationToken {
28: //~ Instance fields ================================================================================================
29:
30: private OpenIDAuthenticationStatus status;
31: private String identityUrl;
32: private String message;
33:
34: //~ Constructors ===================================================================================================
35:
36: public OpenIDAuthenticationToken(OpenIDAuthenticationStatus status,
37: String identityUrl, String message) {
38: super (new GrantedAuthority[0]);
39: this .status = status;
40: this .identityUrl = identityUrl;
41: this .message = message;
42: setAuthenticated(false);
43: }
44:
45: /**
46: * Created by the OpenIDAuthenticationProvider on successful authentication.
47: * <b>Do not use directly</b>
48: *
49: * @param authorities
50: * @param status
51: * @param identityUrl
52: */
53: public OpenIDAuthenticationToken(GrantedAuthority[] authorities,
54: OpenIDAuthenticationStatus status, String identityUrl) {
55: super (authorities);
56: this .status = status;
57: this .identityUrl = identityUrl;
58:
59: setAuthenticated(true);
60: }
61:
62: //~ Methods ========================================================================================================
63:
64: /* (non-Javadoc)
65: * @see org.acegisecurity.Authentication#getCredentials()
66: */
67: public Object getCredentials() {
68: return null;
69: }
70:
71: public String getIdentityUrl() {
72: return identityUrl;
73: }
74:
75: public String getMessage() {
76: return message;
77: }
78:
79: /* (non-Javadoc)
80: * @see org.acegisecurity.Authentication#getPrincipal()
81: */
82: public Object getPrincipal() {
83: return identityUrl;
84: }
85:
86: public OpenIDAuthenticationStatus getStatus() {
87: return status;
88: }
89: }
|