Elexis: Das führende OpenSource-Arztpraxisprogamm
im deutschsprachigen Raum
Java doc für Elexis version 2.1.7.dev vom 01.09.2013

ch.rgw.crypt
Class JCECrypter

java.lang.Object
  extended by ch.rgw.crypt.JCECrypter
All Implemented Interfaces:
Cryptologist

public class JCECrypter
extends java.lang.Object
implements Cryptologist


Nested Class Summary
 
Nested classes/interfaces inherited from interface ch.rgw.crypt.Cryptologist
Cryptologist.VERIFY_RESULT
 
Field Summary
static short DATA_MARKER
           
static short IV_MARKER
           
static short KEY_MARKER
           
protected  JCEKeyManager km
           
static short MAGIC
           
protected  char[] pwd
           
protected  java.lang.String userKey
           
static short VERSION
           
 
Constructor Summary
protected JCECrypter(char[] kspwd, java.lang.String mykey, char[] keypwd)
           
  JCECrypter(java.lang.String keystore, char[] kspwd, java.lang.String mykey, char[] keypwd)
          Create a new Crypter.
 
Method Summary
 boolean addCertificate(byte[] certEncoded)
           
 boolean addCertificate(java.security.cert.X509Certificate cert)
           
 Result<byte[]> decrypt(byte[] encrypted)
          decrypt a byte array
 void decrypt(java.io.InputStream source, java.io.OutputStream dest)
           
 byte[] encrypt(byte[] source, java.lang.String receiverKeyName)
          encrypt a byte array
 void encrypt(java.io.InputStream source, java.io.OutputStream dest, java.lang.String receiverKeyName)
           
protected  void finalize()
           
 java.security.cert.X509Certificate generateCertificate(java.security.PublicKey pk, java.lang.String alias, TimeTool validFrom, TimeTool validUntil)
           
 java.security.KeyPair generateKeys(java.lang.String alias, char[] keypwd, TimeTool validFrom, TimeTool validUntil)
           
 java.security.cert.X509Certificate getCertificate(java.lang.String alias)
           
 byte[] getCertificateEncoded(java.lang.String alias)
           
 java.lang.String getUser()
           
 boolean hasCertificateOf(java.lang.String alias)
           
 boolean hasKeyOf(java.lang.String alias)
           
 boolean isFunctional()
           
 boolean removeCertificate(java.lang.String alias)
           
 byte[] sign(byte[] source)
          Sign a byte array (create and sign a MAC)
 Cryptologist.VERIFY_RESULT verify(byte[] data, byte[] signature, java.lang.String signerKeyName)
          Verify a MAC
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static short VERSION

MAGIC

public static short MAGIC

KEY_MARKER

public static short KEY_MARKER

IV_MARKER

public static short IV_MARKER

DATA_MARKER

public static short DATA_MARKER

km

protected JCEKeyManager km

userKey

protected java.lang.String userKey

pwd

protected char[] pwd
Constructor Detail

JCECrypter

public JCECrypter(java.lang.String keystore,
                  char[] kspwd,
                  java.lang.String mykey,
                  char[] keypwd)
           throws java.lang.Exception
Create a new Crypter. If the named keystore does not exist, it well created newly and a key for the named user will be created as well.

Parameters:
keystore - keystore to use or NULL for default keystore
kspwd - keystore password or NULL for default password
mykey - identifier for user's key in the named keystore
keypwd - password for the user's key
Throws:
java.lang.Exception

JCECrypter

protected JCECrypter(char[] kspwd,
                     java.lang.String mykey,
                     char[] keypwd)
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

decrypt

public Result<byte[]> decrypt(byte[] encrypted)
Description copied from interface: Cryptologist
decrypt a byte array

Specified by:
decrypt in interface Cryptologist
Parameters:
encrypted - the encrypted bytes
Returns:
the plain array or null of decryption failed

decrypt

public void decrypt(java.io.InputStream source,
                    java.io.OutputStream dest)
             throws CryptologistException
Specified by:
decrypt in interface Cryptologist
Throws:
CryptologistException

encrypt

public void encrypt(java.io.InputStream source,
                    java.io.OutputStream dest,
                    java.lang.String receiverKeyName)
             throws CryptologistException
Specified by:
encrypt in interface Cryptologist
Throws:
CryptologistException

encrypt

public byte[] encrypt(byte[] source,
                      java.lang.String receiverKeyName)
Description copied from interface: Cryptologist
encrypt a byte array

Specified by:
encrypt in interface Cryptologist
Parameters:
source - the plain bytes
receiverKeyName - name of the receiver's public key
Returns:
the encrypted bytes or null if encryption failed

sign

public byte[] sign(byte[] source)
Description copied from interface: Cryptologist
Sign a byte array (create and sign a MAC)

Specified by:
sign in interface Cryptologist
Parameters:
source - the bytes to sign
Returns:
the signature

verify

public Cryptologist.VERIFY_RESULT verify(byte[] data,
                                         byte[] signature,
                                         java.lang.String signerKeyName)
Description copied from interface: Cryptologist
Verify a MAC

Specified by:
verify in interface Cryptologist
Parameters:
data - the signed data
signature - the signed digest
signerKeyName - name of the signer's public key
Returns:

hasCertificateOf

public boolean hasCertificateOf(java.lang.String alias)
Specified by:
hasCertificateOf in interface Cryptologist

hasKeyOf

public boolean hasKeyOf(java.lang.String alias)
Specified by:
hasKeyOf in interface Cryptologist

addCertificate

public boolean addCertificate(java.security.cert.X509Certificate cert)
Specified by:
addCertificate in interface Cryptologist

addCertificate

public boolean addCertificate(byte[] certEncoded)
Specified by:
addCertificate in interface Cryptologist

generateKeys

public java.security.KeyPair generateKeys(java.lang.String alias,
                                          char[] keypwd,
                                          TimeTool validFrom,
                                          TimeTool validUntil)
Specified by:
generateKeys in interface Cryptologist

generateCertificate

public java.security.cert.X509Certificate generateCertificate(java.security.PublicKey pk,
                                                              java.lang.String alias,
                                                              TimeTool validFrom,
                                                              TimeTool validUntil)
Specified by:
generateCertificate in interface Cryptologist

getUser

public java.lang.String getUser()
Specified by:
getUser in interface Cryptologist

getCertificate

public java.security.cert.X509Certificate getCertificate(java.lang.String alias)
Specified by:
getCertificate in interface Cryptologist

getCertificateEncoded

public byte[] getCertificateEncoded(java.lang.String alias)
                             throws CryptologistException
Specified by:
getCertificateEncoded in interface Cryptologist
Throws:
CryptologistException

isFunctional

public boolean isFunctional()
Specified by:
isFunctional in interface Cryptologist

removeCertificate

public boolean removeCertificate(java.lang.String alias)
Specified by:
removeCertificate in interface Cryptologist

Elexis: Das führende OpenSource-Arztpraxisprogamm
im deutschsprachigen Raum
Java doc für Elexis version 2.1.7.dev vom 01.09.2013