Search in sources :

Example 1 with AutoProvPrincipalBy

use of com.zimbra.soap.type.AutoProvPrincipalBy in project zm-mailbox by Zimbra.

the class AutoProvAccount method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    AutoProvAccountRequest req = JaxbUtil.elementToJaxb(request);
    DomainBy domainBy = req.getDomain().getBy().toKeyDomainBy();
    String domainKey = req.getDomain().getKey();
    Domain domain = prov.get(domainBy, domainKey);
    if (domain == null) {
        throw AccountServiceException.NO_SUCH_DOMAIN(domainKey);
    }
    checkRight(zsc, context, domain, Admin.R_autoProvisionAccount);
    AutoProvPrincipalBy by = req.getPrincipal().getBy();
    String principal = req.getPrincipal().getKey();
    String password = req.getPassword();
    Account acct = prov.autoProvAccountManual(domain, by, principal, password);
    if (acct == null) {
        throw ServiceException.FAILURE("unable to auto provision account: " + principal, null);
    }
    Element response = zsc.createElement(AdminConstants.AUTO_PROV_ACCOUNT_RESPONSE);
    ToXML.encodeAccount(response, acct);
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) DomainBy(com.zimbra.common.account.Key.DomainBy) AutoProvPrincipalBy(com.zimbra.soap.type.AutoProvPrincipalBy) Element(com.zimbra.common.soap.Element) AutoProvAccountRequest(com.zimbra.soap.admin.message.AutoProvAccountRequest) Domain(com.zimbra.cs.account.Domain) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

DomainBy (com.zimbra.common.account.Key.DomainBy)1 Element (com.zimbra.common.soap.Element)1 Account (com.zimbra.cs.account.Account)1 Domain (com.zimbra.cs.account.Domain)1 Provisioning (com.zimbra.cs.account.Provisioning)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 AutoProvAccountRequest (com.zimbra.soap.admin.message.AutoProvAccountRequest)1 AutoProvPrincipalBy (com.zimbra.soap.type.AutoProvPrincipalBy)1