use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAdminConsoleUIComp method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
GetAdminConsoleUICompRequest req = zsc.elementToJaxb(request);
AccountSelector accountSel = req.getAccount();
DistributionListSelector dlSel = req.getDl();
Element resp = zsc.createElement(AdminConstants.GET_ADMIN_CONSOLE_UI_COMP_RESPONSE);
if ((null != accountSel) && (null != dlSel)) {
throw ServiceException.INVALID_REQUEST("can only specify eith account or dl", null);
}
Account authedAcct = getAuthenticatedAccount(zsc);
Set<String> added = new HashSet<String>();
GroupMembership aclGroups = null;
if (accountSel != null) {
AccountBy by = accountSel.getBy().toKeyAccountBy();
String key = accountSel.getKey();
Account acct = prov.get(by, key);
AccountHarvestingCheckerUsingCheckRight checker = new AccountHarvestingCheckerUsingCheckRight(zsc, context, Admin.R_viewAccountAdminUI);
if (acct == null) {
defendAgainstAccountHarvestingWhenAbsent(by, key, zsc, checker);
} else {
if (!authedAcct.getId().equals(acct.getId())) {
defendAgainstAccountHarvesting(acct, by, key, zsc, checker);
}
addValues(acct, resp, added, false);
aclGroups = prov.getGroupMembership(acct, true);
}
} else if (dlSel != null) {
Key.DistributionListBy by = dlSel.getBy().toKeyDistributionListBy();
String key = dlSel.getKey();
DistributionList dl = prov.getDLBasic(by, key);
GroupHarvestingCheckerUsingCheckRight checker = new GroupHarvestingCheckerUsingCheckRight(zsc, context, Admin.R_viewDistributionListAdminUI);
if (dl == null) {
defendAgainstGroupHarvestingWhenAbsent(by, key, zsc, checker);
} else {
defendAgainstGroupHarvesting(dl, by, key, zsc, checker);
addValues(dl, resp, added, false);
aclGroups = prov.getGroupMembership(dl, true);
}
} else {
// use the authed account
addValues(authedAcct, resp, added, false);
aclGroups = prov.getGroupMembership(authedAcct, true);
}
if (aclGroups != null) {
for (String groupId : aclGroups.groupIds()) {
DistributionList dl = prov.get(Key.DistributionListBy.id, groupId);
addValues(dl, resp, added, true);
}
}
return resp;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAdminSavedSearches method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account acct = getRequestedAccount(zsc);
checkAccountRight(zsc, acct, Admin.R_viewAdminSavedSearch);
Element response = zsc.createElement(AdminConstants.GET_ADMIN_SAVED_SEARCHES_RESPONSE);
HashSet<String> specificSearches = null;
for (Iterator it = request.elementIterator(AdminConstants.E_SEARCH); it.hasNext(); ) {
if (specificSearches == null)
specificSearches = new HashSet<String>();
Element e = (Element) it.next();
String name = e.getAttribute(AdminConstants.A_NAME);
if (name != null)
specificSearches.add(name);
}
handle(acct, response, specificSearches);
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAllAccountLoggers method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Server localServer = Provisioning.getInstance().getLocalServer();
checkRight(zsc, context, localServer, Admin.R_manageAccountLogger);
Provisioning prov = Provisioning.getInstance();
Map<String, Element> accountElements = new HashMap<String, Element>();
Element response = zsc.createElement(AdminConstants.GET_ALL_ACCOUNT_LOGGERS_RESPONSE);
for (AccountLogger al : LogFactory.getAllAccountLoggers()) {
// Look up account
Account account = prov.get(AccountBy.name, al.getAccountName(), zsc.getAuthToken());
if (account == null) {
ZimbraLog.misc.info("GetAllAccountLoggers: unable to find account '%s'. Ignoring account logger.", al.getAccountName());
continue;
}
// Add elements
Element eAccountLogger = accountElements.get(account.getId());
if (eAccountLogger == null) {
eAccountLogger = response.addElement(AdminConstants.E_ACCOUNT_LOGGER);
accountElements.put(account.getId(), eAccountLogger);
}
eAccountLogger.addAttribute(AdminConstants.A_ID, account.getId());
eAccountLogger.addAttribute(AdminConstants.A_NAME, account.getName());
Element eLogger = eAccountLogger.addElement(AdminConstants.E_LOGGER);
eLogger.addAttribute(AdminConstants.A_CATEGORY, al.getCategory());
eLogger.addAttribute(AdminConstants.A_LEVEL, al.getLevel().toString());
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAllActiveServers method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
Element response = zsc.createElement(AdminConstants.GET_ALL_ACTIVE_SERVERS_RESPONSE);
CuratorManager curator = CuratorManager.getInstance();
if (curator == null) {
return response;
}
Set<String> serverIds;
try {
serverIds = curator.getActiveServers();
} catch (Exception e) {
throw ServiceException.FAILURE("error while getting active servers", e);
}
Provisioning prov = Provisioning.getInstance();
List<Server> servers = new ArrayList<Server>();
for (String serverId : serverIds) {
Server server = prov.getServerById(serverId);
servers.add(server);
}
AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(zsc);
for (Iterator<Server> it = servers.iterator(); it.hasNext(); ) {
Server server = it.next();
if (aac.hasRightsToList(server, Admin.R_listServer, null))
GetServer.encodeServer(response, server, true, null, aac.getAttrRightChecker(server));
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAllAlwaysOnClusters method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
List<AlwaysOnCluster> clusters = prov.getAllAlwaysOnClusters();
AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(zsc);
Element response = zsc.createElement(AdminConstants.GET_ALL_ALWAYSONCLUSTERS_RESPONSE);
for (Iterator<AlwaysOnCluster> it = clusters.iterator(); it.hasNext(); ) {
AlwaysOnCluster cluster = it.next();
if (aac.hasRightsToList(cluster, Admin.R_listAlwaysOnCluster, null))
GetAlwaysOnCluster.encodeAlwaysOnCluster(response, cluster, null, aac.getAttrRightChecker(cluster));
}
return response;
}
Aggregations