Search in sources :

Example 1 with Cas20WithoutProxyingValidationSpecification

use of org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification in project cas by apereo.

the class CentralAuthenticationServiceImplTests method authenticateTwiceWithRenew.

/**
     * This test simulates :
     * - a first authentication for a default service
     * - a second authentication with the renew parameter and the same service (and same credentials)
     * - a validation of the second ticket.
     * When supplemental authentications were returned with the chained authentications, the validation specification
     * failed as it only expects one authentication. Thus supplemental authentications should not be returned in the
     * chained authentications. Both concepts are orthogonal.
     */
@Test
public void authenticateTwiceWithRenew() throws AbstractTicketException, AuthenticationException {
    final CentralAuthenticationService cas = getCentralAuthenticationService();
    final Service svc = getService("testDefault");
    final UsernamePasswordCredential goodCredential = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
    final TicketGrantingTicket tgtId = cas.createTicketGrantingTicket(ctx);
    cas.grantServiceTicket(tgtId.getId(), svc, ctx);
    // simulate renew with new good same credentials
    final ServiceTicket st2Id = cas.grantServiceTicket(tgtId.getId(), svc, ctx);
    final Assertion assertion = cas.validateServiceTicket(st2Id.getId(), svc);
    final ValidationSpecification validationSpecification = new Cas20WithoutProxyingValidationSpecification();
    assertTrue(validationSpecification.isSatisfiedBy(assertion, new MockHttpServletRequest()));
}
Also used : Cas20WithoutProxyingValidationSpecification(org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification) ValidationSpecification(org.apereo.cas.validation.ValidationSpecification) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Assertion(org.apereo.cas.validation.Assertion) AbstractWebApplicationService(org.apereo.cas.authentication.principal.AbstractWebApplicationService) Service(org.apereo.cas.authentication.principal.Service) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Cas20WithoutProxyingValidationSpecification(org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult) Test(org.junit.Test)

Example 2 with Cas20WithoutProxyingValidationSpecification

use of org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyRenewSpecFailsCorrectly.

@Test
public void verifyRenewSpecFailsCorrectly() throws Exception {
    this.serviceValidateController.setValidationSpecification(new Cas20WithoutProxyingValidationSpecification(true));
    assertFalse(this.serviceValidateController.handleRequestInternal(getHttpServletRequest(), new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
Also used : Cas20WithoutProxyingValidationSpecification(org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 3 with Cas20WithoutProxyingValidationSpecification

use of org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification in project cas by apereo.

the class AbstractServiceValidateControllerTests method onSetUp.

@Before
public void onSetUp() throws Exception {
    final StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.serviceValidateController = new ServiceValidateController();
    this.serviceValidateController.setCentralAuthenticationService(getCentralAuthenticationService());
    this.serviceValidateController.setAuthenticationSystemSupport(getAuthenticationSystemSupport());
    final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler(new SimpleHttpClientFactoryBean().getObject(), new DefaultUniqueTicketIdGenerator());
    this.serviceValidateController.setProxyHandler(proxyHandler);
    this.serviceValidateController.setApplicationContext(context);
    this.serviceValidateController.setArgumentExtractor(getArgumentExtractor());
    this.serviceValidateController.setServicesManager(getServicesManager());
    this.serviceValidateController.setValidationSpecification(new Cas20WithoutProxyingValidationSpecification());
    this.serviceValidateController.setMultifactorTriggerSelectionStrategy(new DefaultMultifactorTriggerSelectionStrategy("", ""));
}
Also used : SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Cas20ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas20ProxyHandler) Cas20WithoutProxyingValidationSpecification(org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification) DefaultMultifactorTriggerSelectionStrategy(org.apereo.cas.authentication.DefaultMultifactorTriggerSelectionStrategy) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) Before(org.junit.Before)

Aggregations

Cas20WithoutProxyingValidationSpecification (org.apereo.cas.validation.Cas20WithoutProxyingValidationSpecification)3 Test (org.junit.Test)2 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)1 DefaultMultifactorTriggerSelectionStrategy (org.apereo.cas.authentication.DefaultMultifactorTriggerSelectionStrategy)1 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)1 AbstractWebApplicationService (org.apereo.cas.authentication.principal.AbstractWebApplicationService)1 Service (org.apereo.cas.authentication.principal.Service)1 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)1 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)1 Cas20ProxyHandler (org.apereo.cas.ticket.proxy.support.Cas20ProxyHandler)1 DefaultUniqueTicketIdGenerator (org.apereo.cas.util.DefaultUniqueTicketIdGenerator)1 SimpleHttpClientFactoryBean (org.apereo.cas.util.http.SimpleHttpClientFactoryBean)1 Assertion (org.apereo.cas.validation.Assertion)1 ValidationSpecification (org.apereo.cas.validation.ValidationSpecification)1 Before (org.junit.Before)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1