org.bouncycastle.jsse.BCX509ExtendedKeyManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bctls-fips Show documentation
Show all versions of bctls-fips Show documentation
The Bouncy Castle Java APIs for the TLS, including a JSSE provider. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
package org.bouncycastle.jsse;
import java.net.Socket;
import java.security.Principal;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.X509ExtendedKeyManager;
public abstract class BCX509ExtendedKeyManager
extends X509ExtendedKeyManager
{
public BCX509Key chooseClientKeyBC(String[] keyTypes, Principal[] issuers, Socket socket)
{
if (null != keyTypes)
{
for (String keyType : keyTypes)
{
String alias = chooseClientAlias(new String[]{ keyType }, issuers, socket);
if (null != alias)
{
BCX509Key key = validateKeyBC(false, keyType, alias, socket);
if (null != key)
{
return key;
}
}
}
}
return null;
}
public BCX509Key chooseEngineClientKeyBC(String[] keyTypes, Principal[] issuers, SSLEngine engine)
{
if (null != keyTypes)
{
for (String keyType : keyTypes)
{
String alias = chooseEngineClientAlias(new String[]{ keyType }, issuers, engine);
if (null != alias)
{
BCX509Key key = validateKeyBC(false, keyType, alias, engine);
if (null != key)
{
return key;
}
}
}
}
return null;
}
public BCX509Key chooseEngineServerKeyBC(String[] keyTypes, Principal[] issuers, SSLEngine engine)
{
if (null != keyTypes)
{
for (String keyType : keyTypes)
{
String alias = chooseEngineServerAlias(keyType, issuers, engine);
if (null != alias)
{
BCX509Key key = validateKeyBC(true, keyType, alias, engine);
if (null != key)
{
return key;
}
}
}
}
return null;
}
public BCX509Key chooseServerKeyBC(String[] keyTypes, Principal[] issuers, Socket socket)
{
if (null != keyTypes)
{
for (String keyType : keyTypes)
{
String alias = chooseServerAlias(keyType, issuers, socket);
if (null != alias)
{
BCX509Key key = validateKeyBC(true, keyType, alias, socket);
if (null != key)
{
return key;
}
}
}
}
return null;
}
protected abstract BCX509Key getKeyBC(String keyType, String alias);
protected BCX509Key validateKeyBC(boolean forServer, String keyType, String alias, Socket socket)
{
return getKeyBC(keyType, alias);
}
protected BCX509Key validateKeyBC(boolean forServer, String keyType, String alias, SSLEngine engine)
{
return getKeyBC(keyType, alias);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy