Search in sources :

Example 1 with GetShareInfoResponse

use of com.zimbra.soap.account.message.GetShareInfoResponse in project zm-mailbox by Zimbra.

the class TestJaxbProvisioning method accountGetShareInfo.

public GetShareInfoResponse accountGetShareInfo(Account acct, AccountSelector owner, Boolean includeSelf, ShareSet shareSet) {
    GetShareInfoResponse resp = null;
    GranteeChooser grantee = null;
    try {
        resp = prov.invokeJaxbOnTargetAccount(GetShareInfoRequest.create(owner, grantee, includeSelf), acct.getId());
        Assert.assertNotNull(String.format("GetShareInfoRequest for account %s", acct.getName()), resp);
        checkGetShareInfo(shareSet, resp.getShares());
    } catch (ServiceException e) {
        Assert.fail("Unexpected exception while creating mountpoint " + e);
    }
    return resp;
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) GetShareInfoResponse(com.zimbra.soap.account.message.GetShareInfoResponse) GranteeChooser(com.zimbra.soap.type.GranteeChooser)

Example 2 with GetShareInfoResponse

use of com.zimbra.soap.account.message.GetShareInfoResponse in project zm-mailbox by Zimbra.

the class TestAclPush method testAclPushAndDiscovery.

@Test
public void testAclPushAndDiscovery() throws Exception {
    // create a folder in user1's mailbox
    Mailbox mbox1 = MailboxManager.getInstance().getMailboxByAccount(acct1);
    Folder.FolderOptions fopt = new Folder.FolderOptions().setDefaultView(MailItem.Type.DOCUMENT);
    Folder folder = mbox1.createFolder(null, "/folder1", fopt);
    // grant access to the created folder to user2
    Account acct2 = Provisioning.getInstance().getAccountByName(TestUtil.getAddress(USER2_NAME));
    mbox1.grantAccess(null, folder.getId(), acct2.getId(), ACL.GRANTEE_USER, ACL.stringToRights("r"), null);
    // Give some time for AclPushTask to run
    Thread.sleep(100);
    // invoke GetShareInfoRequest from user2 and check that the shared is discovered
    ZMailbox zMailbox2 = TestUtil.getZMailbox(USER2_NAME);
    GetShareInfoRequest req = new GetShareInfoRequest();
    GetShareInfoResponse resp = zMailbox2.invokeJaxb(req);
    List<ShareInfo> shares = resp.getShares();
    ShareInfo share = getShare(shares, "/folder1");
    assertNotNull(share);
    assertEquals(acct2.getId(), share.getGranteeId());
    assertEquals(ACL.typeToString(ACL.GRANTEE_USER), share.getGranteeType());
    assertEquals(folder.getPath(), share.getFolderPath());
    assertEquals(folder.getId(), share.getFolderId());
    assertEquals(folder.getUuid(), share.getFolderUuid());
    assertEquals(folder.getDefaultView().toString(), share.getDefaultView());
    assertEquals("r", share.getRights());
    assertEquals(acct1.getId(), share.getOwnerId());
    // rename folder
    mbox1.rename(null, folder.getId(), MailItem.Type.FOLDER, "/folder2");
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    assertNotNull(getShare(shares, "/folder2"));
    // create another folder and share with DL
    Folder dlFolder = mbox1.createFolder(null, "/" + DL_NAME, fopt);
    mbox1.grantAccess(null, dlFolder.getId(), dl.getId(), ACL.GRANTEE_GROUP, ACL.stringToRights("rwi"), null);
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    ShareInfo dlShare = getShare(shares, "/" + DL_NAME);
    assertNotNull(dlShare);
    assertEquals(dl.getId(), dlShare.getGranteeId());
    assertEquals(dlFolder.getPath(), dlShare.getFolderPath());
    assertEquals(dlFolder.getDefaultView().toString(), dlShare.getDefaultView());
    assertEquals("rwi", dlShare.getRights());
    assertEquals(acct1.getId(), dlShare.getOwnerId());
    // create another folder and share with "public"
    Folder pubFolder = mbox1.createFolder(null, "/public", fopt);
    mbox1.grantAccess(null, pubFolder.getId(), null, ACL.GRANTEE_PUBLIC, ACL.stringToRights("rw"), null);
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    ShareInfo pubShare = getShare(shares, "/public");
    assertNotNull(pubShare);
    assertEquals(pubFolder.getPath(), pubShare.getFolderPath());
    assertEquals(pubFolder.getDefaultView().toString(), pubShare.getDefaultView());
    assertEquals("rw", pubShare.getRights());
    assertEquals(acct1.getId(), pubShare.getOwnerId());
    // revoke access for user2 on the first folder
    mbox1.revokeAccess(null, folder.getId(), acct2.getId());
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    assertNull(getShare(shares, "/folder2"));
    assertNotNull(getShare(shares, "/" + DL_NAME));
    assertNotNull(getShare(shares, "/public"));
    // delete dlFolder and pubFolder
    mbox1.delete(null, dlFolder.getId(), MailItem.Type.FOLDER);
    mbox1.delete(null, pubFolder.getId(), MailItem.Type.FOLDER);
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    assertNull(getShare(shares, "/" + DL_NAME));
    assertNull(getShare(shares, "/public"));
}
Also used : Account(com.zimbra.cs.account.Account) ZMailbox(com.zimbra.client.ZMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) GetShareInfoResponse(com.zimbra.soap.account.message.GetShareInfoResponse) GetShareInfoRequest(com.zimbra.soap.account.message.GetShareInfoRequest) Folder(com.zimbra.cs.mailbox.Folder) ShareInfo(com.zimbra.soap.type.ShareInfo) Test(org.junit.Test)

Example 3 with GetShareInfoResponse

use of com.zimbra.soap.account.message.GetShareInfoResponse in project zm-mailbox by Zimbra.

the class GetShareInfo method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    if (!canAccessAccount(zsc, account)) {
        throw ServiceException.PERM_DENIED("can not access account");
    }
    GetShareInfoResponse response = new GetShareInfoResponse();
    doGetShareInfo(zsc, context, account, request, response);
    return zsc.jaxbToElement(response);
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) GetShareInfoResponse(com.zimbra.soap.account.message.GetShareInfoResponse)

Example 4 with GetShareInfoResponse

use of com.zimbra.soap.account.message.GetShareInfoResponse in project zm-mailbox by Zimbra.

the class TestJaxbProvisioning method testPublicSharesVisibility.

@Test
public void testPublicSharesVisibility() throws Exception {
    ZimbraLog.test.debug("Starting test %s", testName());
    ensureDomainExists(domain1);
    ensureDomainExists(domain2);
    Cos cos = prov.createCos(testCos, null);
    Assert.assertNotNull("Cos for " + testCos, cos);
    Account sameDomAcct = TestUtil.createAccount(sharer);
    Account shareeAcct = ensureMailboxExists(sharee);
    Account otherAcct = ensureMailboxExists(other);
    Account diffDomAcct = TestUtil.createAccount(testAcctEmail);
    // anticipate that LC.public_share_advertising_scope config will be done by account/cos/domain in the future.
    shareeAcct.setCOSId(cos.getId());
    TestUtil.setLCValue(LC.public_share_advertising_scope, LC.PUBLIC_SHARE_VISIBILITY.all.toString());
    GetShareInfoResponse gsiResp = accountGetShareInfo(shareeAcct, null, /* owner account */
    false, null);
    // Remember how many baseline public shares there are before we start.
    ShareSet baselinePublicShares = new ShareSet().addAll(gsiResp.getShares());
    CutDownShareInfo mountedUsrSameDom = setupShare(sameDomAcct, "USER_Mounted", (byte) 2, "usr", shareeAcct, shareeAcct, "USR_SAME_DOM");
    CutDownShareInfo notMountedUsrSameDom = setupShare(sameDomAcct, "USER_NOT_Mounted", (byte) 3, "usr", shareeAcct, null, null);
    CutDownShareInfo mountedPubSameDom = setupShare(sameDomAcct, "PUB_Mounted", (byte) 4, "pub", null, shareeAcct, "PUB_SAME_DOM");
    CutDownShareInfo notMountedPubSameDom = setupShare(sameDomAcct, "PUB_NOT_Mounted", (byte) 5, "pub", null, null, null);
    /* never visible to sharee */
    CutDownShareInfo usrUnrelatedSameDom = setupShare(sameDomAcct, "USER_Unrelated", (byte) 2, "usr", otherAcct, null, null);
    CutDownShareInfo mountedUsrDiffDom = setupShare(diffDomAcct, "USER_MountedDiffDom", (byte) 2, "usr", shareeAcct, shareeAcct, "USR_DIFF_DOM");
    CutDownShareInfo notMountedUsrDiffDom = setupShare(diffDomAcct, "USER_NOT_MountedDiffDom", (byte) 3, "usr", shareeAcct, null, null);
    CutDownShareInfo mountedPubDiffDom = setupShare(diffDomAcct, "PUB_MountedDiffDom", (byte) 4, "pub", null, shareeAcct, "PUB_DIFF_DOM");
    CutDownShareInfo notMountedPubDiffDom = setupShare(diffDomAcct, "PUB_NOT_MountedDiffDom", (byte) 5, "pub", null, null, null);
    /* never visible to sharee */
    CutDownShareInfo usrUnrelatedDiffDom = setupShare(diffDomAcct, "USER_UnrelatedDiffDom", (byte) 2, "usr", otherAcct, null, null);
    ShareSet allMounted = new ShareSet(mountedUsrSameDom).add(mountedPubSameDom).add(mountedUsrDiffDom).add(mountedPubDiffDom);
    ShareSet allSharedSameDom = new ShareSet(mountedUsrSameDom).add(mountedPubSameDom).add(notMountedUsrSameDom).add(notMountedPubSameDom);
    ShareSet allSharedDiffDom = new ShareSet(mountedUsrDiffDom).add(mountedPubDiffDom).add(notMountedUsrDiffDom).add(notMountedPubDiffDom);
    ShareSet allShares = new ShareSet(allSharedSameDom.shares).addAll(allSharedDiffDom.shares);
    TestUtil.setLCValue(LC.public_share_advertising_scope, LC.PUBLIC_SHARE_VISIBILITY.samePrimaryDomain.toString());
    prov.flushCache(CacheEntryType.all, null);
    accountGetShareInfo(shareeAcct, null, /* owner account */
    false, new ShareSet(allMounted.shares).add(notMountedUsrSameDom).add(notMountedPubSameDom).add(notMountedUsrDiffDom));
    accountGetShareInfo(shareeAcct, AccountSelector.fromId(sameDomAcct.getId()), false, new ShareSet(mountedUsrSameDom).add(mountedPubSameDom).add(notMountedPubSameDom).add(notMountedUsrSameDom));
    accountGetShareInfo(shareeAcct, AccountSelector.fromId(diffDomAcct.getId()), false, new ShareSet(mountedUsrDiffDom).add(mountedPubDiffDom).add(notMountedUsrDiffDom));
    ShareSet adminSet = new ShareSet(allSharedSameDom.shares).add(usrUnrelatedSameDom);
    adminGetShareInfo(sameDomAcct, adminSet);
    TestUtil.setLCValue(LC.public_share_advertising_scope, LC.PUBLIC_SHARE_VISIBILITY.all.toString());
    prov.flushCache(CacheEntryType.account, null);
    accountGetShareInfo(shareeAcct, null, /* owner account */
    false, new ShareSet(baselinePublicShares.shares).addAll(allShares.shares));
    accountGetShareInfo(shareeAcct, AccountSelector.fromId(sameDomAcct.getId()), false, allSharedSameDom);
    accountGetShareInfo(shareeAcct, AccountSelector.fromId(diffDomAcct.getId()), false, allSharedDiffDom);
    adminGetShareInfo(sameDomAcct, adminSet);
    TestUtil.setLCValue(LC.public_share_advertising_scope, LC.PUBLIC_SHARE_VISIBILITY.none.toString());
    prov.flushCache(CacheEntryType.account, null);
    accountGetShareInfo(shareeAcct, null, /* owner account */
    false, new ShareSet(allMounted.shares).add(notMountedUsrSameDom).add(notMountedUsrDiffDom));
    accountGetShareInfo(shareeAcct, AccountSelector.fromId(sameDomAcct.getId()), false, new ShareSet(mountedUsrSameDom).add(mountedPubSameDom).add(notMountedUsrSameDom));
    accountGetShareInfo(shareeAcct, AccountSelector.fromId(diffDomAcct.getId()), false, new ShareSet(mountedUsrDiffDom).add(mountedPubDiffDom).add(notMountedUsrDiffDom));
    adminGetShareInfo(sameDomAcct, adminSet);
    // Confirm that can't use GetShareInfoRequest with self as owner. If could, may want to alter things
    // so that public shares are always included in results if owner==self...
    accountGetShareInfoExpectFail(shareeAcct, AccountSelector.fromId(shareeAcct.getId()), true, "invalid request: cannot discover shares on self");
}
Also used : Account(com.zimbra.cs.account.Account) Cos(com.zimbra.cs.account.Cos) GetShareInfoResponse(com.zimbra.soap.account.message.GetShareInfoResponse) Test(org.junit.Test)

Aggregations

GetShareInfoResponse (com.zimbra.soap.account.message.GetShareInfoResponse)4 Account (com.zimbra.cs.account.Account)3 Test (org.junit.Test)2 ZMailbox (com.zimbra.client.ZMailbox)1 ServiceException (com.zimbra.common.service.ServiceException)1 Cos (com.zimbra.cs.account.Cos)1 Folder (com.zimbra.cs.mailbox.Folder)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 GetShareInfoRequest (com.zimbra.soap.account.message.GetShareInfoRequest)1 GranteeChooser (com.zimbra.soap.type.GranteeChooser)1 ShareInfo (com.zimbra.soap.type.ShareInfo)1