use of org.jboss.pnc.common.json.moduleconfig.KeycloakClientConfig in project pnc by project-ncl.
the class SystemConfigMock method withKeycloakServiceAccount.
public static SystemConfig withKeycloakServiceAccount() throws IOException {
String configJson = IoUtils.readResource("keycloakClientConfig.json", SystemConfigMock.class.getClassLoader());
KeycloakClientConfig serviceAccountConfig = JsonOutputConverterMapper.readValue(configJson, KeycloakClientConfig.class);
return new SystemConfig(null, null, null, null, null, null, null, "10", serviceAccountConfig, null, null, "", "10");
}
use of org.jboss.pnc.common.json.moduleconfig.KeycloakClientConfig in project pnc by project-ncl.
the class JaxRsActivatorNew method getAuthScheme.
private SecurityScheme getAuthScheme() {
try {
final KeycloakClientConfig keycloakConfig = systemConfig.getKeycloakServiceAccountConfig();
if (keycloakConfig == null || StringUtils.isEmpty(keycloakConfig.getAuthServerUrl())) {
return null;
}
URI keycloakURL = new URI(keycloakConfig.getAuthServerUrl() + "/").resolve("realms/" + keycloakConfig.getRealm() + "/protocol/openid-connect/auth");
final OAuthFlow implicitFlow = new OAuthFlow().authorizationUrl(keycloakURL.toString());
SecurityScheme scheme = new SecurityScheme();
scheme.type(SecurityScheme.Type.OAUTH2).description("This application uses Keycloak oauth authentication").flows(new OAuthFlows().implicit(implicitFlow));
return scheme;
} catch (URISyntaxException ex) {
logger.warn("Failed to parse Keycloak setting", ex);
return null;
}
}
Aggregations