Search in sources :

Example 11 with DefaultRegisteredServiceProperty

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

the class TokenAuthenticationActionTests method before.

@BeforeEach
public void before() {
    val svc = RegisteredServiceTestUtils.getRegisteredService("https://example.token.org");
    svc.setAttributeReleasePolicy(new ReturnAllAttributeReleasePolicy());
    val prop = new DefaultRegisteredServiceProperty();
    prop.addValue(SIGNING_SECRET);
    svc.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.TOKEN_SECRET_SIGNING.getPropertyName(), prop);
    val prop2 = new DefaultRegisteredServiceProperty();
    prop2.addValue(ENCRYPTION_SECRET);
    svc.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.TOKEN_SECRET_ENCRYPTION.getPropertyName(), prop2);
    this.servicesManager.getObject().save(svc);
}
Also used : lombok.val(lombok.val) ReturnAllAttributeReleasePolicy(org.apereo.cas.services.ReturnAllAttributeReleasePolicy) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with DefaultRegisteredServiceProperty

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

the class RegisteredServiceJwtTicketCipherExecutorTests method verifyCipherStrategyPerService.

@Test
public void verifyCipherStrategyPerService() {
    val service = RegisteredServiceTestUtils.getRegisteredService();
    val c = new RegisteredServiceJwtTicketCipherExecutor();
    assertTrue(c.getCipherOperationsStrategyType(service).isEmpty());
    service.getProperties().put(RegisteredServiceProperties.TOKEN_AS_SERVICE_TICKET_CIPHER_STRATEGY_TYPE.getPropertyName(), new DefaultRegisteredServiceProperty(BaseStringCipherExecutor.CipherOperationsStrategyType.SIGN_AND_ENCRYPT.name()));
    assertTrue(c.getCipherOperationsStrategyType(service).isPresent());
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) Test(org.junit.jupiter.api.Test)

Example 13 with DefaultRegisteredServiceProperty

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

the class VerifyRequiredServiceActionTests method verifySkipServiceByProperty.

@Test
public void verifySkipServiceByProperty() throws Exception {
    val service = RegisteredServiceTestUtils.getRegisteredService("^https://yahoo.com.+");
    service.setEvaluationOrder(1);
    service.setProperties(CollectionUtils.wrap(RegisteredServiceProperty.RegisteredServiceProperties.SKIP_REQUIRED_SERVICE_CHECK.getPropertyName(), new DefaultRegisteredServiceProperty("true")));
    getServicesManager().save(service);
    WebUtils.putServiceIntoFlowScope(this.requestContext, RegisteredServiceTestUtils.getService("https://yahoo.com/"));
    val result = verifyRequiredServiceAction.execute(this.requestContext);
    assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, result.getId());
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) Test(org.junit.jupiter.api.Test)

Example 14 with DefaultRegisteredServiceProperty

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

the class DefaultDelegatedClientAuthenticationWebflowManagerTests method verifyPassiveAuthnOperation.

@Test
public void verifyPassiveAuthnOperation() throws Exception {
    val registeredService = RegisteredServiceTestUtils.getRegisteredService(UUID.randomUUID().toString());
    registeredService.setProperties(Map.of(RegisteredServiceProperty.RegisteredServiceProperties.DELEGATED_AUTHN_PASSIVE_AUTHN.getPropertyName(), new DefaultRegisteredServiceProperty("true")));
    servicesManager.save(registeredService);
    httpServletRequest.setParameter(CasProtocolConstants.PARAMETER_SERVICE, registeredService.getServiceId());
    val pair = setupTestContextFor(File.createTempFile("sp-metadata", ".xml").getAbsolutePath(), "cas.example.sp");
    val ticket = delegatedClientAuthenticationWebflowManager.store(context, pair.getLeft());
    assertNotNull(ticketRegistry.getTicket(ticket.getId()));
    assertEquals(ticket.getId(), delegatedClientDistributedSessionStore.get(context, SAML2StateGenerator.SAML_RELAY_STATE_ATTRIBUTE).get());
    val builder = new SAML2AuthnRequestBuilder();
    val result = builder.build(pair.getRight());
    assertTrue(result.isPassive());
    httpServletRequest.addParameter("RelayState", ticket.getId());
    val service = delegatedClientAuthenticationWebflowManager.retrieve(requestContext, context, pair.getLeft());
    assertNotNull(service);
    assertNull(ticketRegistry.getTicket(ticket.getId()));
}
Also used : lombok.val(lombok.val) SAML2AuthnRequestBuilder(org.pac4j.saml.sso.impl.SAML2AuthnRequestBuilder) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with DefaultRegisteredServiceProperty

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

the class DefaultDelegatedClientAuthenticationWebflowManagerTests method verifyForceAuthnOperation.

@Test
public void verifyForceAuthnOperation() throws Exception {
    val registeredService = RegisteredServiceTestUtils.getRegisteredService(UUID.randomUUID().toString());
    registeredService.setProperties(Map.of(RegisteredServiceProperty.RegisteredServiceProperties.DELEGATED_AUTHN_FORCE_AUTHN.getPropertyName(), new DefaultRegisteredServiceProperty("true")));
    servicesManager.save(registeredService);
    httpServletRequest.setParameter(CasProtocolConstants.PARAMETER_SERVICE, registeredService.getServiceId());
    val pair = setupTestContextFor(File.createTempFile("sp-metadata", ".xml").getAbsolutePath(), "cas.example.sp");
    val ticket = delegatedClientAuthenticationWebflowManager.store(context, pair.getLeft());
    assertNotNull(ticketRegistry.getTicket(ticket.getId()));
    assertEquals(ticket.getId(), delegatedClientDistributedSessionStore.get(context, SAML2StateGenerator.SAML_RELAY_STATE_ATTRIBUTE).get());
    val builder = new SAML2AuthnRequestBuilder();
    val result = builder.build(pair.getRight());
    assertTrue(result.isForceAuthn());
    httpServletRequest.addParameter("RelayState", ticket.getId());
    val service = delegatedClientAuthenticationWebflowManager.retrieve(requestContext, context, pair.getLeft());
    assertNotNull(service);
    assertNull(ticketRegistry.getTicket(ticket.getId()));
}
Also used : lombok.val(lombok.val) SAML2AuthnRequestBuilder(org.pac4j.saml.sso.impl.SAML2AuthnRequestBuilder) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

DefaultRegisteredServiceProperty (org.apereo.cas.services.DefaultRegisteredServiceProperty)28 lombok.val (lombok.val)24 Test (org.junit.jupiter.api.Test)20 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)7 HashSet (java.util.HashSet)4 LinkedHashMap (java.util.LinkedHashMap)4 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)4 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)4 HashMap (java.util.HashMap)3 Service (org.apereo.cas.authentication.principal.Service)3 AnonymousRegisteredServiceUsernameAttributeProvider (org.apereo.cas.services.AnonymousRegisteredServiceUsernameAttributeProvider)3 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)3 ShibbolethCompatiblePersistentIdGenerator (org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator)2 GoogleRecaptchaProperties (org.apereo.cas.configuration.model.support.captcha.GoogleRecaptchaProperties)2 RefuseRegisteredServiceProxyPolicy (org.apereo.cas.services.RefuseRegisteredServiceProxyPolicy)2 RegisteredServiceProperty (org.apereo.cas.services.RegisteredServiceProperty)2 RegisteredServicePublicKeyImpl (org.apereo.cas.services.RegisteredServicePublicKeyImpl)2 ReturnAllAttributeReleasePolicy (org.apereo.cas.services.ReturnAllAttributeReleasePolicy)2 ClientInfo (org.apereo.inspektr.common.web.ClientInfo)2