Search in sources :

Example 1 with DefaultUniqueTicketIdGenerator

use of org.apereo.cas.util.DefaultUniqueTicketIdGenerator in project cas by apereo.

the class Cas20ProxyHandlerTests method setUp.

@Before
public void setUp() throws Exception {
    final SimpleHttpClientFactoryBean factory = new SimpleHttpClientFactoryBean();
    factory.setConnectionTimeout(10000);
    factory.setReadTimeout(10000);
    this.handler = new Cas20ProxyHandler(factory.getObject(), new DefaultUniqueTicketIdGenerator());
    when(this.proxyGrantingTicket.getId()).thenReturn("proxyGrantingTicket");
}
Also used : SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) Before(org.junit.Before)

Example 2 with DefaultUniqueTicketIdGenerator

use of org.apereo.cas.util.DefaultUniqueTicketIdGenerator in project cas by apereo.

the class JpaTicketRegistryTests method verifySecurityTokenTicket.

@RepeatedTest(2)
public void verifySecurityTokenTicket() throws Exception {
    val securityTokenTicketFactory = new DefaultSecurityTokenTicketFactory(new DefaultUniqueTicketIdGenerator(), neverExpiresExpirationPolicyBuilder());
    val originalAuthn = CoreAuthenticationTestUtils.getAuthentication();
    val tgt = new TicketGrantingTicketImpl(ticketGrantingTicketId, originalAuthn, NeverExpiresExpirationPolicy.INSTANCE);
    this.newTicketRegistry.addTicket(tgt);
    val token = securityTokenTicketFactory.create(tgt, "dummy-token".getBytes(StandardCharsets.UTF_8));
    this.newTicketRegistry.addTicket(token);
    assertNotNull(this.newTicketRegistry.getTicket(token.getId()));
    this.newTicketRegistry.deleteTicket(token);
    assertNull(this.newTicketRegistry.getTicket(token.getId()));
}
Also used : lombok.val(lombok.val) DefaultSecurityTokenTicketFactory(org.apereo.cas.ticket.DefaultSecurityTokenTicketFactory) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Example 3 with DefaultUniqueTicketIdGenerator

use of org.apereo.cas.util.DefaultUniqueTicketIdGenerator in project cas by apereo.

the class Cas20ProxyHandlerTests method verifyNonValidProxyTicket.

@Test
public void verifyNonValidProxyTicket() throws Exception {
    val clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setAcceptableCodes(CollectionUtils.wrapList(900));
    this.handler = new Cas20ProxyHandler(clientFactory.getObject(), new DefaultUniqueTicketIdGenerator());
    assertNull(this.handler.handle(new HttpBasedServiceCredential(new URL("http://www.rutgers.edu"), CoreAuthenticationTestUtils.getRegisteredService("https://some.app.edu")), proxyGrantingTicket));
}
Also used : lombok.val(lombok.val) SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) HttpBasedServiceCredential(org.apereo.cas.authentication.credential.HttpBasedServiceCredential) URL(java.net.URL) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultUniqueTicketIdGenerator

use of org.apereo.cas.util.DefaultUniqueTicketIdGenerator in project cas by apereo.

the class Cas20ProxyHandlerTests method initialize.

@BeforeEach
public void initialize() {
    val factory = new SimpleHttpClientFactoryBean();
    factory.setConnectionTimeout(10000);
    factory.setReadTimeout(10000);
    this.handler = new Cas20ProxyHandler(factory.getObject(), new DefaultUniqueTicketIdGenerator());
    when(this.proxyGrantingTicket.getId()).thenReturn("proxyGrantingTicket");
}
Also used : lombok.val(lombok.val) SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with DefaultUniqueTicketIdGenerator

use of org.apereo.cas.util.DefaultUniqueTicketIdGenerator in project cas by apereo.

the class SamlRestServiceTicketResourceEntityResponseFactoryTests method verifyOperation.

@Test
public void verifyOperation() {
    val factory = new SamlRestServiceTicketResourceEntityResponseFactory(new DefaultUniqueTicketIdGenerator());
    assertEquals(0, factory.getOrder());
    val service = new SamlService();
    service.setId("https://saml.example.org");
    assertTrue(factory.supports(service, CoreAuthenticationTestUtils.getAuthenticationResult()));
    assertNotNull(factory.build(new MockTicketGrantingTicket("casuser").getId(), service, CoreAuthenticationTestUtils.getAuthenticationResult()));
}
Also used : lombok.val(lombok.val) SamlService(org.apereo.cas.support.saml.authentication.principal.SamlService) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) DefaultUniqueTicketIdGenerator(org.apereo.cas.util.DefaultUniqueTicketIdGenerator) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultUniqueTicketIdGenerator (org.apereo.cas.util.DefaultUniqueTicketIdGenerator)5 lombok.val (lombok.val)4 SimpleHttpClientFactoryBean (org.apereo.cas.util.http.SimpleHttpClientFactoryBean)3 Test (org.junit.jupiter.api.Test)2 URL (java.net.URL)1 HttpBasedServiceCredential (org.apereo.cas.authentication.credential.HttpBasedServiceCredential)1 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)1 SamlService (org.apereo.cas.support.saml.authentication.principal.SamlService)1 DefaultSecurityTokenTicketFactory (org.apereo.cas.ticket.DefaultSecurityTokenTicketFactory)1 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)1 Before (org.junit.Before)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1