Search in sources :

Example 31 with Config

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;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Config(com.zimbra.cs.account.Config) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 32 with Config

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;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Config(com.zimbra.cs.account.Config) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 33 with Config

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;
}
Also used : Account(com.zimbra.cs.account.Account) ServiceException(com.zimbra.common.service.ServiceException) Config(com.zimbra.cs.account.Config) Provisioning(com.zimbra.cs.account.Provisioning)

Example 34 with Config

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();
}
Also used : Config(com.zimbra.cs.account.Config) Test(org.junit.Test)

Example 35 with Config

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);
}
Also used : Message(com.zimbra.cs.mailbox.Message) SMTPMessage(com.sun.mail.smtp.SMTPMessage) MimeMessage(javax.mail.internet.MimeMessage) MessagingException(javax.mail.MessagingException) Config(com.zimbra.cs.account.Config) JavaMailInternetAddress(com.zimbra.common.mime.shim.JavaMailInternetAddress)

Aggregations

Config (com.zimbra.cs.account.Config)73 HashMap (java.util.HashMap)24 Provisioning (com.zimbra.cs.account.Provisioning)10 Test (org.junit.Test)8 ServiceException (com.zimbra.common.service.ServiceException)7 Account (com.zimbra.cs.account.Account)7 RetentionPolicy (com.zimbra.soap.mail.type.RetentionPolicy)7 Element (com.zimbra.common.soap.Element)6 Policy (com.zimbra.soap.mail.type.Policy)6 Cos (com.zimbra.cs.account.Cos)5 Server (com.zimbra.cs.account.Server)5 Domain (com.zimbra.cs.account.Domain)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 Pair (com.zimbra.common.util.Pair)3 HashSet (java.util.HashSet)3 SMTPMessage (com.sun.mail.smtp.SMTPMessage)2 ZFilterAction (com.zimbra.client.ZFilterAction)2 ZFileIntoAction (com.zimbra.client.ZFilterAction.ZFileIntoAction)2 ZFilterCondition (com.zimbra.client.ZFilterCondition)2 ZHeaderCondition (com.zimbra.client.ZFilterCondition.ZHeaderCondition)2