LDAPDelete.java revision 480256311ff1597d92043303772f072d8d67fb3c
/*
* 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 2006-2007 Sun Microsystems, Inc.
*/
/**
* This class provides a tool that can be used to issue delete requests to the
* Directory Server.
*/
public class LDAPDelete
{
/**
* The tracer object for the debug logger.
*/
/**
* The fully-qualified name of this class.
*/
// The message ID counter to use for requests.
private AtomicInteger nextMessageID;
// The print stream to use for standard error.
private PrintStream err;
// The print stream to use for standard output.
private PrintStream out;
/**
* Constructor for the LDAPDelete object.
*
* @param nextMessageID The next message ID to use for requests.
* @param out The print stream to use for standard output.
* @param err The print stream to use for standard error.
*/
{
this.nextMessageID = nextMessageID;
}
/**
* Execute the delete request on the specified list of DNs.
*
* @param connection The connection to use to execute the request.
* @param lines The list of DNs to delete.
* @param deleteOptions The constraints to use for this request.
*
* @throws IOException If a problem occurs while attempting to communicate
* with the Directory Server.
*
* @throws LDAPException If the Directory Server returns an error response.
*/
throws IOException, LDAPException
{
{
}
}
/**
* Read the specified DNs from the given reader
* (file or stdin) and execute the given delete request.
*
* @param connection The connection to use to execute the request.
* @param reader The reader to read the list of DNs from.
* @param deleteOptions The constraints to use for this request.
*
* @throws IOException If a problem occurs while attempting to communicate
* with the Directory Server.
*
* @throws LDAPException If the Directory Server returns an error response.
*/
throws IOException, LDAPException
{
{
}
}
/**
* Execute the delete request for the specified DN.
*
* @param connection The connection to use to execute the request.
* @param line The DN to delete.
* @param deleteOptions The list of constraints for this request.
*
* @throws IOException If a problem occurs while attempting to communicate
* with the Directory Server.
*
* @throws LDAPException If the Directory Server returns an error response.
*/
throws IOException, LDAPException
{
int msgID = MSGID_PROCESSING_OPERATION;
if(!deleteOptions.showOperations())
{
try
{
} catch(ASN1Exception ae)
{
if (debugEnabled())
{
}
if (!deleteOptions.continueOnError())
{
}
else
{
return;
}
}
{
} else
{
{
op.getMatchedDN());
} else
{
}
}
}
}
/**
* The main method for LDAPDelete tool.
*
* @param args The command-line arguments provided to this program.
*/
{
if(retCode != 0)
{
}
}
/**
* Parses the provided command-line arguments and uses that information to
* run the ldapdelete tool.
*
* @param args The command-line arguments provided to this program.
*
* @return The error code.
*/
{
}
/**
* Parses the provided command-line arguments and uses that information to
* run the ldapdelete tool.
*
* @param args The command-line arguments provided to this
* program.
* @param initializeServer Indicates whether to initialize the server.
* @param outStream The output stream to use for standard output, or
* <CODE>null</CODE> if standard output is not
* needed.
* @param errStream The output stream to use for standard error, or
* <CODE>null</CODE> if standard error is not
* needed.
*
* @return The error code.
*/
{
{
}
else
{
}
{
}
else
{
}
// Create the command-line argument parser for use with this program.
false, true, 0, 1, "\"DN\"");
try
{
OPTION_LONG_HOST, false, false, true,
OPTION_LONG_PORT, false, false, true,
OPTION_LONG_BINDDN, false, false, true,
false, false, true,
false, false,
OPTION_LONG_FILENAME, false, false,
"useSASLExternal",
false, true, true,
false, false, true,
false, false,
true, OPTION_VALUE_KEYSTORE_PWD,
new FileBasedArgument("keyStorePasswordFile",
false, false,
false, false, true, "{nickname}", null,
false, false, true,
false, false, true,
new FileBasedArgument("trustStorePasswordFile",
OPTION_LONG_TRUSTSTORE_PWD_FILE, false, false,
"{controloid[:criticality[:value|::b64value|:<fileurl]]}",
OPTION_LONG_PROTOCOL_VERSION, false, false,
true, OPTION_VALUE_PROTOCOL_VERSION, 3,
} catch (ArgumentException ae)
{
return 1;
}
// Parse the command-line arguments provided to this program.
try
{
}
catch (ArgumentException ae)
{
int msgID = MSGID_ERROR_PARSING_ARGS;
return 1;
}
// If we should just display usage or version information,
// then it has already been done so just exit.
if (argParser.usageOrVersionDisplayed())
{
return 0;
}
{
int msgID = MSGID_TOOL_CONFLICTING_ARGS;
return 1;
}
int portNumber = 389;
try
{
} catch(ArgumentException ae)
{
if (debugEnabled())
{
}
return 1;
}
try
{
{
return 1;
}
} catch(ArgumentException ae)
{
if (debugEnabled())
{
}
return 1;
}
{
// read the password from the stdin.
try
{
{
if (debugEnabled())
{
}
return 1;
}
} else if(bindPasswordValue == null)
{
// Read from file if it exists.
}
if (keyStorePassword.isPresent())
{
}
else if (keyStorePasswordFile.isPresent())
{
}
if (trustStorePassword.isPresent())
{
}
else if (trustStorePasswordFile.isPresent())
{
}
if(controlStr.isPresent())
{
{
{
return 1;
}
}
}
{
}
for(String s : trailingArgs)
{
}
// Set the connection options.
// Parse the SASL properties.
if(saslOptions.isPresent())
{
{
{
if(val == false)
{
return 1;
}
} else
{
if(val == false)
{
return 1;
}
}
}
}
{
{
return 1;
}
if(keyStorePathValue == null)
{
return 1;
}
}
try
{
if (initializeServer)
{
// Bootstrap and initialize directory data structures.
}
// Connect to the specified host with the supplied userDN and password.
{
if (certNickname.isPresent())
{
}
else
{
clientAlias = null;
}
sslConnectionFactory = new SSLConnectionFactory();
}
{
// Read from stdin.
} else if(fileNameValue != null)
{
}
{
} else
{
}
} catch(LDAPException le)
{
if (debugEnabled())
{
}
return code;
} catch(LDAPConnectionException lce)
{
if (debugEnabled())
{
}
lce.getResultCode(),
lce.getMatchedDN());
return code;
} catch(Exception e)
{
if (debugEnabled())
{
}
return 1;
} finally
{
if(connection != null)
{
if (ldapDelete == null)
{
}
else
{
}
}
}
return 0;
}
}