Search in sources :

Example 21 with InMemoryServiceRegistry

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

the class RegisteredServiceResponseHeadersEnforcementFilterTests method getFilterForProperty.

private static RegisteredServiceResponseHeadersEnforcementFilter getFilterForProperty(final Pair<RegisteredServiceProperties, String>... properties) {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val context = ServicesManagerConfigurationContext.builder().serviceRegistry(new InMemoryServiceRegistry(appCtx)).applicationContext(appCtx).environments(new HashSet<>(0)).servicesCache(Caffeine.newBuilder().build()).registeredServiceLocators(List.of(new DefaultServicesManagerRegisteredServiceLocator())).build();
    val servicesManager = new DefaultServicesManager(context);
    val argumentExtractor = new DefaultArgumentExtractor(new WebApplicationServiceFactory());
    val service = RegisteredServiceTestUtils.getRegisteredService("service-0");
    val props1 = new LinkedHashMap<String, RegisteredServiceProperty>();
    for (val p : properties) {
        val prop1 = new DefaultRegisteredServiceProperty();
        prop1.addValue(p.getValue());
        props1.put(p.getKey().getPropertyName(), prop1);
    }
    service.setProperties(props1);
    servicesManager.save(service);
    return new RegisteredServiceResponseHeadersEnforcementFilter(servicesManager, argumentExtractor, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()), new RegisteredServiceAccessStrategyAuditableEnforcer(new CasConfigurationProperties()));
}
Also used : lombok.val(lombok.val) RegisteredServiceAccessStrategyAuditableEnforcer(org.apereo.cas.services.RegisteredServiceAccessStrategyAuditableEnforcer) DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) RegisteredServiceResponseHeadersEnforcementFilter(org.apereo.cas.services.web.support.RegisteredServiceResponseHeadersEnforcementFilter) DefaultServicesManagerRegisteredServiceLocator(org.apereo.cas.services.DefaultServicesManagerRegisteredServiceLocator) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) LinkedHashMap(java.util.LinkedHashMap) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) DefaultArgumentExtractor(org.apereo.cas.web.support.DefaultArgumentExtractor) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) HashSet(java.util.HashSet)

Example 22 with InMemoryServiceRegistry

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

the class DefaultSingleLogoutServiceLogoutUrlBuilderTests method beforeEach.

@BeforeEach
public void beforeEach() {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val context = ServicesManagerConfigurationContext.builder().serviceRegistry(new InMemoryServiceRegistry(appCtx)).applicationContext(appCtx).environments(new HashSet<>(0)).servicesCache(Caffeine.newBuilder().build()).registeredServiceLocators(List.of(new DefaultServicesManagerRegisteredServiceLocator())).build();
    this.servicesManager = new DefaultServicesManager(context);
}
Also used : lombok.val(lombok.val) DefaultServicesManagerRegisteredServiceLocator(org.apereo.cas.services.DefaultServicesManagerRegisteredServiceLocator) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) HashSet(java.util.HashSet) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)22 lombok.val (lombok.val)16 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)16 DefaultServicesManager (org.apereo.cas.services.DefaultServicesManager)14 HashSet (java.util.HashSet)9 DefaultServicesManagerRegisteredServiceLocator (org.apereo.cas.services.DefaultServicesManagerRegisteredServiceLocator)8 Test (org.junit.jupiter.api.Test)8 PublisherIdentifier (org.apereo.cas.util.PublisherIdentifier)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 RegisteredService (org.apereo.cas.services.RegisteredService)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)4 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)4 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)3 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)3 DefaultArgumentExtractor (org.apereo.cas.web.support.DefaultArgumentExtractor)3 List (java.util.List)2 DefaultAuthenticationAttributeReleasePolicy (org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy)2 DefaultAuthenticationEventExecutionPlan (org.apereo.cas.authentication.DefaultAuthenticationEventExecutionPlan)2