use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class TestServiceServlet method before.
@BeforeClass
public static void before() throws Exception {
cleanup();
TestUtil.createAccount(USER_NAME);
baseURL = TestUtil.getBaseUrl() + "/fromservice/";
prov = Provisioning.getInstance();
localServer = prov.getLocalServer();
Map<String, Object> attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraIsDelegatedAdminAccount, "TRUE");
attrs.put(Provisioning.A_zimbraAdminConsoleUIComponents, "accountListView");
attrs.put(Provisioning.A_zimbraAdminConsoleUIComponents, "downloadsView");
attrs.put(Provisioning.A_zimbraAdminConsoleUIComponents, "DLListView");
delegatedAdminWithoutRights = TestUtil.createAccount(TestUtil.addDomainIfNecessary(DELEGATED_ADMIN_WITHOUT_RIGHTS), attrs);
attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraIsDelegatedAdminAccount, "TRUE");
attrs.put(Provisioning.A_zimbraAdminConsoleUIComponents, "accountListView");
attrs.put(Provisioning.A_zimbraAdminConsoleUIComponents, "downloadsView");
attrs.put(Provisioning.A_zimbraAdminConsoleUIComponents, "DLListView");
delegatedAdminWithRights = TestUtil.createAccount(TestUtil.addDomainIfNecessary(DELEGATED_ADMIN_WITH_RIGHTS), attrs);
SoapProvisioning adminSoapProv = TestUtil.newSoapProvisioning();
TestUtil.grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.server.toString()), localServer.getName(), delegatedAdminWithRights.getName(), Admin.R_deployZimlet.getName());
TestUtil.grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.server.toString()), localServer.getName(), delegatedAdminWithRights.getName(), Admin.R_flushCache.getName());
GetMethod method = new GetMethod(String.format("%sflushacl", baseURL));
addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
HttpClient client = new HttpClient();
int code = HttpClientUtil.executeMethod(client, method);
if (HttpStatus.SC_OK != code) {
Assert.fail(String.format("Failed to flush all cache in /zimbra web app. Response code: %d", code));
}
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class TestSoapProvisioning method isExpired.
@Test
public void isExpired() throws Exception {
// 5 seconds
long lifeTimeSecs = 5;
String acctName = TestUtil.getAddress("isExpired", domain.getName());
String password = "test123";
Map<String, Object> attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraIsAdminAccount, ProvisioningConstants.TRUE);
attrs.put(Provisioning.A_zimbraAdminAuthTokenLifetime, String.valueOf(lifeTimeSecs) + "s");
Account acct = provUtil.createAccount(acctName, password, attrs);
SoapProvisioning soapProv = new SoapProvisioning();
Server server = prov.getLocalServer();
soapProv.soapSetURI(URLUtil.getAdminURL(server));
assertTrue(soapProv.isExpired());
soapProv.soapAdminAuthenticate(acctName, password);
assertFalse(soapProv.isExpired());
System.out.println("Waiting for " + lifeTimeSecs + " seconds");
Thread.sleep((lifeTimeSecs + 1) * 1000);
assertTrue(soapProv.isExpired());
prov.deleteAccount(acct.getId());
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class LocalConfigCLI method reload.
private void reload() throws ServiceException {
String host = LC.zimbra_zmprov_default_soap_server.value();
int port = LC.zimbra_admin_service_port.intValue();
SoapHttpTransport transport = new SoapHttpTransport("https://" + host + ":" + port + AdminConstants.ADMIN_SERVICE_URI);
SoapProvisioning prov = new SoapProvisioning();
prov.soapSetURI(transport.getURI());
prov.soapZimbraAdminAuthenticate();
transport.setAuthToken(prov.getAuthToken());
try {
transport.invoke(JaxbUtil.jaxbToElement(new ReloadLocalConfigRequest()));
} catch (IOException e) {
throw ZClientException.IO_ERROR(e.getMessage(), e);
}
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class ModifyAccount method checkNewServer.
/*
* if the account's home server is changed as a result of this command and the new server is no longer this server,
* need to send a flush cache command to the new server so we don't get into the following:
*
* account is on server A (this server)
*
* on server B: zmprov ma {account} zimbraMailHost B (the ma is proxied to server A; and on server B, the account
* still appears to be on A)
*
* zmprov ma {account} {any attr} {value} ERROR: service.TOO_MANY_HOPS Until the account is expired from cache on
* server B.
*/
private void checkNewServer(ZimbraSoapContext zsc, Map<String, Object> context, Account acct, Server newServer) {
try {
if (!Provisioning.onLocalServer(acct)) {
// in the case when zimbraMailHost is being removed, newServer will be null
if (newServer != null) {
SoapProvisioning soapProv = new SoapProvisioning();
String adminUrl = URLUtil.getAdminURL(newServer, AdminConstants.ADMIN_SERVICE_URI, true);
soapProv.soapSetURI(adminUrl);
soapProv.soapZimbraAdminAuthenticate();
soapProv.flushCache(CacheEntryType.account, new CacheEntry[] { new CacheEntry(CacheEntryBy.id, acct.getId()) });
}
}
} catch (ServiceException e) {
// ignore any error and continue
ZimbraLog.mailbox.warn("cannot flush account cache on server " + (newServer == null ? "" : newServer.getName()) + " for " + acct.getName(), e);
}
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class TestJaxbProvisioning method ensureMailboxExists.
public static Account ensureMailboxExists(String name) throws ServiceException {
SoapProvisioning prov = TestUtil.newSoapProvisioning();
Account acct = ensureAccountExists(name);
if (acct == null) {
ZimbraLog.test.debug("ensureMailboxExists returning null!!!");
} else {
// The act of getting a mailbox is sufficient to create it if the associated account exists.
// Note that prov.getAccount() USED TO implicitly created a mailbox even though it was not really
// supposed to and this routine used to rely on that.
MailboxInfo mboxInfo = prov.getMailbox(acct);
ZimbraLog.test.debug("ensureMailboxExists Returning Mailbox=%s Account=%s Id=%s", mboxInfo.getMailboxId(), acct.getName(), acct.getId());
}
return acct;
}
Aggregations