1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Map ; 26 import java.util.HashMap ; 27 28 import javax.management.ObjectName ; 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 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 authLayer ) 66 { 67 final SecurityServiceConfig ss = getDefaultSecurityServiceConfig( domainRoot ); 68 69 final Map <String ,String > optional = new HashMap <String ,String >(); 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 AUTH_TYPE = MessageSecurityConfig.AUTH_LAYER_HTTP_SERVLET; 90 91 95 public void 96 testCreateRemove( ) 97 { 98 final SecurityServiceConfig ss = getDefaultSecurityServiceConfig( getDomainRoot() ); 99 final Map <String ,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 |