View Javadoc

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;
20  
21  import java.security.Principal;
22  
23  import javax.security.auth.Subject;
24  import javax.security.auth.login.LoginContext;
25  
26  
27  
28  /* ---------------------------------------------------- */
29  /** JAASUserPrincipal
30   * <p>Implements the JAAS version of the
31   *  org.eclipse.jetty.http.UserPrincipal interface.
32   *
33   * @version $Id: JAASUserPrincipal.java 4780 2009-03-17 15:36:08Z jesse $
34   *
35   */
36  public class JAASUserPrincipal implements Principal
37  {
38      private final String _name;
39      private final Subject _subject;
40      private final LoginContext _loginContext;
41  
42      /* ------------------------------------------------ */
43  
44      public JAASUserPrincipal(String name, Subject subject, LoginContext loginContext)
45      {
46          this._name = name;
47          this._subject = subject;
48          this._loginContext = loginContext;
49      }
50  
51      /* ------------------------------------------------ */
52      /** Get the name identifying the user
53       */
54      public String getName ()
55      {
56          return _name;
57      }
58  
59  
60      /* ------------------------------------------------ */
61      /** Provide access to the Subject
62       * @return subject
63       */
64      public Subject getSubject ()
65      {
66          return this._subject;
67      }
68  
69      LoginContext getLoginContext ()
70      {
71          return this._loginContext;
72      }
73  
74      public String toString()
75      {
76          return getName();
77      }
78  
79  }