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;
}
Aggregations