Apereo CAS Core Configuration API providing configuration management and property source location capabilities for the Central Authentication Service
npx @tessl/cli install tessl/maven-org-apereo-cas--cas-server-core-configuration-api@7.2.0A comprehensive Java library providing configuration management and property source location capabilities for the Central Authentication Service (CAS). This module serves as the foundational component for dynamically locating, loading, validating, and decrypting configuration properties from various sources including files, environment variables, and external systems.
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-configuration-api</artifactId>
<version>7.2.4</version>
</dependency>import org.apereo.cas.configuration.api.CasConfigurationPropertiesSourceLocator;
import org.apereo.cas.configuration.CasConfigurationPropertiesEnvironmentManager;
import org.apereo.cas.configuration.CasConfigurationWatchService;
import org.apereo.cas.configuration.support.CasConfigurationJasyptCipherExecutor;For configuration loaders:
import org.apereo.cas.configuration.loader.CasConfigurationPropertiesLoader;
import org.apereo.cas.configuration.loader.YamlConfigurationPropertiesLoader;
import org.apereo.cas.configuration.loader.SimpleConfigurationPropertiesLoader;import org.apereo.cas.configuration.api.CasConfigurationPropertiesSourceLocator;
import org.apereo.cas.configuration.DefaultCasConfigurationPropertiesSourceLocator;
import org.apereo.cas.configuration.support.CasConfigurationJasyptCipherExecutor;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader;
// Create environment and resource loader
Environment environment = new StandardEnvironment();
ResourceLoader resourceLoader = new DefaultResourceLoader();
// Create cipher executor for encryption support
CasConfigurationJasyptCipherExecutor cipherExecutor =
new CasConfigurationJasyptCipherExecutor(environment);
// Create property source locator
CasConfigurationPropertiesSourceLocator locator =
new DefaultCasConfigurationPropertiesSourceLocator(cipherExecutor);
// Locate configuration property sources
Optional<PropertySource<?>> propertySource = locator.locate(environment, resourceLoader);
if (propertySource.isPresent()) {
System.out.println("Configuration loaded successfully");
// Use the property source with Spring environment
}The CAS Configuration API is built around several key architectural components:
This architecture enables CAS to support flexible configuration deployment patterns including standalone files, directory-based configurations, embedded classpath resources, and Docker secrets integration.
Core functionality for locating and loading configuration properties from multiple sources with defined precedence. Supports standalone files, configuration directories, classpath resources, system properties, environment variables, and Docker secrets.
public interface CasConfigurationPropertiesSourceLocator {
Optional<PropertySource<?>> locate(Environment environment, ResourceLoader resourceLoader);
// Static utility methods
static File getStandaloneProfileConfigurationDirectory(Environment environment);
static File getStandaloneProfileConfigurationFile(Environment environment);
static String getApplicationName(Environment environment);
static String getConfigurationName(Environment environment);
static List<CasConfigurationPropertiesLoader> getConfigurationPropertiesLoaders();
}Pluggable configuration loading system supporting multiple file formats (YAML, Properties) with encryption/decryption capabilities and ServiceLoader-based extensibility.
public interface CasConfigurationPropertiesLoader extends NamedObject {
PropertySource load(Resource resource, Environment environment, String name,
CipherExecutor<String, String> configurationCipherExecutor);
boolean supports(Resource resource);
}Jasypt-based encryption and decryption support for sensitive configuration values with configurable algorithms, providers, and initialization vectors.
public class CasConfigurationJasyptCipherExecutor implements CipherExecutor<String, String> {
public CasConfigurationJasyptCipherExecutor(String algorithm, String password);
public CasConfigurationJasyptCipherExecutor(Environment environment);
public String encode(String value, Object[] parameters);
public String decode(String value, Object[] parameters);
public String encryptValue(String value);
public String decryptValue(String value);
// Static utility methods
static boolean isValueEncrypted(String value);
static String extractEncryptedValue(String value);
}Runtime configuration management including property rebinding, environment configuration, and validation of configuration properties.
public class CasConfigurationPropertiesEnvironmentManager {
public CasConfigurationPropertiesEnvironmentManager(ConfigurationPropertiesBindingPostProcessor binder);
public ApplicationContext rebindCasConfigurationProperties(ApplicationContext applicationContext);
// Static methods
static ApplicationContext rebindCasConfigurationProperties(
ConfigurationPropertiesBindingPostProcessor binder, ApplicationContext applicationContext);
static CompositePropertySource configureEnvironmentPropertySources(ConfigurableEnvironment environment);
}File system monitoring service that watches configuration files and directories for changes, automatically publishing configuration events when modifications are detected.
public class CasConfigurationWatchService implements Closeable, InitializingBean {
public CasConfigurationWatchService(ConfigurableApplicationContext applicationContext);
public void initialize();
public void close();
public void afterPropertiesSet();
}Core utility classes providing configuration-related helper functions and type conversion capabilities.
@UtilityClass
public final class CasCoreConfigurationUtils {
/**
* Load YAML properties from resources.
*
* @param resource the resources
* @return map of YAML properties
*/
static Map<String, Object> loadYamlProperties(Resource... resource);
}
public class CommaSeparatedStringToThrowablesConverter implements Converter<String, List<Class<? extends Throwable>>> {
/**
* Convert comma-separated class names to Throwable classes.
*
* @param source comma-separated string
* @return list of Throwable classes
*/
@Override
List<Class<? extends Throwable>> convert(String source);
}// Property source locator constants
String BOOTSTRAP_PROPERTY_LOCATOR_BEAN_NAME = "casCoreBootstrapPropertySourceLocator";
String PROPERTY_CAS_STANDALONE_CONFIGURATION_FILE = "cas.standalone.configuration-file";
String PROPERTY_CAS_STANDALONE_CONFIGURATION_DIRECTORY = "cas.standalone.configuration-directory";
// Default configuration directories
List<File> DEFAULT_CAS_CONFIG_DIRECTORIES = List.of(
new File("/etc/cas/config"),
new File("/opt/cas/config"),
new File("/var/cas/config")
);
// Configuration profiles
String PROFILE_STANDALONE = "standalone";
String PROFILE_NATIVE = "native";
String PROFILE_EMBEDDED = "embedded";
String PROFILE_NONE = "none";
// Encryption constants
String ENCRYPTED_VALUE_PREFIX = "{cas-cipher}";
String DEFAULT_SECRETS_DIR = "/run/secrets/";
String VAR_CAS_DOCKER_SECRETS_DIRECTORY = "CAS_DOCKER_SECRETS_DIRECTORY";
String VAR_CONTAINER = "CONTAINER";
// Environment manager bean name
String BEAN_NAME = "configurationPropertiesEnvironmentManager";// Jasypt encryption parameters enum
public enum JasyptEncryptionParameters {
ALGORITHM("cas.standalone.configuration-security.alg", "PBEWithMD5AndTripleDES"),
PROVIDER("cas.standalone.configuration-security.provider", null),
ITERATIONS("cas.standalone.configuration-security.iterations", null),
PASSWORD("cas.standalone.configuration-security.psw", null),
INITIALIZATION_VECTOR("cas.standalone.configuration-security.initialization-vector", null);
String getPropertyName();
String getDefaultValue();
}