KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > SecurityMapConfigImpl


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 package com.sun.enterprise.management.config;
24
25 import java.util.Set JavaDoc;
26
27 import javax.management.ObjectName JavaDoc;
28 import javax.management.Attribute JavaDoc;
29
30 import com.sun.appserv.management.base.XTypes;
31 import com.sun.appserv.management.config.SecurityMapConfig;
32
33 import com.sun.appserv.management.util.misc.GSetUtil;
34 import com.sun.appserv.management.util.misc.ExceptionUtil;
35 import com.sun.appserv.management.util.misc.StringUtil;
36
37 import com.sun.enterprise.management.config.AMXConfigImplBase;
38
39 import com.sun.enterprise.management.support.Delegate;
40 import com.sun.enterprise.management.support.AMXAttributeNameMapper;
41
42 import com.sun.enterprise.management.support.oldconfig.OldSecurityMap;
43
44 /**
45     @since Appserver 9.0
46 */

47 public final class SecurityMapConfigImpl extends AMXConfigImplBase
48 {
49         public
50     SecurityMapConfigImpl( final Delegate delegate )
51     {
52         super( delegate );
53     }
54
55         protected void
56     addCustomMappings( final AMXAttributeNameMapper mapper )
57     {
58         super.addCustomMappings( mapper );
59         
60         mapper.matchName( "PrincipalNames", "Principal" );
61         mapper.matchName( "UserGroupNames", "UserGroup" );
62     }
63     
64         private SecurityMapConfig
65     self()
66     {
67         return (SecurityMapConfig)getSelf();
68     }
69     
70         public void
71     createPrincipal( final String JavaDoc principal )
72     {
73         final String JavaDoc[] existing = self().getPrincipalNames();
74         
75         final Set JavaDoc<String JavaDoc> newSet = GSetUtil.newSet( existing );
76         newSet.add( principal );
77         
78         final String JavaDoc[] newOnes = GSetUtil.toStringArray( newSet );
79         
80         delegateSetAttributeNoThrow( "PrincipalNames", newOnes );
81     }
82     
83         public void
84     removePrincipal( final String JavaDoc principal )
85     {
86         final String JavaDoc[] existing = self().getPrincipalNames();
87         
88         final Set JavaDoc<String JavaDoc> newSet = GSetUtil.newSet( existing );
89         newSet.remove( principal );
90         
91         final String JavaDoc[] newOnes = GSetUtil.toStringArray( newSet );
92         
93         delegateSetAttributeNoThrow( "PrincipalNames", newOnes );
94     }
95     
96         public void
97     createUserGroup( final String JavaDoc userGroup )
98     {
99         final String JavaDoc[] existing = self().getUserGroupNames();
100         
101         final Set JavaDoc<String JavaDoc> newSet = GSetUtil.newSet( existing );
102         newSet.add( userGroup );
103         
104         final String JavaDoc[] newOnes = GSetUtil.toStringArray( newSet );
105         
106         delegateSetAttributeNoThrow( "UserGroupNames", newOnes );
107     }
108     
109         public void
110     removeUserGroup( final String JavaDoc userGroup )
111     {
112         final String JavaDoc[] existing = self().getUserGroupNames();
113         
114         final Set JavaDoc<String JavaDoc> newSet = GSetUtil.newSet( existing );
115         newSet.remove( userGroup );
116         
117         final String JavaDoc[] newOnes = GSetUtil.toStringArray( newSet );
118         
119         delegateSetAttributeNoThrow( "UserGroupNames", newOnes );
120     }
121     
122     /*
123         public ObjectName
124     getBackendPrincipalConfigObjectName()
125     {
126         return getContaineeObjectName( XTypes.BACKEND_PRINCIPAL_CONFIG );
127     }
128     */

129 }
130
131
132
133
Popular Tags