use of com.zimbra.soap.type.GranteeChooser 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;
}
use of com.zimbra.soap.type.GranteeChooser in project zm-mailbox by Zimbra.
the class TestJaxbProvisioning method accountGetShareInfoExpectFail.
public void accountGetShareInfoExpectFail(Account acct, AccountSelector owner, Boolean includeSelf, String reason) {
GranteeChooser grantee = null;
try {
prov.invokeJaxbOnTargetAccount(GetShareInfoRequest.create(owner, grantee, includeSelf), acct.getId());
Assert.fail("Unexpected success for GetShareInfoRequest");
} catch (ServiceException e) {
Assert.assertTrue(String.format("Unexpected exception %s (expected msg '%s')", e.getMessage(), reason), e.getMessage().contains(reason));
}
}
use of com.zimbra.soap.type.GranteeChooser in project zm-mailbox by Zimbra.
the class GetShareInfo method doGetShareInfo.
/**
* @param zsc
* @param targetAcct
* @param request
* @param response
*/
private void doGetShareInfo(ZimbraSoapContext zsc, Map<String, Object> context, Account targetAcct, Element request, GetShareInfoResponse response) throws ServiceException {
Provisioning prov = Provisioning.getInstance();
GetShareInfoRequest req = JaxbUtil.elementToJaxb(request);
GranteeChooser granteeChooser = req.getGrantee();
byte granteeType = getGranteeType(granteeChooser);
String granteeId = granteeChooser == null ? null : granteeChooser.getId();
String granteeName = granteeChooser == null ? null : granteeChooser.getName();
Account owner = null;
AccountSelector ownerSelector = req.getOwner();
if (ownerSelector != null) {
owner = prov.get(ownerSelector);
// when an invalid user name/id is used.
if ((owner == null) || (owner.isAccountExternal())) {
return;
} else {
AccountStatus status = owner.getAccountStatus();
if (status != null && status.isClosed()) {
return;
}
}
}
OperationContext octxt = getOperationContext(zsc, context);
ShareInfo.MountedFolders mountedFolders = null;
if (!Boolean.TRUE.equals(req.getInternal())) {
// this (new ShareInfo.MountedFolders) should be executed on the requested
// account's home server.
// If we get here, we should be proxied to the right server naturally by the framework.
mountedFolders = new ShareInfo.MountedFolders(octxt, targetAcct);
}
ResultFilter resultFilter;
if (Boolean.FALSE.equals(req.getIncludeSelf())) {
resultFilter = new ResultFilterByTargetExcludeSelf(granteeId, granteeName, targetAcct);
} else {
resultFilter = new ResultFilterByTarget(granteeId, granteeName);
}
String filterDomain = null;
if (LC.PUBLIC_SHARE_VISIBILITY.samePrimaryDomain.equals(LC.getPublicShareAdvertisingScope())) {
filterDomain = targetAcct.getDomainName();
}
ResultFilter resultFilter2 = new ResultFilterForPublicShares(filterDomain);
ShareInfoVisitor visitor = new ShareInfoVisitor(prov, response, mountedFolders, resultFilter, resultFilter2);
if (owner == null) {
// retrieve from published share info
ShareInfo.Published.get(prov, targetAcct, granteeType, owner, visitor);
} else {
if (targetAcct.getId().equals(owner.getId()))
throw ServiceException.INVALID_REQUEST("cannot discover shares on self", null);
if (Provisioning.onLocalServer(owner))
ShareInfo.Discover.discover(octxt, prov, targetAcct, granteeType, owner, visitor);
else {
// issue an GetShareInfoRequest to the home server of the owner, and tell it *not*
// to proxy to the requesting account's mailbox server.
fetchRemoteShareInfo(context, request, owner.getId(), visitor);
}
}
visitor.finish();
}
use of com.zimbra.soap.type.GranteeChooser 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);
OperationContext octxt = getOperationContext(zsc, context);
Provisioning prov = Provisioning.getInstance();
GetShareInfoRequest req = JaxbUtil.elementToJaxb(request);
GranteeChooser granteeChooser = req.getGrantee();
byte granteeType = com.zimbra.cs.service.account.GetShareInfo.getGranteeType(granteeChooser == null ? null : granteeChooser.getType());
String granteeId = null;
String granteeName = null;
if (granteeChooser != null) {
granteeId = granteeChooser.getId();
granteeName = granteeChooser.getName();
}
Account ownerAcct = null;
AccountBy acctBy = req.getOwner().getBy().toKeyAccountBy();
String accountSelectorKey = req.getOwner().getKey();
ownerAcct = prov.get(acctBy, accountSelectorKey);
// in the account namespace GetShareInfo
// to defend against harvest attacks return "no shares" instead of error when an invalid user name/id is used.
// this is the admin namespace GetShareInfo, we want to let the admin know if the owner name is bad
// unless the admin is a domain admin for a different domain...
defendAgainstAccountOrCalendarResourceHarvesting(ownerAcct, acctBy, accountSelectorKey, zsc, Admin.R_adminLoginAs, Admin.R_adminLoginCalendarResourceAs);
GetShareInfoResponse response = new GetShareInfoResponse();
ResultFilter resultFilter = new ResultFilterByTarget(granteeId, granteeName);
ShareInfoVisitor visitor = new ShareInfoVisitor(prov, response, null, resultFilter);
ShareInfo.Discover.discover(octxt, prov, null, granteeType, ownerAcct, visitor);
visitor.finish();
return zsc.jaxbToElement(response);
}
Aggregations