Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.rgw.crypt
Class JCEKeyManager

java.lang.Object
  extended by ch.rgw.crypt.JCEKeyManager

public class JCEKeyManager
extends java.lang.Object

Vereinfachtes API für die Java Kryptographie-Klassen KeyManager stellt die Verbindung zu einem keystore her und lässt auf die darin befindlichen Schlüssel zugreifen.


Constructor Summary
JCEKeyManager(java.lang.String type, char[] storepwd)
           
JCEKeyManager(java.lang.String keystoreFile, java.lang.String type, char[] keystorePwd)
          The Constructor does not actually create or access a keystore but only defines the access rules The keystore ist valid after a successful call to create() or load()
 
Method Summary
 boolean addCertificate(java.security.cert.X509Certificate cert)
          Zertifikat dem keystore zufügen
 boolean addKeyPair(java.security.PrivateKey kpriv, java.security.cert.X509Certificate cert, char[] keyPwd)
           
 boolean create(boolean bDeleteIfExists)
           
 boolean existsCertificate(java.lang.String alias)
           
 boolean existsPrivate(java.lang.String alias)
           
 java.security.cert.X509Certificate generateCertificate(java.security.PublicKey pk, java.security.PrivateKey signingKey, java.lang.String issuer, java.lang.String subject, TimeTool ttFrom, TimeTool ttUntil)
          Generate a certificate from a public key and a signing private key.
 java.security.KeyPair generateKeys()
           
 java.security.cert.X509Certificate getCertificate(java.lang.String alias)
           
 java.security.PrivateKey getPrivateKey(java.lang.String alias, char[] pwd)
          Private key mit dem Alias alias holen
 java.security.PublicKey getPublicKey(java.io.InputStream is)
          Public key aus einem Input Stream lesen
 java.security.PublicKey getPublicKey(java.lang.String alias)
          Public key mit dem Alias alias holen.
 java.security.SecureRandom getRandom()
           
 boolean isKeystoreLoaded()
           
 boolean load(boolean bCreateIfNotExists)
          Keystore laden
 boolean removeKey(java.lang.String alias)
           
 boolean save()
           
static java.lang.String Version()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCEKeyManager

public JCEKeyManager(java.lang.String keystoreFile,
                     java.lang.String type,
                     char[] keystorePwd)
The Constructor does not actually create or access a keystore but only defines the access rules The keystore ist valid after a successful call to create() or load()

Parameters:
keystoreFile - path and name of the keystore to use if null: {user.home}/.keystore is used.
type - type of the keystore. If NULL: jks
keystorePwd - password for the keystore must not be null.

JCEKeyManager

public JCEKeyManager(java.lang.String type,
                     char[] storepwd)
Method Detail

Version

public static java.lang.String Version()

load

public boolean load(boolean bCreateIfNotExists)
Keystore laden


create

public boolean create(boolean bDeleteIfExists)

save

public boolean save()

isKeystoreLoaded

public boolean isKeystoreLoaded()

getPublicKey

public java.security.PublicKey getPublicKey(java.lang.String alias)
Public key mit dem Alias alias holen. Es wird auf Gültigkeit des Zertifiktats getestet

Parameters:
alias - Name des gesuchten Schlüssels
Returns:
den gesuchten Schlüssel oder null - nicht gefunden

getCertificate

public java.security.cert.X509Certificate getCertificate(java.lang.String alias)

getPublicKey

public java.security.PublicKey getPublicKey(java.io.InputStream is)
Public key aus einem Input Stream lesen


getPrivateKey

public java.security.PrivateKey getPrivateKey(java.lang.String alias,
                                              char[] pwd)
Private key mit dem Alias alias holen

Parameters:
alias - Zu holender Schlüssel
pwd - Schlüssel-Passwort
Returns:
den Schlüssel oder null

addCertificate

public boolean addCertificate(java.security.cert.X509Certificate cert)
Zertifikat dem keystore zufügen

Parameters:
cert - Ein X.509 Zertifikat
Returns:
true bei Erfolg

generateCertificate

public java.security.cert.X509Certificate generateCertificate(java.security.PublicKey pk,
                                                              java.security.PrivateKey signingKey,
                                                              java.lang.String issuer,
                                                              java.lang.String subject,
                                                              TimeTool ttFrom,
                                                              TimeTool ttUntil)
                                                       throws java.security.InvalidKeyException,
                                                              java.security.NoSuchProviderException,
                                                              java.security.SignatureException,
                                                              java.security.cert.CertificateEncodingException,
                                                              java.lang.IllegalStateException,
                                                              java.security.NoSuchAlgorithmException,
                                                              java.security.KeyStoreException
Generate a certificate from a public key and a signing private key.

Parameters:
pk - the key to make a certficate from
signingKey - the signer's private key
name - of the issuer
name - of the certificate holder
Returns:
the signed certificate.
Throws:
java.security.KeyStoreException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException
java.security.cert.CertificateEncodingException
java.lang.IllegalStateException
java.security.NoSuchAlgorithmException

addKeyPair

public boolean addKeyPair(java.security.PrivateKey kpriv,
                          java.security.cert.X509Certificate cert,
                          char[] keyPwd)
                   throws java.lang.Exception
Throws:
java.lang.Exception

existsPrivate

public boolean existsPrivate(java.lang.String alias)

existsCertificate

public boolean existsCertificate(java.lang.String alias)

generateKeys

public java.security.KeyPair generateKeys()

getRandom

public java.security.SecureRandom getRandom()

removeKey

public boolean removeKey(java.lang.String alias)

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis