KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > runtime > common > SecurityRoleMapping


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment.runtime.common;
25
26 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor;
27 import java.util.ArrayList JavaDoc;
28 import java.util.List JavaDoc;
29
30 /**
31  * This is the in memory representation of the security-role-mapping
32  * information. Note that we are keeping just the literal Strings
33  * in this object. The implementation of Principal is not instantiated
34  * here. This is because 1) the dol should avoid loading any classes
35  * as the classloaders used for deployment and runtime can be different.
36  * 2) verifier uses this information and it has not access to the rolemaper
37  * on the server.
38  *
39  * @author Jerome Dochez
40  */

41 public class SecurityRoleMapping extends RuntimeDescriptor {
42
43     private String JavaDoc roleName = null; //mandatory element
44
private List JavaDoc<PrincipalNameDescriptor> principals =
45                         new ArrayList JavaDoc<PrincipalNameDescriptor>();
46     private List JavaDoc<String JavaDoc> groups = new ArrayList JavaDoc<String JavaDoc>();
47
48     public String JavaDoc getRoleName() {
49         return roleName;
50     }
51
52     public void setRoleName(String JavaDoc name) {
53         roleName = name;
54     }
55
56     public List JavaDoc<PrincipalNameDescriptor> getPrincipalNames() {
57         return principals;
58     }
59
60     public void addPrincipalName(PrincipalNameDescriptor p) {
61         principals.add(p);
62     }
63
64     public List JavaDoc<String JavaDoc> getGroupNames() {
65         return groups;
66     }
67
68     public void addGroupName(String JavaDoc g) {
69         groups.add(g);
70     }
71
72     /**
73      *@deprecated
74      *This method needs to be removed once the custom principal is fully
75      *supported. We keep it for now for backward compatiblity in API. Note
76      *that this method only returns the name of the principals, not their
77      *class-names. Use with caution!
78      */

79     public String JavaDoc[] getPrincipalName() {
80         String JavaDoc[] names = new String JavaDoc[principals.size()];
81         for (int i = 0; i < principals.size(); i++) {
82             names[i] = new String JavaDoc(principals.get(i).getName());
83         }
84         return names;
85     }
86 }
87
Popular Tags