From: Dave H. <hel...@us...> - 2012-06-01 17:49:39
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient In directory vz-cvs-3.sog:/tmp/cvs-serv7997/src/org/sblim/cimclient Modified Files: Tag: Experimental WBEMListenerSBLIM.java Log Message: 3529065 - Enable WBEMListener get/setProperty Index: WBEMListenerSBLIM.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/WBEMListenerSBLIM.java,v retrieving revision 1.5.2.13 retrieving revision 1.5.2.14 diff -u -d -r1.5.2.13 -r1.5.2.14 --- WBEMListenerSBLIM.java 23 May 2012 16:59:22 -0000 1.5.2.13 +++ WBEMListenerSBLIM.java 1 Jun 2012 17:49:37 -0000 1.5.2.14 @@ -26,12 +26,15 @@ * 3496385 2012-03-02 blaschke-oss JSR48 1.0.0: add WBEMListener get/setProperty * 3513228 2012-04-23 blaschke-oss Reliable Indications support can create lots of threads * 3529062 2012-05-23 blaschke-oss WBEMListenerFactory should return new instance + * 3529065 2012-05-31 hellerda Enable WBEMListener get/setProperty */ package org.sblim.cimclient; +import java.io.File; import java.io.IOException; import java.net.BindException; +import java.util.Enumeration; import java.util.EventListener; import java.util.HashMap; import java.util.Map; @@ -39,6 +42,7 @@ import javax.wbem.listener.IndicationListener; import javax.wbem.listener.WBEMListener; +import javax.wbem.listener.WBEMListenerConstants; import org.sblim.cimclient.internal.http.HttpConnectionHandler; import org.sblim.cimclient.internal.http.HttpServerConnection; @@ -59,7 +63,7 @@ * processes incoming indications * */ - public static class WBEMListenerImpl { + public class WBEMListenerImpl { private EventListener iIndicationListener; @@ -89,8 +93,16 @@ */ public WBEMListenerImpl(String pLocalAddress, int pPort, boolean pSSL, EventListener pIndicationListener, Properties pProperties) throws IOException { - WBEMConfiguration config = (pProperties != null ? new WBEMConfiguration(pProperties) - : WBEMConfiguration.getGlobalConfiguration()); + + // Merge any properties passed via addListener + if (pProperties != null) { + for (Enumeration<Object> e = pProperties.keys(); e.hasMoreElements();) { + String key = (String) e.nextElement(); + String value = pProperties.getProperty(key); + setProperty(key, value); + } + } + WBEMConfiguration config = iConfiguration; if (!(pIndicationListener instanceof IndicationListener) && !(pIndicationListener instanceof IndicationListenerSBLIM)) throw new IllegalArgumentException( "Listener must be instance of IndicationListener or IndicationListenerSBLIM"); @@ -157,8 +169,8 @@ } - // private final WBEMConfiguration iConfiguration = new - // WBEMConfiguration(new Properties()); + private final WBEMConfiguration iConfiguration = new + WBEMConfiguration(new Properties()); private Map<Integer, WBEMListenerImpl> iPortMap = new HashMap<Integer, WBEMListenerImpl>(); @@ -334,9 +346,17 @@ public String getProperty(String pName) { if (pName.startsWith("javax.wbem.")) { // Process JSR48 properties - return null; + if (pName.equals(WBEMListenerConstants.PROP_LISTENER_KEYSTORE)) { + return this.iConfiguration.getSslKeyStorePath(); + } else if (pName.equals(WBEMListenerConstants.PROP_LISTENER_KEYSTORE_PASSWORD)) { + return this.iConfiguration.getSslKeyStorePassword(); + } else if (pName.equals(WBEMListenerConstants.PROP_LISTENER_TRUSTSTORE)) { + return this.iConfiguration.getSslTrustStorePath(); + } else { + return null; + } } - return null; + return this.iConfiguration.getDomainProperty(pName); } public synchronized void removeListener(int pPort) { @@ -347,7 +367,22 @@ } public void setProperty(String pName, String pValue) { - throw new IllegalArgumentException("Property " + pName + " with value " + pValue - + " not supported!"); + if (pName.startsWith("javax.wbem.")) { + // Process JSR48 properties + if (pName.equals(WBEMListenerConstants.PROP_LISTENER_KEYSTORE)) { + this.iConfiguration.setDomainProperty(WBEMConfigurationProperties.KEYSTORE_PATH, + pValue); + } else if (pName.equals(WBEMListenerConstants.PROP_LISTENER_KEYSTORE_PASSWORD)) { + this.iConfiguration.setDomainProperty( + WBEMConfigurationProperties.KEYSTORE_PASSWORD, pValue); + } else if (pName.equals(WBEMListenerConstants.PROP_LISTENER_TRUSTSTORE)) { + this.iConfiguration.setDomainProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, + pValue); + } else { + throw new IllegalArgumentException(pName); + } + } else { + this.iConfiguration.setDomainProperty(pName, pValue); + } } } |