/** * Reverts all configuration done for PicketBox * @throws Exception */ private void cleanUpPicketBox() throws Exception { try { ops.removeIfExists(PICKETBOX_SECURITY_DOMAIN_ADDRESS); administration.reloadIfRequired(); } finally { managementClient.close(); } } }
@Override public void setup(ManagementClient fakemanagementClient, String s) throws Exception { // Set path for users.properties and roles.properties setConfigurationPath(); // Create and initialize management client managementClient = TestUtil.clientInit(); administration = new Administration(managementClient); ops = new Operations(managementClient); if (subsystem.equals("elytron")) { configureElytron(); } else { configurePicketBox(); } }
/** * Reloads given {@code host} if required. Reloading the host includes restarting all its servers. * This is a variant of {@link Administration#reloadIfRequired()}. */ public boolean reloadIfRequired(String host) throws IOException, InterruptedException, TimeoutException { if (domainOps.isRestartOperationRequired(host, CommonRestartOperation.RELOAD)) { reload(host); return true; } return false; }
/** * Performs the reload from original configuration. */ // in managed domain, this would apply to the default host public void perform() throws InterruptedException, TimeoutException, IOException { checkReloadToOriginalMakesSense(client, null); new StandaloneAdministrationOperations(client, timeoutInSeconds) .performRestartOperation(new ReloadToOriginalRestartOperation()); }
/** * Reload the server to a snapshot. In managed domain, reloads the default host to a domain.xml snapshot. */ public void perform() throws InterruptedException, TimeoutException, IOException { if (client.options().isStandalone) { new StandaloneAdministrationOperations(client, timeoutInSeconds) .performRestartOperation(new ReloadToStandaloneSnapshotRestartOperation(snapshot)); } else { perform(client.options().defaultHost); } }
void performRestartOperation(String host, RestartOperation restartOperation) throws IOException, TimeoutException, InterruptedException { List<String> allServers = allRunningServers(host); boolean needsToReconnect = false; try { restartOperation.perform(ops, Address.host(host)); } catch (Throwable e) { // server went down before we received the response, this can happen needsToReconnect = true; } waitUntilServersAreRunning(host, allServers, needsToReconnect); }
/** * Returns whether reload is required. In domain, returns {@code true} if at least one of the servers * requires reload. */ public final boolean isReloadRequired() { try { return ops.isReloadRequired(); } catch (IOException e) { throw sneakyThrow(e); } }
/** Restarts given {@code host} if required. This is a variant of {@link Administration#restartIfRequired()}. */ public boolean restartIfRequired(String host) throws IOException, InterruptedException, TimeoutException { if (domainOps.isRestartOperationRequired(host, CommonRestartOperation.RESTART)) { restart(host); return true; } return false; }
/** * Returns whether restart is required. In domain, returns {@code true} if at least one of the servers * requires restart. */ public final boolean isRestartRequired() { try { return ops.isRestartRequired(); } catch (IOException e) { throw sneakyThrow(e); } }
/** * Shuts down all the servers on given {@code host} gracefully. As opposed to * {@link Administration#shutdownGracefully(int)}, this doesn't shut down the entire host, just the servers. * * @param timeoutInSeconds if {@code == 0}, then the server will shutdown immediately without waiting * for the active requests to finish; if {@code <= 0}, then the server will wait indefinitely for the active * requests to finish */ public void shutdownAllServersGracefully(String host, int timeoutInSeconds) throws InterruptedException, TimeoutException, IOException { shutdownServersGracefully(host, allRunningServers(host), timeoutInSeconds); }
public boolean restartIfRequired() throws IOException, InterruptedException, TimeoutException { if (isRestartOperationRequired(CommonRestartOperation.RESTART)) { restart(); return true; } return false; }
/** * Shuts down all the servers on given {@code host}. As opposed to {@link Administration#shutdown()}, this doesn't * shut down the entire host, just the servers. */ public void shutdownAllServers(String host) throws InterruptedException, TimeoutException, IOException { shutdownServers(host, allRunningServers(host)); }
/** Waits until all the {@code servers} on given {@code host} are running. */ public void waitUntilServersRunning(String host, List<String> servers) throws InterruptedException, TimeoutException, IOException { domainOps.waitUntilServersAreRunning(host, servers, true); }
/** * Reloads the server if required. In domain, reloads the entire host if at least one server requires reload. * Reloading the host includes restarting all its servers. * @return if the server was in fact reloaded; in domain, if the host was reloaded */ public final boolean reloadIfRequired() throws IOException, InterruptedException, TimeoutException { return ops.reloadIfRequired(); }
/** * Restarts the server if required. In domain, restarts the entire host if at least one server requires restart. * @return if the server was in fact restarted; in domain, if the host was restarted */ public final boolean restartIfRequired() throws IOException, InterruptedException, TimeoutException { return ops.restartIfRequired(); }
/** * Returns whether the {@code host} requires restart (that is, at least one of the servers on the host * requires restart). This is a variant of {@link Administration#isRestartRequired()}. */ public boolean isRestartRequired(String host) throws IOException { return domainOps.isRestartOperationRequired(host, CommonRestartOperation.RESTART); }
/** * Reverts all configuration done for Elytron * @throws Exception */ private void cleanUpElytron() throws Exception { try { ops.removeIfExists(UNDERTOW_APPLICATION_SECURITY_DOMAIN_ADDRESS); ops.removeIfExists(ELYTRON_PROP_HTTP_AUTHENTICATION_FACTORY_ADDRESS); ops.removeIfExists(ELYTRON_SECURITY_DOMAIN_ADDRESS); ops.removeIfExists(ELYTRON_PROPERTIES_REALM_ADDRESS); administration.reloadIfRequired(); } finally { managementClient.close(); } }
/** * Waits until the the host controller of given {@code host} is running. * This is a variant of {@link Administration#waitUntilRunning()}. */ public void waitUntilRunning(String host) throws InterruptedException, TimeoutException, IOException { domainOps.waitUntilServersAreRunning(host, null, true); }
/** * Creates PicketBox security domain * @throws Exception */ private void configurePicketBox() throws Exception { // Create security domain AddSecurityDomain addSecurityDomain = new AddSecurityDomain.Builder(securityDomainName).build(); managementClient.apply(addSecurityDomain); // Create login module AddLoginModule addLoginModule = new AddLoginModule.Builder("org.jboss.security.auth.spi.UsersRolesLoginModule", PICKETBOX_LOGIN_MODULE_NAME) .securityDomainName(securityDomainName) .flag("required") .module("org.picketbox") .addModuleOption("usersProperties", USERS_FILE.getAbsolutePath()) .addModuleOption("rolesProperties", ROLES_FILE.getAbsolutePath()) .build(); managementClient.apply(addLoginModule); administration.reloadIfRequired(); assertTrue("The login module should be created", ops.exists(PICKETBOX_LOGIN_MODULE_ADDRESS)); }
.and("path", ROLES_FILE.getAbsolutePath()))); administration.reloadIfRequired(); + ELYTRON_PROP_HTTP_AUTHENTICATION_FACTORY_NAME + ")"); administration.reloadIfRequired();