Search in sources :

Example 11 with InMemoryServiceRegistry

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

the class ManageRegisteredServicesMultiActionControllerTests method setUp.

@Before
public void setUp() throws Exception {
    this.servicesManager = new DefaultServicesManager(new InMemoryServiceRegistry());
    this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new DefaultRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.emptyList());
    this.controller = new ManageRegisteredServicesMultiActionController(this.servicesManager, this.registeredServiceFactory, new WebApplicationServiceFactory(), "https://cas.example.org");
}
Also used : WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultAccessStrategyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultAccessStrategyMapper) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) DefaultRegisteredServiceFactory(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceFactory) DefaultProxyPolicyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper) DefaultRegisteredServiceMapper(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceMapper) DefaultUsernameAttributeProviderMapper(org.apereo.cas.mgmt.services.web.factory.DefaultUsernameAttributeProviderMapper) ManageRegisteredServicesMultiActionController(org.apereo.cas.mgmt.services.web.ManageRegisteredServicesMultiActionController) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) Before(org.junit.Before)

Example 12 with InMemoryServiceRegistry

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

the class CasCoreServicesConfiguration method serviceRegistry.

@ConditionalOnMissingBean(name = "serviceRegistry")
@Bean
@RefreshScope
public ServiceRegistry serviceRegistry() {
    final List<ServiceRegistryExecutionPlanConfigurer> configurers = ObjectUtils.defaultIfNull(serviceRegistryDaoConfigurers.getIfAvailable(), new ArrayList<>(0));
    final DefaultServiceRegistryExecutionPlan plan = new DefaultServiceRegistryExecutionPlan();
    configurers.forEach(c -> {
        final String name = StringUtils.removePattern(c.getClass().getSimpleName(), "\\$.+");
        LOGGER.debug("Configuring service registry [{}]", name);
        c.configureServiceRegistry(plan);
    });
    final Predicate filter = Predicates.not(Predicates.instanceOf(ImmutableServiceRegistry.class));
    if (plan.getServiceRegistries(filter).isEmpty()) {
        final List<RegisteredService> services = new ArrayList<>();
        LOGGER.warn("Runtime memory is used as the persistence storage for retrieving and persisting service definitions. " + "Changes that are made to service definitions during runtime WILL be LOST when the web server is restarted. " + "Ideally for production, you need to choose a storage option (JDBC, etc) to store and track service definitions.");
        if (applicationContext.containsBean("inMemoryRegisteredServices")) {
            services.addAll(applicationContext.getBean("inMemoryRegisteredServices", List.class));
            LOGGER.debug("Found a list of registered services in the application context. Registering services [{}]", services);
        }
        plan.registerServiceRegistry(new InMemoryServiceRegistry(services));
    }
    return new ChainingServiceRegistry(plan.getServiceRegistries());
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) ArrayList(java.util.ArrayList) Predicate(com.google.common.base.Predicate) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) ImmutableServiceRegistry(org.apereo.cas.services.ImmutableServiceRegistry) DefaultServiceRegistryExecutionPlan(org.apereo.cas.services.DefaultServiceRegistryExecutionPlan) ChainingServiceRegistry(org.apereo.cas.services.ChainingServiceRegistry) ArrayList(java.util.ArrayList) List(java.util.List) ServiceRegistryExecutionPlanConfigurer(org.apereo.cas.services.ServiceRegistryExecutionPlanConfigurer) 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 13 with InMemoryServiceRegistry

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

the class SamlRegisteredServiceTests method checkPattern.

@Test
public void checkPattern() {
    final SamlRegisteredService service = new SamlRegisteredService();
    service.setName(SAML_SERVICE);
    service.setServiceId("^http://.+");
    service.setMetadataLocation(METADATA_LOCATION);
    final InMemoryServiceRegistry dao = new InMemoryServiceRegistry();
    dao.setRegisteredServices(Collections.singletonList(service));
    final DefaultServicesManager impl = new DefaultServicesManager(dao, mock(ApplicationEventPublisher.class));
    impl.load();
    final RegisteredService s = impl.findServiceBy(new WebApplicationServiceFactory().createService("http://mmoayyed.unicon.net:8081/sp/saml/SSO"));
    assertNotNull(s);
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) Test(org.junit.Test)

Example 14 with InMemoryServiceRegistry

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

the class RegisteredServiceAuthenticationPolicySingleSignOnParticipationStrategyTests method getSingleSignOnStrategy.

private static SingleSignOnParticipationStrategy getSingleSignOnStrategy(final RegisteredService svc, final TicketRegistry ticketRegistry) {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val context = ServicesManagerConfigurationContext.builder().serviceRegistry(new InMemoryServiceRegistry(appCtx, List.of(svc), List.of())).applicationContext(appCtx).environments(new HashSet<>(0)).servicesCache(Caffeine.newBuilder().build()).registeredServiceLocators(List.of(new DefaultServicesManagerRegisteredServiceLocator())).build();
    val servicesManager = new DefaultServicesManager(context);
    servicesManager.load();
    val authenticationExecutionPlan = new DefaultAuthenticationEventExecutionPlan();
    authenticationExecutionPlan.registerAuthenticationHandler(new SimpleTestUsernamePasswordAuthenticationHandler());
    return new RegisteredServiceAuthenticationPolicySingleSignOnParticipationStrategy(servicesManager, new DefaultTicketRegistrySupport(ticketRegistry), new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()), authenticationExecutionPlan, appCtx);
}
Also used : lombok.val(lombok.val) DefaultAuthenticationEventExecutionPlan(org.apereo.cas.authentication.DefaultAuthenticationEventExecutionPlan) DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) DefaultServicesManagerRegisteredServiceLocator(org.apereo.cas.services.DefaultServicesManagerRegisteredServiceLocator) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) DefaultTicketRegistrySupport(org.apereo.cas.ticket.registry.DefaultTicketRegistrySupport) SimpleTestUsernamePasswordAuthenticationHandler(org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) HashSet(java.util.HashSet)

Example 15 with InMemoryServiceRegistry

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

the class DefaultDelegatedClientIdentityProviderRedirectionStrategyTests method setup.

@BeforeEach
public void setup() {
    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);
    this.casCookieBuilder = mock(CasCookieBuilder.class);
}
Also used : lombok.val(lombok.val) CasCookieBuilder(org.apereo.cas.web.cookie.CasCookieBuilder) 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