Search in sources :

Example 16 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class GetAllXMPPComponents method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    List<XMPPComponent> components = prov.getAllXMPPComponents();
    AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(zsc);
    Element response = zsc.createElement(AdminConstants.GET_ALL_XMPPCOMPONENTS_REQUEST);
    for (XMPPComponent comp : components) {
        if (aac.hasRightsToList(comp, Admin.R_listXMPPComponent, null))
            GetXMPPComponent.encodeXMPPComponent(response, comp, null, aac.getAttrRightChecker(comp));
    }
    return response;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) XMPPComponent(com.zimbra.cs.account.XMPPComponent) Provisioning(com.zimbra.cs.account.Provisioning)

Example 17 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class LdapProvisioning method getXMPPComponentByName.

private XMPPComponent getXMPPComponentByName(String name, boolean nocache) throws ServiceException {
    if (!nocache) {
        XMPPComponent x = xmppComponentCache.getByName(name);
        if (x != null)
            return x;
    }
    try {
        String dn = mDIT.xmppcomponentNameToDN(name);
        ZAttributes attrs = helper.getAttributes(LdapUsage.GET_XMPPCOMPONENT, dn);
        XMPPComponent x = new LdapXMPPComponent(dn, attrs, this);
        xmppComponentCache.put(x);
        return x;
    } catch (LdapEntryNotFoundException e) {
        return null;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to lookup xmpp component by name: " + name + " message: " + e.getMessage(), e);
    }
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapEntryNotFoundException(com.zimbra.cs.ldap.LdapException.LdapEntryNotFoundException) ZAttributes(com.zimbra.cs.ldap.ZAttributes) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent) XMPPComponent(com.zimbra.cs.account.XMPPComponent) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent)

Example 18 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class LdapProvisioning method createXMPPComponent.

@Override
public XMPPComponent createXMPPComponent(String name, Domain domain, Server server, Map<String, Object> inAttrs) throws ServiceException {
    name = name.toLowerCase().trim();
    // sanity checking
    removeAttrIgnoreCase("objectclass", inAttrs);
    removeAttrIgnoreCase(A_zimbraDomainId, inAttrs);
    removeAttrIgnoreCase(A_zimbraServerId, inAttrs);
    CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
    AttributeManager.getInstance().preModify(inAttrs, null, callbackContext, true);
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_XMPPCOMPONENT);
        ZMutableEntry entry = LdapClient.createMutableEntry();
        entry.mapToAttrs(inAttrs);
        entry.setAttr(A_objectClass, "zimbraXMPPComponent");
        String compId = LdapUtil.generateUUID();
        entry.setAttr(A_zimbraId, compId);
        entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
        entry.setAttr(A_cn, name);
        String dn = mDIT.xmppcomponentNameToDN(name);
        entry.setDN(dn);
        entry.setAttr(A_zimbraDomainId, domain.getId());
        entry.setAttr(A_zimbraServerId, server.getId());
        zlc.createEntry(entry);
        XMPPComponent comp = getXMPPComponentById(compId, zlc, true);
        AttributeManager.getInstance().postModify(inAttrs, comp, callbackContext);
        return comp;
    } catch (LdapEntryAlreadyExistException nabe) {
        throw AccountServiceException.IM_COMPONENT_EXISTS(name);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZMutableEntry(com.zimbra.cs.ldap.ZMutableEntry) LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) CallbackContext(com.zimbra.cs.account.callback.CallbackContext) XMPPComponent(com.zimbra.cs.account.XMPPComponent) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent) Date(java.util.Date)

Example 19 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class GetXMPPComponent method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Set<String> reqAttrs = getReqAttrs(request, AttributeClass.xmppComponent);
    Element id = request.getElement(AdminConstants.E_XMPP_COMPONENT);
    String byStr = id.getAttribute(AdminConstants.A_BY);
    String name = id.getText();
    if (name == null || name.equals(""))
        throw ServiceException.INVALID_REQUEST("must specify a value for a xmppcomponent", null);
    Key.XMPPComponentBy by = Key.XMPPComponentBy.valueOf(byStr);
    XMPPComponent comp = prov.get(by, name);
    if (comp == null)
        throw AccountServiceException.NO_SUCH_XMPP_COMPONENT(name);
    AdminAccessControl aac = checkRight(zsc, context, comp, AdminRight.PR_ALWAYS_ALLOW);
    Element response = zsc.createElement(AdminConstants.GET_XMPPCOMPONENT_RESPONSE);
    encodeXMPPComponent(response, comp, reqAttrs, aac.getAttrRightChecker(comp));
    return response;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) XMPPComponentBy(com.zimbra.common.account.Key.XMPPComponentBy) Element(com.zimbra.common.soap.Element) XMPPComponent(com.zimbra.cs.account.XMPPComponent) Provisioning(com.zimbra.cs.account.Provisioning) Key(com.zimbra.common.account.Key)

Example 20 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class DeleteXMPPComponent method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Element id = request.getElement(AdminConstants.E_XMPP_COMPONENT);
    String byStr = id.getAttribute(AdminConstants.A_BY);
    String name = id.getText();
    if (name == null || name.equals(""))
        throw ServiceException.INVALID_REQUEST("must specify a value for a xmppcomponent", null);
    Key.XMPPComponentBy by = Key.XMPPComponentBy.valueOf(byStr);
    XMPPComponent comp = prov.get(by, name);
    if (comp == null) {
        throw AccountServiceException.NO_SUCH_XMPP_COMPONENT(name);
    }
    checkRight(zsc, context, comp, Admin.R_deleteXMPPComponent);
    prov.deleteXMPPComponent(comp);
    Element response = zsc.createElement(AdminConstants.DELETE_XMPPCOMPONENT_RESPONSE);
    return response;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) XMPPComponentBy(com.zimbra.common.account.Key.XMPPComponentBy) Element(com.zimbra.common.soap.Element) XMPPComponent(com.zimbra.cs.account.XMPPComponent) Provisioning(com.zimbra.cs.account.Provisioning) Key(com.zimbra.common.account.Key)

Aggregations

XMPPComponent (com.zimbra.cs.account.XMPPComponent)20 Element (com.zimbra.common.soap.Element)5 LdapXMPPComponent (com.zimbra.cs.account.ldap.entry.LdapXMPPComponent)5 Provisioning (com.zimbra.cs.account.Provisioning)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 HashMap (java.util.HashMap)4 Key (com.zimbra.common.account.Key)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 Server (com.zimbra.cs.account.Server)3 XMPPComponentBy (com.zimbra.common.account.Key.XMPPComponentBy)2 ServiceException (com.zimbra.common.service.ServiceException)2 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)2 Domain (com.zimbra.cs.account.Domain)2 ArrayList (java.util.ArrayList)2 DomainBy (com.zimbra.common.account.Key.DomainBy)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 Account (com.zimbra.cs.account.Account)1 AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)1 DynamicGroup (com.zimbra.cs.account.DynamicGroup)1 Group (com.zimbra.cs.account.Group)1