OSCI2-StarterKit


eu.osci.helper
Class CryptoTools

java.lang.Object
  extended by eu.osci.helper.CryptoTools

public class CryptoTools
extends java.lang.Object

This is a helper class to load key stores or certificates.
Copyright © 2010 Freie Hansestadt Bremen.
Created by bremen online services Entwicklungs- und Betriebsgesellschaft mbH & Co. KG.
This library (Starter Kit) can be used by anybody according to the Bremer Lizenz für freie Softwarebibliotheken. The license terms can be viewed at www.osci.de or can be ordered at the OSCI-Leitstelle (Die Senatorin für Finanzen, Freie Hansestadt Bremen, Postfach 10 15 40, 28015 Bremen).


Constructor Summary
CryptoTools()
           
 
Method Summary
static int createRandom()
          Creates a simple random value.
static java.security.PrivateKey getPrivateKey(java.security.KeyStore store, char[] password)
           
static java.security.cert.X509Certificate getX509Certificate(java.security.KeyStore store)
           
static java.security.cert.X509Certificate loadCertificate(java.io.InputStream certificate)
          Loads an X509Certificate object out of a given InputStream.
static java.security.KeyStore loadPKCS12(java.io.InputStream stream, char[] password)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CryptoTools

public CryptoTools()
Method Detail

loadPKCS12

public static java.security.KeyStore loadPKCS12(java.io.InputStream stream,
                                                char[] password)
                                         throws java.security.GeneralSecurityException,
                                                java.io.IOException
Parameters:
stream - The stream to load as key store.
password - The password for the key store.
Returns:
The loaded key store.
Throws:
java.security.GeneralSecurityException - In case of parsing errors.
java.io.IOException - In case of unexpected streams.

loadCertificate

public static java.security.cert.X509Certificate loadCertificate(java.io.InputStream certificate)
                                                          throws java.security.cert.CertificateException
Loads an X509Certificate object out of a given InputStream.

Parameters:
certificate - The certificate stream.
Returns:
The created X509Certificate object.
Throws:
java.security.cert.CertificateException - In case of parsing errors.

getX509Certificate

public static java.security.cert.X509Certificate getX509Certificate(java.security.KeyStore store)
                                                             throws java.security.KeyStoreException
Parameters:
store - The key store to use.
Returns:
The first X509Certificate out of the given key store.
Throws:
java.security.KeyStoreException - In case of key store exceptions.

getPrivateKey

public static java.security.PrivateKey getPrivateKey(java.security.KeyStore store,
                                                     char[] password)
                                              throws java.security.GeneralSecurityException,
                                                     java.security.UnrecoverableKeyException
Parameters:
store - A key store to look for the private key.
password - The password to use for key store.
Returns:
The excluded private key.
Throws:
java.security.GeneralSecurityException
java.security.UnrecoverableKeyException

createRandom

public static int createRandom()
Creates a simple random value.


OSCI2-StarterKit


Copyright © 2010 Freie Hansestadt Bremen.