org.jsslutils.sslcontext.keymanagers
Class FixedServerAliasKeyManager

java.lang.Object
  extended by org.jsslutils.sslcontext.keymanagers.FixedServerAliasKeyManager
All Implemented Interfaces:
javax.net.ssl.KeyManager, javax.net.ssl.X509KeyManager

public class FixedServerAliasKeyManager
extends java.lang.Object
implements javax.net.ssl.X509KeyManager

This is an X509KeyManager that will always choose the server alias name it has been constructed with.

Author:
Bruno Harbulot.

Nested Class Summary
static class FixedServerAliasKeyManager.Wrapper
          Wrapper factory class that wraps existing X509KeyManagers into FixedServerAliasKeyManager, with the alias passed to the constructor.
 
Constructor Summary
FixedServerAliasKeyManager(javax.net.ssl.X509KeyManager keyManager, java.lang.String alias)
          Creates a new instance from an existing X509KeyManager.
 
Method Summary
 java.lang.String chooseClientAlias(java.lang.String[] keyType, java.security.Principal[] issuers, java.net.Socket socket)
          Relays the call to the wrapped X509KeyManager.
 java.lang.String chooseServerAlias(java.lang.String keyType, java.security.Principal[] issuers, java.net.Socket socket)
          Returns the alias this instance has been constructed with, regardless of any other parameters.
 java.security.cert.X509Certificate[] getCertificateChain(java.lang.String alias)
          Relays the call to the wrapped X509KeyManager.
 java.lang.String[] getClientAliases(java.lang.String keyType, java.security.Principal[] issuers)
          Relays the call to the wrapped X509KeyManager.
 java.security.PrivateKey getPrivateKey(java.lang.String alias)
          Relays the call to the wrapped X509KeyManager.
 java.lang.String[] getServerAliases(java.lang.String keyType, java.security.Principal[] issuers)
          Relays the call to the wrapped X509KeyManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedServerAliasKeyManager

public FixedServerAliasKeyManager(javax.net.ssl.X509KeyManager keyManager,
                                  java.lang.String alias)
Creates a new instance from an existing X509KeyManager.

Parameters:
keyManager - X509KeyManager to wrap.
alias - alias to use to choose a key for the server sockets.
Method Detail

chooseClientAlias

public java.lang.String chooseClientAlias(java.lang.String[] keyType,
                                          java.security.Principal[] issuers,
                                          java.net.Socket socket)
Relays the call to the wrapped X509KeyManager.

Specified by:
chooseClientAlias in interface javax.net.ssl.X509KeyManager
See Also:
X509KeyManager.chooseClientAlias(java.lang.String[], java.security.Principal[], java.net.Socket)

chooseServerAlias

public java.lang.String chooseServerAlias(java.lang.String keyType,
                                          java.security.Principal[] issuers,
                                          java.net.Socket socket)
Returns the alias this instance has been constructed with, regardless of any other parameters.

Specified by:
chooseServerAlias in interface javax.net.ssl.X509KeyManager
Returns:
The alias passed to the constructor.
See Also:
X509KeyManager.chooseServerAlias(java.lang.String, java.security.Principal[], java.net.Socket)

getCertificateChain

public java.security.cert.X509Certificate[] getCertificateChain(java.lang.String alias)
Relays the call to the wrapped X509KeyManager.

Specified by:
getCertificateChain in interface javax.net.ssl.X509KeyManager
See Also:
X509KeyManager.getCertificateChain(java.lang.String)

getClientAliases

public java.lang.String[] getClientAliases(java.lang.String keyType,
                                           java.security.Principal[] issuers)
Relays the call to the wrapped X509KeyManager.

Specified by:
getClientAliases in interface javax.net.ssl.X509KeyManager
See Also:
X509KeyManager.getClientAliases(java.lang.String, java.security.Principal[])

getPrivateKey

public java.security.PrivateKey getPrivateKey(java.lang.String alias)
Relays the call to the wrapped X509KeyManager.

Specified by:
getPrivateKey in interface javax.net.ssl.X509KeyManager
See Also:
X509KeyManager.getPrivateKey(java.lang.String)

getServerAliases

public java.lang.String[] getServerAliases(java.lang.String keyType,
                                           java.security.Principal[] issuers)
Relays the call to the wrapped X509KeyManager.

Specified by:
getServerAliases in interface javax.net.ssl.X509KeyManager
See Also:
X509KeyManager.getServerAliases(java.lang.String, java.security.Principal[])


Copyright © 2011. All Rights Reserved.