org.n52.security.common.crypto
Class FilesystemKeyPairProvider

java.lang.Object
  extended by org.n52.security.common.crypto.FilesystemKeyPairProvider
All Implemented Interfaces:
KeyPairProvider

public class FilesystemKeyPairProvider
extends Object
implements KeyPairProvider

Looks for private keys and their according certificates in a file system folder.

Certificates need to be base64 + DER-encoded files with the .cer file name extension.

Private keys need to be base64 + PKCS #8-encoded with the .key file name extension.

A certificate and its according private key have to share a common file name that is used as the alias name during key pair lookup.

Author:
jdr

Constructor Summary
FilesystemKeyPairProvider()
           
 
Method Summary
 String getFilePath()
           
 Map<String,String> getPassphrasesByAlias()
           
 void init()
           
 KeyPair resolveByAlias(String alias, char[] password)
          Resolves a keypair by an alias.
 KeyPair resolveByCertificate(Certificate cert, char[] password)
          Resolves a key pair by a given certificate.
 KeyPair resolveBySerialIssuer(String issuerDN, BigInteger serial, char[] password)
          Resolves a key pair by a SerialIssuer, this is required to resolve certificates and it's private keys by the id of the certificate.
 void setFilePath(String filePath)
           
 void setPassphrasesByAlias(Map<String,String> passphrasesByAlias)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilesystemKeyPairProvider

public FilesystemKeyPairProvider()
Method Detail

init

public void init()

resolveByAlias

public KeyPair resolveByAlias(String alias,
                              char[] password)
                       throws KeyPairResolvingException
Description copied from interface: KeyPairProvider
Resolves a keypair by an alias. The provider tries to resolve the private key and its public key or certificate. Only if none of the elements can be resolved an exception is thrown.

Specified by:
resolveByAlias in interface KeyPairProvider
Parameters:
alias - the alias.
password - a password for the private key, can be null.
Returns:
KeyPair.
Throws:
KeyPairResolvingException - if keypair can't be resolved.

resolveBySerialIssuer

public KeyPair resolveBySerialIssuer(String issuerDN,
                                     BigInteger serial,
                                     char[] password)
Description copied from interface: KeyPairProvider
Resolves a key pair by a SerialIssuer, this is required to resolve certificates and it's private keys by the id of the certificate. Only if none of the elements can be resolved an exception is thrown.

Specified by:
resolveBySerialIssuer in interface KeyPairProvider
Parameters:
issuerDN - the issuerDN.
serial - the serial.
password - a password for the private key, can be null.
Returns:
KeyPair.

resolveByCertificate

public KeyPair resolveByCertificate(Certificate cert,
                                    char[] password)
                             throws KeyPairResolvingException
Description copied from interface: KeyPairProvider
Resolves a key pair by a given certificate. Only if none of the elements can be resolved an exception is thrown.

Specified by:
resolveByCertificate in interface KeyPairProvider
Parameters:
cert - the cert.
password - a password for the private key, can be null.
Returns:
KeyPair.
Throws:
KeyPairResolvingException - if error occurs.

getFilePath

public String getFilePath()

setFilePath

public void setFilePath(String filePath)

setPassphrasesByAlias

public void setPassphrasesByAlias(Map<String,String> passphrasesByAlias)

getPassphrasesByAlias

public Map<String,String> getPassphrasesByAlias()


Copyright © 2004–2014 52north.org. All rights reserved.