View Javadoc

1   // ========================================================================
2   // $Id: UserInfo.java 305 2006-03-07 10:32:14Z janb $
3   // Copyright 1999-2004 Mort Bay Consulting Pty. Ltd.
4   // ------------------------------------------------------------------------
5   // Licensed under the Apache License, Version 2.0 (the "License");
6   // you may not use this file except in compliance with the License.
7   // You may obtain a copy of the License at 
8   // http://www.apache.org/licenses/LICENSE-2.0
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.mortbay.jetty.plus.jaas.spi;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.mortbay.jetty.security.Credential;
22  
23  /**
24   * UserInfo
25   *
26   * This is the information read from the external source
27   * about a user.
28   * 
29   * Can be cached by a UserInfoCache implementation
30   */
31  public class UserInfo
32  {
33      
34      private String userName;
35      private Credential credential;
36      private List roleNames;
37      
38      
39      public UserInfo (String userName, Credential credential, List roleNames)
40      {
41          this.userName = userName;
42          this.credential = credential;
43          this.roleNames = new ArrayList();
44          if (roleNames != null)
45              this.roleNames.addAll(roleNames);
46      }
47      
48      public String getUserName()
49      {
50          return this.userName;
51      }
52      
53      public List getRoleNames ()
54      {
55          return new ArrayList(this.roleNames);
56      }
57      
58      public boolean checkCredential (Object suppliedCredential)
59      {
60          return this.credential.check(suppliedCredential);
61      }
62      
63      protected Credential getCredential ()
64      {
65          return this.credential;
66      }
67      
68  }