ResetUserPasswordTask.java revision 6638c2755466ca601450700d5a39f390f23d4781
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* The task called when we want to reset the password of the user.
*
*/
public class ResetUserPasswordTask extends Task
{
private char[] currentPassword;
private char[] newPassword;
private boolean useAdminCtx;
/**
* Constructor of the task.
* @param info the control panel information.
* @param dlg the progress dialog where the task progress will be displayed.
* @param node the node corresponding to the entry whose password is going
* to be reset.
* @param controller the BrowserController.
* @param pwd the new password.
*/
{
this.newPassword = pwd;
try
{
{
{
{
}
}
}
}
catch (OpenDsException ode)
{
}
try
{
{
}
}
catch (Throwable t)
{
}
}
/** {@inheritDoc} */
{
return Type.MODIFY_ENTRY;
}
/** {@inheritDoc} */
{
return backendSet;
}
/** {@inheritDoc} */
public LocalizableMessage getTaskDescription()
{
}
/** {@inheritDoc} */
public boolean regenerateDescriptor()
{
return false;
}
/** {@inheritDoc} */
protected String getCommandLinePath()
{
return getCommandLinePath("ldappasswordmodify");
}
/** {@inheritDoc} */
{
if (currentPassword == null)
{
}
else
{
}
return args;
}
/** {@inheritDoc} */
{
if (!isServerRunning()
{
// All the operations are incompatible if they apply to this
// backend for safety. This is a short operation so the limitation
// has not a lot of impact.
{
return false;
}
}
return true;
}
/** {@inheritDoc} */
public void runTask()
{
try
{
if (returnCode != 0)
{
}
else
{
{
// The connections must be updated, just update the environment, which
// is what we use to clone connections and to launch scripts.
// The environment will also be used if we want to reconnect.
{
}
}
}
}
catch (Throwable t)
{
lastException = t;
}
}
/**
* Returns <CODE>true</CODE> if we are bound using the provided entry. In
* the case of root entries this is not necessarily the same as using that
* particular DN (we might be binding using a value specified in
* ds-cfg-alternate-bind-dn).
* @param dn the DN.
* @param ctx the connection that we are using to modify the password.
* @return <CODE>true</CODE> if we are bound using the provided entry.
*/
{
boolean isBoundAs = false;
try
{
}
catch (Throwable t)
{
// Ignore
}
if (!isBoundAs)
{
try
{
"(|(objectClass=*)(objectclass=ldapsubentry))";
try
{
{
{
{
isBoundAs = true;
break;
}
}
}
}
finally
{
}
}
catch (Throwable t)
{
}
}
return isBoundAs;
}
}