1 23 24 package com.sun.enterprise.admin.server.core.mbean.config; 25 26 import javax.management.*; 28 29 import com.sun.enterprise.config.ConfigException; 31 import com.sun.enterprise.config.serverbeans.ServerTags; 32 import com.sun.enterprise.config.serverbeans.ServerXPathHelper; 33 import com.sun.enterprise.config.serverbeans.IiopService; 34 import com.sun.enterprise.config.serverbeans.IiopListener; 35 import com.sun.enterprise.config.serverbeans.Ssl; 36 import com.sun.enterprise.config.serverbeans.SslClientConfig; 37 38 import com.sun.enterprise.admin.common.ObjectNames; 40 import com.sun.enterprise.admin.common.exception.MBeanConfigException; 41 import com.sun.enterprise.admin.common.constant.ConfigAttributeName; 42 43 import com.sun.enterprise.util.i18n.StringManager; 45 46 47 53 public class ManagedORBComponent extends ConfigMBeanBase implements ConfigAttributeName.OrbComponent 54 { 55 private static StringManager localStrings = 57 StringManager.getManager( ManagedORBComponent.class ); 58 59 private static final String ORB_ATTRIBUTE = ServerTags.ORB+ServerXPathHelper.XPATH_SEPARATOR+ATTRIBUTE; 60 63 private static final String [][] MAPLIST = 64 { 65 {kMessageFragmentSize , ORB_ATTRIBUTE + ServerTags.MESSAGE_FRAGMENT_SIZE}, 66 {kMaxConnections , ORB_ATTRIBUTE + ServerTags.MAX_CONNECTIONS}, 67 }; 69 72 private static final String [] ATTRIBUTES = 73 { 74 kMessageFragmentSize + ", int, RW" , 75 kMaxConnections + ", int, RW" , 76 }; 78 81 private static final String [] OPERATIONS = 82 { 83 "createORBListener(String id, String address, Integer port, Boolean enabled), ACTION", 84 "deleteORBListener(String id), ACTION", 85 "listORBListeners(), INFO", 86 "createSsl(String certNickname, Boolean ssl2Enabled, String ssl2Ciphers, Boolean ssl3Enabled, String ssl3TlsCiphers, Boolean tlsEnabled, Boolean tlsRollbackEnabled, Boolean clientAuthEnabled), ACTION", 87 "deleteSsl(), ACTION", 88 "isSslCreated(), INFO", 89 }; 90 91 92 93 96 public ManagedORBComponent() throws MBeanConfigException 97 { 98 Object [] mergedAttrs = MergeAttributesWithAnotherMbean( 99 MAPLIST, ATTRIBUTES, SslBase.MAPLIST, SslBase.ATTRIBUTES, 100 ServerTags.SSL_CLIENT_CONFIG+ServerXPathHelper.XPATH_SEPARATOR+ServerTags.SSL , null); 101 this.setDescriptions( (String [][])mergedAttrs[0], (String [])mergedAttrs[1], OPERATIONS); 102 } 103 104 108 public ManagedORBComponent(String instanceName) throws MBeanConfigException 109 { 110 this(); initialize(ObjectNames.kOrbType, new String []{instanceName}); 112 } 113 114 118 public void createORBListener(String id, String address, Integer port, Boolean enabled) throws ConfigException 119 { 120 IiopListener listener = new IiopListener(); 121 if(id!=null) 122 listener.setId(id); 123 if(address!=null) 124 listener.setAddress(address); 125 if(port!=null) 126 listener.setPort(port.toString()); 127 if(enabled!=null) 128 listener.setEnabled(enabled.booleanValue()); 129 IiopService service = (IiopService)getConfigBeanByXPath( ServerXPathHelper.getIIOPServiceXpath() ); 130 service.addIiopListener(listener); 131 132 getConfigContext().flush(); 133 } 134 135 139 public void deleteORBListener(String id) throws ConfigException 140 { 141 IiopService service = (IiopService)getConfigBeanByXPath( ServerXPathHelper.getIIOPServiceXpath() ); 142 IiopListener listener = service.getIiopListenerById(id); 143 if(listener!=null) 144 service.removeIiopListener(listener); 145 getConfigContext().flush(); 146 } 147 148 151 public String [] listORBListeners() throws ConfigException 152 { 153 IiopService service = (IiopService)getConfigBeanByXPath( ServerXPathHelper.getIIOPServiceXpath() ); 154 IiopListener[] listeners = service.getIiopListener(); 155 String [] res = new String [listeners.length]; 156 for(int i=0; i<listeners.length; i++) 157 { 158 res[i] = listeners[i].getId(); 159 } 160 return res; 161 } 162 163 166 public boolean isSslCreated() throws ConfigException 167 { 168 IiopService service = (IiopService)this.getBaseConfigBean(); 169 SslClientConfig config = service.getSslClientConfig(); 170 if(config==null) 171 return false; 172 return (config.getSsl()!=null); 173 } 174 175 178 public void deleteSsl() throws ConfigException 179 { 180 IiopService service = (IiopService)this.getBaseConfigBean(); 181 service.setSslClientConfig(null); getConfigContext().flush(); 183 } 184 188 public void createSsl(String certNickname, Boolean ssl2Enabled, String ssl2Ciphers, 189 Boolean ssl3Enabled, String ssl3TlsCiphers, 190 Boolean tlsEnabled, Boolean tlsRollbackEnabled, Boolean clientAuthEnabled) throws ConfigException 191 { 192 if(isSslCreated()) 193 { 194 String msg = localStrings.getString( "admin.server.core.mbean.config.iiopservice_has_ssl_created" ); 195 throw new ConfigException( msg ); 196 } 197 198 IiopService service = (IiopService)this.getBaseConfigBean(); 199 SslClientConfig config = service.getSslClientConfig(); 200 if(config == null) 201 { 202 config = new SslClientConfig(); 203 } 204 205 Ssl ssl = new Ssl(); 206 if(certNickname!=null) 208 ssl.setCertNickname(certNickname); 209 if(ssl2Ciphers!=null) 210 ssl.setSsl2Ciphers(ssl2Ciphers); 211 if(ssl3TlsCiphers!=null) 212 ssl.setSsl3TlsCiphers(ssl3TlsCiphers); 213 if(ssl2Enabled!=null) 215 ssl.setSsl2Enabled(ssl2Enabled.booleanValue()); 216 if(ssl3Enabled!=null) 217 ssl.setSsl3Enabled(ssl3Enabled.booleanValue()); 218 if(tlsEnabled!=null) 219 ssl.setTlsEnabled(tlsEnabled.booleanValue()); 220 if(tlsRollbackEnabled!=null) 221 ssl.setTlsRollbackEnabled(tlsRollbackEnabled.booleanValue()); 222 if(clientAuthEnabled!=null) 223 ssl.setClientAuthEnabled(clientAuthEnabled.booleanValue()); 224 225 config.setSsl(ssl); 226 service.setSslClientConfig(config); 227 228 getConfigContext().flush(); 229 } 230 } 231 | Popular Tags |