use of com.zimbra.soap.admin.message.SetPasswordRequest in project zm-mailbox by Zimbra.
the class SoapProvisioning method setPassword.
@Override
public SetPasswordResult setPassword(Account acct, String newPassword) throws ServiceException {
SetPasswordResponse resp = invokeJaxb(new SetPasswordRequest(acct.getId(), newPassword));
SetPasswordResult result = new SetPasswordResult();
String eMsg = resp.getMessage();
if (eMsg != null)
result.setMessage(eMsg);
return result;
}
use of com.zimbra.soap.admin.message.SetPasswordRequest in project zm-mailbox by Zimbra.
the class TestSetPassword method setPassword.
private String setPassword(Account authedAcct, Account targetAcct, boolean againstPolicy) throws Exception {
String newPassword = againstPolicy ? genBadPassword() : genGoodPassword();
SoapTransport transport = authAdmin(authedAcct.getName());
SetPasswordRequest req = new SetPasswordRequest(targetAcct.getId(), newPassword);
SetPasswordResponse resp = invokeJaxb(transport, req);
return newPassword;
}
use of com.zimbra.soap.admin.message.SetPasswordRequest in project zm-mailbox by Zimbra.
the class SetPassword method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
SetPasswordResponse resp = null;
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
SetPasswordRequest req = zsc.elementToJaxb(request);
String id = req.getId();
String newPassword = req.getNewPassword();
Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
if (account == null) {
try {
defendAgainstAccountOrCalendarResourceHarvestingWhenAbsent(AccountBy.id, id, zsc, Admin.R_setAccountPassword, Admin.R_setCalendarResourcePassword);
} catch (ServiceException se1) {
defendAgainstAccountOrCalendarResourceHarvestingWhenAbsent(AccountBy.id, id, zsc, Admin.R_changeAccountPassword, Admin.R_changeCalendarResourcePassword);
}
} else {
try {
defendAgainstAccountOrCalendarResourceHarvesting(account, AccountBy.id, id, zsc, Admin.R_setAccountPassword, Admin.R_setCalendarResourcePassword);
} catch (ServiceException se1) {
defendAgainstAccountOrCalendarResourceHarvesting(account, AccountBy.id, id, zsc, Admin.R_changeAccountPassword, Admin.R_changeCalendarResourcePassword);
}
boolean enforcePasswordPolicy;
if (account.isCalendarResource()) {
CalendarResource resource = prov.get(CalendarResourceBy.id, id);
enforcePasswordPolicy = checkCalendarResourceRights(zsc, resource);
} else {
enforcePasswordPolicy = checkAccountRights(zsc, account);
}
SetPasswordResult result = prov.setPassword(account, newPassword, enforcePasswordPolicy);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "SetPassword", "name", account.getName() }));
if (result.hasMessage()) {
ZimbraLog.security.info(result.getMessage());
resp = new SetPasswordResponse(result.getMessage());
} else {
resp = new SetPasswordResponse((String) null);
}
}
return zsc.jaxbToElement(resp);
}
Aggregations