Search in sources :

Example 1 with JsonServiceRegistry

use of org.apereo.cas.services.JsonServiceRegistry in project cas by apereo.

the class GrouperRegisteredServiceAccessStrategyRegistryTests method checkAccessStrategyJson.

@Test
public void checkAccessStrategyJson() throws Exception {
    final Map<String, Set<String>> attributes = new HashMap<>();
    final Set<String> v1 = new HashSet<>();
    v1.add("admin");
    attributes.put("memberOf", v1);
    final AbstractRegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
    final GrouperRegisteredServiceAccessStrategy grouper = new GrouperRegisteredServiceAccessStrategy();
    grouper.setRequiredAttributes(attributes);
    service.setAccessStrategy(grouper);
    final JsonServiceRegistry dao = new JsonServiceRegistry(RESOURCE, false, mock(ApplicationEventPublisher.class), new NoOpRegisteredServiceReplicationStrategy());
    dao.save(service);
    dao.load();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with JsonServiceRegistry

use of org.apereo.cas.services.JsonServiceRegistry in project cas by apereo.

the class SamlRegisteredServiceTests method verifySavingInCommonSamlService.

@Test
public void verifySavingInCommonSamlService() throws Exception {
    final SamlRegisteredService service = new SamlRegisteredService();
    service.setName(SAML_SERVICE);
    service.setServiceId("http://mmoayyed.unicon.net");
    service.setMetadataLocation(METADATA_LOCATION);
    final InCommonRSAttributeReleasePolicy policy = new InCommonRSAttributeReleasePolicy();
    final ChainingAttributeReleasePolicy chain = new ChainingAttributeReleasePolicy();
    chain.setPolicies(Arrays.asList(policy, new DenyAllAttributeReleasePolicy()));
    service.setAttributeReleasePolicy(chain);
    final JsonServiceRegistry dao = new JsonServiceRegistry(RESOURCE, false, mock(ApplicationEventPublisher.class), new NoOpRegisteredServiceReplicationStrategy());
    dao.save(service);
    dao.load();
}
Also used : InCommonRSAttributeReleasePolicy(org.apereo.cas.support.saml.services.InCommonRSAttributeReleasePolicy) DenyAllAttributeReleasePolicy(org.apereo.cas.services.DenyAllAttributeReleasePolicy) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) ChainingAttributeReleasePolicy(org.apereo.cas.services.ChainingAttributeReleasePolicy) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) Test(org.junit.Test)

Example 3 with JsonServiceRegistry

use of org.apereo.cas.services.JsonServiceRegistry in project cas by apereo.

the class SamlRegisteredServiceTests method verifySavingSamlService.

@Test
public void verifySavingSamlService() throws Exception {
    final SamlRegisteredService service = new SamlRegisteredService();
    service.setName(SAML_SERVICE);
    service.setServiceId("http://mmoayyed.unicon.net");
    service.setMetadataLocation(METADATA_LOCATION);
    final JsonServiceRegistry dao = new JsonServiceRegistry(RESOURCE, false, mock(ApplicationEventPublisher.class), new NoOpRegisteredServiceReplicationStrategy());
    dao.save(service);
    dao.load();
}
Also used : SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) Test(org.junit.Test)

Example 4 with JsonServiceRegistry

use of org.apereo.cas.services.JsonServiceRegistry in project cas by apereo.

the class JsonServiceRegistryConfiguration method jsonServiceRegistry.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "jsonServiceRegistry")
public ServiceRegistry jsonServiceRegistry(@Qualifier("registeredServiceResourceNamingStrategy") final RegisteredServiceResourceNamingStrategy resourceNamingStrategy, final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, @Qualifier("registeredServiceReplicationStrategy") final RegisteredServiceReplicationStrategy registeredServiceReplicationStrategy, final ObjectProvider<List<ServiceRegistryListener>> serviceRegistryListeners) throws Exception {
    val registry = casProperties.getServiceRegistry();
    val json = new JsonServiceRegistry(registry.getJson().getLocation(), WatcherService.noOp(), applicationContext, registeredServiceReplicationStrategy, resourceNamingStrategy, Optional.ofNullable(serviceRegistryListeners.getIfAvailable()).orElseGet(ArrayList::new));
    if (registry.getJson().isWatcherEnabled()) {
        json.enableDefaultWatcherService();
    }
    return json;
}
Also used : lombok.val(lombok.val) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with JsonServiceRegistry

use of org.apereo.cas.services.JsonServiceRegistry in project cas by apereo.

the class SamlRegisteredServiceTests method verifySavingInCommonSamlService.

@Test
public void verifySavingInCommonSamlService() throws Exception {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val service = new SamlRegisteredService();
    service.setName(SAML_SERVICE);
    service.setServiceId("http://mmoayyed.unicon.net");
    service.setMetadataLocation(METADATA_LOCATION);
    val policy = new InCommonRSAttributeReleasePolicy();
    val chain = new ChainingAttributeReleasePolicy();
    chain.setPolicies(Arrays.asList(policy, new DenyAllAttributeReleasePolicy()));
    service.setAttributeReleasePolicy(chain);
    val dao = new JsonServiceRegistry(new FileSystemResource(FileUtils.getTempDirectoryPath() + File.separator + "json-service-registry"), WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
    dao.save(service);
    dao.load();
}
Also used : lombok.val(lombok.val) DenyAllAttributeReleasePolicy(org.apereo.cas.services.DenyAllAttributeReleasePolicy) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ChainingAttributeReleasePolicy(org.apereo.cas.services.ChainingAttributeReleasePolicy) FileSystemResource(org.springframework.core.io.FileSystemResource) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) Test(org.junit.jupiter.api.Test)

Aggregations

JsonServiceRegistry (org.apereo.cas.services.JsonServiceRegistry)7 NoOpRegisteredServiceReplicationStrategy (org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy)6 lombok.val (lombok.val)4 DefaultRegisteredServiceResourceNamingStrategy (org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy)3 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)3 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)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 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1