use of com.zimbra.cs.security.sasl.ZimbraAuthenticator in project zm-mailbox by Zimbra.
the class ImapHandler method doFLUSHCACHE.
private boolean doFLUSHCACHE(String tag, List<CacheEntryType> types, List<CacheEntrySelector> entries) throws IOException {
if (!checkState(tag, State.AUTHENTICATED)) {
return true;
} else if (!checkZimbraAdminAuth()) {
sendNO(tag, "must be authenticated as admin with X-ZIMBRA auth mechanism");
return true;
}
if (types.isEmpty()) {
// nothing to do here
sendOK(tag, "FLUSHCACHE completed");
return true;
}
AuthToken authToken = ((ZimbraAuthenticator) authenticator).getAuthToken();
try {
AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(authToken);
Server localServer = Provisioning.getInstance().getLocalServer();
aac.checkRight(localServer, Admin.R_flushCache);
} catch (ServiceException e) {
if (e.getCode().equalsIgnoreCase(ServiceException.PERM_DENIED)) {
ZimbraLog.imap.error("insufficient rights for flushing cache on IMAP server", e);
} else {
ZimbraLog.imap.error("error while checking rights for flushing cache on IMAP server", e);
}
return canContinue(e);
}
CacheSelector cacheSelector = new CacheSelector();
cacheSelector.setEntries(entries);
for (CacheEntryType type : types) {
try {
FlushCache.doFlush(null, type, cacheSelector);
} catch (ServiceException e) {
ZimbraLog.imap.error("error flushing cache on IMAP server", e);
return canContinue(e);
}
}
sendOK(tag, "FLUSHCACHE completed");
return true;
}
Aggregations