Monday, December 22, 2008
Wednesday, December 17, 2008
Java SSL
package com.thewoodiefamily.sslconn;
import java.io.*;
import java.net.URL;
import java.security.KeyStore;
import java.security.SecureRandom;
import javax.net.ssl.*;
public class SSLTest {
public static SSLSocketFactory getFactory(File pKeyFile, String pKeyPassword) {
SSLContext context = null;
try {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs,
String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs,
String authType) {
}
} };
KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance("SunX509");
KeyStore keyStore = KeyStore.getInstance("PKCS12");
InputStream keyInput = new FileInputStream(pKeyFile);
keyStore.load(keyInput, pKeyPassword.toCharArray());
keyInput.close();
keyManagerFactory.init(keyStore, pKeyPassword.toCharArray());
context = SSLContext.getInstance("TLS");
context.init(keyManagerFactory.getKeyManagers(), trustAllCerts,
new SecureRandom());
} catch (Exception e) {
e.printStackTrace();
}
return context.getSocketFactory();
}
/**
* @param args
*/
public static void main(String[] args) {
try {
URL url = new URL("");
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setSSLSocketFactory(getFactory(new File(
"C:\\bundle-username.p12"), ""));
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(con
.getInputStream()));
StringBuffer sb = new StringBuffer();
String line;
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
System.out.println(sb);
} catch (Exception e) {
e.printStackTrace();
}
}
}
import java.io.*;
import java.net.URL;
import java.security.KeyStore;
import java.security.SecureRandom;
import javax.net.ssl.*;
public class SSLTest {
public static SSLSocketFactory getFactory(File pKeyFile, String pKeyPassword) {
SSLContext context = null;
try {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs,
String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs,
String authType) {
}
} };
KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance("SunX509");
KeyStore keyStore = KeyStore.getInstance("PKCS12");
InputStream keyInput = new FileInputStream(pKeyFile);
keyStore.load(keyInput, pKeyPassword.toCharArray());
keyInput.close();
keyManagerFactory.init(keyStore, pKeyPassword.toCharArray());
context = SSLContext.getInstance("TLS");
context.init(keyManagerFactory.getKeyManagers(), trustAllCerts,
new SecureRandom());
} catch (Exception e) {
e.printStackTrace();
}
return context.getSocketFactory();
}
/**
* @param args
*/
public static void main(String[] args) {
try {
URL url = new URL("");
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setSSLSocketFactory(getFactory(new File(
"C:\\bundle-username.p12"), ""));
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(con
.getInputStream()));
StringBuffer sb = new StringBuffer();
String line;
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
System.out.println(sb);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Thursday, September 18, 2008
Decrypt WebSphere Passwords
Save yourself a google....
A Blog with the Answer
WebSphere 5.0
cd $WAS_INSTALL_DIR/lib
> ../java/bin/java -cp securityimpl.jar:iwsorb.jar com.ibm.ws.security.util.PasswordDecoder {xor}LDo8LTor
encoded password == "{xor}LDo8LTor", decoded password == "secret"
WebSphere 6.X
> cd $WAS_INSTALL_DIR/lib
> ../java/bin/java -cp securityimpl.jar:iwsorb.jar::ras.jar:wsexception.jar:bootstrap.jar:emf.jar:ffdc.jar com.ibm.ws.security.util.PasswordDecoder {xor}LDo8LTor
encoded password == "{xor}LDo8LTor", decoded password == "secret"
A Blog with the Answer
WebSphere 5.0
cd $WAS_INSTALL_DIR/lib
> ../java/bin/java -cp securityimpl.jar:iwsorb.jar com.ibm.ws.security.util.PasswordDecoder {xor}LDo8LTor
encoded password == "{xor}LDo8LTor", decoded password == "secret"
WebSphere 6.X
> cd $WAS_INSTALL_DIR/lib
> ../java/bin/java -cp securityimpl.jar:iwsorb.jar::ras.jar:wsexception.jar:bootstrap.jar:emf.jar:ffdc.jar com.ibm.ws.security.util.PasswordDecoder {xor}LDo8LTor
encoded password == "{xor}LDo8LTor", decoded password == "secret"
Google and the Electric "Smart Grid" Yahoo News Link
I just read an article on yahoo: http://news.yahoo.com/s/afp/20080918/tc_afp/usitinternetenergycompanygooglege
That outlines that GE and Google are working together to revolutionize the electric grid in the next few years. Its kind of scary, where will Google stop?
That outlines that GE and Google are working together to revolutionize the electric grid in the next few years. Its kind of scary, where will Google stop?
Tuesday, September 2, 2008
Hurricanes and Vice Presidents
Today I have read way too much about hurricanes and Vice Presidential candidates. The two topics don't seem that far apart. Everyone has their own opinion about how the hurricane or election will end up. Myself I personally think that election is much like a hurricane at this point because it is steering toward something substantial, but yet we are still uncertain how much damage it will do. I am generally concerned about the weather because I have tickets to this weekend's Appalachian State University football game, plus I also work for a power company that could have weather effected outages that could force me into what is called "Storm Mode", but lets hope not.
For all of you who don't know I graduated from Appalachian State University with a Computer Science Degree. Go APPSTATE!
Yes, I know we lost to LSU, but we did pretty good for a small team from Boone, NC.
For all of you who don't know I graduated from Appalachian State University with a Computer Science Degree. Go APPSTATE!
Yes, I know we lost to LSU, but we did pretty good for a small team from Boone, NC.
Sunday, August 31, 2008
Fall 2008 TV Schedule
Today I spent some time researching the final selections from the Fall 2008 TV Schedule. Drum roll please....... The following shows will be appearing on my family's DVR starting 9/3 with a few shows coming later..
Network, Name, Time and Premier Date
Monday
--------------
CBS Big Bang Theory 8pm 9/22
NBC Chuck 8pm 9/29
CBS Two and a Half Men 9pm 9/22
NBC Heroes 9pm 9/22
ABC Samantha Who? 9:30pm 10/6
Tuesday
---------------
ABC Opportunity Knocks 8pm 9/23
Fox House 8pm 9/16 (9pm)
CBS The Mentalist 9pm 9/23
CBS Without a Trace 10pm 9/23
Wednesday
-----------------
FOX Bones 8pm 9/3
Fox Til Death 9pm 9/10
Fox Do Not Disturb 9:30pm 9/10
Thursday
------------------
NBC The Office 9:00pm 9/25
Friday
--------------------
CBS Numbers 10pm 10/3
NBC Crusoe 8pm 10/17
Sunday
---------------------
CBS Amazing Race 8pm 9/28
ABC Desperate Housewives 9pm 9/28
I hope this inspires you to go program your DVR right NOW!
Network, Name, Time and Premier Date
Monday
--------------
CBS Big Bang Theory 8pm 9/22
NBC Chuck 8pm 9/29
CBS Two and a Half Men 9pm 9/22
NBC Heroes 9pm 9/22
ABC Samantha Who? 9:30pm 10/6
Tuesday
---------------
ABC Opportunity Knocks 8pm 9/23
Fox House 8pm 9/16 (9pm)
CBS The Mentalist 9pm 9/23
CBS Without a Trace 10pm 9/23
Wednesday
-----------------
FOX Bones 8pm 9/3
Fox Til Death 9pm 9/10
Fox Do Not Disturb 9:30pm 9/10
Thursday
------------------
NBC The Office 9:00pm 9/25
Friday
--------------------
CBS Numbers 10pm 10/3
NBC Crusoe 8pm 10/17
Sunday
---------------------
CBS Amazing Race 8pm 9/28
ABC Desperate Housewives 9pm 9/28
I hope this inspires you to go program your DVR right NOW!
Saturday, August 30, 2008
JBoss Messaging
After a few hours of playing with JBoss messaging I have decided that it is a pretty decent product for Open Source developers and companies try to save money. JBoss provides all of the needed JMS features at no cost. Basically my test was to create a JMS server on an existing Ubuntu Linux server I have and use a couple of java clients I wrote to both write and read to the queue from my Apple MacBook Pro. I was able to designate the messages as "Persistent" and even restart the Java JMS provider without loosing the messages. I plan on using this in my next messaging project. If your interested I highly recommend checking it out at JBoss's WebSite. One important note that would have helped me to begin with, you must install a JBoss Application Server as a "Base" foundation for the messaging engine to run in. The following example code will simply take the queue name from the command line.
You will need the following JAR files to establish the connection to the queue:
jbossall-client.jar
jboss-aop-jdk50.jar
jboss-messaging-client.jar
javassist.jar
trove.jar
log4j.jar
Here is the example publish client:
And here is the consumer client:
You will need the following JAR files to establish the connection to the queue:
jbossall-client.jar
jboss-aop-jdk50.jar
jboss-messaging-client.jar
javassist.jar
trove.jar
log4j.jar
Here is the example publish client:
/**
*
*/
package com.thewoodiefamily.jms;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import java.util.Properties;
import javax.naming.InitialContext;
import org.apache.log4j.Logger;
/**
* @author kwoodie
*
*/
public class JMSSender {
static Logger logger = Logger.getLogger(JMSSender.class);
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");
env.put(Context.PROVIDER_URL, "harry:1099");
InitialContext remoteCtx = new InitialContext(env);
String destinationName = "/queue/" + args[0];
Queue queue = (Queue)remoteCtx.lookup(destinationName);
logger.info("Queue " + destinationName + " exists");
ConnectionFactory cf = (ConnectionFactory) remoteCtx.lookup("ConnectionFactory");
Connection connection = null;
try
{
connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = session.createProducer(queue);
TextMessage message = session.createTextMessage("Hello!" + Math.random());
message.setJMSExpiration(0);
message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
connection.start();
sender.send(message);
System.out.println("The " + message.getText() + " message was successfully sent to the " + queue.getQueueName() + " queue");
}
finally
{
if (connection != null)
{
connection.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
And here is the consumer client:
/**
*
*/
package com.thewoodiefamily.jms;
import javax.jms.QueueConnection;
import javax.jms.QueueReceiver;
import javax.jms.QueueConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.naming.Context;
import java.util.Properties;
import javax.naming.InitialContext;
import org.apache.log4j.Logger;
/**
* @author kwoodie
*
*/
public class JMSConsumer {
static final Logger logger = Logger.getLogger(JMSConsumer.class);
public static class ExListener implements MessageListener
{
public void onMessage(Message msg)
{
TextMessage tm = (TextMessage) msg;
try {
logger.info("onMessage, recv text=" + tm.getText());
} catch(Throwable t) {
t.printStackTrace();
}
}
};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
QueueConnection connection = null;
try {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");
env.put(Context.PROVIDER_URL, "harry:1099");
InitialContext remoteCtx = new InitialContext(env);
String queueName = "/queue/" + args[0];
Queue queue = (Queue)remoteCtx.lookup(queueName);
logger.info("Queue " + queueName + " exists");
QueueConnectionFactory cf = (QueueConnectionFactory) remoteCtx.lookup("ConnectionFactory");
connection = cf.createQueueConnection();
connection.start();
QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
QueueReceiver consumer = session.createReceiver(queue);
consumer.setMessageListener(new ExListener());
while(true) {
Thread.sleep(5000);
System.out.println("waiting");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Saturday, June 28, 2008
Subscribe to:
Posts (Atom)
