KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > offline > SecurityMapConfigBeanHelper


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  
25 package com.sun.enterprise.management.offline;
26
27 import java.util.Set JavaDoc;
28
29 import javax.management.AttributeNotFoundException JavaDoc;
30 import javax.management.InvalidAttributeValueException JavaDoc;
31
32 import com.sun.enterprise.config.ConfigContext;
33 import com.sun.enterprise.config.ConfigBean;
34 import com.sun.enterprise.config.ConfigException;
35
36
37 final class SecurityMapConfigBeanHelper extends StdConfigBeanHelper
38 {
39     static private final String JavaDoc PRINCIPAL_ATTR = "Principal";
40     static private final String JavaDoc USER_GROUP_ATTR = "UserGroup";
41     
42         public
43     SecurityMapConfigBeanHelper(
44         final ConfigContext configContext,
45         final ConfigBean configBean )
46     {
47         super( configContext, configBean );
48         
49     }
50     
51         public Object JavaDoc
52     getAttribute( final String JavaDoc attrName )
53         throws AttributeNotFoundException JavaDoc
54     {
55         Object JavaDoc result = null;
56         
57         if ( PRINCIPAL_ATTR.equals( attrName ) )
58         {
59             result = getPrincipalNames();
60         }
61         else if ( USER_GROUP_ATTR.equals( attrName ) )
62         {
63             result = getUserGroupNames();
64         }
65         else
66         {
67             result = super.getAttribute( attrName );
68         }
69         return result;
70     }
71     
72         protected Class JavaDoc
73     getAttributeClass( final String JavaDoc attrName )
74     {
75         Class JavaDoc result = null;
76         
77         if ( PRINCIPAL_ATTR.equals( attrName ) ||
78             USER_GROUP_ATTR.equals( attrName ) )
79         {
80             result = String JavaDoc[].class;
81         }
82         else
83         {
84             result = super.getAttributeClass( attrName );
85         }
86         return result;
87     }
88     
89         protected Set JavaDoc<String JavaDoc>
90     _getAttributeNames()
91     {
92         final Set JavaDoc<String JavaDoc> attrNames = super._getAttributeNames();
93         
94         attrNames.add( PRINCIPAL_ATTR );
95         attrNames.add( USER_GROUP_ATTR );
96         
97         return attrNames;
98     }
99     
100         public String JavaDoc[]
101     getPrincipalNames()
102     {
103         final String JavaDoc value = (String JavaDoc)getValue( PRINCIPAL_ATTR );
104         
105         // presumably spaces are not allowed in a JVM option
106
final String JavaDoc[] result = (value == null) ? EMPTY_STRING_ARRAY : value.split( " " );
107         
108         return result;
109     }
110     
111         public String JavaDoc[]
112     getUserGroupNames()
113     {
114         final String JavaDoc value = (String JavaDoc)getValue( USER_GROUP_ATTR );
115         
116         // presumably spaces are not allowed in a JVM option
117
final String JavaDoc[] result = (value == null) ? EMPTY_STRING_ARRAY : value.split( " " );
118         
119         return result;
120     }
121 }
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Popular Tags