Search in sources :

Example 1 with ServicesManager

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

the class PolicyBasedAuthenticationManagerTests method mockServicesManager.

protected ServicesManager mockServicesManager() {
    final ServicesManager svc = mock(ServicesManager.class);
    final RegisteredService reg = CoreAuthenticationTestUtils.getRegisteredService();
    when(svc.findServiceBy(any(Service.class))).thenReturn(reg);
    when(svc.getAllServices()).thenReturn(Collections.singletonList(reg));
    return svc;
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) ServicesManager(org.apereo.cas.services.ServicesManager) RegisteredService(org.apereo.cas.services.RegisteredService) Service(org.apereo.cas.authentication.principal.Service)

Example 2 with ServicesManager

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

the class DelegatedClientAuthenticationActionTests method getServicesManagerWith.

private ServicesManager getServicesManagerWith(final Service service, final BaseClient client) {
    final ServicesManager mgr = mock(ServicesManager.class);
    final AbstractRegisteredService regSvc = RegisteredServiceTestUtils.getRegisteredService(service.getId());
    final DefaultRegisteredServiceAccessStrategy strategy = new DefaultRegisteredServiceAccessStrategy();
    strategy.setDelegatedAuthenticationPolicy(new DefaultRegisteredServiceDelegatedAuthenticationPolicy(CollectionUtils.wrapList(client.getName())));
    regSvc.setAccessStrategy(strategy);
    when(mgr.findServiceBy(any(Service.class))).thenReturn(regSvc);
    return mgr;
}
Also used : ServicesManager(org.apereo.cas.services.ServicesManager) CentralAuthenticationService(org.apereo.cas.CentralAuthenticationService) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) Service(org.apereo.cas.authentication.principal.Service) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) DefaultRegisteredServiceDelegatedAuthenticationPolicy(org.apereo.cas.services.DefaultRegisteredServiceDelegatedAuthenticationPolicy) DefaultRegisteredServiceAccessStrategy(org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy)

Example 3 with ServicesManager

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

the class Saml10SuccessResponseViewTests method setUp.

@Before
public void setUp() {
    final List<RegisteredService> list = new ArrayList<>();
    list.add(RegisteredServiceTestUtils.getRegisteredService("https://.+"));
    final InMemoryServiceRegistry dao = new InMemoryServiceRegistry();
    dao.setRegisteredServices(list);
    final ServicesManager mgmr = new DefaultServicesManager(dao, mock(ApplicationEventPublisher.class));
    mgmr.load();
    this.response = new Saml10SuccessResponseView(new DefaultCasProtocolAttributeEncoder(mgmr, CipherExecutor.noOpOfStringToString()), mgmr, "attribute", new Saml10ObjectBuilder(configBean), new DefaultArgumentExtractor(new SamlServiceFactory()), StandardCharsets.UTF_8.name(), 1000, 30, "testIssuer", "whatever", new DefaultAuthenticationAttributeReleasePolicy());
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) SamlServiceFactory(org.apereo.cas.support.saml.authentication.principal.SamlServiceFactory) ArrayList(java.util.ArrayList) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) DefaultAuthenticationAttributeReleasePolicy(org.apereo.cas.authentication.DefaultAuthenticationAttributeReleasePolicy) ServicesManager(org.apereo.cas.services.ServicesManager) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) DefaultArgumentExtractor(org.apereo.cas.web.support.DefaultArgumentExtractor) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) DefaultCasProtocolAttributeEncoder(org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) Saml10ObjectBuilder(org.apereo.cas.support.saml.util.Saml10ObjectBuilder) Before(org.junit.Before)

Example 4 with ServicesManager

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

the class CasSamlServiceProvidersConfiguration method coreSamlServiceProvidersInitializingBean.

@Bean
public InitializingBean coreSamlServiceProvidersInitializingBean(@Qualifier(ServicesManager.BEAN_NAME) final ServicesManager servicesManager, final CasConfigurationProperties casProperties, @Qualifier(SamlRegisteredServiceCachingMetadataResolver.DEFAULT_BEAN_NAME) final SamlRegisteredServiceCachingMetadataResolver samlRegisteredServiceCachingMetadataResolver) {
    return () -> {
        val preloadMetadata = (Function<SamlRegisteredService, Void>) service -> {
            LOGGER.info("Launching background thread to load the metadata. This might take a while...");
            new Thread(() -> {
                LOGGER.debug("Loading metadata at [{}]...", service.getMetadataLocation());
                samlRegisteredServiceCachingMetadataResolver.resolve(service, new CriteriaSet());
            }, getClass().getSimpleName()).start();
            return null;
        };
        val samlSp = casProperties.getSamlSp();
        processSamlServiceProvider(samlSp.getAcademicHealthPlans(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAcademicWorks(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAdobeCloud(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAmazon(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAppDynamics(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getArcGIS(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getArmsSoftware(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAsana(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBenefitFocus(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBlackBaud(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBox(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBynder(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getCccco(), servicesManager, samlRegisteredServiceCachingMetadataResolver, preloadMetadata);
        processSamlServiceProvider(samlSp.getCherWell(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getConcurSolutions(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getConfluence(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getCraniumCafe(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getCrashPlan(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getDocuSign(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getDropbox(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEasyIep(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEgnyte(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEmma(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEverBridge(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEvernote(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getFamis(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getGartner(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getGitlab(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getGiveCampus(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getInCommon(), servicesManager, samlRegisteredServiceCachingMetadataResolver, preloadMetadata);
        processSamlServiceProvider(samlSp.getInfiniteCampus(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getJira(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getNeoGov(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getNetPartner(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getNewRelic(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getOffice365(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getOpenAthens(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getPagerDuty(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getPollEverywhere(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getQualtrics(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getRocketChat(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSafariOnline(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSalesforce(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSaManage(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSansSth(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getServiceNow(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSlack(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getTopHat(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSserca(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSymplicity(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getTableau(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWarpWire(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWebAdvisor(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWebex(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWorkday(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getYuja(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getZendesk(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getZimbra(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getZoom(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
    };
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) SamlRegisteredServiceCachingMetadataResolver(org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver) lombok.val(lombok.val) SamlSPUtils(org.apereo.cas.util.SamlSPUtils) Function(java.util.function.Function) InitializingBean(org.springframework.beans.factory.InitializingBean) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) AbstractSamlSPProperties(org.apereo.cas.configuration.model.support.saml.sps.AbstractSamlSPProperties) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Qualifier(org.springframework.beans.factory.annotation.Qualifier) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) Bean(org.springframework.context.annotation.Bean) ServicesManager(org.apereo.cas.services.ServicesManager) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) InitializingBean(org.springframework.beans.factory.InitializingBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with ServicesManager

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

the class CentralAuthenticationServiceImplWithMockitoTests method getServicesManager.

private static ServicesManager getServicesManager(final Service service1, final Service service2) {
    final RegisteredService mockRegSvc1 = createMockRegisteredService(service1.getId(), true, getServiceProxyPolicy(false));
    final RegisteredService mockRegSvc2 = createMockRegisteredService("test", false, getServiceProxyPolicy(true));
    final RegisteredService mockRegSvc3 = createMockRegisteredService(service2.getId(), true, getServiceProxyPolicy(true));
    final ServicesManager smMock = mock(ServicesManager.class);
    when(smMock.findServiceBy(argThat(new VerifyServiceByIdMatcher(service1.getId())))).thenReturn(mockRegSvc1);
    when(smMock.findServiceBy(argThat(new VerifyServiceByIdMatcher("test")))).thenReturn(mockRegSvc2);
    when(smMock.findServiceBy(argThat(new VerifyServiceByIdMatcher(service2.getId())))).thenReturn(mockRegSvc3);
    return smMock;
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) ServicesManager(org.apereo.cas.services.ServicesManager)

Aggregations

ServicesManager (org.apereo.cas.services.ServicesManager)8 Service (org.apereo.cas.authentication.principal.Service)4 RegisteredService (org.apereo.cas.services.RegisteredService)4 Before (org.junit.Before)3 Slf4j (lombok.extern.slf4j.Slf4j)2 DefaultPrincipalFactory (org.apereo.cas.authentication.principal.DefaultPrincipalFactory)2 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Function (java.util.function.Function)1 lombok.val (lombok.val)1 CriteriaSet (net.shibboleth.utilities.java.support.resolver.CriteriaSet)1 StringUtils (org.apache.commons.lang3.StringUtils)1 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)1 CipherExecutor (org.apereo.cas.CipherExecutor)1 AuditableExecution (org.apereo.cas.audit.AuditableExecution)1 AuditableExecutionResult (org.apereo.cas.audit.AuditableExecutionResult)1 Authentication (org.apereo.cas.authentication.Authentication)1