@Override public KeycloakDeployment resolve(OIDCHttpFacade.Request request) { if (keycloakDeployment != null) { return keycloakDeployment; } keycloakDeployment = KeycloakDeploymentBuilder.build(KeycloakSpringBootConfigResolver.adapterConfig); return keycloakDeployment; }
public static KeycloakDeployment build(InputStream is) { AdapterConfig adapterConfig = loadAdapterConfig(is); return new KeycloakDeploymentBuilder().internalBuild(adapterConfig); }
public static KeycloakDeployment build(AdapterConfig adapterConfig) { return new KeycloakDeploymentBuilder().internalBuild(adapterConfig); }
/** * Convert the adapter configuration into an object we can use to configure the rest of the * context. * * @return configuration for the Keycloak-Java adapter * @throws IOException if the provided string does not represent valid config */ public AdapterConfig readAdapterConfig() throws IOException { LOG.log(Level.FINER, "GeoServerKeycloakFilterConfig.readAdapterConfig ENTRY"); try { return KeycloakDeploymentBuilder.loadAdapterConfig( IOUtils.toInputStream(getAdapterConfig())); } catch (RuntimeException e) { throw new IOException(e); } }
KeycloakInstalled(InputStream config) { deployment = KeycloakDeploymentBuilder.build(config); }
public void updateDeployment(AdapterConfig config) { if (null != configResolver) { throw new IllegalStateException("Cannot parse an adapter config and build an updated deployment when on a multi-tenant scenario."); } deployment = KeycloakDeploymentBuilder.build(config); } }
KeycloakInstalled() { InputStream config = Thread.currentThread().getContextClassLoader().getResourceAsStream(KEYCLOAK_JSON); deployment = KeycloakDeploymentBuilder.build(config); }
private KeycloakDeployment createKeycloakDeploymentFrom(InputStream is) { if (is == null) { log.fine("No adapter configuration. Keycloak is unconfigured and will deny all requests."); return new KeycloakDeployment(); } return KeycloakDeploymentBuilder.build(is); }
public static void build(InputStream is, ServletOAuthClient oauthClient) { KeycloakDeployment deployment = KeycloakDeploymentBuilder.build(is); oauthClient.setDeployment(deployment); } }
public ApplicationBuilder(AdapterConfig config) { this.deployment = KeycloakDeploymentBuilder.build(config); this.deploymentContext = new AdapterDeploymentContext(deployment); }
private KeycloakDeployment loadKeycloakDeployment() throws IOException { if (!keycloakConfigFileResource.isReadable()) { throw new FileNotFoundException(String.format("Unable to locate Keycloak configuration file: %s", keycloakConfigFileResource.getFilename())); } return KeycloakDeploymentBuilder.build(keycloakConfigFileResource.getInputStream()); }
private AdapterDeploymentContext createDeploymentContext(byte[] config) { return new AdapterDeploymentContext(KeycloakDeploymentBuilder.build(new ByteArrayInputStream(config))); } }
public void initializeKeycloak() { KeycloakDeployment kd = KeycloakDeploymentBuilder.build(adapterConfig); deploymentContext = new AdapterDeploymentContext(kd); }
private AdapterDeploymentContext getDeploymentContext() { if (configResolver != null) { LOG.log(Level.INFO, "Using {0} to resolve Keycloak configuration on a per-request basis.", configResolver.getClass()); return new AdapterDeploymentContext(configResolver); } else if (adapterConfig != null) { KeycloakDeployment kd = KeycloakDeploymentBuilder.build(adapterConfig); return new AdapterDeploymentContext(kd); } LOG.warning("Adapter is unconfigured, Keycloak will deny every request"); return new AdapterDeploymentContext(); }
protected KeycloakDeployment resolveDeployment(String keycloakConfigFile) { try { InputStream is = null; if (keycloakConfigFile.startsWith(PROFILE_RESOURCE)) { try { is = new URL(keycloakConfigFile).openStream(); } catch (MalformedURLException mfue) { throw new RuntimeException(mfue); } catch (IOException ioe) { throw new RuntimeException(ioe); } } else { is = FindFile.findFile(keycloakConfigFile); } KeycloakDeployment kd = KeycloakDeploymentBuilder.build(is); return kd; } catch (RuntimeException e) { getLogger().debug("Unable to find or parse file " + keycloakConfigFile + " due to " + e.getMessage(), e); throw e; } }
/** * Validates the configuration content. This builds a dummy deployment, and recasts and * exceptions so that GeoServer can process them as security-related. * * @param config the configuration to validate * @throws FilterConfigException if the configuration is invalid */ public void validateKeycloakConfig(GeoServerKeycloakFilterConfig config) throws FilterConfigException { try { KeycloakDeploymentBuilder.build(config.readAdapterConfig()); LOG.log(Level.FINE, "valid Keycloak config"); } catch (RuntimeException | IOException e) { LOG.log(Level.FINE, "invalid Keycloak config", e); throw new FilterConfigException(null, e.getLocalizedMessage()); } } }
public static ServletOAuthClient build(InputStream is) { KeycloakDeployment deployment = KeycloakDeploymentBuilder.build(is); ServletOAuthClient client = new ServletOAuthClient(); client.setDeployment(deployment); return client; }
@Override public void setup(Config config) { String configFile = "classpath:conf/keycloak.json"; if (config.hasPath("file")) { configFile = config.getString("file"); } keycloakConfig = parseKeycloakConfig(configFile); keycloakDeployment = KeycloakDeploymentBuilder.build(keycloakConfig); realmName = keycloakConfig.getRealm() + "/" + keycloakConfig.getResource(); if (config.hasPath("name")) { realmName = config.getString("name"); } definedRoles.clear(); definedRoles.putAll(parseDefinedRoles(config)); }
public static ServletOAuthClient build(AdapterConfig adapterConfig) { KeycloakDeployment deployment = KeycloakDeploymentBuilder.build(adapterConfig); ServletOAuthClient client = new ServletOAuthClient(); client.setDeployment(deployment); return client; }