Search in sources :

Example 61 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class ProvUtil method doGetAllAccountLoggers.

private void doGetAllAccountLoggers(AccountLoggerOptions alo) throws ServiceException {
    if (!(prov instanceof SoapProvisioning)) {
        throwSoapOnly();
    }
    SoapProvisioning sp = (SoapProvisioning) prov;
    Map<String, List<AccountLogger>> allLoggers = sp.getAllAccountLoggers(alo.server);
    for (String accountName : allLoggers.keySet()) {
        console.printf("# name %s\n", accountName);
        for (AccountLogger logger : allLoggers.get(accountName)) {
            console.printf("%s=%s\n", logger.getCategory(), logger.getLevel());
        }
    }
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger) ArrayList(java.util.ArrayList) List(java.util.List)

Example 62 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class ProvUtil method sendMailboxLockoutRequest.

private void sendMailboxLockoutRequest(String acctName, String server, String operation) throws ServiceException, IOException {
    LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(acctName));
    req.setOperation(operation);
    String url = URLUtil.getAdminURL(server);
    ZAuthToken token = ((SoapProvisioning) prov).getAuthToken();
    SoapHttpTransport transport = new SoapHttpTransport(url);
    transport.setAuthToken(token);
    transport.invokeWithoutSession(JaxbUtil.jaxbToElement(req));
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport) ZAuthToken(com.zimbra.common.auth.ZAuthToken) LockoutMailboxRequest(com.zimbra.soap.admin.message.LockoutMailboxRequest)

Example 63 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class ScriptUtil method initProvisioning.

/**
     * Initializes the default {@link Provisioning} configuration,
     * based on values that were passed to the methods in this class.
     * By default, connects to <tt>https://localhost:7071/service/admin/soap</tt>
     * with <tt>zimbra_ldap_user</tt> and <tt>zimbra_ldap_password</tt>.
     * 
     * @param options provisioning options, or <tt>null</tt> for default options
     */
public static void initProvisioning(ProvisioningOptions options) throws ServiceException {
    if (options == null) {
        options = new ProvisioningOptions();
    }
    CliUtil.toolSetup();
    SoapProvisioning sp = new SoapProvisioning();
    String userAgent = options.getUserAgent();
    String userAgentVersion = options.getUserAgentVersion();
    if (userAgent == null) {
        userAgent = "Zimbra Scripting";
        userAgentVersion = BuildInfo.VERSION;
    }
    SoapTransport.setDefaultUserAgent(userAgent, userAgentVersion);
    String uri = options.getSoapURI();
    if (uri == null) {
        uri = LC.zimbra_admin_service_scheme.value() + "localhost:7071" + AdminConstants.ADMIN_SERVICE_URI;
    }
    sp.soapSetURI(uri);
    String user = options.getUsername();
    if (user == null) {
        user = LC.zimbra_ldap_user.value();
    }
    String password = options.getPassword();
    if (password == null) {
        password = LC.zimbra_ldap_password.value();
    }
    sp.soapAdminAuthenticate(user, password);
    Provisioning.setInstance(sp);
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Example 64 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class TestLog method testRemoveAll.

/**
     * Tests removing all account loggers for a given account.
     */
public void testRemoveAll() throws Exception {
    SoapProvisioning prov = TestUtil.newSoapProvisioning();
    Account user1 = TestUtil.getAccount("user1");
    Account user2 = TestUtil.getAccount("user2");
    prov.addAccountLogger(user1, "zimbra.soap", "debug", null);
    prov.addAccountLogger(user1, "zimbra.sync", "debug", null);
    prov.addAccountLogger(user2, "zimbra.soap", "debug", null);
    prov.addAccountLogger(user2, "zimbra.sync", "debug", null);
    // Test removing loggers with no category specified.
    List<AccountLogger> loggers = prov.getAccountLoggers(user1, null);
    assertEquals(2, loggers.size());
    prov.removeAccountLoggers(user1, null, null);
    loggers = prov.getAccountLoggers(user1, null);
    assertEquals(0, loggers.size());
    // Test removing loggers with category "all".
    loggers = prov.getAccountLoggers(user2, null);
    assertEquals(2, loggers.size());
    prov.removeAccountLoggers(user2, "all", null);
    loggers = prov.getAccountLoggers(user2, null);
    assertEquals(0, loggers.size());
}
Also used : Account(com.zimbra.cs.account.Account) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger)

Example 65 with SoapProvisioning

use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.

the class TestLog method testAccountLoggers.

public void testAccountLoggers() throws Exception {
    SoapProvisioning prov = TestUtil.newSoapProvisioning();
    Account user1 = TestUtil.getAccount("user1");
    Account user2 = TestUtil.getAccount("user2");
    Account user3 = TestUtil.getAccount("user3");
    Account user4 = TestUtil.getAccount("user4");
    // Add loggers.
    List<AccountLogger> loggers = prov.addAccountLogger(user1, "zimbra.filter", "debug", null);
    assertLoggerExists(loggers, user1, "zimbra.filter", Level.debug);
    loggers = prov.addAccountLogger(user2, "zimbra.backup", "info", null);
    assertLoggerExists(loggers, user2, "zimbra.backup", Level.info);
    loggers = prov.addAccountLogger(user3, "zimbra.sync", "warn", null);
    assertLoggerExists(loggers, user3, "zimbra.sync", Level.warn);
    loggers = prov.addAccountLogger(user3, "zimbra.lmtp", "warn", null);
    assertLoggerExists(loggers, user3, "zimbra.lmtp", Level.warn);
    assertEquals(1, loggers.size());
    loggers = prov.addAccountLogger(user4, "zimbra.lmtp", "error", null);
    assertLoggerExists(loggers, user4, "zimbra.lmtp", Level.error);
    // Verify <GetAccountLoggersRequest>.
    loggers = prov.getAccountLoggers(user1, null);
    assertEquals(1, loggers.size());
    assertLoggerExists(loggers, user1, "zimbra.filter", Level.debug);
    loggers = prov.getAccountLoggers(user2, null);
    assertEquals(1, loggers.size());
    assertLoggerExists(loggers, user2, "zimbra.backup", Level.info);
    loggers = prov.getAccountLoggers(user3, null);
    assertEquals(2, loggers.size());
    assertLoggerExists(loggers, user3, "zimbra.sync", Level.warn);
    assertLoggerExists(loggers, user3, "zimbra.lmtp", Level.warn);
    loggers = prov.getAccountLoggers(user4, null);
    assertEquals(1, loggers.size());
    assertLoggerExists(loggers, user4, "zimbra.lmtp", Level.error);
    // Remove loggers for everyone except user3.
    prov.removeAccountLoggers(user1, "zimbra.filter", null);
    prov.removeAccountLoggers(user2, null, null);
    prov.removeAccountLoggers(user4, null, null);
    // Test <GetAllAccountLoggersRequest>.
    Map<String, List<AccountLogger>> map = prov.getAllAccountLoggers(null);
    assertEquals(1, map.size());
    loggers = map.get(user3.getName());
    assertEquals(2, loggers.size());
    assertLoggerExists(loggers, user3, "zimbra.sync", Level.warn);
    assertLoggerExists(loggers, user3, "zimbra.lmtp", Level.warn);
}
Also used : Account(com.zimbra.cs.account.Account) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger) List(java.util.List)

Aggregations

SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)78 Test (org.junit.Test)18 SoapFaultException (com.zimbra.common.soap.SoapFaultException)14 Account (com.zimbra.cs.account.Account)13 Attr (com.zimbra.soap.admin.type.Attr)10 ServiceException (com.zimbra.common.service.ServiceException)9 CreateDistributionListRequest (com.zimbra.soap.admin.message.CreateDistributionListRequest)6 CreateDistributionListResponse (com.zimbra.soap.admin.message.CreateDistributionListResponse)6 AccountLogger (com.zimbra.common.util.AccountLogger)5 Server (com.zimbra.cs.account.Server)5 CreateCalendarResourceRequest (com.zimbra.soap.admin.message.CreateCalendarResourceRequest)4 CreateCalendarResourceResponse (com.zimbra.soap.admin.message.CreateCalendarResourceResponse)4 DeleteCalendarResourceRequest (com.zimbra.soap.admin.message.DeleteCalendarResourceRequest)4 List (java.util.List)4 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 Provisioning (com.zimbra.cs.account.Provisioning)3 CacheEntry (com.zimbra.cs.account.Provisioning.CacheEntry)3 DeleteAccountRequest (com.zimbra.soap.admin.message.DeleteAccountRequest)3 DeleteAccountResponse (com.zimbra.soap.admin.message.DeleteAccountResponse)3