use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class ModifyConfig method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Map<String, Object> attrs = AdminService.getAttrs(request);
Config config = prov.getConfig();
checkRight(zsc, context, config, attrs);
// pass in true to checkImmutable
prov.modifyAttrs(config, attrs, true);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyConfig" }, attrs));
Element response = zsc.createElement(AdminConstants.MODIFY_CONFIG_RESPONSE);
return response;
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class GetAllConfig method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Config config = prov.getConfig();
AdminAccessControl aac = checkRight(zsc, context, config, AdminRight.PR_ALWAYS_ALLOW);
Element response = zsc.createElement(AdminConstants.GET_ALL_CONFIG_RESPONSE);
encodeConfig(response, config, null, aac.getAttrRightChecker(config));
return response;
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class SpamExtract method getAccount.
private static Account getAccount(CommandLine cl) throws ServiceException {
Provisioning prov = Provisioning.getInstance();
Config conf;
try {
conf = prov.getConfig();
} catch (ServiceException e) {
throw ServiceException.FAILURE("Unable to connect to LDAP directory", e);
}
String name = null;
if (cl.hasOption('s')) {
if (cl.hasOption('n') || cl.hasOption('m')) {
LOG.error("only one of s, n or m options can be specified");
return null;
}
name = conf.getAttr(Provisioning.A_zimbraSpamIsSpamAccount);
if (name == null || name.length() == 0) {
LOG.error("no account configured for spam");
return null;
}
} else if (cl.hasOption('n')) {
if (cl.hasOption('m')) {
LOG.error("only one of s, n, or m options can be specified");
return null;
}
name = conf.getAttr(Provisioning.A_zimbraSpamIsNotSpamAccount);
if (name == null || name.length() == 0) {
LOG.error("no account configured for ham");
return null;
}
} else if (cl.hasOption('m')) {
name = cl.getOptionValue('m');
if (name.length() == 0) {
LOG.error("illegal argument to m option");
return null;
}
} else {
LOG.error("one of s, n or m options must be specified");
return null;
}
Account account = prov.get(AccountBy.name, name);
if (account == null) {
LOG.error("can not find account " + name);
return null;
}
return account;
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class TestACLAll method test.
/*
* test basic target-grantee-right combos
*/
@Test
public void test() throws Exception {
Config config = Provisioning.getInstance().getConfig();
config.setUCProviderEnabled(ProvTestUtil.DEFAULT_UC_PROVIDER);
// testAll();
// testTarget();
testGrantee();
// testOne();
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class SpamHandler method handle.
public void handle(OperationContext octxt, Mailbox mbox, int itemId, MailItem.Type type, SpamReport report) throws ServiceException {
Config config = Provisioning.getInstance().getConfig();
String address;
if (report.isSpam) {
address = config.getSpamIsSpamAccount();
if (Strings.isNullOrEmpty(address)) {
log.debug("Spam address is not set. Nothing to do.");
return;
}
} else {
address = config.getSpamIsNotSpamAccount();
if (Strings.isNullOrEmpty(address)) {
log.debug("Ham address is not set. Nothing to do.");
return;
}
}
try {
report.reportRecipient = new JavaMailInternetAddress(address, true);
} catch (MessagingException e) {
throw ServiceException.INVALID_REQUEST("Invalid address: " + address, e);
}
report.accountName = mbox.getAccount().getName();
report.mailboxId = mbox.getId();
if (octxt != null) {
report.origIp = octxt.getRequestIP();
}
List<SpamReport> reports = Lists.newArrayList();
switch(type) {
case MESSAGE:
report.messageId = itemId;
reports.add(report);
break;
case CONVERSATION:
for (Message msg : mbox.getMessagesByConversation(null, itemId)) {
SpamReport msgReport = new SpamReport(report);
msgReport.messageId = msg.getId();
reports.add(report);
}
break;
default:
ZimbraLog.misc.warn("SpamHandler called on unhandled item type=" + type + " account=" + report.accountName + " id=" + itemId);
return;
}
enqueue(reports);
}
Aggregations