Search in sources :

Example 1 with SetPasswordResponse

use of com.zimbra.soap.admin.message.SetPasswordResponse 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;
}
Also used : SetPasswordResponse(com.zimbra.soap.admin.message.SetPasswordResponse) SetPasswordRequest(com.zimbra.soap.admin.message.SetPasswordRequest) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 2 with SetPasswordResponse

use of com.zimbra.soap.admin.message.SetPasswordResponse 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 = JaxbUtil.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);
}
Also used : Account(com.zimbra.cs.account.Account) ServiceException(com.zimbra.common.service.ServiceException) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) SetPasswordResponse(com.zimbra.soap.admin.message.SetPasswordResponse) SetPasswordRequest(com.zimbra.soap.admin.message.SetPasswordRequest) SetPasswordResult(com.zimbra.cs.account.Provisioning.SetPasswordResult) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

SetPasswordRequest (com.zimbra.soap.admin.message.SetPasswordRequest)2 SetPasswordResponse (com.zimbra.soap.admin.message.SetPasswordResponse)2 ServiceException (com.zimbra.common.service.ServiceException)1 SoapTransport (com.zimbra.common.soap.SoapTransport)1 Account (com.zimbra.cs.account.Account)1 CalendarResource (com.zimbra.cs.account.CalendarResource)1 Provisioning (com.zimbra.cs.account.Provisioning)1 SetPasswordResult (com.zimbra.cs.account.Provisioning.SetPasswordResult)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1