1 //
2 // ========================================================================
3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.jaas.spi;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.eclipse.jetty.util.security.Credential;
25
26 /**
27 * UserInfo
28 *
29 * This is the information read from the external source
30 * about a user.
31 *
32 * Can be cached by a UserInfoCache implementation
33 */
34 public class UserInfo
35 {
36
37 private String _userName;
38 private Credential _credential;
39 private List<String> _roleNames;
40
41
42 public UserInfo (String userName, Credential credential, List<String> roleNames)
43 {
44 _userName = userName;
45 _credential = credential;
46 _roleNames = new ArrayList<String>();
47 if (roleNames != null)
48 {
49 _roleNames.addAll(roleNames);
50 }
51 }
52
53 public String getUserName()
54 {
55 return this._userName;
56 }
57
58 public List<String> getRoleNames ()
59 {
60 return new ArrayList<String>(_roleNames);
61 }
62
63 public boolean checkCredential (Object suppliedCredential)
64 {
65 return _credential.check(suppliedCredential);
66 }
67
68 protected Credential getCredential ()
69 {
70 return _credential;
71 }
72
73 }