use of org.wildfly.security.WildFlyElytronProvider in project fuse-karaf by jboss-fuse.
the class CreateCredentialStoreTest method shouldCreateInitializeAndPersistCredentialStore.
@Test
public void shouldCreateInitializeAndPersistCredentialStore() throws IOException, GeneralSecurityException {
final File storeFile = new File(tmp.getRoot(), "credential.store");
final Map<String, String> attributes = Collections.singletonMap("location", storeFile.getAbsolutePath());
final Provider provider = new WildFlyElytronProvider();
final CredentialSource credentialSource = IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, "test".toCharArray())));
CreateCredentialStore.createCredentialStore(KeyStoreCredentialStore.KEY_STORE_CREDENTIAL_STORE, attributes, credentialSource, provider);
assertThat(storeFile).exists().isFile();
}
use of org.wildfly.security.WildFlyElytronProvider in project wildfly-swarm by wildfly-swarm.
the class ArqSecuredManagementInterfaceTest method testClient.
@Test
@RunAsClient
public void testClient() throws Exception {
Security.addProvider(new WildFlyElytronProvider());
ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9990, new AuthCallbackHandler("TestRealm", "bob", "tacos!"));
ModelNode response = client.execute(Operations.createOperation("whoami"));
assertThat(response.get("outcome").asString()).isEqualTo("success");
ModelNode result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
ModelNode identity = result.get("identity");
assertThat(identity).isNotNull();
assertThat(identity.isDefined()).isTrue();
assertThat(identity.get("username").asString()).isEqualTo("bob");
// ===
response = client.execute(Operations.createOperation("read-resource", PathAddress.pathAddress(PathElement.pathElement("deployment", "*")).toModelNode()));
assertThat(response.get("outcome").asString()).isEqualTo("success");
result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
assertThat(result.getType()).isEqualTo(ModelType.LIST);
assertThat(result.asList()).hasSize(1);
ModelNode myapp = result.get(0);
assertThat(myapp).isNotNull();
assertThat(myapp.isDefined()).isTrue();
ModelNode myappResult = myapp.get("result");
assertThat(myappResult).isNotNull();
assertThat(myappResult.isDefined()).isTrue();
assertThat(myappResult.get("name").asString()).isEqualTo("myapp.jar");
}
use of org.wildfly.security.WildFlyElytronProvider in project wildfly by wildfly.
the class ElytronRemoteOutboundConnectionTestCase method callIntermediateWhoAmI.
private String callIntermediateWhoAmI(boolean useRestrictedMethod) {
AuthenticationConfiguration common = AuthenticationConfiguration.empty().useProviders(() -> new Provider[] { new WildFlyElytronProvider() }).setSaslMechanismSelector(SaslMechanismSelector.ALL);
AuthenticationContext authCtxEmpty = AuthenticationContext.empty();
final AuthenticationContext authCtx = authCtxEmpty.with(MatchRule.ALL, common);
final EJBClientContext.Builder ejbClientBuilder = new EJBClientContext.Builder();
ejbClientBuilder.addTransportProvider(new RemoteTransportProvider());
final EJBClientConnection.Builder connBuilder = new EJBClientConnection.Builder();
connBuilder.setDestination(URI.create("remote+http://" + TestSuiteEnvironment.getServerAddressNode1() + ":8180"));
ejbClientBuilder.addClientConnection(connBuilder.build());
final EJBClientContext ejbCtx = ejbClientBuilder.build();
AuthenticationContext.getContextManager().setThreadDefault(authCtx);
EJBClientContext.getContextManager().setThreadDefault(ejbCtx);
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
String result;
try {
InitialContext ctx = new InitialContext(props);
String lookupName = "ejb:/outbound-module/IntermediateWhoAmI!org.jboss.as.test.manualmode.ejb.client.outbound.connection.security.WhoAmI";
WhoAmI intermediate = (WhoAmI) ctx.lookup(lookupName);
if (useRestrictedMethod) {
result = intermediate.whoAmIRestricted();
} else {
result = intermediate.whoAmI();
}
ctx.close();
} catch (NamingException e) {
throw new RuntimeException(e);
}
return result;
}
use of org.wildfly.security.WildFlyElytronProvider in project wildfly-swarm by wildfly-swarm.
the class ArqSecuredManagementInterfaceWithPropertiesTest method testClient.
@Test
@RunAsClient
public void testClient() throws Exception {
Security.addProvider(new WildFlyElytronProvider());
ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9990, new AuthCallbackHandler("ManagementRealm", "bob", "tacos!"));
ModelNode response = client.execute(Operations.createOperation("whoami"));
assertThat(response.get("outcome").asString()).isEqualTo("success");
ModelNode result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
ModelNode identity = result.get("identity");
assertThat(identity).isNotNull();
assertThat(identity.isDefined()).isTrue();
assertThat(identity.get("username").asString()).isEqualTo("bob");
// ===
response = client.execute(Operations.createOperation("read-resource", PathAddress.pathAddress(PathElement.pathElement("deployment", "*")).toModelNode()));
assertThat(response.get("outcome").asString()).isEqualTo("success");
result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
assertThat(result.getType()).isEqualTo(ModelType.LIST);
assertThat(result.asList()).hasSize(1);
ModelNode myapp = result.get(0);
assertThat(myapp).isNotNull();
assertThat(myapp.isDefined()).isTrue();
ModelNode myappResult = myapp.get("result");
assertThat(myappResult).isNotNull();
assertThat(myappResult.isDefined()).isTrue();
assertThat(myappResult.get("name").asString()).isEqualTo("myapp.jar");
}
use of org.wildfly.security.WildFlyElytronProvider in project wildfly-swarm by wildfly-swarm.
the class ArqSecuredManagementInterfaceTest method testClient.
@Test
@RunAsClient
public void testClient() throws Exception {
Security.addProvider(new WildFlyElytronProvider());
ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9990, new AuthCallbackHandler("ManagementRealm", "bob", "tacos!"));
ModelNode response = client.execute(Operations.createOperation("whoami"));
assertThat(response.get("outcome").asString()).isEqualTo("success");
ModelNode result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
ModelNode identity = result.get("identity");
assertThat(identity).isNotNull();
assertThat(identity.isDefined()).isTrue();
assertThat(identity.get("username").asString()).isEqualTo("bob");
// ===
response = client.execute(Operations.createOperation("read-resource", PathAddress.pathAddress(PathElement.pathElement("deployment", "*")).toModelNode()));
assertThat(response.get("outcome").asString()).isEqualTo("success");
result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
assertThat(result.getType()).isEqualTo(ModelType.LIST);
assertThat(result.asList()).hasSize(1);
ModelNode myapp = result.get(0);
assertThat(myapp).isNotNull();
assertThat(myapp.isDefined()).isTrue();
ModelNode myappResult = myapp.get("result");
assertThat(myappResult).isNotNull();
assertThat(myappResult.isDefined()).isTrue();
assertThat(myappResult.get("name").asString()).isEqualTo("ArqSecuredManagementInterfaceTest.war");
}
Aggregations