TrustedSocketFactory.java revision a395dd575518d9e5280fc5d5d5ef47c61b174647
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
*/
/**
* An implementation of SSLSocketFactory.
*/
public class TrustedSocketFactory extends SSLSocketFactory
{
private SSLSocketFactory innerFactory;
private TrustManager trustManager;
private KeyManager keyManager;
/**
* Constructor of the TrustedSocketFactory.
* @param trustManager the trust manager to use.
* @param keyManager the key manager to use.
*/
{
this.trustManager = trustManager;
this.keyManager = keyManager;
}
/**
* Sets the provided trust and key manager for the operations in the
* current thread.
*
* @param trustManager
* the trust manager to use.
* @param keyManager
* the key manager to use.
*/
public static synchronized void setCurrentThreadTrustManager(
{
}
/**
* Sets the provided trust manager for the operations in the provided thread.
* @param trustManager the trust manager to use.
* @param thread the thread where we want to use the provided trust manager.
*/
public static synchronized void setThreadTrustManager(
{
if (currentTrustManager != null) {
}
if (trustManager != null) {
}
}
/**
* Sets the provided key manager for the operations in the provided thread.
* @param keyManager the key manager to use.
* @param thread the thread where we want to use the provided key manager.
*/
public static synchronized void setThreadKeyManager(
{
if (currentKeyManager != null) {
}
if (keyManager != null) {
}
}
//
// SocketFactory implementation
//
/**
* Returns the default SSL socket factory. The default
* implementation can be changed by setting the value of the
* "ssl.SocketFactory.provider" security property (in the Java
* security properties file) to the desired class. If SSL has not
* been configured properly for this virtual machine, the factory
* will be inoperative (reporting instantiation exceptions).
*
* @return the default SocketFactory
*/
public static synchronized SocketFactory getDefault()
{
if (trustManager == null)
{
if (keyManager == null)
{
}
else
{
{
}
}
}
else
{
if (keyManager == null)
{
{
}
}
else
{
{
}
else
{
}
else
{
}
}
}
return result;
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
int clientPort) throws IOException
{
}
/**
* {@inheritDoc}
*/
throws IOException
{
}
/**
* {@inheritDoc}
*/
public String[] getDefaultCipherSuites()
{
try
{
return getInnerFactory().getDefaultCipherSuites();
}
catch(IOException x)
{
return new String[0];
}
}
/**
* {@inheritDoc}
*/
public String[] getSupportedCipherSuites()
{
try
{
return getInnerFactory().getSupportedCipherSuites();
}
catch(IOException x)
{
return new String[0];
}
}
//
// Private
//
if (innerFactory == null)
{
try {
if (trustManager != null)
{
}
if (keyManager != null)
{
}
}
catch(GeneralSecurityException x) {
throw xx;
}
}
return innerFactory;
}
}