All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apereo.cas.services.YamlServiceRegistry Maven / Gradle / Ivy

There is a newer version: 7.1.0
Show newest version
package org.apereo.cas.services;

import lombok.extern.slf4j.Slf4j;
import org.apereo.cas.services.replication.RegisteredServiceReplicationStrategy;
import org.apereo.cas.services.resource.AbstractResourceBasedServiceRegistry;
import org.apereo.cas.services.resource.RegisteredServiceResourceNamingStrategy;
import org.apereo.cas.services.util.RegisteredServiceYamlSerializer;
import org.apereo.cas.util.CollectionUtils;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.io.Resource;
import java.nio.file.Path;
import lombok.Getter;

/**
 * Implementation of {@code ServiceRegistry} that reads services definition from YAML
 * configuration file at the Spring Application Context initialization time. YAML files are
 * expected to be found inside a directory location and this registry will recursively look through
 * the directory structure to find relevant YAML files. Files are expected to have the
 * {@value YamlServiceRegistry#FILE_EXTENSION} extension. An example of the YAML file is included here:
 * 
 * --- !<org.apereo.cas.services.RegexRegisteredService>
 * serviceId: "testId"
 * name: "YAML"
 * id: 1000
 * description: "description"
 * attributeReleasePolicy: !<org.apereo.cas.services.ReturnAllAttributeReleasePolicy>
 * accessStrategy: !<org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy>
 * enabled: true
 * ssoEnabled: true
 * 
* * @author Dmitriy Kopylenko * @author Misagh Moayyed * @since 5.0.0 */ @Slf4j @Getter public class YamlServiceRegistry extends AbstractResourceBasedServiceRegistry { /** * File extension of registered service YAML files. */ private static final String FILE_EXTENSION = "yml"; /** * Instantiates a new YAML service registry dao. * Sets the path to the directory where YAML service registry entries are * stored. Uses the {@link RegisteredServiceYamlSerializer} by default. * * @param configDirectory the config directory where service registry files can be found. * @param enableWatcher the enable watcher * @param eventPublisher the event publisher * @param registeredServiceReplicationStrategy the registered service replication strategy * @param resourceNamingStrategy the registered service naming strategy */ public YamlServiceRegistry(final Path configDirectory, final boolean enableWatcher, final ApplicationEventPublisher eventPublisher, final RegisteredServiceReplicationStrategy registeredServiceReplicationStrategy, final RegisteredServiceResourceNamingStrategy resourceNamingStrategy) { super(configDirectory, new RegisteredServiceYamlSerializer(), enableWatcher, eventPublisher, registeredServiceReplicationStrategy, resourceNamingStrategy); } /** * Instantiates a new YAML service registry dao. * Sets the path to the directory where YAML service registry entries are * stored. Uses the {@link RegisteredServiceYamlSerializer} by default. * * @param configDirectory the config directory where service registry files can be found. * @param enableWatcher the enable watcher * @param eventPublisher the event publisher * @param registeredServiceReplicationStrategy the registered service replication strategy * @param resourceNamingStrategy the registered service naming strategy * @throws Exception the IO exception */ public YamlServiceRegistry(final Resource configDirectory, final boolean enableWatcher, final ApplicationEventPublisher eventPublisher, final RegisteredServiceReplicationStrategy registeredServiceReplicationStrategy, final RegisteredServiceResourceNamingStrategy resourceNamingStrategy) throws Exception { super(configDirectory, CollectionUtils.wrapList(new RegisteredServiceYamlSerializer()), enableWatcher, eventPublisher, registeredServiceReplicationStrategy, resourceNamingStrategy); } @Override protected String getExtension() { return FILE_EXTENSION; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy