/** * 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 OnlineManagementClient clientInit() throws IOException { OnlineOptions onlineOptions = OnlineOptions .standalone() .hostAndPort(PortProviderUtil.getHost(), 9990) // 9990 is default port for EAP 7 .connectionTimeout(120000) .build(); return ManagementClient.online(onlineOptions); }
ops.add(ELYTRON_PROPERTIES_REALM_ADDRESS, Values.empty() .andObject("users-properties", Values.empty() .and("path", USERS_FILE.getAbsolutePath()) .andOptional("plain-text", true)) .andObjectOptional("groups-properties", Values.empty() .and("path", ROLES_FILE.getAbsolutePath()))); administration.reloadIfRequired(); 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 + ")"); administration.reloadIfRequired(); assertTrue("The elytron/properties-realm should be created", ops.exists(ELYTRON_PROPERTIES_REALM_ADDRESS)); assertTrue("The elytron/security-domain should be created", ops.exists(ELYTRON_SECURITY_DOMAIN_ADDRESS)); assertTrue("The elytron/http-authentication-factory should be created", ops.exists(ELYTRON_PROP_HTTP_AUTHENTICATION_FACTORY_ADDRESS)); assertTrue("The undertow/application-security-domain should be created", ops.exists(UNDERTOW_APPLICATION_SECURITY_DOMAIN_ADDRESS));
public void reloadServer() throws IOException, TimeoutException, InterruptedException { Administration admin = new Administration(org.wildfly.extras.creaper.core.ManagementClient.online(OnlineOptions.domain() .forHost("master") .build() .hostAndPort(NODE0_ADDRESS, NODE0_PORT) .auth(LOGIN, PASSWORD) .build() )); admin.reload(); }
@Override public ModelNodeResult execute(String operation) { try { ModelNodeResult result = delegate.execute(operation); if (result.isFailed() && throwExceptionsOnOperationFailures) { commandFailedWithMessage("Operation " + operation + " failed: " + result.asString()); } return result; } catch (RuntimeCommandFailedException e) { throw e; } catch (Exception e) { commandFailedWithCause(e); return null; // dead code } }
@Override public ModelNodeResult execute(ModelNode operation) throws IOException { ensureInitialized(); return delegate.execute(operation); }
/** * 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)); }
@Override public void executeCli(String cliOperation) throws CliException, IOException { ensureInitialized(); delegate.executeCli(cliOperation); }
@Override public void executeCli(String cliOperation) { try { delegate.executeCli(cliOperation); } catch (Exception e) { commandFailedWithCause(e); } }
@Override public ServerVersion version() throws IOException { ensureInitialized(); return delegate.version(); }
/** Connect to a domain controller. */ public static DomainOnlineOptions domain() { Data data = new Data(); data.isDomain = true; data.bootTimeout = 120000; return new DomainOnlineOptions(data); }
OnlineManagementClientImpl(OnlineOptions options) throws IOException { this.options = options; this.adjustOperationForDomain = new AdjustOperationForDomain(options); connect(); }
@Override public FailuresAllowedBlock allowFailures() throws IOException { ensureInitialized(); return delegate.allowFailures(); }
/** Connect to a standalone server. */ public static ConnectionOnlineOptions standalone() { Data data = new Data(); data.isStandalone = true; data.bootTimeout = 20000; return new ConnectionOnlineOptions(data); }
@Override public void apply(Iterable<OnlineCommand> commands) throws CommandFailedException { try { delegate.apply(commands); } catch (RuntimeCommandFailedException e) { throw e.original; } }
/** Builds the final {@code SslOptions}. */ public SslOptions build() { return new SslOptions(this); } }
/** * 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 ModelNodeResult execute(Operation operation) throws IOException { ensureInitialized(); return delegate.execute(operation); }
@Override public ModelNodeResult execute(String operation) throws CliException, IOException { ensureInitialized(); return delegate.execute(operation); }