use of com.zimbra.soap.account.message.ResetPasswordRequest in project zm-mailbox by Zimbra.
the class ResetPassword method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
if (!checkPasswordSecurity(context)) {
throw ServiceException.INVALID_REQUEST("clear text password is not allowed", null);
}
Provisioning prov = Provisioning.getInstance();
ZimbraSoapContext zsc = getZimbraSoapContext(context);
ResetPasswordRequest req = JaxbUtil.elementToJaxb(request);
req.validateResetPasswordRequest();
AuthToken at = zsc.getAuthToken();
AuthProvider.validateAuthToken(prov, at, false);
Account acct = at.getAccount();
boolean locked = acct.getBooleanAttr(Provisioning.A_zimbraPasswordLocked, false);
if (locked) {
throw AccountServiceException.PASSWORD_LOCKED();
}
ResetPasswordUtil.validateFeatureResetPasswordStatus(acct);
String newPassword = req.getPassword();
checkPasswordStrength(prov, acct, newPassword);
// proxy if required
if (!Provisioning.onLocalServer(acct)) {
try {
return proxyRequest(request, context, acct.getId());
} catch (ServiceException e) {
// if something went wrong proxying the request, just execute it locally
if (ServiceException.PROXY_ERROR.equals(e.getCode())) {
ZimbraLog.account.warn("encountered proxy error", e);
} else {
// but if it's a real error, it's a real error
throw e;
}
}
}
setPasswordAndPurgeAuthTokens(prov, acct, newPassword);
Element response = zsc.createElement(AccountConstants.E_RESET_PASSWORD_RESPONSE);
return response;
}
use of com.zimbra.soap.account.message.ResetPasswordRequest in project zm-mailbox by Zimbra.
the class TestResetPassword method testResetPassword.
@Test
public void testResetPassword() throws Exception {
Provisioning prov = Provisioning.getInstance();
Account acct1 = prov.getAccount(USER_NAME);
acct1.setFeatureResetPasswordStatus(FeatureResetPasswordStatus.enabled);
ResetPassword resetPassword = new TestResetPassword();
Map<String, Object> ctxt = ServiceTestUtil.getRequestContext(acct1);
ResetPasswordRequest resetReq = new ResetPasswordRequest();
resetReq.setPassword(NEW_PASSWORD);
Element request = JaxbUtil.jaxbToElement(resetReq);
try {
resetPassword.handle(request, ctxt);
} catch (ServiceException se) {
Assert.fail("This should not happen");
}
}
use of com.zimbra.soap.account.message.ResetPasswordRequest in project zm-mailbox by Zimbra.
the class TestResetPassword method testResetPassword_FeatureDisabled.
@Test
public void testResetPassword_FeatureDisabled() throws Exception {
Provisioning prov = Provisioning.getInstance();
Account acct1 = prov.getAccount(USER_NAME);
acct1.setFeatureResetPasswordStatus(FeatureResetPasswordStatus.enabled);
ResetPassword resetPassword = new TestResetPassword();
Map<String, Object> ctxt = ServiceTestUtil.getRequestContext(acct1);
ResetPasswordRequest resetReq = new ResetPasswordRequest();
resetReq.setPassword(NEW_PASSWORD);
Element request = JaxbUtil.jaxbToElement(resetReq);
try {
resetPassword.handle(request, ctxt);
} catch (ServiceException se) {
Assert.assertEquals("permission denied: Reset password feature is disabled", se.getMessage());
}
}
Aggregations