View Javadoc

1   /* Copyright 2004 Acegi Technology Pty Limited
2    *
3    * Licensed under the Apache License, Version 2.0 (the "License");
4    * you may not use this file except in compliance with the License.
5    * You may obtain a copy of the License at
6    *
7    *     http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * 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  import org.acegisecurity.adapters.AbstractAdapterAuthenticationToken;
20  
21  import org.mortbay.http.UserPrincipal;
22  
23  
24  /***
25   * A Jetty compatible {@link org.acegisecurity.Authentication} object.
26   *
27   * @author Ben Alex
28   * @version $Id: JettyAcegiUserToken.java,v 1.5 2005/11/17 00:56:28 benalex Exp $
29   */
30  public class JettyAcegiUserToken extends AbstractAdapterAuthenticationToken
31      implements UserPrincipal {
32      //~ Instance fields ========================================================
33  
34      private String password;
35      private String username;
36  
37      //~ Constructors ===========================================================
38  
39      public JettyAcegiUserToken(String key, String username, String password,
40          GrantedAuthority[] authorities) {
41          super(key, authorities);
42          this.username = username;
43          this.password = password;
44      }
45  
46      protected JettyAcegiUserToken() {
47          throw new IllegalArgumentException("Cannot use default constructor");
48      }
49  
50      //~ Methods ================================================================
51  
52      public Object getCredentials() {
53          return this.password;
54      }
55  
56      public String getName() {
57          return this.username;
58      }
59  
60      public Object getPrincipal() {
61          return this.username;
62      }
63  }