|
JCas v0.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cas.io.SSLTools
Useful methods for working with SSL sockets and streams.
Field Summary | |
protected static SSLSocketFactory |
factory
The SSL socket factory for all trusted certs. |
protected static SSLServerSocketFactory |
serverFactory
The SSL server socket factory. |
Constructor Summary | |
SSLTools()
|
Method Summary | |
static KeyStore |
createKeyStore(char[] passwd)
Returns a new and empty KeyStore. |
static SSLServerSocketFactory |
getServerSocketFactory(KeyManagerFactory kmf)
Returns the SSL server socket factory based on the given KeyManagerFactory. |
static SSLServerSocketFactory |
getServerSocketFactory(KeyStore ks,
char[] passwd)
Returns the SSL server socket factory based on the given KeyStore. |
static SSLServerSocketFactory |
getServerSocketFactory(SSLContext sslContext)
Returns the SSL server socket factory based on the given SSLContext. |
static SSLSocketFactory |
getSocketFactory()
Returns the SSL socket factory. |
static Certificate |
loadCertificate(InputStream in)
Returns the certificate in the stream. |
static Certificate[] |
loadCertificates(InputStream in)
Returns the certificates in the stream. |
static KeyStore |
loadKeyStore(File file,
char[] passwd)
Loads a KeyStore from a file. |
static KeyStore |
loadKeyStore(InputStream in,
char[] passwd)
Loads a KeyStore from an input stream. |
static KeyStore |
loadKeyStore(String file,
char[] passwd)
Loads a KeyStore from a file. |
static void |
main(String[] args)
For test use only. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static SSLSocketFactory factory
protected static SSLServerSocketFactory serverFactory
Constructor Detail |
public SSLTools()
Method Detail |
public static SSLSocketFactory getSocketFactory()
public static Certificate loadCertificate(InputStream in) throws IOException, CertificateException
IOException
CertificateException
public static Certificate[] loadCertificates(InputStream in) throws CertificateException
CertificateException
public static KeyStore loadKeyStore(String file, char[] passwd) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static KeyStore loadKeyStore(File file, char[] passwd) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static KeyStore loadKeyStore(InputStream in, char[] passwd) throws GeneralSecurityException, IOException
GeneralSecurityException
IOException
public static KeyStore createKeyStore(char[] passwd) throws GeneralSecurityException, IOException
GeneralSecurityException
IOException
public static SSLServerSocketFactory getServerSocketFactory(KeyStore ks, char[] passwd) throws GeneralSecurityException
char passwd[] = "passwd".toCharArray(); // password of the keystore
char keypass[] = "passwd".toCharArray(); // password of the private key
String alias = "localkey"; // alias for the keystore entry to create
String keyfile = "your.key.der"; // see notice below
String certfile = "your.crt";
// Read authentication keys. These are used to authenticate
// ourselves to the client
java.security.KeyStore ks = createKeyStore(passwd);
// Import certificate and key
rfc.io.ImportKey.importKey(ks, keyfile, certfile, keypass, alias);
You need to transform the PEM coded private key to a PKCS#8 format, e.g. with OpenSSL
openssl pkcs8 -topk8 -nocrypt -in your.key -out your.key.der -outform der
GeneralSecurityException
public static SSLServerSocketFactory getServerSocketFactory(KeyManagerFactory kmf) throws GeneralSecurityException
GeneralSecurityException
public static SSLServerSocketFactory getServerSocketFactory(SSLContext sslContext)
public static void main(String[] args)
|
JCas v0.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |