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:
16: package org.acegisecurity.adapters.jetty;
17:
18: import org.acegisecurity.GrantedAuthority;
19:
20: import org.acegisecurity.adapters.AbstractAdapterAuthenticationToken;
21:
22: import org.mortbay.http.UserPrincipal;
23:
24: /**
25: * A Jetty compatible {@link org.acegisecurity.Authentication} object.
26: *
27: * @author Ben Alex
28: * @version $Id: JettyAcegiUserToken.java 1680 2006-09-15 08:38:11Z benalex $
29: */
30: public class JettyAcegiUserToken extends
31: AbstractAdapterAuthenticationToken implements UserPrincipal {
32: //~ Instance fields ================================================================================================
33:
34: private static final long serialVersionUID = 1L;
35: private String password;
36: private String username;
37:
38: //~ Constructors ===================================================================================================
39:
40: public JettyAcegiUserToken(String key, String username,
41: String password, GrantedAuthority[] authorities) {
42: super (key, authorities);
43: this .username = username;
44: this .password = password;
45: }
46:
47: protected JettyAcegiUserToken() {
48: throw new IllegalArgumentException(
49: "Cannot use default constructor");
50: }
51:
52: //~ Methods ========================================================================================================
53:
54: public Object getCredentials() {
55: return this .password;
56: }
57:
58: public String getName() {
59: return this .username;
60: }
61:
62: public Object getPrincipal() {
63: return this.username;
64: }
65: }
|