use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class DeploymentArchiveProcessor method modifyAdapterConfig.
protected void modifyAdapterConfig(Archive<?> archive, String adapterConfigPath, boolean relative) {
if (archive.contains(adapterConfigPath)) {
log.info("Modifying adapter config " + adapterConfigPath + " in " + archive.getName());
if (adapterConfigPath.endsWith(".xml")) {
// SAML adapter config
log.info("Modifying saml adapter config in " + archive.getName());
Document doc = loadXML(archive.get(adapterConfigPath).getAsset().openStream());
if (AUTH_SERVER_SSL_REQUIRED) {
modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "8080", System.getProperty("auth.server.https.port"));
modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "http", "https");
modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "8080", System.getProperty("app.server.https.port"));
modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "http", "https");
modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "8080", System.getProperty("auth.server.https.port"));
modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "http", "https");
modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "8080", System.getProperty("auth.server.https.port"));
modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "http", "https");
modifyDocElementAttribute(doc, "SP", "logoutPage", "8080", System.getProperty("app.server.https.port"));
modifyDocElementAttribute(doc, "SP", "logoutPage", "http", "https");
} else {
modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "8080", System.getProperty("auth.server.http.port"));
modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "8080", System.getProperty("app.server.http.port"));
modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "8080", System.getProperty("auth.server.http.port"));
modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "8080", System.getProperty("auth.server.http.port"));
modifyDocElementAttribute(doc, "SP", "logoutPage", "8080", System.getProperty("app.server.http.port"));
}
archive.add(new StringAsset(IOUtil.documentToString(doc)), adapterConfigPath);
((WebArchive) archive).addAsResource(new File(DeploymentArchiveProcessor.class.getResource("/keystore/keycloak.truststore").getFile()));
// For running SAML tests it is necessary to have few dependencies on app-server side.
// Few of them are not in adapter zip so we need to add them manually here
} else {
// OIDC adapter config
try {
AdapterConfig adapterConfig = loadJson(archive.get(adapterConfigPath).getAsset().openStream(), AdapterConfig.class);
adapterConfig.setAuthServerUrl(getAuthServerContextRoot() + "/auth");
if (APP_SERVER_SSL_REQUIRED) {
adapterConfig.setSslRequired("all");
}
archive.add(new StringAsset(JsonSerialization.writeValueAsPrettyString(adapterConfig)), adapterConfigPath);
} catch (IOException ex) {
log.error("Cannot serialize adapter config to JSON.", ex);
}
}
}
}
use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class AdapterInstallationConfigTest method getConfig.
@Test
public void getConfig() throws ClientRegistrationException {
reg.auth(Auth.client(client.getClientId(), "RegistrationAccessTokenTestClientSecret"));
AdapterConfig config = reg.getAdapterConfig(client.getClientId());
assertNotNull(config);
assertEquals(suiteContext.getAuthServerInfo().getContextRoot() + "/auth/", config.getAuthServerUrl());
assertEquals("test", config.getRealm());
assertEquals(1, config.getCredentials().size());
assertEquals("RegistrationAccessTokenTestClientSecret", config.getCredentials().get("secret"));
assertEquals(client.getClientId(), config.getResource());
if (AUTH_SERVER_SSL_REQUIRED)
assertEquals(SslRequired.EXTERNAL.name().toLowerCase(), config.getSslRequired());
}
use of org.keycloak.representations.adapters.config.AdapterConfig in project keycloak by keycloak.
the class DeploymentArchiveProcessorUtils method modifyOIDCAdapterConfig.
public static void modifyOIDCAdapterConfig(Archive<?> archive, String adapterConfigPath) {
try {
AdapterConfig adapterConfig = IOUtil.loadJson(archive.get(adapterConfigPath).getAsset().openStream(), AdapterConfig.class);
adapterConfig.setAuthServerUrl(getAuthServerUrl());
if (APP_SERVER_SSL_REQUIRED) {
adapterConfig.setSslRequired("all");
}
if (AUTH_SERVER_SSL_REQUIRED) {
String trustStorePathInDeployment = "keycloak.truststore";
if (adapterConfigPath.contains("WEB-INF")) {
// This is a Java adapter, we can use classpath
trustStorePathInDeployment = "classpath:keycloak.truststore";
}
adapterConfig.setTruststore(trustStorePathInDeployment);
adapterConfig.setTruststorePassword(TRUSTSTORE_PASSWORD);
String truststoreUrl = System.getProperty("dependency.keystore.root", "") + "/keycloak.truststore";
File truststore = new File(truststoreUrl);
if (!truststore.exists()) {
truststore = new File(DeploymentArchiveProcessorUtils.class.getResource("/keystore/keycloak.truststore").getFile());
}
((WebArchive) archive).addAsResource(truststore);
log.debugf("Adding Truststore to the deployment, path %s, password %s, adapter path %s", truststore.getAbsolutePath(), TRUSTSTORE_PASSWORD, trustStorePathInDeployment);
}
archive.add(new StringAsset(JsonSerialization.writeValueAsPrettyString(adapterConfig)), adapterConfigPath);
} catch (IOException ex) {
log.error("Cannot serialize adapter config to JSON.", ex);
}
}
Aggregations