Search in sources :

Example 6 with NoOpRegisteredServiceReplicationStrategy

use of org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy in project cas by apereo.

the class SamlRegisteredServiceTests method verifySavingSamlService.

@Test
public void verifySavingSamlService() throws Exception {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val registeredService = new SamlRegisteredService();
    registeredService.setName(SAML_SERVICE);
    registeredService.setServiceId("http://mmoayyed.unicon.net");
    registeredService.setMetadataLocation(METADATA_LOCATION);
    val dao = new JsonServiceRegistry(RESOURCE, WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
    dao.save(registeredService);
    dao.load();
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) Test(org.junit.jupiter.api.Test)

Example 7 with NoOpRegisteredServiceReplicationStrategy

use of org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy in project cas by apereo.

the class AbstractResourceBasedServiceRegistry method initializeRegistry.

private void initializeRegistry(final Path configDirectory, final Collection<StringSerializer<RegisteredService>> serializers, final RegisteredServiceReplicationStrategy registeredServiceReplicationStrategy, final RegisteredServiceResourceNamingStrategy resourceNamingStrategy, final WatcherService serviceRegistryConfigWatcher) {
    this.registeredServiceReplicationStrategy = ObjectUtils.defaultIfNull(registeredServiceReplicationStrategy, new NoOpRegisteredServiceReplicationStrategy());
    this.resourceNamingStrategy = ObjectUtils.defaultIfNull(resourceNamingStrategy, new DefaultRegisteredServiceResourceNamingStrategy());
    this.registeredServiceSerializers = serializers;
    this.serviceFileNamePattern = resourceNamingStrategy.buildNamingPattern(getExtensions());
    LOGGER.trace("Constructed service name file pattern [{}]", serviceFileNamePattern.pattern());
    this.serviceRegistryDirectory = configDirectory;
    val file = this.serviceRegistryDirectory.toFile();
    Assert.isTrue(file.exists(), this.serviceRegistryDirectory + " does not exist");
    Assert.isTrue(file.isDirectory(), this.serviceRegistryDirectory + " is not a directory");
    LOGGER.trace("Service registry directory is specified at [{}]", file);
    this.serviceRegistryWatcherService = serviceRegistryConfigWatcher;
    this.serviceRegistryWatcherService.start(getClass().getSimpleName());
}
Also used : lombok.val(lombok.val) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy)

Example 8 with NoOpRegisteredServiceReplicationStrategy

use of org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy in project cas by apereo.

the class JsonServiceRegistryTests method verifyRegistry.

@Test
public void verifyRegistry() throws Exception {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val registry = new JsonServiceRegistry(RESOURCE, WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
    assertNotNull(registry.getName());
    assertNotNull(registry.getExtensions());
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with NoOpRegisteredServiceReplicationStrategy

use of org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy in project cas by apereo.

the class JsonServiceRegistryTests method getNewServiceRegistry.

@SneakyThrows
@Override
public ResourceBasedServiceRegistry getNewServiceRegistry() {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    newServiceRegistry = new JsonServiceRegistry(RESOURCE, WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
    return newServiceRegistry;
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ArrayList(java.util.ArrayList) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) SneakyThrows(lombok.SneakyThrows)

Example 10 with NoOpRegisteredServiceReplicationStrategy

use of org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy in project cas by apereo.

the class GrouperRegisteredServiceAccessStrategyTests method checkAccessStrategyJson.

@Test
public void checkAccessStrategyJson() throws Exception {
    val attributes = new HashMap<String, Set<String>>();
    val v1 = new HashSet<String>();
    v1.add("admin");
    attributes.put("memberOf", v1);
    val service = RegisteredServiceTestUtils.getRegisteredService("test");
    val grouper = new GrouperRegisteredServiceAccessStrategy();
    grouper.setConfigProperties(CollectionUtils.wrap("hello", "world"));
    grouper.setRequiredAttributes(attributes);
    service.setAccessStrategy(grouper);
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val dao = new JsonServiceRegistry(RESOURCE, WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
    val saved = dao.save(service);
    assertEquals(service, saved);
    assertFalse(dao.load().isEmpty());
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) HashMap(java.util.HashMap) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

NoOpRegisteredServiceReplicationStrategy (org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy)10 lombok.val (lombok.val)7 JsonServiceRegistry (org.apereo.cas.services.JsonServiceRegistry)6 DefaultRegisteredServiceResourceNamingStrategy (org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy)6 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)6 Test (org.junit.jupiter.api.Test)4 Test (org.junit.Test)3 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 SneakyThrows (lombok.SneakyThrows)2 ChainingAttributeReleasePolicy (org.apereo.cas.services.ChainingAttributeReleasePolicy)2 DenyAllAttributeReleasePolicy (org.apereo.cas.services.DenyAllAttributeReleasePolicy)2 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)2 Set (java.util.Set)1 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)1 InCommonRSAttributeReleasePolicy (org.apereo.cas.support.saml.services.InCommonRSAttributeReleasePolicy)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1