KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > web > tomcat > security > JBossGenericPrincipal


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.web.tomcat.security;
23
24 import java.security.Principal JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Set JavaDoc;
27 import javax.security.auth.Subject JavaDoc;
28
29 import org.apache.catalina.Realm;
30 import org.apache.catalina.realm.GenericPrincipal;
31
32 /**
33  * An implementation of the catalina GenericPrincipal to allow caching of
34  * security manager invocation results.
35  *
36  * @author remm@jboss.org
37  * @author Scott.Stark@jboss.org
38  * @version $Revision: 43292 $
39  */

40 class JBossGenericPrincipal
41    extends GenericPrincipal
42 {
43    /** The authenticated user name as a Principal */
44    private Principal JavaDoc authPrincipal = null;
45    /** The caller principal name mapping if any */
46    private Principal JavaDoc callerPrincipal = null;
47    /** The authenticated user credentials */
48    private Object JavaDoc credentials = null;
49    /** The authenticated user Subject */
50    private Subject JavaDoc subject = null;
51    /** Set<Principal> of the roles assigned to the subject */
52    private Set JavaDoc userRoles = null;
53
54    /**
55     * Create an encapsulation of the authenticated caller information.
56     *
57     * @param realm - the Relam implementation creating the principal
58     * @param subject - the authenticated JAAS subject
59     * @param authPrincipal - the principal used for authentication and stored in
60     * the security manager cache
61     * @param callerPrincipal - the possibly different caller principal
62     * representation of the authenticated principal
63     * @param credentials - the opaque credentials used for authentication
64     * @param roles - the List<String> of the role names assigned to the subject
65     * @param userRoles - the Set<Principal> of the roles assigned to the subject
66     */

67    JBossGenericPrincipal(Realm realm, Subject JavaDoc subject,
68       Principal JavaDoc authPrincipal, Principal JavaDoc callerPrincipal,
69       Object JavaDoc credentials, List JavaDoc roles, Set JavaDoc userRoles)
70    {
71       super(realm, callerPrincipal.getName(), null, roles, callerPrincipal);
72       this.credentials = credentials;
73       this.authPrincipal = authPrincipal;
74       this.callerPrincipal = callerPrincipal;
75       this.subject = subject;
76       this.userRoles = userRoles;
77    }
78
79    Principal JavaDoc getAuthPrincipal()
80    {
81       return this.authPrincipal;
82    }
83    /**
84     * Gets the value of principal
85     *
86     * @return the value of principal
87     */

88    Principal JavaDoc getCallerPrincipal()
89    {
90       return this.callerPrincipal;
91    }
92
93    /**
94     * Gets the value of credentials
95     *
96     * @return the value of credentials
97     */

98    Object JavaDoc getCredentials()
99    {
100       return this.credentials;
101    }
102
103    Subject JavaDoc getSubject()
104    {
105       return subject;
106    }
107
108    /**
109     * Get the original set of role Principals
110     * @return Set<Princpals> for the roles assigned to the user
111     */

112    Set JavaDoc getUserRoles()
113    {
114       return userRoles;
115    }
116 }
117
Popular Tags