/** * 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)); }
/** * 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(); } } }
public static ModelNodeResult runCmd(OnlineManagementClient client, String cmd) throws Exception { ModelNodeResult result = client.execute(cmd); logger.info("CLI command: " + cmd); logger.info("Result: " + result.toString()); return result; }
@Override public OnlineOptions options() { return delegate.options(); }
managementClient.executeCli("/subsystem=elytron/security-domain=" + ELYTRON_SECURITY_DOMAIN_NAME + ":add(realms=[{realm=" managementClient.executeCli("/subsystem=elytron/http-authentication-factory=" + ELYTRON_PROP_HTTP_AUTHENTICATION_FACTORY_NAME + ":add(http-server-mechanism-factory=global,security-domain=" + ELYTRON_SECURITY_DOMAIN_NAME managementClient.executeCli("/subsystem=undertow/application-security-domain=" + securityDomainName + ":add(http-authentication-factory=" + ELYTRON_PROP_HTTP_AUTHENTICATION_FACTORY_NAME + ")");
public ReloadToOriginal(OnlineManagementClient client, int timeoutInSeconds) throws IOException { if (!client.options().isStandalone) { throw new IllegalStateException("ReloadToOriginal is only supported for a standalone server"); } if (client.version().lessThan(ServerVersion.VERSION_1_4_0)) { throw new IllegalStateException("ReloadToOriginal requires at least JBoss AS 7.2.0 (EAP 6.1.0)"); } this.client = client; this.timeoutInSeconds = timeoutInSeconds; }
@Override public ServerVersion version() throws IOException { return delegate.version(); }
@Override public void reconnect(int timeoutInSeconds) throws TimeoutException, InterruptedException { if (delegate != null) { delegate.reconnect(timeoutInSeconds); } }
@Override public FailuresAllowedBlock allowFailures() throws IOException { ensureInitialized(); return delegate.allowFailures(); }
OnlineCommandContext(OnlineManagementClient client, ServerVersion version) { this.client = client; this.options = client.options(); this.version = version; } }
@Override public void executeCli(String cliOperation) throws CliException, IOException { ensureInitialized(); delegate.executeCli(cliOperation); }
@Override public ServerVersion version() throws IOException { ensureInitialized(); return delegate.version(); }
@Override public void reconnect(int timeoutInSeconds) throws TimeoutException, InterruptedException { delegate.reconnect(timeoutInSeconds); }
/** * @return {@code true} if the resource specified by {@code address} was actually removed (i.e., it used to exist), * {@code false} if it didn't exist and therefore wasn't actually removed * @throws OperationException if the underlying {@code remove} operation fails with something else than "not found" */ public boolean removeIfExists(Address address) throws IOException, OperationException { FailuresAllowedBlock expectedFailures = client.allowFailures(); try { ModelNodeResult result = remove(address); if (result.isSuccess()) { return true; } if (isResultUnknownOrNotFound(result)) { return false; } throw new OperationException("removeIfExists failed: " + result.asString()); } finally { expectedFailures.close(); } }
public ModelNodeResult invoke(OnlineManagementClient client) throws IOException { return client.execute(operation); } }
/** @see #shutdownServer(String, String) */ public void shutdownServerGracefully(String server, int timeoutInSeconds) throws InterruptedException, TimeoutException, IOException { shutdownServerGracefully(client.options().defaultHost, server, timeoutInSeconds); }
@Override public void apply(OnlineCommand... commands) throws CommandFailedException { try { delegate.apply(commands); } catch (RuntimeCommandFailedException e) { throw e.original; } }
/** * 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(); } }
@Override public void executeCli(String cliOperation) { try { delegate.executeCli(cliOperation); } catch (Exception e) { commandFailedWithCause(e); } }
public ReloadToSnapshot(OnlineManagementClient client, String snapshot, int timeoutInSeconds) throws IOException { if (client.version().lessThan(ServerVersion.VERSION_5_0_0)) { throw new IllegalStateException("ReloadToSnapshot requires at least WildFly Core 3."); } this.client = client; this.snapshot = snapshot; this.timeoutInSeconds = timeoutInSeconds; }