/*
* 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 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2012 profiq, s.r.o.
* Portions Copyright 2012-2013 ForgeRock AS.
*/
/**
* This class provides a tool that can be used to issue modify requests to the
* Directory Server.
*/
public class LDAPModify
{
/**
* The tracer object for the debug logger.
*/
/**
* The fully-qualified name of this class.
*/
/** The message ID counter to use for requests. */
/** The print stream to use for standard error. */
/** The print stream to use for standard output. */
/**
* Constructor for the LDAPModify object.
*
* @param nextMessageID The message ID counter 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;
}
/**
* Read the specified change records from the given input stream
* (file or stdin) and execute the given modify request.
*
* @param connection The connection to use for this modify request.
* @param fileNameValue Name of the file from which to read. If null,
* input will be read from <code>System.in</code>.
* @param modifyOptions The constraints for the modify 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
{
// Create an LDIF import configuration to do this and then get the reader.
try
{
if(fileNameValue != null)
{
}
importConfig.setValidateSchema(false);
} catch (Exception e)
{
if (debugEnabled())
{
}
e.getLocalizedMessage());
}
// Set this for error messages
if (fileNameValue == null)
{
fileNameValue = "Console";
}
while (true)
{
try
{
} catch (LDIFException le)
{
if (debugEnabled())
{
}
if (!modifyOptions.continueOnError())
{
try
{
}
catch (Exception e)
{
if (debugEnabled())
{
}
}
}
else
{
continue;
}
} catch (Exception e)
{
if (debugEnabled())
{
}
if (!modifyOptions.continueOnError())
{
try
{
}
{
if (debugEnabled())
{
}
}
}
else
{
continue;
}
}
// If the entry is null, then we have reached the end of the config file.
{
try
{
}
catch (Exception e)
{
if (debugEnabled())
{
}
}
break;
}
switch(entry.getChangeOperationType())
{
case ADD:
operationType = "ADD";
{
}
break;
case DELETE:
operationType = "DELETE";
break;
case MODIFY:
operationType = "MODIFY";
break;
case MODIFY_DN:
operationType = "MODIFY DN";
{
} else
{
}
break;
default:
break;
}
if(!modifyOptions.showOperations())
{
try
{
controls);
} catch(ASN1Exception ae)
{
if (debugEnabled())
{
}
if (!modifyOptions.continueOnError())
{
}
return;
}
int resultCode = 0;
try
{
switch(entry.getChangeOperationType())
{
case ADD:
break;
case DELETE:
break;
case MODIFY:
break;
case MODIFY_DN:
break;
default:
break;
}
}
catch (ClassCastException ce)
{
// It is possible that this is extended response.
if (responseMessage.getProtocolOpType() ==
{
}
else
{
// This shouldnt happen but if it does debug
// log it, set the error code to OTHER and
// fall thru.
if (debugEnabled())
{
}
errorMessage = null;
referralURLs = null;
}
}
{
if(!modifyOptions.continueOnError())
{
} else
{
}
} else
{
if (errorMessage != null)
{
}
if (referralURLs != null)
{
}
}
{
{
try
{
if(c instanceof LDAPControl)
{
// Control needs to be decoded
}
else
{
}
}
catch (DirectoryException de)
{
de.getMessage()),
continue;
}
}
{
try
{
if (c instanceof LDAPControl)
{
// Control needs to be decoded
}
else
{
}
}
catch (DirectoryException de)
{
de.getMessage()),
continue;
}
}
{
if(c instanceof LDAPControl)
{
// Don't really need to decode since its just an octet string.
}
else
{
getChangeNumber().toString()));
}
}
}
}
}
}
/**
* The main method for LDAPModify 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 ldapmodify 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 ldapmodify 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);
try
{
OPTION_LONG_HOST, false, false, true,
null,
OPTION_LONG_PORT, false, false, true,
true, 1, true, 65535,
OPTION_LONG_BINDDN, false, false, true,
false, false, true,
new FileBasedArgument("bindPasswordFile",
false, false,
defaultAdd = new BooleanArgument(
"defaultAdd", 'a', "defaultAdd",
OPTION_LONG_FILENAME, false, false,
null,
saslExternal = new BooleanArgument(
"useSASLExternal", 'r',
"useSASLExternal",
OPTION_LONG_SASLOPTION, false,
true, true,
null,
false, false, true,
new StringArgument("keyStorePassword",
false, false,
true,
new FileBasedArgument("keystorepasswordfile",
false, false,
certNickname = new StringArgument(
"certnickname", 'N', "certNickname",
trustStorePath = new StringArgument(
"trustStorePath",
false, false, true,
false, false, true,
new FileBasedArgument(
"truststorepasswordfile",
OPTION_LONG_TRUSTSTORE_PWD_FILE, false, false,
OPTION_LONG_PROXYAUTHID, false,
false, true,
reportAuthzID = new BooleanArgument(
"reportauthzid", 'E',
"reportAuthzID",
assertionFilter = new StringArgument(
"assertionfilter", null,
false, false,
true,
preReadAttributes = new StringArgument(
"prereadattrs", null,
"preReadAttributes", false, false,
postReadAttributes = new StringArgument(
"postreadattrs", null,
"postReadAttributes", false,
null,
false, false, true,
false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
false, false,
true, INFO_ENCODING_PLACEHOLDER.get(),
"continueOnError",
} catch (ArgumentException ae)
{
return CLIENT_SIDE_PARAM_ERROR;
}
// Parse the command-line arguments provided to this program.
try
{
}
catch (ArgumentException ae)
{
return CLIENT_SIDE_PARAM_ERROR;
}
// If we should just display usage or version information,
// then print it and exit.
if (argParser.usageOrVersionDisplayed())
{
return SUCCESS;
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
int portNumber = 389;
try
{
} catch(ArgumentException ae)
{
if (debugEnabled())
{
}
return CLIENT_SIDE_PARAM_ERROR;
}
try
{
{
return CLIENT_SIDE_PARAM_ERROR;
}
} catch(ArgumentException ae)
{
if (debugEnabled())
{
}
return CLIENT_SIDE_PARAM_ERROR;
}
(!bindPasswordFile.isPresent() &&
{
// read the password from the stdin.
try
{
//As per rfc 4513(section-5.1.2) a client should avoid sending
//an empty password to the server.
{
}
{
if (debugEnabled())
{
}
return CLIENT_SIDE_PARAM_ERROR;
}
} 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 CLIENT_SIDE_PARAM_ERROR;
}
}
}
if (proxyAuthzID.isPresent())
{
new ProxiedAuthV2Control(true,
}
if (assertionFilter.isPresent())
{
try
{
new LDAPAssertionRequestControl(true, filter);
}
catch (LDAPException le)
{
le.getMessage());
return CLIENT_SIDE_PARAM_ERROR;
}
}
if (preReadAttributes.isPresent())
{
while (tokenizer.hasMoreTokens())
{
}
}
if (postReadAttributes.isPresent())
{
while (tokenizer.hasMoreTokens())
{
}
}
// Set the connection options.
if(saslOptions.isPresent())
{
{
{
if(val == false)
{
return CLIENT_SIDE_PARAM_ERROR;
}
} else
{
if(val == false)
{
return CLIENT_SIDE_PARAM_ERROR;
}
}
}
}
{
{
return CLIENT_SIDE_PARAM_ERROR;
}
if(keyStorePathValue == null)
{
return CLIENT_SIDE_PARAM_ERROR;
}
}
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();
}
timeout);
} catch(LDAPException le)
{
if (debugEnabled())
{
}
le.getResultCode(),
return code;
} catch(LDAPConnectionException lce)
{
if (debugEnabled())
{
}
lce.getResultCode(),
lce.getMatchedDN());
return code;
} catch (FileNotFoundException fe)
{
if (debugEnabled())
{
}
return CLIENT_SIDE_PARAM_ERROR;
} catch(Exception e)
{
if (debugEnabled())
{
}
return OPERATIONS_ERROR;
} finally
{
if(connection != null)
{
if (ldapModify == null)
{
}
else
{
}
}
}
return SUCCESS;
}
}