or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration-encryption.mdconfiguration-loading.mdconfiguration-management.mdconfiguration-watching.mdindex.mdproperty-source-location.md
tile.json

tessl/maven-org-apereo-cas--cas-server-core-configuration-api

Apereo CAS Core Configuration API providing configuration management and property source location capabilities for the Central Authentication Service

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.apereo.cas/cas-server-core-configuration-api@7.2.x

To install, run

npx @tessl/cli install tessl/maven-org-apereo-cas--cas-server-core-configuration-api@7.2.0

index.mddocs/

CAS Server Core Configuration API

A 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.

Package Information

  • Package Name: cas-server-core-configuration-api
  • Group ID: org.apereo.cas
  • Language: Java
  • Version: 7.2.4
  • License: Apache-2.0
  • Installation: Add to Maven dependencies:
<dependency>
    <groupId>org.apereo.cas</groupId>
    <artifactId>cas-server-core-configuration-api</artifactId>
    <version>7.2.4</version>
</dependency>

Core Imports

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;

Basic Usage

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
}

Architecture

The CAS Configuration API is built around several key architectural components:

  • Property Source Locators: Primary interfaces for discovering and loading configuration from various sources with defined precedence
  • Configuration Loaders: Pluggable mechanism for reading different configuration file formats (YAML, Properties) using ServiceLoader pattern
  • Encryption Support: Jasypt-based cipher executors for encrypting/decrypting sensitive configuration values
  • Configuration Management: Environment managers and validators for runtime configuration handling
  • File Watching: Services that monitor configuration files for changes and publish events

This architecture enables CAS to support flexible configuration deployment patterns including standalone files, directory-based configurations, embedded classpath resources, and Docker secrets integration.

Capabilities

Property Source Location

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();
}

Property Source Location

Configuration File Loading

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);
}

Configuration Loading

Configuration Encryption

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);
}

Configuration Encryption

Configuration Management

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);
}

Configuration Management

Configuration File Watching

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();
}

Configuration Watching

Utility Classes

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);
}

Constants and Configuration Properties

// 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";

Types

// 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();
}