2.17.2: 2011-06-17

net.sf.basedb.util.ssl
Class StaticKeyManager

java.lang.Object
  extended by net.sf.basedb.util.ssl.StaticKeyManager
All Implemented Interfaces:
KeyManager, X509KeyManager

public class StaticKeyManager
extends Object
implements X509KeyManager

A key manager implementation that always selects a specified keystore entry. We use it to make sure that a client certificate that has been registered with a FileServer is always selected for authoriation independent of other settings.

Since:
2.16
Author:
Nicklas
Last modified
$Date: 2010-06-16 14:28:36 +0200 (Wed, 16 Jun 2010) $

Field Summary
private  String alias
           
private  KeyStore keyStore
           
private  char[] password
           
 
Constructor Summary
StaticKeyManager(KeyStore keyStore, String alias, String password)
          Create a new key manager
 
Method Summary
 String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket)
           
 String chooseServerAlias(String keyType, Principal[] issuers, Socket socket)
           
 X509Certificate[] getCertificateChain(String alias)
           
 String[] getClientAliases(String keyType, Principal[] issuers)
           
 PrivateKey getPrivateKey(String alias)
           
 String[] getServerAliases(String keyType, Principal[] issuers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyStore

private final KeyStore keyStore

alias

private final String alias

password

private final char[] password
Constructor Detail

StaticKeyManager

public StaticKeyManager(KeyStore keyStore,
                        String alias,
                        String password)
                 throws KeyStoreException
Create a new key manager

Parameters:
keyStore - The key-store containing the client certificate
alias - The alias of the key-store entry to use, or null to use the first entry in the key-store
password - The password that is required to unlock the entry
Throws:
KeyStoreException
Method Detail

chooseClientAlias

public String chooseClientAlias(String[] keyType,
                                Principal[] issuers,
                                Socket socket)
Specified by:
chooseClientAlias in interface X509KeyManager
Returns:
Always the alias specified in the constructor

chooseServerAlias

public String chooseServerAlias(String keyType,
                                Principal[] issuers,
                                Socket socket)
Specified by:
chooseServerAlias in interface X509KeyManager
Returns:
Always null

getCertificateChain

public X509Certificate[] getCertificateChain(String alias)
Specified by:
getCertificateChain in interface X509KeyManager

getClientAliases

public String[] getClientAliases(String keyType,
                                 Principal[] issuers)
Specified by:
getClientAliases in interface X509KeyManager
Returns:
An array with the alias given in the constructor as the only element

getPrivateKey

public PrivateKey getPrivateKey(String alias)
Specified by:
getPrivateKey in interface X509KeyManager

getServerAliases

public String[] getServerAliases(String keyType,
                                 Principal[] issuers)
Specified by:
getServerAliases in interface X509KeyManager
Returns:
Always null

2.17.2: 2011-06-17