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());
}
}
}
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));
}
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);
}
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());
}
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);
}
Aggregations