View Javadoc

1   // ========================================================================
2   // Copyright (c) 2002-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.plus.jaas;
15  
16  import java.security.Principal;
17  
18  import javax.security.auth.Subject;
19  import javax.security.auth.login.LoginContext;
20  
21  
22  
23  /* ---------------------------------------------------- */
24  /** JAASUserPrincipal
25   * <p>Implements the JAAS version of the 
26   *  org.eclipse.http.UserPrincipal interface.
27   *
28   * @version $Id: JAASUserPrincipal.java 4780 2009-03-17 15:36:08Z jesse $
29   * 
30   */
31  public class JAASUserPrincipal implements Principal 
32  {
33      private final String _name;
34      private final Subject _subject;
35      private final LoginContext _loginContext;
36  
37      /* ------------------------------------------------ */
38  
39      public JAASUserPrincipal(String name, Subject subject, LoginContext loginContext)
40      {
41          this._name = name;
42          this._subject = subject;
43          this._loginContext = loginContext;
44      }
45  
46      /* ------------------------------------------------ */
47      /** Get the name identifying the user
48       */
49      public String getName ()
50      {
51          return _name;
52      }
53      
54      
55      /* ------------------------------------------------ */
56      /** Provide access to the Subject
57       * @return subject
58       */
59      public Subject getSubject ()
60      {
61          return this._subject;
62      }
63      
64      LoginContext getLoginContext ()
65      {
66          return this._loginContext;
67      }
68      
69      public String toString()
70      {
71          return getName();
72      }
73      
74  }