Do not use raw parameterized PropertyMapper (#26093)
Closes #26092 Signed-off-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
parent
c78c2de653
commit
5d3df39f04
31 changed files with 90 additions and 90 deletions
|
@ -9,7 +9,7 @@ public class CachingOptions {
|
|||
local
|
||||
}
|
||||
|
||||
public static final Option CACHE = new OptionBuilder<>("cache", Mechanism.class)
|
||||
public static final Option<Mechanism> CACHE = new OptionBuilder<>("cache", Mechanism.class)
|
||||
.category(OptionCategory.CACHE)
|
||||
.description("Defines the cache mechanism for high-availability. "
|
||||
+ "By default in production mode, a 'ispn' cache is used to create a cluster between multiple server nodes. "
|
||||
|
@ -27,7 +27,7 @@ public class CachingOptions {
|
|||
google;
|
||||
}
|
||||
|
||||
public static final Option CACHE_STACK = new OptionBuilder<>("cache-stack", Stack.class)
|
||||
public static final Option<Stack> CACHE_STACK = new OptionBuilder<>("cache-stack", Stack.class)
|
||||
.category(OptionCategory.CACHE)
|
||||
.description("Define the default stack to use for cluster communication and node discovery. This option only takes effect "
|
||||
+ "if 'cache' is set to 'ispn'. Default: udp.")
|
||||
|
|
|
@ -18,7 +18,7 @@ public class FeatureOptions {
|
|||
.buildTime(true)
|
||||
.build();
|
||||
|
||||
public static final Option FEATURES_DISABLED = new OptionBuilder("features-disabled", List.class, Profile.Feature.class)
|
||||
public static final Option<List> FEATURES_DISABLED = new OptionBuilder("features-disabled", List.class, Profile.Feature.class)
|
||||
.category(OptionCategory.FEATURE)
|
||||
.description("Disables a set of one or more features.")
|
||||
.expectedValues(() -> getFeatureValues(false))
|
||||
|
|
|
@ -2,56 +2,56 @@ package org.keycloak.config;
|
|||
|
||||
public class HostnameOptions {
|
||||
|
||||
public static final Option HOSTNAME = new OptionBuilder<>("hostname", String.class)
|
||||
public static final Option<String> HOSTNAME = new OptionBuilder<>("hostname", String.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("Hostname for the Keycloak server.")
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_URL = new OptionBuilder<>("hostname-url", String.class)
|
||||
public static final Option<String> HOSTNAME_URL = new OptionBuilder<>("hostname-url", String.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("Set the base URL for frontend URLs, including scheme, host, port and path.")
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_ADMIN = new OptionBuilder<>("hostname-admin", String.class)
|
||||
public static final Option<String> HOSTNAME_ADMIN = new OptionBuilder<>("hostname-admin", String.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("The hostname for accessing the administration console. Use this option if you are exposing the administration console using a hostname other than the value set to the 'hostname' option.")
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_ADMIN_URL = new OptionBuilder<>("hostname-admin-url", String.class)
|
||||
public static final Option<String> HOSTNAME_ADMIN_URL = new OptionBuilder<>("hostname-admin-url", String.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("Set the base URL for accessing the administration console, including scheme, host, port and path")
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_STRICT = new OptionBuilder<>("hostname-strict", Boolean.class)
|
||||
public static final Option<Boolean> HOSTNAME_STRICT = new OptionBuilder<>("hostname-strict", Boolean.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("Disables dynamically resolving the hostname from request headers. Should always be set to true in production, unless proxy verifies the Host header.")
|
||||
.defaultValue(Boolean.TRUE)
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_STRICT_HTTPS = new OptionBuilder<>("hostname-strict-https", Boolean.class)
|
||||
public static final Option<Boolean> HOSTNAME_STRICT_HTTPS = new OptionBuilder<>("hostname-strict-https", Boolean.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("Forces frontend URLs to use the 'https' scheme. If set to false, the HTTP scheme is inferred from requests.")
|
||||
.hidden()
|
||||
.defaultValue(Boolean.TRUE)
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_STRICT_BACKCHANNEL = new OptionBuilder<>("hostname-strict-backchannel", Boolean.class)
|
||||
public static final Option<Boolean> HOSTNAME_STRICT_BACKCHANNEL = new OptionBuilder<>("hostname-strict-backchannel", Boolean.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("By default backchannel URLs are dynamically resolved from request headers to allow internal and external applications. If all applications use the public URL this option should be enabled.")
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_PATH = new OptionBuilder<>("hostname-path", String.class)
|
||||
public static final Option<String> HOSTNAME_PATH = new OptionBuilder<>("hostname-path", String.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("This should be set if proxy uses a different context-path for Keycloak.")
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_PORT = new OptionBuilder<>("hostname-port", Integer.class)
|
||||
public static final Option<Integer> HOSTNAME_PORT = new OptionBuilder<>("hostname-port", Integer.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("The port used by the proxy when exposing the hostname. Set this option if the proxy uses a port other than the default HTTP and HTTPS ports.")
|
||||
.defaultValue(-1)
|
||||
.build();
|
||||
|
||||
public static final Option HOSTNAME_DEBUG = new OptionBuilder<>("hostname-debug", Boolean.class)
|
||||
public static final Option<Boolean> HOSTNAME_DEBUG = new OptionBuilder<>("hostname-debug", Boolean.class)
|
||||
.category(OptionCategory.HOSTNAME)
|
||||
.description("Toggle the hostname debug page that is accessible at /realms/master/hostname-debug")
|
||||
.defaultValue(Boolean.FALSE)
|
||||
|
|
|
@ -11,13 +11,13 @@ public class HttpOptions {
|
|||
.defaultValue(Boolean.FALSE)
|
||||
.build();
|
||||
|
||||
public static final Option HTTP_HOST = new OptionBuilder<>("http-host", String.class)
|
||||
public static final Option<String> HTTP_HOST = new OptionBuilder<>("http-host", String.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("The used HTTP Host.")
|
||||
.defaultValue("0.0.0.0")
|
||||
.build();
|
||||
|
||||
public static final Option HTTP_RELATIVE_PATH = new OptionBuilder<>("http-relative-path", String.class)
|
||||
public static final Option<String> HTTP_RELATIVE_PATH = new OptionBuilder<>("http-relative-path", String.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("Set the path relative to '/' for serving resources. The path must start with a '/'.")
|
||||
.defaultValue("/")
|
||||
|
@ -42,19 +42,19 @@ public class HttpOptions {
|
|||
required
|
||||
}
|
||||
|
||||
public static final Option HTTPS_CLIENT_AUTH = new OptionBuilder<>("https-client-auth", ClientAuth.class)
|
||||
public static final Option<ClientAuth> HTTPS_CLIENT_AUTH = new OptionBuilder<>("https-client-auth", ClientAuth.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("Configures the server to require/request client authentication.")
|
||||
.defaultValue(ClientAuth.none)
|
||||
.buildTime(true)
|
||||
.build();
|
||||
|
||||
public static final Option HTTPS_CIPHER_SUITES = new OptionBuilder<>("https-cipher-suites", String.class)
|
||||
public static final Option<String> HTTPS_CIPHER_SUITES = new OptionBuilder<>("https-cipher-suites", String.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("The cipher suites to use. If none is given, a reasonable default is selected.")
|
||||
.build();
|
||||
|
||||
public static final Option HTTPS_PROTOCOLS = new OptionBuilder<>("https-protocols", String.class)
|
||||
public static final Option<String> HTTPS_PROTOCOLS = new OptionBuilder<>("https-protocols", String.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("The list of protocols to explicitly enable.")
|
||||
.defaultValue("TLSv1.3,TLSv1.2")
|
||||
|
@ -70,12 +70,12 @@ public class HttpOptions {
|
|||
.description("The file path to a private key in PEM format.")
|
||||
.build();
|
||||
|
||||
public static final Option HTTPS_KEY_STORE_FILE = new OptionBuilder<>("https-key-store-file", File.class)
|
||||
public static final Option<File> HTTPS_KEY_STORE_FILE = new OptionBuilder<>("https-key-store-file", File.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("The key store which holds the certificate information instead of specifying separate files.")
|
||||
.build();
|
||||
|
||||
public static final Option HTTPS_KEY_STORE_PASSWORD = new OptionBuilder<>("https-key-store-password", String.class)
|
||||
public static final Option<String> HTTPS_KEY_STORE_PASSWORD = new OptionBuilder<>("https-key-store-password", String.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("The password of the key store file.")
|
||||
.defaultValue("password")
|
||||
|
@ -88,13 +88,13 @@ public class HttpOptions {
|
|||
"If '" + SecurityOptions.FIPS_MODE.getKey() + "' is set to '" + FipsMode.STRICT + "' and no value is set, it defaults to 'BCFKS'.")
|
||||
.build();
|
||||
|
||||
public static final Option HTTPS_TRUST_STORE_FILE = new OptionBuilder<>("https-trust-store-file", File.class)
|
||||
public static final Option<File> HTTPS_TRUST_STORE_FILE = new OptionBuilder<>("https-trust-store-file", File.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("The trust store which holds the certificate information of the certificates to trust.")
|
||||
.deprecated("Use the System Truststore instead, see the docs for details.")
|
||||
.build();
|
||||
|
||||
public static final Option HTTPS_TRUST_STORE_PASSWORD = new OptionBuilder<>("https-trust-store-password", String.class)
|
||||
public static final Option<String> HTTPS_TRUST_STORE_PASSWORD = new OptionBuilder<>("https-trust-store-password", String.class)
|
||||
.category(OptionCategory.HTTP)
|
||||
.description("The password of the trust store file.")
|
||||
.deprecated("Use the System Truststore instead, see the docs for details.")
|
||||
|
|
|
@ -30,7 +30,7 @@ public class LoggingOptions {
|
|||
.toList();
|
||||
}
|
||||
|
||||
public static final Option LOG = new OptionBuilder("log", List.class, Handler.class)
|
||||
public static final Option<List> LOG = new OptionBuilder("log", List.class, Handler.class)
|
||||
.category(OptionCategory.LOGGING)
|
||||
.description("Enable one or more log handlers in a comma-separated list.")
|
||||
.expectedValues(() -> getAvailableHandlerNames())
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.keycloak.config;
|
|||
|
||||
public class MetricsOptions {
|
||||
|
||||
public static final Option METRICS_ENABLED = new OptionBuilder<>("metrics-enabled", Boolean.class)
|
||||
public static final Option<Boolean> METRICS_ENABLED = new OptionBuilder<>("metrics-enabled", Boolean.class)
|
||||
.category(OptionCategory.METRICS)
|
||||
.description("If the server should expose metrics. If enabled, metrics are available at the '/metrics' endpoint.")
|
||||
.buildTime(true)
|
||||
|
|
|
@ -466,7 +466,7 @@ class KeycloakProcessor {
|
|||
Map<String, String> configProperties = dbConfig.getDefaultDatasource().getConfigProperties();
|
||||
|
||||
for (Entry<String, String> dbConfigProperty : configProperties.entrySet()) {
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(dbConfigProperty.getKey());
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(dbConfigProperty.getKey());
|
||||
|
||||
if (mapper == null) {
|
||||
continue;
|
||||
|
@ -525,7 +525,7 @@ class KeycloakProcessor {
|
|||
}
|
||||
|
||||
private void putPersistedProperty(Properties properties, String name) {
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(name);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(name);
|
||||
ConfigValue value = null;
|
||||
|
||||
if (mapper == null) {
|
||||
|
|
|
@ -194,7 +194,7 @@ public final class Picocli {
|
|||
parseConfigArgs(new BiConsumer<String, String>() {
|
||||
@Override
|
||||
public void accept(String key, String value) {
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(key);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(key);
|
||||
|
||||
if (mapper != null && mapper.isBuildTime()) {
|
||||
return;
|
||||
|
@ -280,7 +280,7 @@ public final class Picocli {
|
|||
List<String> ignoredRunTime = new ArrayList<>();
|
||||
Set<String> deprecatedInUse = new HashSet<>();
|
||||
for (OptionCategory category : abstractCommand.getOptionCategories()) {
|
||||
List<PropertyMapper> mappers = new ArrayList<>();
|
||||
List<PropertyMapper<?>> mappers = new ArrayList<>();
|
||||
Optional.ofNullable(PropertyMappers.getRuntimeMappers().get(category)).ifPresent(mappers::addAll);
|
||||
Optional.ofNullable(PropertyMappers.getBuildTimeMappers().get(category)).ifPresent(mappers::addAll);
|
||||
for (PropertyMapper<?> mapper : mappers) {
|
||||
|
@ -388,7 +388,7 @@ public final class Picocli {
|
|||
// compare only the relevant options for this command, as not all options might be set for this command
|
||||
if (cmdCommand.getCommand() instanceof AbstractCommand) {
|
||||
AbstractCommand abstractCommand = cmdCommand.getCommand();
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(propertyName);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(propertyName);
|
||||
if (mapper != null) {
|
||||
if (!abstractCommand.getOptionCategories().contains(mapper.getCategory())) {
|
||||
continue;
|
||||
|
@ -397,7 +397,7 @@ public final class Picocli {
|
|||
}
|
||||
|
||||
if (runtimeValue == null && isNotBlank(persistedValue)) {
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(propertyName);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(propertyName);
|
||||
|
||||
if (mapper != null && persistedValue.equals(mapper.getDefaultValue().map(Object::toString).orElse(null))) {
|
||||
// same as default
|
||||
|
@ -551,16 +551,16 @@ public final class Picocli {
|
|||
}
|
||||
|
||||
private static void addOptionsToCli(CommandLine commandLine, boolean includeBuildTime, boolean includeRuntime) {
|
||||
Map<OptionCategory, List<PropertyMapper>> mappers = new EnumMap<>(OptionCategory.class);
|
||||
Map<OptionCategory, List<PropertyMapper<?>>> mappers = new EnumMap<>(OptionCategory.class);
|
||||
|
||||
if (includeRuntime) {
|
||||
mappers.putAll(PropertyMappers.getRuntimeMappers());
|
||||
}
|
||||
|
||||
if (includeBuildTime) {
|
||||
for (Map.Entry<OptionCategory, List<PropertyMapper>> entry : PropertyMappers.getBuildTimeMappers()
|
||||
for (Map.Entry<OptionCategory, List<PropertyMapper<?>>> entry : PropertyMappers.getBuildTimeMappers()
|
||||
.entrySet()) {
|
||||
List<PropertyMapper> result = new ArrayList<>(mappers.getOrDefault(entry.getKey(), Collections.emptyList()));
|
||||
List<PropertyMapper<?>> result = new ArrayList<>(mappers.getOrDefault(entry.getKey(), Collections.emptyList()));
|
||||
|
||||
result.addAll(entry.getValue());
|
||||
|
||||
|
@ -571,10 +571,10 @@ public final class Picocli {
|
|||
addMappedOptionsToArgGroups(commandLine, mappers);
|
||||
}
|
||||
|
||||
private static void addMappedOptionsToArgGroups(CommandLine commandLine, Map<OptionCategory, List<PropertyMapper>> propertyMappers) {
|
||||
private static void addMappedOptionsToArgGroups(CommandLine commandLine, Map<OptionCategory, List<PropertyMapper<?>>> propertyMappers) {
|
||||
CommandSpec cSpec = commandLine.getCommandSpec();
|
||||
for(OptionCategory category : ((AbstractCommand) commandLine.getCommand()).getOptionCategories()) {
|
||||
List<PropertyMapper> mappersInCategory = propertyMappers.get(category);
|
||||
List<PropertyMapper<?>> mappersInCategory = propertyMappers.get(category);
|
||||
|
||||
if (mappersInCategory == null) {
|
||||
//picocli raises an exception when an ArgGroup is empty, so ignore it when no mappings found for a category.
|
||||
|
@ -586,7 +586,7 @@ public final class Picocli {
|
|||
.order(category.getOrder())
|
||||
.validate(false);
|
||||
|
||||
for (PropertyMapper mapper: mappersInCategory) {
|
||||
for (PropertyMapper<?> mapper: mappersInCategory) {
|
||||
String name = mapper.getCliFormat();
|
||||
String description = mapper.getDescription();
|
||||
|
||||
|
@ -725,7 +725,7 @@ public final class Picocli {
|
|||
|
||||
private static void checkChangesInBuildOptionsDuringAutoBuild() {
|
||||
if (Configuration.isOptimized()) {
|
||||
List<PropertyMapper> buildOptions = stream(Configuration.getPropertyNames(true).spliterator(), false)
|
||||
List<PropertyMapper<?>> buildOptions = stream(Configuration.getPropertyNames(true).spliterator(), false)
|
||||
.sorted()
|
||||
.map(PropertyMappers::getMapper)
|
||||
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||
|
@ -736,7 +736,7 @@ public final class Picocli {
|
|||
|
||||
StringBuilder options = new StringBuilder();
|
||||
|
||||
for (PropertyMapper mapper : buildOptions) {
|
||||
for (PropertyMapper<?> mapper : buildOptions) {
|
||||
String newValue = ofNullable(getCurrentBuiltTimeProperty(mapper.getFrom()))
|
||||
.map(ConfigValue::getValue)
|
||||
.orElse("<unset>");
|
||||
|
|
|
@ -142,7 +142,7 @@ public final class ShowConfig extends AbstractCommand implements Runnable {
|
|||
value = configValue.getValue();
|
||||
}
|
||||
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(property);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(property);
|
||||
|
||||
if (mapper != null && mapper.isRunTime()) {
|
||||
value = getRuntimeProperty(property).orElse(value);
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ConfigArgsConfigSource extends PropertiesConfigSource {
|
|||
|
||||
properties.put(key, value);
|
||||
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(key);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(key);
|
||||
|
||||
if (mapper != null) {
|
||||
String to = mapper.getTo();
|
||||
|
|
|
@ -130,7 +130,7 @@ public final class Configuration {
|
|||
}
|
||||
|
||||
public static String getMappedPropertyName(String key) {
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(key);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(key);
|
||||
|
||||
if (mapper == null) {
|
||||
return key;
|
||||
|
|
|
@ -44,7 +44,7 @@ public class KcEnvConfigSource extends EnvConfigSource {
|
|||
if (key.startsWith(kcPrefix)) {
|
||||
properties.put(key, value);
|
||||
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(key);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(key);
|
||||
|
||||
if (mapper != null) {
|
||||
String to = mapper.getTo();
|
||||
|
|
|
@ -144,7 +144,7 @@ public class KeycloakPropertiesConfigSource extends AbstractLocationConfigSource
|
|||
Map<String, String> result = new HashMap<>(properties.size());
|
||||
properties.keySet().forEach(k -> {
|
||||
String key = transformKey(k);
|
||||
PropertyMapper mapper = PropertyMappers.getMapper(key);
|
||||
PropertyMapper<?> mapper = PropertyMappers.getMapper(key);
|
||||
|
||||
//TODO: remove explicit checks for spi and feature options once we have proper support in our config mappers
|
||||
if (mapper != null
|
||||
|
|
|
@ -16,7 +16,7 @@ final class CachingPropertyMappers {
|
|||
private CachingPropertyMappers() {
|
||||
}
|
||||
|
||||
public static PropertyMapper[] getClusteringPropertyMappers() {
|
||||
public static PropertyMapper<?>[] getClusteringPropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(CachingOptions.CACHE)
|
||||
.paramLabel("type")
|
||||
|
|
|
@ -14,7 +14,7 @@ final class ClassLoaderPropertyMappers {
|
|||
|
||||
private ClassLoaderPropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getMappers() {
|
||||
public static PropertyMapper<?>[] getMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(ClassLoaderOptions.IGNORE_ARTIFACTS)
|
||||
.to(QUARKUS_REMOVED_ARTIFACTS_PROPERTY)
|
||||
|
|
|
@ -18,7 +18,7 @@ final class ConfigKeystorePropertyMappers {
|
|||
private ConfigKeystorePropertyMappers() {
|
||||
}
|
||||
|
||||
public static PropertyMapper[] getConfigKeystorePropertyMappers() {
|
||||
public static PropertyMapper<?>[] getConfigKeystorePropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(ConfigKeystoreOptions.CONFIG_KEYSTORE)
|
||||
.to(SMALLRYE_KEYSTORE_PATH)
|
||||
|
|
|
@ -18,7 +18,7 @@ final class DatabasePropertyMappers {
|
|||
|
||||
private DatabasePropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getDatabasePropertyMappers() {
|
||||
public static PropertyMapper<?>[] getDatabasePropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(DatabaseOptions.DB_DIALECT)
|
||||
.mapFrom("db")
|
||||
|
|
|
@ -15,12 +15,12 @@ import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper.
|
|||
|
||||
public final class FeaturePropertyMappers {
|
||||
|
||||
private static Pattern VERSIONED_PATTERN = Pattern.compile("([^:]+):v(\\d+)");
|
||||
private static final Pattern VERSIONED_PATTERN = Pattern.compile("([^:]+):v(\\d+)");
|
||||
|
||||
private FeaturePropertyMappers() {
|
||||
}
|
||||
|
||||
public static PropertyMapper[] getMappers() {
|
||||
public static PropertyMapper<?>[] getMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(FeatureOptions.FEATURES)
|
||||
.paramLabel("feature")
|
||||
|
@ -57,7 +57,7 @@ public final class FeaturePropertyMappers {
|
|||
feature, FeatureOptions.getFeatureValues(false)));
|
||||
}
|
||||
int version = Integer.parseInt(matcher.group(2));
|
||||
if (!featureVersions.stream().anyMatch(f -> f.getVersion() == version)) {
|
||||
if (featureVersions.stream().noneMatch(f -> f.getVersion() == version)) {
|
||||
throw new PropertyException(
|
||||
String.format("%s has an unrecognized feature version, it should be one of %s", feature,
|
||||
featureVersions.stream().map(Feature::getVersion).map(String::valueOf).collect(Collectors.toList())));
|
||||
|
|
|
@ -9,7 +9,7 @@ final class HealthPropertyMappers {
|
|||
|
||||
private HealthPropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getHealthPropertyMappers() {
|
||||
public static PropertyMapper<?>[] getHealthPropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(HealthOptions.HEALTH_ENABLED)
|
||||
.to("quarkus.health.extensions.enabled")
|
||||
|
|
|
@ -8,7 +8,7 @@ final class HostnamePropertyMappers {
|
|||
|
||||
private HostnamePropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getHostnamePropertyMappers() {
|
||||
public static PropertyMapper<?>[] getHostnamePropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(HostnameOptions.HOSTNAME)
|
||||
.to("kc.spi-hostname-default-hostname")
|
||||
|
|
|
@ -27,7 +27,7 @@ final class HttpPropertyMappers {
|
|||
|
||||
private HttpPropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getHttpPropertyMappers() {
|
||||
public static PropertyMapper<?>[] getHttpPropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(HttpOptions.HTTP_ENABLED)
|
||||
.to("quarkus.http.insecure-requests")
|
||||
|
@ -142,14 +142,14 @@ final class HttpPropertyMappers {
|
|||
return of(enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
private static String getDefaultKeystorePathValue() {
|
||||
private static File getDefaultKeystorePathValue() {
|
||||
String homeDir = Environment.getHomeDir();
|
||||
|
||||
if (homeDir != null) {
|
||||
File file = Paths.get(homeDir, "conf", "server.keystore").toFile();
|
||||
|
||||
if (file.exists()) {
|
||||
return file.getAbsolutePath();
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ public final class LoggingPropertyMappers {
|
|||
|
||||
private LoggingPropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getMappers() {
|
||||
PropertyMapper[] defaultMappers = new PropertyMapper[]{
|
||||
public static PropertyMapper<?>[] getMappers() {
|
||||
PropertyMapper<?>[] defaultMappers = new PropertyMapper[]{
|
||||
fromOption(LoggingOptions.LOG)
|
||||
.paramLabel("<handler>")
|
||||
.build(),
|
||||
|
@ -74,7 +74,7 @@ public final class LoggingPropertyMappers {
|
|||
return GELF_ACTIVATED ? ArrayUtils.addAll(defaultMappers, getGelfMappers()) : defaultMappers;
|
||||
}
|
||||
|
||||
public static PropertyMapper[] getGelfMappers() {
|
||||
public static PropertyMapper<?>[] getGelfMappers() {
|
||||
return new PropertyMapper[]{
|
||||
fromOption(LoggingOptions.LOG_GELF_ENABLED)
|
||||
.mapFrom("log")
|
||||
|
|
|
@ -9,7 +9,7 @@ final class MetricsPropertyMappers {
|
|||
|
||||
private MetricsPropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getMetricsPropertyMappers() {
|
||||
public static PropertyMapper<?>[] getMetricsPropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(MetricsOptions.METRICS_ENABLED)
|
||||
.to("quarkus.micrometer.enabled")
|
||||
|
|
|
@ -45,8 +45,8 @@ import org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider;
|
|||
|
||||
public class PropertyMapper<T> {
|
||||
|
||||
static PropertyMapper IDENTITY = new PropertyMapper(
|
||||
new OptionBuilder<String>(null, String.class).build(),
|
||||
static PropertyMapper<?> IDENTITY = new PropertyMapper<>(
|
||||
new OptionBuilder<>(null, String.class).build(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
@ -116,7 +116,7 @@ public class PropertyMapper<T> {
|
|||
|
||||
if (parentValue == null) {
|
||||
// parent value not explicitly set, try to resolve the default value set to the parent property
|
||||
PropertyMapper parentMapper = PropertyMappers.getMapper(parentKey);
|
||||
PropertyMapper<?> parentMapper = PropertyMappers.getMapper(parentKey);
|
||||
|
||||
if (parentMapper != null && parentMapper.getDefaultValue().isPresent()) {
|
||||
parentValue = ConfigValue.builder().withValue(parentMapper.getDefaultValue().get().toString()).build();
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class PropertyMappers {
|
|||
}
|
||||
|
||||
public static ConfigValue getValue(ConfigSourceInterceptorContext context, String name) {
|
||||
PropertyMapper mapper = MAPPERS.getOrDefault(name, PropertyMapper.IDENTITY);
|
||||
PropertyMapper<?> mapper = MAPPERS.getOrDefault(name, PropertyMapper.IDENTITY);
|
||||
return mapper.getConfigValue(name, context);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public final class PropertyMappers {
|
|||
return true;
|
||||
}
|
||||
|
||||
PropertyMapper mapper = MAPPERS.get(name);
|
||||
PropertyMapper<?> mapper = MAPPERS.get(name);
|
||||
boolean isBuildTimeProperty = mapper == null ? false : mapper.isBuildTime();
|
||||
|
||||
return isBuildTimeProperty
|
||||
|
@ -75,17 +75,17 @@ public final class PropertyMappers {
|
|||
return name.startsWith("kc.features");
|
||||
}
|
||||
|
||||
public static Map<OptionCategory, List<PropertyMapper>> getRuntimeMappers() {
|
||||
public static Map<OptionCategory, List<PropertyMapper<?>>> getRuntimeMappers() {
|
||||
return MAPPERS.getRuntimeMappers();
|
||||
}
|
||||
|
||||
public static Map<OptionCategory, List<PropertyMapper>> getBuildTimeMappers() {
|
||||
public static Map<OptionCategory, List<PropertyMapper<?>>> getBuildTimeMappers() {
|
||||
return MAPPERS.getBuildTimeMappers();
|
||||
}
|
||||
|
||||
public static String formatValue(String property, String value) {
|
||||
property = removeProfilePrefixIfNeeded(property);
|
||||
PropertyMapper mapper = getMapper(property);
|
||||
PropertyMapper<?> mapper = getMapper(property);
|
||||
|
||||
if (mapper != null && mapper.isMask()) {
|
||||
return VALUE_MASK;
|
||||
|
@ -102,28 +102,28 @@ public final class PropertyMappers {
|
|||
return property;
|
||||
}
|
||||
|
||||
public static PropertyMapper getMapper(String property) {
|
||||
public static PropertyMapper<?> getMapper(String property) {
|
||||
if (property.startsWith("%")) {
|
||||
return MAPPERS.get(property.substring(property.indexOf('.') + 1));
|
||||
}
|
||||
return MAPPERS.get(property);
|
||||
}
|
||||
|
||||
public static Collection<PropertyMapper> getMappers() {
|
||||
public static Collection<PropertyMapper<?>> getMappers() {
|
||||
return MAPPERS.values();
|
||||
}
|
||||
|
||||
public static boolean isSupported(PropertyMapper mapper) {
|
||||
public static boolean isSupported(PropertyMapper<?> mapper) {
|
||||
return mapper.getCategory().getSupportLevel().equals(ConfigSupportLevel.SUPPORTED);
|
||||
}
|
||||
|
||||
private static class MappersConfig extends HashMap<String, PropertyMapper> {
|
||||
private static class MappersConfig extends HashMap<String, PropertyMapper<?>> {
|
||||
|
||||
private Map<OptionCategory, List<PropertyMapper>> buildTimeMappers = new EnumMap<>(OptionCategory.class);
|
||||
private Map<OptionCategory, List<PropertyMapper>> runtimeTimeMappers = new EnumMap<>(OptionCategory.class);
|
||||
private Map<OptionCategory, List<PropertyMapper<?>>> buildTimeMappers = new EnumMap<>(OptionCategory.class);
|
||||
private Map<OptionCategory, List<PropertyMapper<?>>> runtimeTimeMappers = new EnumMap<>(OptionCategory.class);
|
||||
|
||||
public void addAll(PropertyMapper[] mappers) {
|
||||
for (PropertyMapper mapper : mappers) {
|
||||
public void addAll(PropertyMapper<?>[] mappers) {
|
||||
for (PropertyMapper<?> mapper : mappers) {
|
||||
super.put(mapper.getTo(), mapper);
|
||||
super.put(mapper.getFrom(), mapper);
|
||||
super.put(mapper.getCliFormat(), mapper);
|
||||
|
@ -137,29 +137,29 @@ public final class PropertyMappers {
|
|||
}
|
||||
}
|
||||
|
||||
private void addMapperByStage(PropertyMapper mapper, Map<OptionCategory, List<PropertyMapper>> mappers) {
|
||||
private void addMapperByStage(PropertyMapper<?> mapper, Map<OptionCategory, List<PropertyMapper<?>>> mappers) {
|
||||
mappers.computeIfAbsent(mapper.getCategory(),
|
||||
new Function<OptionCategory, List<PropertyMapper>>() {
|
||||
new Function<OptionCategory, List<PropertyMapper<?>>>() {
|
||||
@Override
|
||||
public List<PropertyMapper> apply(OptionCategory c) {
|
||||
public List<PropertyMapper<?>> apply(OptionCategory c) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}).add(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyMapper put(String key, PropertyMapper value) {
|
||||
public PropertyMapper<?> put(String key, PropertyMapper<?> value) {
|
||||
if (containsKey(key)) {
|
||||
throw new IllegalArgumentException("Duplicated mapper for key [" + key + "]");
|
||||
}
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
public Map<OptionCategory, List<PropertyMapper>> getRuntimeMappers() {
|
||||
public Map<OptionCategory, List<PropertyMapper<?>>> getRuntimeMappers() {
|
||||
return runtimeTimeMappers;
|
||||
}
|
||||
|
||||
public Map<OptionCategory, List<PropertyMapper>> getBuildTimeMappers() {
|
||||
public Map<OptionCategory, List<PropertyMapper<?>>> getBuildTimeMappers() {
|
||||
return buildTimeMappers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class ProxyPropertyMappers {
|
|||
|
||||
private ProxyPropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getProxyPropertyMappers() {
|
||||
public static PropertyMapper<?>[] getProxyPropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(ProxyOptions.PROXY_HEADERS)
|
||||
.to("quarkus.http.proxy.proxy-address-forwarding")
|
||||
|
|
|
@ -17,7 +17,7 @@ final class SecurityPropertyMappers {
|
|||
private SecurityPropertyMappers() {
|
||||
}
|
||||
|
||||
public static PropertyMapper[] getMappers() {
|
||||
public static PropertyMapper<?>[] getMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(SecurityOptions.FIPS_MODE).transformer(SecurityPropertyMappers::resolveFipsMode)
|
||||
.paramLabel("mode")
|
||||
|
|
|
@ -15,7 +15,7 @@ public class TransactionPropertyMappers {
|
|||
|
||||
private TransactionPropertyMappers(){}
|
||||
|
||||
public static PropertyMapper[] getTransactionPropertyMappers() {
|
||||
public static PropertyMapper<?>[] getTransactionPropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(TransactionOptions.TRANSACTION_XA_ENABLED)
|
||||
.to(QUARKUS_TXPROP_TARGET)
|
||||
|
|
|
@ -6,7 +6,7 @@ import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper.
|
|||
|
||||
public class TruststorePropertyMappers {
|
||||
|
||||
public static PropertyMapper[] getMappers() {
|
||||
public static PropertyMapper<?>[] getMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(TruststoreOptions.TRUSTSTORE_PATHS)
|
||||
.paramLabel(TruststoreOptions.TRUSTSTORE_PATHS.getKey())
|
||||
|
|
|
@ -9,7 +9,7 @@ final class VaultPropertyMappers {
|
|||
private VaultPropertyMappers() {
|
||||
}
|
||||
|
||||
public static PropertyMapper[] getVaultPropertyMappers() {
|
||||
public static PropertyMapper<?>[] getVaultPropertyMappers() {
|
||||
return new PropertyMapper[] {
|
||||
fromOption(VaultOptions.VAULT)
|
||||
.paramLabel("provider")
|
||||
|
|
|
@ -134,8 +134,8 @@ public final class RawKeycloakDistribution implements KeycloakDistribution {
|
|||
throw new RuntimeException("Failed to start the server", cause);
|
||||
} finally {
|
||||
if (arguments.contains(Build.NAME) && removeBuildOptionsAfterBuild) {
|
||||
for (List<PropertyMapper> mappers : PropertyMappers.getBuildTimeMappers().values()) {
|
||||
for (PropertyMapper mapper : mappers) {
|
||||
for (List<PropertyMapper<?>> mappers : PropertyMappers.getBuildTimeMappers().values()) {
|
||||
for (PropertyMapper<?> mapper : mappers) {
|
||||
removeProperty(mapper.getFrom().substring(3));
|
||||
}
|
||||
}
|
||||
|
@ -180,9 +180,9 @@ public final class RawKeycloakDistribution implements KeycloakDistribution {
|
|||
return;
|
||||
}
|
||||
|
||||
CompletableFuture allProcesses = CompletableFuture.completedFuture(null);
|
||||
CompletableFuture<?> allProcesses = CompletableFuture.completedFuture(null);
|
||||
|
||||
for (ProcessHandle process : parent.descendants().collect(Collectors.toList())) {
|
||||
for (ProcessHandle process : parent.descendants().toList()) {
|
||||
if (force) {
|
||||
process.destroyForcibly();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue