Initial checkin after git reorg
This commit is contained in:
commit
512e492f9e
|
@ -0,0 +1,21 @@
|
|||
package de.startux.j2ee.bea;
|
||||
|
||||
import weblogic.common.*;
|
||||
import java.util.Hashtable;
|
||||
import java.security.Security;
|
||||
|
||||
public class Register_IBMJCE implements T3StartupDef {
|
||||
public void setServices(T3ServicesDef services) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind selected values into the Naming Service.
|
||||
*/
|
||||
public String startup(String name, Hashtable args) throws Exception {
|
||||
System.out.println(name + " Trying to register IBM JCE");
|
||||
Security.addProvider(new com.ibm.crypto.provider.IBMJCE());
|
||||
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package de.startux.j2ee.bea;
|
||||
|
||||
import weblogic.application.ApplicationLifecycleListener;
|
||||
import java.util.Hashtable;
|
||||
import java.security.Security;
|
||||
|
||||
public class Register_IBMJCE_wls9 extends ApplicationLifecycleListener {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
System.out.println("Trying to register IBM JCE...");
|
||||
try {
|
||||
Security.addProvider(new com.ibm.crypto.provider.IBMJCE());
|
||||
System.out.println("Successfully registered IBM JCE !");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception caught: " + e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
package de.startux.j2ee.bea;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.*;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.remote.JMXConnector;
|
||||
import javax.management.remote.JMXConnectorFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
import weblogic.application.ApplicationLifecycleListener;
|
||||
|
||||
public class setSSLProperties extends ApplicationLifecycleListener {
|
||||
private static final ObjectName service;
|
||||
|
||||
static {
|
||||
// Initializing the object name for DomainRuntimeServiceMBean
|
||||
// so it can be used throughout the class.
|
||||
try {
|
||||
service = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");
|
||||
} catch (MalformedObjectNameException e) {
|
||||
throw new AssertionError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
JMXConnector connector;
|
||||
|
||||
// String hostname = args[0];
|
||||
// String portString = args[1];
|
||||
// String username = args[2];
|
||||
// String password = args[3];
|
||||
|
||||
String trustStore = "";
|
||||
String trustStorePasswd = "";
|
||||
String trustStoreType = "";
|
||||
String keyStore = "";
|
||||
String keyStorePasswd = "";
|
||||
String keyStoreType = "";
|
||||
|
||||
System.out.println("Trying to set SSL javax.* properties");
|
||||
|
||||
setSSLProperties s = new setSSLProperties();
|
||||
// connector = initConnection(hostname, portString, username, password);
|
||||
// MBeanServerConnection connection = connector.getMBeanServerConnection();
|
||||
|
||||
MBeanServer connection = initConnectionLocal();
|
||||
|
||||
System.out.println("Using connection " + connection);
|
||||
try {
|
||||
// Get the Domain MBean
|
||||
ObjectName server = (ObjectName) connection.getAttribute(service, "ServerConfiguration");
|
||||
|
||||
trustStore = (String) connection.getAttribute(server, "CustomTrustKeyStoreFileName");
|
||||
trustStorePasswd = (String) connection.getAttribute(server, "CustomTrustKeyStorePassPhrase");
|
||||
trustStoreType = (String) connection.getAttribute(server, "CustomTrustKeyStoreType");
|
||||
keyStore = (String) connection.getAttribute(server, "CustomIdentityKeyStoreFileName");
|
||||
keyStorePasswd = (String) connection.getAttribute(server, "CustomIdentityKeyStorePassPhrase");
|
||||
keyStoreType = (String) connection.getAttribute(server, "CustomIdentityKeyStoreType");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception caught: " + e);
|
||||
}
|
||||
|
||||
if (trustStore != null && trustStore.length() > 0) {
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||
System.out.println("Setting javax.net.ssl.trustStore: " + trustStore);
|
||||
}
|
||||
if (trustStorePasswd != null && trustStorePasswd.length() > 0) {
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePasswd);
|
||||
System.out.println("Setting javax.net.ssl.trustStorePassword: ******");
|
||||
}
|
||||
if (trustStoreType != null && trustStoreType.length() > 0) {
|
||||
System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);
|
||||
System.out.println("Setting javax.net.sslq.trustStoreType: " + trustStoreType);
|
||||
}
|
||||
if (keyStore != null && keyStore.length() > 0) {
|
||||
System.setProperty("javax.net.ssl.keyStore", keyStore);
|
||||
System.out.println("Setting javax.net.ssl.keyStore: " + keyStore);
|
||||
}
|
||||
if (keyStorePasswd != null && keyStorePasswd.length() > 0) {
|
||||
System.setProperty("javax.net.ssl.keyStorePassword", keyStorePasswd);
|
||||
System.out.println("Setting javax.net.ssl.keyStorePassword: ******");
|
||||
}
|
||||
if (keyStoreType != null && keyStoreType.length() > 0) {
|
||||
System.setProperty("javax.net.ssl.keyStoreType", keyStoreType);
|
||||
System.out.println("Setting javax.net.ssl.keyStoreType: " + keyStoreType);
|
||||
}
|
||||
|
||||
// connector.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize connection to the Domain Runtime MBean Server.
|
||||
*/
|
||||
public static MBeanServer initConnectionLocal() throws NamingException {
|
||||
InitialContext ctx = new InitialContext();
|
||||
|
||||
// J2EE, WebAPP URL
|
||||
// MBeanServer server = (MBeanServer)
|
||||
// ctx.lookup("java:comp/env/jmx/runtime");
|
||||
// EAR URL
|
||||
MBeanServer server = (MBeanServer) ctx.lookup("java:comp/jmx/runtime");
|
||||
return server;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize JMX connector.
|
||||
*/
|
||||
public static JMXConnector initConnection(String hostname, String portString, String username, String password) throws IOException, MalformedURLException {
|
||||
|
||||
String protocol = "t3";
|
||||
Integer portInteger = Integer.valueOf(portString);
|
||||
int port = portInteger.intValue();
|
||||
String jndiroot = "/jndi/";
|
||||
String mserver = "weblogic.management.mbeanservers.runtime";
|
||||
|
||||
JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port, jndiroot + mserver);
|
||||
|
||||
System.out.println("Trying remote JMX: " + serviceURL);
|
||||
|
||||
Hashtable h = new Hashtable();
|
||||
h.put(Context.SECURITY_PRINCIPAL, username);
|
||||
h.put(Context.SECURITY_CREDENTIALS, password);
|
||||
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
|
||||
return JMXConnectorFactory.connect(serviceURL, h);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue