Search in sources :

Example 1 with AddAccountAliasResponse

use of com.zimbra.soap.admin.message.AddAccountAliasResponse in project zm-mailbox by Zimbra.

the class AddAccountAlias method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    AddAccountAliasRequest req = JaxbUtil.elementToJaxb(request);
    String id = req.getId();
    String alias = req.getAlias();
    Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
    defendAgainstAccountOrCalendarResourceHarvesting(account, AccountBy.id, id, zsc, Admin.R_addAccountAlias, Admin.R_addCalendarResourceAlias);
    // if the admin can create an alias in the domain
    checkDomainRightByEmail(zsc, alias, Admin.R_createAlias);
    prov.addAlias(account, alias);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddAccountAlias", "name", account.getName(), "alias", alias }));
    return zsc.jaxbToElement(new AddAccountAliasResponse());
}
Also used : Account(com.zimbra.cs.account.Account) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) Provisioning(com.zimbra.cs.account.Provisioning)

Example 2 with AddAccountAliasResponse

use of com.zimbra.soap.admin.message.AddAccountAliasResponse in project zm-mailbox by Zimbra.

the class TestDLMembership method testRemoveMemberByAlias.

@Test
public void testRemoveMemberByAlias() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add an alias to the account
        AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
        assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
        Account acct = Provisioning.getInstance().getAccount(testUser.getId());
        assertNotNull(acct);
        assertNotNull("account's aliases are null", acct.getAliases());
        assertEquals("account has no aliases", acct.getAliases().length, 1);
        //add account to DL by alias
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
        //remove the account's alias from the DL
        RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), Arrays.asList(new String[] { TestUtil.getAddress(TEST_ALIAS) })));
        assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
        //verify that account is NOT a member of the DL anymore
        result = new ArrayList<DistributionList>();
        resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        dlInfoList = resp.getDlList();
        assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : Account(com.zimbra.cs.account.Account) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) ArrayList(java.util.ArrayList) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) DLInfo(com.zimbra.soap.admin.type.DLInfo) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 3 with AddAccountAliasResponse

use of com.zimbra.soap.admin.message.AddAccountAliasResponse in project zm-mailbox by Zimbra.

the class TestDLMembership method testRemoveMemberByName.

@Test
public void testRemoveMemberByName() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add an alias to the account
        AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
        assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
        Account acct = Provisioning.getInstance().getAccount(testUser.getId());
        assertNotNull(acct);
        assertNotNull("account's aliases are null", acct.getAliases());
        assertEquals("account has no aliases", acct.getAliases().length, 1);
        //add account to DL by alias
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
        //remove the account's alias from the DL
        RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), null, Arrays.asList(new String[] { TestUtil.getAddress(TEST_USER) })));
        assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
        //verify that account is NOT a member of the DL anymore
        result = new ArrayList<DistributionList>();
        resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        dlInfoList = resp.getDlList();
        assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : Account(com.zimbra.cs.account.Account) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) ArrayList(java.util.ArrayList) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) DLInfo(com.zimbra.soap.admin.type.DLInfo) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 4 with AddAccountAliasResponse

use of com.zimbra.soap.admin.message.AddAccountAliasResponse in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testGetAccountInDiffDomain.

@Test
public void testGetAccountInDiffDomain() throws Exception {
    Account acct = TestJaxbProvisioning.ensureAccountExists(DIFF_ACCT);
    String acctId = acct.getId();
    String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    GetAccountRequest getAcctReq = new GetAccountRequest(AccountSelector.fromName(DIFF_ACCT), true);
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetAccountRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
        fail("GetAccountRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    // try non-existent acct
    getAcctReq = new GetAccountRequest(AccountSelector.fromName(DIFF_ACCT2), true);
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetAccountRequest succeeded for non-existent account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    GetMailboxRequest gmReq = new GetMailboxRequest(new MailboxByAccountIdSelector(acctId));
    try {
        domAdminSoapProv.invokeJaxb(gmReq);
        fail("GetMailboxRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
        fail("GetMailboxRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    AddAccountAliasResponse aaaResp;
    try {
        aaaResp = domAdminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
        fail("AddAccountAliasRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        aaaResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT2), acctId);
        fail("AddAccountAliasRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    aaaResp = adminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
    assertNotNull("AddAccountAliasResponse for " + TARGET_ACCT + " as FULL ADMIN", aaaResp);
    try {
        domAdminSoapProv.invokeJaxb(new RemoveAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
        fail("RemoveAccountAliasRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, TARGET_ACCT_RENAMED));
        fail("RenameAccountRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        domAdminSoapProv.invokeJaxb(new DeleteAccountRequest(acctId));
        fail("DeleteAccountRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
}
Also used : Account(com.zimbra.cs.account.Account) DeleteAccountRequest(com.zimbra.soap.admin.message.DeleteAccountRequest) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) RemoveAccountAliasRequest(com.zimbra.soap.admin.message.RemoveAccountAliasRequest) GetMailboxRequest(com.zimbra.soap.admin.message.GetMailboxRequest) RenameAccountRequest(com.zimbra.soap.admin.message.RenameAccountRequest) MailboxByAccountIdSelector(com.zimbra.soap.admin.type.MailboxByAccountIdSelector) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) GetAccountRequest(com.zimbra.soap.admin.message.GetAccountRequest) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 5 with AddAccountAliasResponse

use of com.zimbra.soap.admin.message.AddAccountAliasResponse in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testGetAccountInDomAdminDomain.

@Test
public void testGetAccountInDomAdminDomain() throws Exception {
    String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    CreateAccountResponse caResp;
    caResp = domAdminSoapProv.invokeJaxb(new CreateAccountRequest(TARGET_ACCT, TestUtil.DEFAULT_PASSWORD));
    assertNotNull("CreateAccountResponse for " + TARGET_ACCT + " simple as domAdmin", caResp);
    String acctId = caResp.getAccount().getId();
    GetAccountRequest getAcctReq = new GetAccountRequest(AccountSelector.fromName(TARGET_ACCT), true);
    GetAccountResponse getAcctResp = domAdminSoapProv.invokeJaxb(getAcctReq);
    assertNotNull("GetAccountResponse for " + TARGET_ACCT + " simple as domAdmin", getAcctResp);
    getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
    assertNotNull("GetAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", getAcctResp);
    GetMailboxRequest gmReq = new GetMailboxRequest(new MailboxByAccountIdSelector(acctId));
    GetMailboxResponse gmResp = domAdminSoapProv.invokeJaxb(gmReq);
    assertNotNull("GetMailboxResponse for " + TARGET_ACCT + " simple as domAdmin", gmResp);
    gmResp = domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
    assertNotNull("GetMailboxResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", gmResp);
    AddAccountAliasResponse aaaResp;
    aaaResp = domAdminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
    assertNotNull("AddAccountAliasResponse for " + TARGET_ACCT + " simple as domAdmin", aaaResp);
    aaaResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT2), acctId);
    assertNotNull("AddAccountAliasResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", aaaResp);
    RemoveAccountAliasResponse daaResp;
    daaResp = domAdminSoapProv.invokeJaxb(new RemoveAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
    assertNotNull("RemoveAccountAliasResponse for " + TARGET_ACCT + " simple as domAdmin", daaResp);
    daaResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new RemoveAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT2), acctId);
    assertNotNull("RemoveAccountAliasResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", daaResp);
    RenameAccountResponse renAResp;
    renAResp = domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, TARGET_ACCT_RENAMED));
    assertNotNull("RenameAccountResponse for " + TARGET_ACCT + " simple as domAdmin", renAResp);
    renAResp = domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, TARGET_ACCT));
    assertNotNull("RenameAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", renAResp);
    DeleteAccountRequest delAcctReq;
    DeleteAccountResponse delAcctResp;
    delAcctReq = new DeleteAccountRequest(null);
    try {
        delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
        fail("DeleteAccountRequest succeeded in spite of having no 'id' specified!!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "invalid request: missing required attribute: id");
    }
    delAcctReq = new DeleteAccountRequest(acctId);
    delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
    assertNotNull("DeleteAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", delAcctResp);
    try {
        getAcctResp = domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetAccountRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "no such account: ");
    }
    try {
        getAcctResp = domAdminSoapProv.invokeJaxb(new GetAccountRequest(AccountSelector.fromId(acctId), true));
        fail("GetAccountRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // because by id not name
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
        fail("GetAccountRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        gmResp = domAdminSoapProv.invokeJaxb(gmReq);
        fail("GetMailboxRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // because by id
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
    try {
        gmResp = domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
        fail("GetMailboxRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
}
Also used : CreateAccountResponse(com.zimbra.soap.admin.message.CreateAccountResponse) DeleteAccountRequest(com.zimbra.soap.admin.message.DeleteAccountRequest) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) RemoveAccountAliasRequest(com.zimbra.soap.admin.message.RemoveAccountAliasRequest) DeleteAccountResponse(com.zimbra.soap.admin.message.DeleteAccountResponse) RenameAccountRequest(com.zimbra.soap.admin.message.RenameAccountRequest) GetMailboxResponse(com.zimbra.soap.admin.message.GetMailboxResponse) MailboxByAccountIdSelector(com.zimbra.soap.admin.type.MailboxByAccountIdSelector) GetAccountRequest(com.zimbra.soap.admin.message.GetAccountRequest) SoapFaultException(com.zimbra.common.soap.SoapFaultException) GetAccountResponse(com.zimbra.soap.admin.message.GetAccountResponse) RemoveAccountAliasResponse(com.zimbra.soap.admin.message.RemoveAccountAliasResponse) CreateAccountRequest(com.zimbra.soap.admin.message.CreateAccountRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) GetMailboxRequest(com.zimbra.soap.admin.message.GetMailboxRequest) RenameAccountResponse(com.zimbra.soap.admin.message.RenameAccountResponse) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) Test(org.junit.Test)

Aggregations

AddAccountAliasRequest (com.zimbra.soap.admin.message.AddAccountAliasRequest)6 AddAccountAliasResponse (com.zimbra.soap.admin.message.AddAccountAliasResponse)6 Account (com.zimbra.cs.account.Account)5 Test (org.junit.Test)5 SoapTransport (com.zimbra.common.soap.SoapTransport)3 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)3 AddDistributionListMemberRequest (com.zimbra.soap.admin.message.AddDistributionListMemberRequest)3 AddDistributionListMemberResponse (com.zimbra.soap.admin.message.AddDistributionListMemberResponse)3 GetAccountMembershipRequest (com.zimbra.soap.admin.message.GetAccountMembershipRequest)3 GetAccountMembershipResponse (com.zimbra.soap.admin.message.GetAccountMembershipResponse)3 DLInfo (com.zimbra.soap.admin.type.DLInfo)3 SoapFaultException (com.zimbra.common.soap.SoapFaultException)2 DistributionList (com.zimbra.cs.account.DistributionList)2 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)2 DeleteAccountRequest (com.zimbra.soap.admin.message.DeleteAccountRequest)2 GetAccountRequest (com.zimbra.soap.admin.message.GetAccountRequest)2 GetMailboxRequest (com.zimbra.soap.admin.message.GetMailboxRequest)2 RemoveAccountAliasRequest (com.zimbra.soap.admin.message.RemoveAccountAliasRequest)2 RemoveDistributionListMemberRequest (com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest)2 RemoveDistributionListMemberResponse (com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse)2