LDAPManagementContextFactory.java revision a03d3e5abfd98a38eea4a1dceb522001530910ab
/*
* 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
*
*
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
/**
* An LDAP management context factory.
*/
public final class LDAPManagementContextFactory implements
// The SecureConnectionCliArgsList object.
// The management context.
/**
* Creates a new LDAP management context factory.
*/
public LDAPManagementContextFactory() {
// No implementation required.
}
/**
* {@inheritDoc}
*/
throws ArgumentException, ClientException
{
// Lazily create the LDAP management context.
{
}
return context;
}
/**
* Gets the management context which sub-commands should use in
* order to manage the directory server. Implementations can use the
* application instance for retrieving passwords interactively.
*
* @param app
* The application instance.
* @param ci the LDAPConsoleInteraction object to be used. The code assumes
* that the LDAPConsoleInteraction has already been run.
* @return Returns the management context which sub-commands should
* use in order to manage the directory server.
* @throws ArgumentException
* If a management context related argument could not be
* parsed successfully.
* @throws ClientException
* If the management context could not be created.
*/
throws ArgumentException, ClientException
{
// Lazily create the LDAP management context.
{
// Interact with the user though the console to get
// LDAP connection information
// Do we have a secure connection ?
{
while (true)
{
try
{
break;
}
catch (NamingException e)
{
{
if ((e.getRootCause() != null)
&& (e.getRootCause().getCause()
instanceof OpendsCertificateException))
{
{
// If the certificate is trusted, update the trust manager.
// Try to connect again.
continue ;
}
}
else
{
throw new ClientException(
}
}
throw new ClientException(
}
}
}
else if (ci.useStartTLS())
{
while (true)
{
try
{
break;
}
catch (NamingException e)
{
{
if ((e.getRootCause() != null)
&& (e.getRootCause().getCause()
instanceof OpendsCertificateException))
{
{
// If the certificate is trusted, update the trust manager.
// Try to connect again.
continue ;
}
}
else
{
throw new ClientException(
}
}
throw new ClientException(
}
}
}
else
{
// Create the management context.
try
{
}
catch (AuthenticationNotSupportedException e)
{
.get();
message);
}
catch (AuthenticationException e)
{
message);
}
catch (CommunicationException e)
{
message);
}
}
}
return context;
}
/**
* {@inheritDoc}
*/
throws ArgumentException {
// Create the global arguments.
secureArgsList = new SecureConnectionCliArgs();
// Register the global arguments.
{
}
}
/**
* {@inheritDoc}
*/
public void validateGlobalArguments() throws ArgumentException {
// Make sure that the user didn't specify any conflicting
// arguments.
{
}
}
}