KickJava   Java API By Example, From Geeks To Geeks.

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


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.Map JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.io.Serializable JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30 import javax.management.Attribute JavaDoc;
31 import javax.management.AttributeList JavaDoc;
32
33 import com.sun.appserv.management.config.DomainConfig;
34 import com.sun.appserv.management.util.jmx.JMXUtil;
35
36 import com.sun.enterprise.management.support.oldconfig.OldConnectorConnectionPoolMBean;
37
38 /**
39     MBean managing all instances of Connector resource.
40  */

41
42 public final class SecurityMapConfigFactory extends ConfigFactory
43 {
44         public
45     SecurityMapConfigFactory( final ConfigFactoryCallback callbacks)
46     {
47         super( callbacks );
48     }
49         
50         private OldConnectorConnectionPoolMBean
51     getOld()
52     {
53         return getOldConfigProxies().getOldConnectorConnectionPool( getContainerName() );
54     }
55
56     static private final String JavaDoc USERNAME_KEY = "username";
57     static private final String JavaDoc PASSWORD_KEY = "password";
58     
59
60         public ObjectName JavaDoc
61     create(
62         final String JavaDoc name,
63         final String JavaDoc username,
64         final String JavaDoc password,
65         final String JavaDoc[] principals,
66         final String JavaDoc[] userGroups )
67     {
68         final String JavaDoc containerName = getContainerName();
69         
70         final OldConnectorConnectionPoolMBean ccp =
71             getOldConfigProxies().getOldConnectorConnectionPool( containerName );
72             
73         final Map JavaDoc<String JavaDoc,Serializable JavaDoc> params = new HashMap JavaDoc<String JavaDoc,Serializable JavaDoc>();
74         params.put( "name", name );
75         params.put( "pool_name", containerName );
76         params.put( "principal", principals );
77         params.put( "user_group", userGroups );
78         
79         final AttributeList JavaDoc attrs = new AttributeList JavaDoc();
80         for( final String JavaDoc key : params.keySet() )
81         {
82             attrs.add( new Attribute JavaDoc( key, params.get( key ) ) );
83         }
84         
85         final String JavaDoc targetName = null;
86         getOld().createSecurityMap( attrs, username, password, targetName );
87         // doesn't return the ObjectName; returns null!
88
final ObjectName JavaDoc oldObjectName = ccp.getSecurityMapByName( name );
89         
90         final ObjectName JavaDoc amxName = finish( oldObjectName, null );
91         
92         return( amxName );
93     }
94     
95     
96         protected void
97     removeByName( final String JavaDoc name )
98     {
99         getOld().removeSecurityMapByName( name );
100     }
101 }
102
103
104
105
106
107
108
109
Popular Tags