Apereo CAS Core Configuration API providing configuration management and property source location capabilities for the Central Authentication Service
—
Runtime configuration management including property rebinding, environment configuration, and validation of configuration properties. The management system provides mechanisms for dynamic configuration updates and comprehensive validation reporting.
Primary manager for handling configuration property rebinding and environment setup during runtime configuration changes.
public class CasConfigurationPropertiesEnvironmentManager {
/**
* Constructor with configuration properties binding post processor.
*
* @param binder the configuration properties binding post processor
*/
public CasConfigurationPropertiesEnvironmentManager(ConfigurationPropertiesBindingPostProcessor binder);
/**
* Rebind CAS configuration properties using instance binder.
*
* @param applicationContext the application context
* @return the application context
*/
public ApplicationContext rebindCasConfigurationProperties(ApplicationContext applicationContext);
}public class CasConfigurationPropertiesEnvironmentManager {
/**
* Rebind CAS configuration properties using provided binder.
*
* @param binder the configuration properties binding post processor
* @param applicationContext the application context
* @return the application context
*/
public static ApplicationContext rebindCasConfigurationProperties(
ConfigurationPropertiesBindingPostProcessor binder,
ApplicationContext applicationContext);
/**
* Configure environment property sources with native composite source.
*
* @param environment the configurable environment
* @return composite property source with native sources
*/
public static CompositePropertySource configureEnvironmentPropertySources(ConfigurableEnvironment environment);
}Comprehensive validation system for CAS configuration properties that reports unbound and invalid property configurations.
public class CasConfigurationPropertiesValidator {
/**
* Constructor with application context.
*
* @param applicationContext the configurable application context
*/
public CasConfigurationPropertiesValidator(ConfigurableApplicationContext applicationContext);
/**
* Validate CAS configuration properties and return validation results.
*
* @return list of validation error messages
*/
public List<String> validate();
}import org.apereo.cas.configuration.CasConfigurationPropertiesEnvironmentManager;
import org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor;
// Get the binding post processor from application context
ConfigurationPropertiesBindingPostProcessor binder =
applicationContext.getBean(ConfigurationPropertiesBindingPostProcessor.class);
// Create environment manager
CasConfigurationPropertiesEnvironmentManager manager =
new CasConfigurationPropertiesEnvironmentManager(binder);
// Rebind configuration properties after changes
ApplicationContext updatedContext = manager.rebindCasConfigurationProperties(applicationContext);// Static method approach for one-time rebinding
ApplicationContext updatedContext = CasConfigurationPropertiesEnvironmentManager
.rebindCasConfigurationProperties(binder, applicationContext);
// Verify rebinding was successful
CasConfigurationProperties config = updatedContext.getBean(CasConfigurationProperties.class);
System.out.println("Configuration rebound: " + config.getClass().getName());import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.CompositePropertySource;
// Configure native property sources for environment
ConfigurableEnvironment environment = (ConfigurableEnvironment) applicationContext.getEnvironment();
CompositePropertySource nativeSource = CasConfigurationPropertiesEnvironmentManager
.configureEnvironmentPropertySources(environment);
// Native source includes:
// - commandLineArgs (if present)
// - systemProperties
// - systemEnvironmentimport org.apereo.cas.configuration.CasConfigurationPropertiesValidator;
// Create validator with application context
CasConfigurationPropertiesValidator validator =
new CasConfigurationPropertiesValidator(applicationContext);
// Validate all CAS configuration properties
List<String> validationResults = validator.validate();
if (validationResults.isEmpty()) {
System.out.println("Configuration validation passed successfully");
} else {
System.err.println("Configuration validation failed:");
validationResults.forEach(System.err::println);
}import org.apereo.cas.configuration.CasConfigurationPropertiesEnvironmentManager;
import org.apereo.cas.configuration.CasConfigurationPropertiesValidator;
// Step 1: Configure environment property sources
ConfigurableEnvironment environment = (ConfigurableEnvironment) applicationContext.getEnvironment();
CompositePropertySource nativeSource = CasConfigurationPropertiesEnvironmentManager
.configureEnvironmentPropertySources(environment);
// Step 2: Rebind configuration properties
ConfigurationPropertiesBindingPostProcessor binder =
applicationContext.getBean(ConfigurationPropertiesBindingPostProcessor.class);
ApplicationContext updatedContext = CasConfigurationPropertiesEnvironmentManager
.rebindCasConfigurationProperties(binder, applicationContext);
// Step 3: Validate configuration
CasConfigurationPropertiesValidator validator =
new CasConfigurationPropertiesValidator((ConfigurableApplicationContext) updatedContext);
List<String> validationResults = validator.validate();
// Step 4: Handle validation results
if (!validationResults.isEmpty()) {
String errorMessage = String.join("\n", validationResults);
System.err.println("Configuration validation errors:\n" + errorMessage);
// Handle validation failures appropriately
}CasConfigurationProperties bean from application contextCasConfigurationProperties.PREFIX and class namepostProcessBeforeInitialization on the configuration beanThe native composite property source includes these sources in order of precedence:
commandLineArgs) - Highest precedencesystemProperties) - JVM system propertiessystemEnvironment) - Operating system environment variablesCasConfigurationProperties in application contextConfigurationPropertiesBean wrapperNoUnboundElementsBindHandlerValidation errors include detailed information about:
/**
* Default bean name for configuration properties environment manager.
*/
String BEAN_NAME = "configurationPropertiesEnvironmentManager";The rebinding process includes comprehensive error handling:
The validation system provides detailed error reporting:
Environment configuration handles missing property sources:
FunctionUtils.doIfNotNull for safe null handlingInstall with Tessl CLI
npx tessl i tessl/maven-org-apereo-cas--cas-server-core-configuration-api