use of io.smallrye.config.ConfigValue in project keycloak by keycloak.
the class KeycloakProcessor method persistBuildTimeProperties.
/**
* <p>Make the build time configuration available at runtime so that the server can run without having to specify some of
* the properties again.
*/
@BuildStep(onlyIf = IsReAugmentation.class)
void persistBuildTimeProperties(BuildProducer<GeneratedResourceBuildItem> resources) {
Properties properties = new Properties();
for (String name : getPropertyNames()) {
PropertyMapper mapper = PropertyMappers.getMapper(name);
ConfigValue value = null;
if (mapper == null) {
if (name.startsWith(NS_QUARKUS)) {
value = Configuration.getConfigValue(name);
if (!QuarkusPropertiesConfigSource.isSameSource(value)) {
continue;
}
}
} else if (mapper.isBuildTime()) {
name = mapper.getFrom();
value = Configuration.getConfigValue(name);
}
if (value != null && value.getValue() != null) {
properties.put(name, value.getValue());
}
}
for (File jar : getProviderFiles().values()) {
properties.put(String.format("kc.provider.file.%s.last-modified", jar.getName()), String.valueOf(jar.lastModified()));
}
String profile = Environment.getProfile();
if (profile != null) {
properties.put(Environment.PROFILE, profile);
properties.put(ProfileManager.QUARKUS_PROFILE_PROP, profile);
}
properties.put(QUARKUS_PROPERTY_ENABLED, String.valueOf(QuarkusPropertiesConfigSource.getConfigurationFile() != null));
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
properties.store(outputStream, " Auto-generated, DO NOT change this file");
resources.produce(new GeneratedResourceBuildItem(PersistedConfigSource.PERSISTED_PROPERTIES, outputStream.toByteArray()));
} catch (Exception cause) {
throw new RuntimeException("Failed to persist configuration", cause);
}
}
use of io.smallrye.config.ConfigValue in project keycloak by keycloak.
the class ExecutionExceptionHandler method printErrorHints.
private void printErrorHints(PrintWriter errorWriter, Throwable cause) {
if (cause instanceof FileSystemException) {
FileSystemException fse = (FileSystemException) cause;
ConfigValue httpsCertFile = getConfig().getConfigValue("kc.https-certificate-file");
if (fse.getFile().equals(Optional.ofNullable(httpsCertFile.getValue()).orElse(null))) {
logError(errorWriter, Messages.httpsConfigurationNotSet().getMessage());
}
}
}
use of io.smallrye.config.ConfigValue in project keycloak by keycloak.
the class ShowConfig method printProperty.
private void printProperty(String property) {
ConfigValue configValue = getConfigValue(property);
if (configValue.getValue() == null) {
configValue = getConfigValue(property);
}
if (configValue.getValue() == null) {
return;
}
if (configValue.getSourceName() == null) {
return;
}
spec.commandLine().getOut().printf("\t%s = %s (%s)%n", configValue.getName(), formatValue(configValue.getName(), configValue.getValue()), configValue.getConfigSourceName());
}
use of io.smallrye.config.ConfigValue in project keycloak by keycloak.
the class ShowConfig method getPropertiesByGroup.
private static Map<String, Set<String>> getPropertiesByGroup() {
Map<String, Set<String>> properties = StreamSupport.stream(getPropertyNames().spliterator(), false).filter(ShowConfig::filterByGroup).collect(Collectors.groupingBy(ShowConfig::groupProperties, Collectors.toSet()));
StreamSupport.stream(getPropertyNames().spliterator(), false).filter(new Predicate<String>() {
@Override
public boolean test(String s) {
ConfigValue configValue = getConfigValue(s);
if (configValue == null) {
return false;
}
return PersistedConfigSource.NAME.equals(configValue.getConfigSourceName());
}
}).filter(ShowConfig::filterByGroup).collect(Collectors.groupingBy(ShowConfig::groupProperties, Collectors.toSet())).forEach(new BiConsumer<String, Set<String>>() {
@Override
public void accept(String group, Set<String> propertyNames) {
properties.computeIfAbsent(group, name -> new HashSet<>()).addAll(propertyNames);
}
});
return properties;
}
use of io.smallrye.config.ConfigValue in project keycloak by keycloak.
the class PropertyMappers method getValue.
public static ConfigValue getValue(ConfigSourceInterceptorContext context, String name) {
PropertyMapper mapper = MAPPERS.getOrDefault(name, PropertyMapper.IDENTITY);
ConfigValue configValue = mapper.getConfigValue(name, context);
if (configValue == null) {
Optional<String> prefixedMapper = getPrefixedMapper(name);
if (prefixedMapper.isPresent()) {
return MAPPERS.get(prefixedMapper.get()).getConfigValue(name, context);
}
} else {
configValue.withName(mapper.getTo());
}
return configValue;
}
Aggregations