com.trendrr.oss
Class SSLContextBuilder

java.lang.Object
  extended by com.trendrr.oss.SSLContextBuilder

public class SSLContextBuilder
extends java.lang.Object

Builder to get to the SSLContext. To create a self signed server cert: http://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 1360 -keysize 2048

Author:
Dustin Norlander

Constructor Summary
SSLContextBuilder(boolean client)
          New builder instance.
 
Method Summary
 SSLContextBuilder certificatePassword(java.lang.String password)
           
 SSLContextBuilder keystore(java.security.KeyStore ks)
           
 SSLContextBuilder keystoreBytes(byte[] bytes)
           
 SSLContextBuilder keystoreFilename(java.lang.String filename)
           
 SSLContextBuilder keystorePassword(java.lang.String password)
           
 SSLContextBuilder keystoreStream(java.io.InputStream stream)
           
 SSLContextBuilder protocol(java.lang.String protocol)
          sets the protocol.
 SSLContextBuilder secureRandom(java.security.SecureRandom rand)
          sets the SecureRandom.
 javax.net.ssl.SSLContext toSSLContext()
           
 SSLContextBuilder trustManager(javax.net.ssl.TrustManager[] tm)
          set the TrustManager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSLContextBuilder

public SSLContextBuilder(boolean client)
New builder instance. set client to true if this is clientside, false for serverside

Parameters:
client -
Method Detail

toSSLContext

public javax.net.ssl.SSLContext toSSLContext()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

secureRandom

public SSLContextBuilder secureRandom(java.security.SecureRandom rand)
sets the SecureRandom.

Parameters:
rand -
Returns:

trustManager

public SSLContextBuilder trustManager(javax.net.ssl.TrustManager[] tm)
set the TrustManager. Believe this is only used for clients validating server certs

Parameters:
tm -
Returns:

certificatePassword

public SSLContextBuilder certificatePassword(java.lang.String password)

keystorePassword

public SSLContextBuilder keystorePassword(java.lang.String password)

protocol

public SSLContextBuilder protocol(java.lang.String protocol)
sets the protocol. defaults to "TLS"

Parameters:
protocol -
Returns:

keystoreFilename

public SSLContextBuilder keystoreFilename(java.lang.String filename)

keystoreBytes

public SSLContextBuilder keystoreBytes(byte[] bytes)

keystoreStream

public SSLContextBuilder keystoreStream(java.io.InputStream stream)

keystore

public SSLContextBuilder keystore(java.security.KeyStore ks)