use of com.zimbra.cs.account.Provisioning in project zm-mailbox by Zimbra.
the class ZimbraLmtpBackend method getAddressStatus.
@Override
public LmtpReply getAddressStatus(LmtpAddress address) {
String addr = address.getEmailAddress();
try {
Provisioning prov = Provisioning.getInstance();
Account acct = prov.get(AccountBy.name, addr);
if (acct == null) {
ZimbraLog.lmtp.info("rejecting address " + addr + ": no account");
return LmtpReply.NO_SUCH_USER;
}
String acctStatus = acct.getAccountStatus(prov);
if (acctStatus == null) {
ZimbraLog.lmtp.warn("rejecting address " + addr + ": no account status");
return LmtpReply.NO_SUCH_USER;
}
if (acctStatus.equals(Provisioning.ACCOUNT_STATUS_MAINTENANCE)) {
ZimbraLog.lmtp.info("try again for address " + addr + ": account status maintenance");
return LmtpReply.MAILBOX_DISABLED;
}
if (Provisioning.onLocalServer(acct)) {
address.setOnLocalServer(true);
} else if (Provisioning.getInstance().getServer(acct) != null) {
address.setOnLocalServer(false);
address.setRemoteServer(acct.getMailHost());
} else {
ZimbraLog.lmtp.warn("try again for address " + addr + ": mailbox is not on this server");
return LmtpReply.MAILBOX_NOT_ON_THIS_SERVER;
}
if (acctStatus.equals(Provisioning.ACCOUNT_STATUS_PENDING)) {
ZimbraLog.lmtp.info("rejecting address " + addr + ": account status pending");
return LmtpReply.NO_SUCH_USER;
}
if (acctStatus.equals(Provisioning.ACCOUNT_STATUS_CLOSED)) {
ZimbraLog.lmtp.info("rejecting address " + addr + ": account status closed");
return LmtpReply.NO_SUCH_USER;
}
if (acctStatus.equals(Provisioning.ACCOUNT_STATUS_ACTIVE) || acctStatus.equals(Provisioning.ACCOUNT_STATUS_LOCKOUT) || acctStatus.equals(Provisioning.ACCOUNT_STATUS_LOCKED)) {
return LmtpReply.RECIPIENT_OK;
}
ZimbraLog.lmtp.info("rejecting address " + addr + ": unknown account status " + acctStatus);
return LmtpReply.NO_SUCH_USER;
} catch (ServiceException e) {
if (e.isReceiversFault()) {
ZimbraLog.lmtp.warn("try again for address " + addr + ": exception occurred", e);
return LmtpReply.MAILBOX_DISABLED;
} else {
ZimbraLog.lmtp.warn("rejecting address " + addr + ": exception occurred", e);
return LmtpReply.NO_SUCH_USER;
}
}
}
use of com.zimbra.cs.account.Provisioning in project zm-mailbox by Zimbra.
the class MilterServer method main.
public static void main(String[] args) {
try {
Provisioning prov = Provisioning.getInstance();
if (prov instanceof LdapProv) {
((LdapProv) prov).waitForLdapServer();
}
MilterConfig config = new MilterConfig();
MilterServer server = new MilterServer(config);
// register the signal handler
ClearCacheSignalHandler.register();
MilterShutdownHook shutdownHook = new MilterShutdownHook(server);
Runtime.getRuntime().addShutdownHook(shutdownHook);
ZimbraLog.milter.info("Starting milter server");
server.start();
} catch (ServiceException e) {
ZimbraLog.milter.error("Unable to start milter server", e);
}
}
use of com.zimbra.cs.account.Provisioning in project zm-mailbox by Zimbra.
the class MimeHandlerManager method getIndexedTextLimit.
/**
* Returns the maximum number of characters that can be returned by
* {@link MimeHandler#getContent}.
* @see Provisioning#A_zimbraAttachmentsIndexedTextLimit
*/
public static int getIndexedTextLimit() {
int length = 1024 * 1024;
try {
Provisioning prov = Provisioning.getInstance();
Server server = prov.getLocalServer();
length = server.getIntAttr(Provisioning.A_zimbraAttachmentsIndexedTextLimit, length);
} catch (ServiceException e) {
sLog.warn("Unable to determine maximum indexed content length", e);
}
return length;
}
use of com.zimbra.cs.account.Provisioning in project zm-mailbox by Zimbra.
the class DumpSessions 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_getSessions);
Element response = zsc.createElement(AdminConstants.DUMP_SESSIONS_RESPONSE);
boolean includeAccounts = request.getAttributeBool(AdminConstants.A_LIST_SESSIONS, false);
boolean groupByAccount = request.getAttributeBool(AdminConstants.A_GROUP_BY_ACCOUNT, false);
int totalActiveSessions = 0;
Provisioning prov = Provisioning.getInstance();
for (Session.Type type : Session.Type.values()) {
if (type == Session.Type.NULL)
continue;
if (!includeAccounts) {
int[] stats = SessionCache.countActive(type);
if (stats[1] == 0)
// no active sessions, skip this type!
continue;
Element e = response.addElement(type.name().toLowerCase());
totalActiveSessions += stats[1];
e.addAttribute(AdminConstants.A_ACTIVE_ACCOUNTS, stats[0]);
e.addAttribute(AdminConstants.A_ACTIVE_SESSIONS, stats[1]);
} else {
List<Session> sessions = SessionCache.getActiveSessions(type);
if (sessions.size() == 0)
// no active sessions, skip this type!
continue;
Element e = response.addElement(type.name().toLowerCase());
totalActiveSessions += sessions.size();
e.addAttribute(AdminConstants.A_ACTIVE_SESSIONS, sessions.size());
if (sessions.size() == 0)
continue;
if (groupByAccount) {
// stick the sessions into a big map organized by the account ID
HashMap<String, List<Session>> /*accountid*/
map = new HashMap<String, List<Session>>();
for (Session s : sessions) {
List<Session> list = map.get(s.getAuthenticatedAccountId());
if (list == null) {
list = new ArrayList<Session>();
map.put(s.getAuthenticatedAccountId(), list);
}
list.add(s);
}
e.addAttribute(AdminConstants.A_ACTIVE_ACCOUNTS, map.size());
for (Map.Entry<String, List<Session>> entry : map.entrySet()) {
Element acctElt = e.addElement(AdminConstants.A_ZIMBRA_ID);
acctElt.addAttribute(AdminConstants.A_NAME, getName(prov, entry.getKey()));
acctElt.addAttribute(AdminConstants.A_ID, entry.getKey());
for (Session s : entry.getValue()) {
encodeSession(acctElt, s, false, prov);
}
}
} else {
int[] stats = SessionCache.countActive(type);
e.addAttribute(AdminConstants.A_ACTIVE_ACCOUNTS, stats[0]);
for (Session s : sessions) {
encodeSession(e, s, true, prov);
}
}
}
}
response.addAttribute(AdminConstants.A_ACTIVE_SESSIONS, totalActiveSessions);
return response;
}
use of com.zimbra.cs.account.Provisioning in project zm-mailbox by Zimbra.
the class FixCalendarEndTime method getAccountsOnServer.
private static List<NamedEntry> getAccountsOnServer() throws ServiceException {
Provisioning prov = Provisioning.getInstance();
Server server = prov.getLocalServer();
String serverName = server.getAttr(Provisioning.A_zimbraServiceHostname);
SearchAccountsOptions searchOpts = new SearchAccountsOptions(new String[] { Provisioning.A_zimbraId });
searchOpts.setSortOpt(SortOpt.SORT_DESCENDING);
List<NamedEntry> accts = prov.searchAccountsOnServer(server, searchOpts);
ZimbraLog.calendar.info("Found " + accts.size() + " accounts on server " + serverName);
return accts;
}
Aggregations