/*
* 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.
*/
/**
* This program provides a utility that uses the LDAP password modify extended
* operation to change the password for a user. It exposes the three primary
* options available for this operation, which are:
*
* <UL>
* <LI>The user identity whose password should be changed.</LI>
* <LI>The current password for the user.</LI>
* <LI>The new password for the user.
* </UL>
*
* All of these are optional components that may be included or omitted from the
* request.
*/
public class LDAPPasswordModify
{
/**
* The fully-qualified name of this class.
*/
"org.opends.server.tools.LDAPPasswordModify";
/**
* Parses the command-line arguments, establishes a connection to the
* Directory Server, sends the password modify request, and reads the
* response.
*
* @param args The command-line arguments provided to this program.
*/
{
if (returnCode != 0)
{
}
}
/**
* Parses the command-line arguments, establishes a connection to the
* Directory Server, sends the password modify request, and reads the
* response.
*
* @param args The command-line arguments provided to this program.
*
* @return An integer value of zero if everything completed successfully, or
* a nonzero value if an error occurred.
*/
{
}
/**
* Parses the command-line arguments, establishes a connection to the
* Directory Server, sends the password modify request, and reads the
* response.
*
* @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.
* @param errStream The output stream to use for standard error.
*
* @return An integer value of zero if everything completed successfully, or
* a nonzero value if an error occurred.
*/
{
{
}
else
{
}
{
}
else
{
}
// Create the arguments that will be used by this program.
// Initialize the argument parser.
false);
try
{
OPTION_LONG_HOST, false, false,
true, INFO_HOST_PLACEHOLDER.get(),
"127.0.0.1", null,
ldapPort = new IntegerArgument(
"ldapport", OPTION_SHORT_PORT,
OPTION_LONG_PORT, false, false,
null, true, 1, true,
OPTION_LONG_BINDDN, false, false, true,
OPTION_LONG_BINDPWD, false, false,
null,
OPTION_LONG_BINDPWD_FILE, false,
false, INFO_BINDPWD_FILE_PLACEHOLDER.get(),
true, INFO_PROXYAUTHID_PLACEHOLDER.get(),
true, INFO_NEW_PASSWORD_PLACEHOLDER.get(),
newPWFile = new FileBasedArgument(
"newpwfile", 'N', "newPasswordFile",
true, INFO_CURRENT_PASSWORD_PLACEHOLDER.get(),
new FileBasedArgument(
"currentpwfile", 'C', "currentPasswordFile",
OPTION_LONG_KEYSTOREPATH, false, false,
null,
new StringArgument("keystorepassword",
false, false, true,
new FileBasedArgument(
"keystorepasswordfile",
false, false, INFO_KEYSTORE_PWD_FILE_PLACEHOLDER.get(),
new StringArgument("truststorepath",
OPTION_LONG_TRUSTSTOREPATH, false,
false, true,
false, false, true,
new FileBasedArgument("truststorepasswordfile",
OPTION_LONG_TRUSTSTORE_PWD_FILE, false, false,
false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
}
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 the usage or version argument was provided,
// then we don't need to do anything else.
if (argParser.usageOrVersionDisplayed())
{
return 0;
}
// Make sure that the user didn't specify any conflicting arguments.
{
return CLIENT_SIDE_PARAM_ERROR;
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
// If a bind DN was provided, make sure that a password was given. If a
// password was given, make sure a bind DN was provided. If neither were
// given, then make sure that an authorization ID and the current password
// were provided.
{
{
return CLIENT_SIDE_PARAM_ERROR;
}
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
else
{
if (provideDNForAuthzID.isPresent())
{
return CLIENT_SIDE_PARAM_ERROR;
}
{
return CLIENT_SIDE_PARAM_ERROR;
}
}
// Get the host and port.
int port;
try
{
}
catch (Exception e)
{
// This should never happen.
return CLIENT_SIDE_PARAM_ERROR;
}
// If a control string was provided, then decode the requested controls.
if(controlStr.isPresent())
{
{
{
return CLIENT_SIDE_PARAM_ERROR;
}
}
}
// Perform a basic Directory Server bootstrap if appropriate.
if (initializeServer)
{
}
// Establish a connection to the Directory Server.
{
if (sslKeyStorePIN.isPresent())
{
}
else if (sslKeyStorePINFile.isPresent())
{
}
if (sslTrustStorePIN.isPresent())
{
}
else if (sslTrustStorePINFile.isPresent())
{
}
try
{
if (certNickname.isPresent())
{
}
else
{
clientAlias = null;
}
}
catch (Exception e)
{
return CLIENT_SIDE_PARAM_ERROR;
}
}
{
}
else if (bindPWFile.isPresent())
{
}
else
{
}
try
{
}
catch (LDAPConnectionException lce)
{
return lce.getResultCode();
}
catch (ArgumentException e)
{
// This should not occur because the arguments are already parsed.
// It is a bug
e.printStackTrace();
throw new IllegalStateException("Unexpected error: "+e, e);
}
// Construct the password modify request.
try
{
{
}
else if (provideDNForAuthzID.isPresent())
{
}
{
}
else if (currentPWFile.isPresent())
{
}
else if (provideDNForAuthzID.isPresent())
{
pw);
}
{
}
{
}
}
catch(Exception e)
{
}
builder.toByteString());
controls);
// Send the request to the server and read the response.
try
{
}
catch (Exception e)
{
try
{
new UnbindRequestProtocolOp());
}
try
{
return 1;
}
// Read the response from the server.
try
{
}
catch (Exception e)
{
try
{
new UnbindRequestProtocolOp());
}
try
{
return 1;
}
// Make sure that the response was acceptable.
{
{
}
{
}
try
{
new UnbindRequestProtocolOp());
}
catch (Exception e) {}
try
{
} catch (Exception e) {}
return resultCode;
}
else
{
{
}
}
// See if the response included any controls that we recognize, and if so
// then handle them.
if (responseControls != null)
{
for (Control c : responseControls)
{
{
try
{
if (pwPolicyWarningType != null)
{
}
if (pwPolicyErrorType != null)
{
}
}
catch (Exception e)
{
}
}
}
}
// See if the response included a generated password.
if (responseValue != null)
{
try
{
while(asn1Reader.hasNextElement())
{
{
}
else
{
}
}
}
catch (Exception e)
{
try
{
new UnbindRequestProtocolOp());
}
try
{
return 1;
}
}
// Unbind from the server and close the connection.
try
{
new UnbindRequestProtocolOp());
}
catch (Exception e) {}
try
{
} catch (Exception e) {}
return 0;
}
}