Search in sources :

Example 26 with RegexRegisteredService

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

the class CasOAuthConfiguration method initializeServletApplicationContext.

@PostConstruct
public void initializeServletApplicationContext() {
    final String oAuthCallbackUrl = casProperties.getServer().getPrefix() + BASE_OAUTH20_URL + '/' + CALLBACK_AUTHORIZE_URL_DEFINITION;
    final Service callbackService = this.webApplicationServiceFactory.createService(oAuthCallbackUrl);
    final RegisteredService svc = servicesManager.findServiceBy(callbackService);
    if (svc == null || !svc.getServiceId().equals(oAuthCallbackUrl)) {
        final RegexRegisteredService service = new RegexRegisteredService();
        service.setId(Math.abs(new SecureRandom().nextLong()));
        service.setEvaluationOrder(0);
        service.setName(service.getClass().getSimpleName());
        service.setDescription("OAuth Authentication Callback Request URL");
        service.setServiceId(oAuthCallbackUrl);
        service.setAttributeReleasePolicy(new DenyAllAttributeReleasePolicy());
        servicesManager.save(service);
        servicesManager.load();
    }
}
Also used : DenyAllAttributeReleasePolicy(org.apereo.cas.services.DenyAllAttributeReleasePolicy) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) Service(org.apereo.cas.authentication.principal.Service) SecureRandom(java.security.SecureRandom) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) PostConstruct(javax.annotation.PostConstruct)

Example 27 with RegexRegisteredService

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

the class RegisteredServiceSerializer method read.

@Override
public RegisteredService read(final Kryo kryo, final Input input, final Class<RegisteredService> type) {
    final AbstractRegisteredService svc = new RegexRegisteredService();
    svc.setServiceId(kryo.readObject(input, String.class));
    svc.setName(kryo.readObject(input, String.class));
    svc.setDescription(kryo.readObject(input, String.class));
    svc.setId(kryo.readObject(input, Long.class));
    svc.setEvaluationOrder(kryo.readObject(input, Integer.class));
    svc.setLogo(kryo.readObject(input, URL.class));
    svc.setLogoutType(kryo.readObject(input, LogoutType.class));
    svc.setLogoutUrl(kryo.readObject(input, URL.class));
    svc.setRequiredHandlers(kryo.readObject(input, HashSet.class));
    svc.setTheme(kryo.readObject(input, String.class));
    svc.setPublicKey(readObjectByReflection(kryo, input));
    svc.setProxyPolicy(readObjectByReflection(kryo, input));
    svc.setAttributeReleasePolicy(readObjectByReflection(kryo, input));
    svc.setUsernameAttributeProvider(readObjectByReflection(kryo, input));
    svc.setAccessStrategy(readObjectByReflection(kryo, input));
    return svc;
}
Also used : AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) LogoutType(org.apereo.cas.services.LogoutType) URL(java.net.URL) HashSet(java.util.HashSet)

Example 28 with RegexRegisteredService

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

the class CasConsentReviewConfiguration method configureServiceRegistry.

@Override
public void configureServiceRegistry(final ServiceRegistryExecutionPlan plan) {
    final RegexRegisteredService service = new RegexRegisteredService();
    service.setEvaluationOrder(0);
    service.setName("CAS Consent Review");
    service.setDescription("Review consent decisions for attribute release");
    service.setServiceId(consentCallbackService().getId());
    final ReturnAllowedAttributeReleasePolicy policy = new ReturnAllowedAttributeReleasePolicy();
    final DefaultRegisteredServiceConsentPolicy consentPolicy = new DefaultRegisteredServiceConsentPolicy();
    consentPolicy.setEnabled(false);
    policy.setConsentPolicy(consentPolicy);
    service.setAttributeReleasePolicy(policy);
    LOGGER.debug("Saving consent service [{}] into the registry", service);
    plan.registerServiceRegistry(new ConsentServiceRegistry(service));
}
Also used : DefaultRegisteredServiceConsentPolicy(org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy) ReturnAllowedAttributeReleasePolicy(org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) ConsentServiceRegistry(org.apereo.cas.consent.services.ConsentServiceRegistry)

Example 29 with RegexRegisteredService

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

the class LogoutActionTests method logoutForServiceWithFollowRedirectsNoAllowedService.

@Test
public void logoutForServiceWithFollowRedirectsNoAllowedService() throws Exception {
    this.request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, TEST_SERVICE_ID);
    final RegexRegisteredService impl = new RegexRegisteredService();
    impl.setServiceId("http://FooBar");
    impl.setName("FooBar");
    this.serviceManager.save(impl);
    final LogoutProperties properties = new LogoutProperties();
    this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
    final Event event = this.logoutAction.doExecute(this.requestContext);
    assertEquals(CasWebflowConstants.TRANSITION_ID_FINISH, event.getId());
    assertNull(this.requestContext.getFlowScope().get("logoutRedirectUrl"));
}
Also used : LogoutProperties(org.apereo.cas.configuration.model.core.logout.LogoutProperties) LogoutAction(org.apereo.cas.web.flow.logout.LogoutAction) Event(org.springframework.webflow.execution.Event) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) Test(org.junit.Test)

Example 30 with RegexRegisteredService

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

the class DefaultRegisteredServiceCipherExecutorTests method getService.

private AbstractRegisteredService getService(final String keyLocation) {
    final AbstractRegisteredService svc = new RegexRegisteredService();
    svc.setServiceId("Testing");
    svc.setPublicKey(new RegisteredServicePublicKeyImpl(keyLocation, "RSA"));
    return svc;
}
Also used : RegisteredServicePublicKeyImpl(org.apereo.cas.services.RegisteredServicePublicKeyImpl) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService)

Aggregations

RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)42 lombok.val (lombok.val)12 Test (org.junit.Test)12 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)10 RegisteredService (org.apereo.cas.services.RegisteredService)10 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)8 Service (org.apereo.cas.authentication.principal.Service)6 Test (org.junit.jupiter.api.Test)6 RegisteredServiceEditBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceEditBean)5 DefaultRegisteredServiceAccessStrategy (org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)4 URL (java.net.URL)3 SecureRandom (java.security.SecureRandom)3 HashMap (java.util.HashMap)3 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)3 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)3 WebApplicationService (org.apereo.cas.authentication.principal.WebApplicationService)3 AnonymousRegisteredServiceUsernameAttributeProvider (org.apereo.cas.services.AnonymousRegisteredServiceUsernameAttributeProvider)3