use of com.emc.storageos.security.authentication.SysSvcEndPointLocator in project coprhd-controller by CoprHD.
the class PasswordUtils method changePassword.
/**
* a wrapper to call change-password internal API or validate-change internal API in PasswordService
*
* bDryRun: if true, call validate-change internal API
* if false, call change-password internal API
*
* @param passwordChange
* @param bDryRun
* @return
*/
public Response changePassword(PasswordChangeParam passwordChange, boolean bDryRun) {
SysSvcEndPointLocator sysSvcEndPointLocator = new SysSvcEndPointLocator();
sysSvcEndPointLocator.setCoordinator(coordinator);
int attempts = 0;
ClientResponse response = null;
while (attempts < MAX_CONFIG_RETRIES) {
_log.debug("change password attempt {}", ++attempts);
AuthSvcInternalApiClientIterator sysSvcClientItr = new AuthSvcInternalApiClientIterator(sysSvcEndPointLocator, coordinator);
try {
if (sysSvcClientItr.hasNext()) {
if (bDryRun) {
_log.debug("change password dry run");
response = sysSvcClientItr.post(URI_VALIDATE_PASSWORD, passwordChange);
} else {
response = sysSvcClientItr.put(URI_CHANGE_PASSWORD, passwordChange);
}
_log.debug("change password response with status: " + response.getStatus());
break;
}
} catch (Exception exception) {
// log the exception and retry the request
_log.warn(exception.getMessage());
if (attempts == MAX_CONFIG_RETRIES - 1) {
throw exception;
}
}
}
Response.ResponseBuilder b = Response.status(response.getStatus());
if (!(response.getStatus() == ClientResponse.Status.NO_CONTENT.getStatusCode())) {
b.entity(response.getEntity(String.class));
}
return b.build();
}
Aggregations