use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class KeycloakDeploymentTest method stripDefaultPorts.
@Test
public void stripDefaultPorts() {
KeycloakDeployment keycloakDeployment = new KeycloakDeploymentMock();
keycloakDeployment.setRealm("test");
AdapterConfig config = new AdapterConfig();
config.setAuthServerUrl("http://localhost:80/auth");
keycloakDeployment.setAuthServerBaseUrl(config);
assertEquals("http://localhost/auth", keycloakDeployment.getAuthServerBaseUrl());
config.setAuthServerUrl("https://localhost:443/auth");
keycloakDeployment.setAuthServerBaseUrl(config);
assertEquals("https://localhost/auth", keycloakDeployment.getAuthServerBaseUrl());
}
use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class KeycloakDeploymentBuilder method loadAdapterConfig.
public static AdapterConfig loadAdapterConfig(InputStream is) {
ObjectMapper mapper = new ObjectMapper(new SystemPropertiesJsonParserFactory());
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
AdapterConfig adapterConfig;
try {
adapterConfig = mapper.readValue(is, AdapterConfig.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
return adapterConfig;
}
use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class SubsystemParsingTestCase method testJsonHttpClientAttributes.
@Test
public void testJsonHttpClientAttributes() {
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
// add a secure deployment
PathAddress addr = PathAddress.pathAddress(PathElement.pathElement("subsystem", "keycloak"), PathElement.pathElement("secure-deployment", "foo"));
ModelNode deploymentOp = new ModelNode();
deploymentOp.get(ModelDescriptionConstants.OP_ADDR).set(addr.toModelNode());
ModelNode deployment = new ModelNode();
deployment.get("realm").set("demo");
deployment.get("resource").set("customer-portal");
deployment.get(SharedAttributeDefinitons.SOCKET_TIMEOUT.getName()).set(3000L);
deployment.get(SharedAttributeDefinitons.CONNECTION_TIMEOUT.getName()).set(5000L);
deployment.get(SharedAttributeDefinitons.CONNECTION_TTL.getName()).set(1000L);
service.addSecureDeployment(deploymentOp, deployment, false);
// get the subsystem config as JSON
String jsonConfig = service.getJSON("foo");
// attempt to create an adapter config instance from the subsystem JSON config
AdapterConfig config = KeycloakDeploymentBuilder.loadAdapterConfig(new ByteArrayInputStream(jsonConfig.getBytes()));
assertThat(config, CoreMatchers.notNullValue());
assertThat(config.getSocketTimeout(), CoreMatchers.notNullValue());
assertThat(config.getSocketTimeout(), CoreMatchers.is(3000L));
assertThat(config.getConnectionTimeout(), CoreMatchers.notNullValue());
assertThat(config.getConnectionTimeout(), CoreMatchers.is(5000L));
assertThat(config.getConnectionTTL(), CoreMatchers.notNullValue());
assertThat(config.getConnectionTTL(), CoreMatchers.is(1000L));
}
use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class JsonParserTest method testParsingSystemProps.
@Test
public void testParsingSystemProps() throws IOException {
System.setProperty("my.host", "foo");
System.setProperty("con.pool.size", "200");
System.setProperty("allow.any.hostname", "true");
System.setProperty("socket.timeout.millis", "6000");
System.setProperty("connection.timeout.millis", "7000");
System.setProperty("connection.ttl.millis", "500");
InputStream is = getClass().getClassLoader().getResourceAsStream("keycloak.json");
AdapterConfig config = JsonSerialization.readValue(is, AdapterConfig.class, true);
Assert.assertEquals("http://foo:8080/auth", config.getAuthServerUrl());
Assert.assertEquals("external", config.getSslRequired());
Assert.assertEquals("angular-product${non.existing}", config.getResource());
Assert.assertTrue(config.isPublicClient());
Assert.assertTrue(config.isAllowAnyHostname());
Assert.assertEquals(100, config.getCorsMaxAge());
Assert.assertEquals(200, config.getConnectionPoolSize());
Assert.assertEquals(6000L, config.getSocketTimeout());
Assert.assertEquals(7000L, config.getConnectionTimeout());
Assert.assertEquals(500L, config.getConnectionTTL());
}
use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class AdapterInstallationConfigTest method getConfigWithRegistrationAccessToken.
@Test
public void getConfigWithRegistrationAccessToken() throws ClientRegistrationException {
reg.auth(Auth.token(client.getRegistrationAccessToken()));
AdapterConfig config = reg.getAdapterConfig(client.getClientId());
assertNotNull(config);
}
Aggregations