KickJava   Java API By Example, From Geeks To Geeks.

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


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
28 import javax.management.ObjectName JavaDoc;
29
30 import com.sun.appserv.management.DomainRoot;
31 import com.sun.appserv.management.config.DomainConfig;
32 import com.sun.appserv.management.config.SecurityMapConfig;
33 import com.sun.appserv.management.config.SecurityServiceConfig;
34 import com.sun.appserv.management.config.MessageSecurityConfig;
35 import com.sun.appserv.management.config.ProviderConfig;
36 import com.sun.appserv.management.config.ConfigConfig;
37
38 import com.sun.enterprise.management.AMXTestBase;
39 import com.sun.enterprise.management.Capabilities;
40
41 import com.sun.appserv.management.util.misc.CollectionUtil;
42
43
44 /**
45  */

46 public final class MessageSecurityConfigTest extends AMXTestBase
47 {
48         public
49     MessageSecurityConfigTest()
50     {
51     }
52     
53         private static SecurityServiceConfig
54     getDefaultSecurityServiceConfig( final DomainRoot domainRoot )
55     {
56         final ConfigConfig config = ConfigConfigTest.ensureDefaultInstance( domainRoot );
57         final SecurityServiceConfig ss = config.getSecurityServiceConfig();
58         assert( ss != null );
59         return ss;
60     }
61         
62         private static MessageSecurityConfig
63     create(
64         final DomainRoot domainRoot,
65         final String JavaDoc authLayer )
66     {
67         final SecurityServiceConfig ss = getDefaultSecurityServiceConfig( domainRoot );
68         
69         final Map JavaDoc<String JavaDoc,String JavaDoc> optional = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
70         final MessageSecurityConfig msc = ss.createMessageSecurityConfig( authLayer,
71                 "ClientProvider", ProviderConfig.PROVIDER_TYPE_CLIENT,
72                 "com.sun.xml.wss.provider.ClientSecurityAuthModul", optional );
73         
74         msc.createProviderConfig( "ServerProvider",
75            ProviderConfig.PROVIDER_TYPE_SERVER, "com.sun.xml.wss.provider.ServerSecurityAuthModule", optional );
76            
77         msc.createProviderConfig( "DummyProvider1",
78            ProviderConfig.PROVIDER_TYPE_SERVER, "AMX.TEST.DummySecurityAuthModule", optional );
79            
80         msc.createProviderConfig( "DummyProvider2",
81            ProviderConfig.PROVIDER_TYPE_SERVER, "AMX.TEST.DummySecurityAuthModule", optional );
82         
83         msc.removeProviderConfig( "DummyProvider1" );
84         msc.removeProviderConfig( "DummyProvider2" );
85         
86         return msc;
87     }
88     
89     static private final String JavaDoc AUTH_TYPE = MessageSecurityConfig.AUTH_LAYER_HTTP_SERVLET;
90     
91     /**
92         Note: this can't be tested except by making a new one, and the names are predefined, so
93         if it already exists, it must be deleted first.
94      */

95         public void
96     testCreateRemove( )
97     {
98         final SecurityServiceConfig ss = getDefaultSecurityServiceConfig( getDomainRoot() );
99         final Map JavaDoc<String JavaDoc,MessageSecurityConfig> messageSecurityConfigs = ss.getMessageSecurityConfigMap();
100         MessageSecurityConfig msc = messageSecurityConfigs.get( AUTH_TYPE );
101         
102         if ( msc != null )
103         {
104             ss.removeMessageSecurityConfig( AUTH_TYPE );
105             msc = null;
106         }
107         
108         msc = create( getDomainRoot(), AUTH_TYPE );
109         
110         ss.removeMessageSecurityConfig( AUTH_TYPE );
111     }
112         
113 }
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
Popular Tags