org.jasig.cas.TestUtils Java Examples

The following examples show how to use org.jasig.cas.TestUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthenticationViaFormActionTests.java    From cas4.0.x-server-wechat with Apache License 2.0 6 votes vote down vote up
@Test
public void testRenewWithServiceAndSameCredentials() throws Exception {
    final String ticketGrantingTicket = getCentralAuthenticationService()
        .createTicketGrantingTicket(
            TestUtils.getCredentialsWithSameUsernameAndPassword());
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockRequestContext context = new MockRequestContext();

    context.getFlowScope().put("ticketGrantingTicketId", ticketGrantingTicket);
    request.addParameter("renew", "true");
    request.addParameter("service", "test");
    request.addParameter("username", "test");
    request.addParameter("password", "test");

    context.setExternalContext(new ServletExternalContext(
        new MockServletContext(), request, new MockHttpServletResponse()));
    context.getFlowScope().put("service", TestUtils.getService("test"));
//    this.action.bind(context);
 //   assertEquals("warn", this.action.submit(context).getId());
}
 
Example #2
Source File: GenericSuccessViewActionTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyValidPrincipal() throws InvalidTicketException {
    final CentralAuthenticationService cas = mock(CentralAuthenticationService.class);
    final Authentication authn = mock(Authentication.class);
    when(authn.getPrincipal()).thenReturn(TestUtils.getPrincipal("cas"));
    final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
    when(tgt.getAuthentication()).thenReturn(authn);



    when(cas.getTicket(any(String.class), any(Ticket.class.getClass()))).thenReturn(tgt);
    final GenericSuccessViewAction action = new GenericSuccessViewAction(cas);
    final Principal p = action.getAuthenticationPrincipal("TGT-1");
    assertNotNull(p);
    assertEquals(p.getId(), "cas");
}
 
Example #3
Source File: TicketGrantingTicketExpirationPolicyTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyTgtIsExpiredByHardTimeOut() throws InterruptedException {
     // keep tgt alive via sliding window until within SLIDING_TIME / 2 of the HARD_TIMEOUT
     while (System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()
             < (HARD_TIMEOUT - SLIDING_TIMEOUT / 2)) {
         ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
         Thread.sleep(SLIDING_TIMEOUT - TIMEOUT_BUFFER);
         assertFalse(this.ticketGrantingTicket.isExpired());
     }

     // final sliding window extension past the HARD_TIMEOUT
     ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
     Thread.sleep(SLIDING_TIMEOUT / 2 + TIMEOUT_BUFFER);
     assertTrue(ticketGrantingTicket.isExpired());

}
 
Example #4
Source File: TicketGrantingTicketExpirationPolicyTests.java    From cas4.0.x-server-wechat with Apache License 2.0 6 votes vote down vote up
@Test
public void testTgtIsExpiredByHardTimeOut() throws InterruptedException {
     // keep tgt alive via sliding window until within SLIDING_TIME / 2 of the HARD_TIMEOUT
     while (System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()
             < (HARD_TIMEOUT - SLIDING_TIMEOUT / 2)) {
         ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
         Thread.sleep(SLIDING_TIMEOUT - TIMEOUT_BUFFER);
         assertFalse(this.ticketGrantingTicket.isExpired());
     }

     // final sliding window extension past the HARD_TIMEOUT
     ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
     Thread.sleep(SLIDING_TIMEOUT / 2 + TIMEOUT_BUFFER);
     assertTrue(ticketGrantingTicket.isExpired());

}
 
Example #5
Source File: PrincipalAttributeRegisteredServiceUsernameProviderTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyUsernameByPrincipalAttributeNotFound() {
    final PrincipalAttributeRegisteredServiceUsernameProvider provider =
            new PrincipalAttributeRegisteredServiceUsernameProvider("cn");
    
    final Map<String, Object> attrs = new HashMap<>();
    attrs.put("userid", "u1");
            
    final Principal p = mock(Principal.class);
    when(p.getId()).thenReturn("person");
    when(p.getAttributes()).thenReturn(attrs);
    
    final String id = provider.resolveUsername(p, TestUtils.getService());
    assertEquals(id, p.getId());
    
}
 
Example #6
Source File: TicketOrCredentialPrincipalResolverTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyResolverTicketGrantingTicket() throws Exception {
    final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketId = getCentralAuthenticationService()
            .createTicketGrantingTicket(c);

    final TicketOrCredentialPrincipalResolver res =
            new TicketOrCredentialPrincipalResolver(getCentralAuthenticationService());
    final JoinPoint jp = mock(JoinPoint.class);

    when(jp.getArgs()).thenReturn(new Object[] {ticketId.getId()});

    final String result = res.resolveFrom(jp, null);
    assertNotNull(result);
    assertEquals(result, c.getId());
}
 
Example #7
Source File: AbstractServiceValidateControllerTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyInvalidServiceTicket() throws Exception {
    final TicketGrantingTicket tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
    final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), TestUtils.getService());

    getCentralAuthenticationService().destroyTicketGrantingTicket(tId.getId());

    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", TestUtils.getService().getId());
    request.addParameter("ticket", sId.getId());

    assertEquals(ServiceValidateController.DEFAULT_SERVICE_FAILURE_VIEW_NAME,
            this.serviceValidateController.handleRequestInternal(request,
                    new MockHttpServletResponse()).getViewName());
}
 
Example #8
Source File: GenerateServiceTicketActionTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyTicketGrantingTicketNotTgtButGateway() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    context.getFlowScope().put("service", TestUtils.getService());
    final MockHttpServletRequest request = new MockHttpServletRequest();
    context.setExternalContext(new ServletExternalContext(
            new MockServletContext(), request, new MockHttpServletResponse()));
    request.addParameter("service", "service");
    request.addParameter("gateway", "true");
    final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
    when(tgt.getId()).thenReturn("bleh");
    WebUtils.putTicketGrantingTicketInScopes(context, tgt);


    assertEquals("gateway", this.action.execute(context).getId());
}
 
Example #9
Source File: DefaultRegisteredServiceMfaRoleProcessorImplTest.java    From cas-mfa with Apache License 2.0 6 votes vote down vote up
@Test
public void testResolveWithoutIncompleteServiceMfaAttributes() throws Exception {
    final WebApplicationService was = getTargetService();
    final Authentication auth = getAuthentication(true);

    final RegisteredService rswa = TestUtils.getRegisteredService("test1");

    DefaultRegisteredServiceProperty prop = new DefaultRegisteredServiceProperty();
    prop.setValues(Collections.singleton(CAS_AUTHN_METHOD));
    rswa.getProperties().put(MultiFactorAuthenticationSupportingWebApplicationService.CONST_PARAM_AUTHN_METHOD, prop);

    prop = new DefaultRegisteredServiceProperty();
    prop.setValues(Collections.singleton(MEMBER_OF_VALUE));
    rswa.getProperties().put(RegisteredServiceMfaRoleProcessor.MFA_ATTRIBUTE_PATTERN, prop);

    final DefaultRegisteredServiceMfaRoleProcessorImpl resolver = new DefaultRegisteredServiceMfaRoleProcessorImpl(
            getMFWASF(was), getAMCP(), getServicesManager(rswa));

    final List<MultiFactorAuthenticationRequestContext> result = resolver.resolve(auth, was);
    assertNotNull(result);
    assertEquals(0, result.size());
}
 
Example #10
Source File: ServiceValidateControllerTests.java    From cas4.0.x-server-wechat with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidServiceTicketWithInvalidPgt() throws Exception {
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final String tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
    final String sId = getCentralAuthenticationService().grantServiceTicket(tId, TestUtils.getService());

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", TestUtils.getService().getId());
    request.addParameter("ticket", sId);
    request.addParameter("pgtUrl", "duh");

    final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
    assertEquals(ServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME, modelAndView.getViewName());
    assertNull(modelAndView.getModel().get("pgtIou"));
}
 
Example #11
Source File: AuthenticationViaFormActionTests.java    From cas4.0.x-server-wechat with Apache License 2.0 6 votes vote down vote up
@Test
 public void testRenewWithServiceAndBadCredentials() throws Exception {
     final String ticketGrantingTicket = getCentralAuthenticationService()
         .createTicketGrantingTicket(
             TestUtils.getCredentialsWithSameUsernameAndPassword());
     final MockHttpServletRequest request = new MockHttpServletRequest();
     final MockRequestContext context = new MockRequestContext();

     context.getFlowScope().put("ticketGrantingTicketId", ticketGrantingTicket);
     request.addParameter("renew", "true");
     request.addParameter("service", "test");

     context.setExternalContext(new ServletExternalContext(
         new MockServletContext(), request, new MockHttpServletResponse()));
     context.getRequestScope().put("credentials",
         TestUtils.getCredentialsWithDifferentUsernameAndPassword());
     context.getRequestScope().put(
         "org.springframework.validation.BindException.credentials",
         new BindException(TestUtils
             .getCredentialsWithDifferentUsernameAndPassword(),
             "credentials"));
//     this.action.bind(context);
//     assertEquals("error", this.action.submit(context).getId());
 }
 
Example #12
Source File: AbstractServiceValidateControllerTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyValidServiceTicketAndPgtUrlMismatch() throws Exception {
    final TicketGrantingTicket tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
    
    final Service svc = TestUtils.getService("proxyService");
    final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc);

    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", svc.getId());
    request.addParameter("ticket", sId.getId());
    request.addParameter("pgtUrl", "http://www.github.com");
    
    final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
    assertEquals(ServiceValidateController.DEFAULT_SERVICE_FAILURE_VIEW_NAME, modelAndView.getViewName());
    assertNull(modelAndView.getModel().get("pgtIou"));
}
 
Example #13
Source File: RemoteCentralAuthenticationServiceTests.java    From cas4.0.x-server-wechat with Apache License 2.0 6 votes vote down vote up
@Test
public void testDelegateTicketGrantingTicketWithInvalidCredentials() throws Exception {
    final String ticketGrantingTicket = this.remoteCentralAuthenticationService
        .createTicketGrantingTicket(TestUtils
            .getCredentialsWithSameUsernameAndPassword());
    final String serviceTicket = this.remoteCentralAuthenticationService
        .grantServiceTicket(ticketGrantingTicket, TestUtils.getService());
    try {
        this.remoteCentralAuthenticationService
            .delegateTicketGrantingTicket(serviceTicket, TestUtils
                .getCredentialsWithDifferentUsernameAndPassword("", ""));
        fail("IllegalArgumentException expected.");
    } catch (final IllegalArgumentException e) {
        return;
    }

}
 
Example #14
Source File: TicketGrantingTicketImplTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testWebApplicationExpire() {
    final MockService testService = new MockService("test");
    TicketGrantingTicket t = new TicketGrantingTicketImpl("test", null,
        TestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    t.grantServiceTicket(this.uniqueTicketIdGenerator
        .getNewTicketId(ServiceTicket.PREFIX), testService,
        new NeverExpiresExpirationPolicy(), false);
    assertFalse(t.isExpired());
    t.markTicketExpired();
    assertTrue(t.isExpired());
}
 
Example #15
Source File: Cas10ResponseViewTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.model = new HashMap<String, Object>();
    List<Authentication> list = new ArrayList<Authentication>();
    list.add(TestUtils.getAuthentication("someothername"));
    this.model.put("assertion", new ImmutableAssertion(
            TestUtils.getAuthentication(), list, TestUtils.getService("TestService"), true));
}
 
Example #16
Source File: RemoteCentralAuthenticationServiceTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testDelegateTicketGrantingTicketWithValidCredentials() throws Exception {
    final String ticketGrantingTicket = this.remoteCentralAuthenticationService
        .createTicketGrantingTicket(TestUtils
            .getCredentialsWithSameUsernameAndPassword());
    final String serviceTicket = this.remoteCentralAuthenticationService
        .grantServiceTicket(ticketGrantingTicket, TestUtils.getService());
    this.remoteCentralAuthenticationService.delegateTicketGrantingTicket(
        serviceTicket, TestUtils.getHttpBasedServiceCredentials());
}
 
Example #17
Source File: Saml10SuccessResponseViewTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testResponseWithNoAttributes() throws Exception {
    final Map<String, Object> model = new HashMap<String, Object>();

    final SimplePrincipal principal = new SimplePrincipal("testPrincipal");

    final Map<String, Object> authAttributes = new HashMap<String, Object>();
    authAttributes.put(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD,
            SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT);
    authAttributes.put("testSamlAttribute", "value");

    final Authentication primary = TestUtils.getAuthentication(principal, authAttributes);

    final Assertion assertion = new ImmutableAssertion(
            primary, Collections.singletonList(primary), TestUtils.getService(), true);
    model.put("assertion", assertion);

    final MockHttpServletResponse servletResponse = new MockHttpServletResponse();

    this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
    final String written = servletResponse.getContentAsString();

    assertTrue(written.contains("testPrincipal"));
    assertTrue(written.contains(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT));
    assertTrue(written.contains("AuthenticationMethod"));
}
 
Example #18
Source File: AbstractTicketRegistryTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test
public void verifyGetExistingTicket() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl("TEST", TestUtils.getAuthentication(),
                new NeverExpiresExpirationPolicy()));
        this.ticketRegistry.getTicket("TEST");
    } catch (final Exception e) {
        e.printStackTrace();
        fail("Caught an exception. But no exception should have been thrown.");
    }
}
 
Example #19
Source File: RememberMeAuthenticationMetaDataPopulatorTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
private AuthenticationBuilder newBuilder(final Credential credential) {
    final CredentialMetaData meta = new BasicCredentialMetaData(new UsernamePasswordCredential());
    final AuthenticationHandler handler = new SimpleTestUsernamePasswordAuthenticationHandler();
    final AuthenticationBuilder builder = new AuthenticationBuilder(TestUtils.getPrincipal())
            .addCredential(meta)
            .addSuccess("test", new HandlerResult(handler, meta));

    this.p.populateAttributes(builder, credential);
    return builder;
}
 
Example #20
Source File: RemoteCentralAuthenticationServiceTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testGrantServiceTicketWithNullCredentials() throws Exception {
    final String ticketGrantingTicketId = this.remoteCentralAuthenticationService
        .createTicketGrantingTicket(TestUtils
            .getCredentialsWithSameUsernameAndPassword());
    this.remoteCentralAuthenticationService.grantServiceTicket(
        ticketGrantingTicketId, TestUtils.getService(), null);
}
 
Example #21
Source File: MultiTimeUseOrTimeoutExpirationPolicyTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.expirationPolicy = new MultiTimeUseOrTimeoutExpirationPolicy(NUMBER_OF_USES, TIMEOUT_MILLISECONDS,
            TimeUnit.MILLISECONDS);

    this.ticket = new TicketGrantingTicketImpl("test", TestUtils.getAuthentication(), this.expirationPolicy);

}
 
Example #22
Source File: AbstractRegistryCleanerTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
private void populateRegistryWithExpiredTickets() {
    for (int i = 0; i < 10; i++) {
        TicketGrantingTicket ticket = new TicketGrantingTicketImpl("test" + i, TestUtils.getAuthentication(),
                new NeverExpiresExpirationPolicy());
        ticket.markTicketExpired();
        this.ticketRegistry.addTicket(ticket);
    }
}
 
Example #23
Source File: TicketGrantingTicketExpirationPolicyTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test
public void verifyTgtIsExpiredBySlidingWindow() throws InterruptedException {
    ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
    Thread.sleep(SLIDING_TIMEOUT - TIMEOUT_BUFFER);
    assertFalse(ticketGrantingTicket.isExpired());

    ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
    Thread.sleep(SLIDING_TIMEOUT - TIMEOUT_BUFFER);
    assertFalse(ticketGrantingTicket.isExpired());

    ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
    Thread.sleep(SLIDING_TIMEOUT + TIMEOUT_BUFFER);
    assertTrue(ticketGrantingTicket.isExpired());

}
 
Example #24
Source File: TicketGrantingTicketExpirationPolicyTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.expirationPolicy = new TicketGrantingTicketExpirationPolicy();
    this.expirationPolicy.setMaxTimeToLiveInMilliSeconds(HARD_TIMEOUT);
    this.expirationPolicy.setTimeToKillInMilliSeconds(SLIDING_TIMEOUT);
    this.ticketGrantingTicket = new TicketGrantingTicketImpl("test", TestUtils.getAuthentication(),
            this.expirationPolicy);
}
 
Example #25
Source File: TimeoutExpirationPolicyTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.expirationPolicy = new TimeoutExpirationPolicy(TIMEOUT);

    this.ticket = new TicketGrantingTicketImpl("test", TestUtils
        .getAuthentication(), this.expirationPolicy);

}
 
Example #26
Source File: AbstractTicketRegistryTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetTicketsFromRegistryEqualToTicketsAdded() {
    final Collection<Ticket> tickets = new ArrayList<Ticket>();

    for (int i = 0; i < TICKETS_IN_REGISTRY; i++) {
        final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl("TEST" + i,
                TestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
        final ServiceTicket st = ticketGrantingTicket.grantServiceTicket("tests" + i, TestUtils.getService(),
                new NeverExpiresExpirationPolicy(), false);
        tickets.add(ticketGrantingTicket);
        tickets.add(st);
        this.ticketRegistry.addTicket(ticketGrantingTicket);
        this.ticketRegistry.addTicket(st);
    }

    try {
        Collection<Ticket> ticketRegistryTickets = this.ticketRegistry.getTickets();
        assertEquals("The size of the registry is not the same as the collection.", ticketRegistryTickets.size(),
                tickets.size());

        for (final Ticket ticket : tickets) {
            if (!ticketRegistryTickets.contains(ticket)) {
                fail("Ticket was added to registry but was not found in retrieval of collection of all tickets.");
            }
        }
    } catch (final Exception e) {
        fail("Caught an exception. But no exception should have been thrown.");
    }
}
 
Example #27
Source File: Cas20ProxyHandlerTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test
public void verifyNonValidProxyTicket() throws Exception {
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setAcceptableCodes(new int[] {900});
    final HttpClient httpClient = clientFactory.getObject();
    this.handler.setHttpClient(httpClient);
    assertNull(this.handler.handle(new HttpBasedServiceCredential(new URL(
        "http://www.rutgers.edu"), TestUtils.getRegisteredService("https://some.app.edu")), proxyGrantingTicket));
}
 
Example #28
Source File: AbstractTicketRegistryTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeleteExistingTicket() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl("TEST", TestUtils.getAuthentication(),
                new NeverExpiresExpirationPolicy()));
        assertTrue("Ticket was not deleted.", this.ticketRegistry.deleteTicket("TEST"));
    } catch (final Exception e) {
        fail("Caught an exception. But no exception should have been thrown.");
    }
}
 
Example #29
Source File: HttpBasedServiceCredentialsAuthenticationHandlerTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test(expected = FailedLoginException.class)
public void verifyNoAcceptableStatusCodeButOneSet() throws Exception {
    final SimpleHttpClientFactoryBean clientFactory = new SimpleHttpClientFactoryBean();
    clientFactory.setAcceptableCodes(new int[] {900});
    final HttpClient httpClient = clientFactory.getObject();
    this.authenticationHandler.setHttpClient(httpClient);
    this.authenticationHandler.authenticate(TestUtils.getHttpBasedServiceCredentials("https://www.ja-sig.org"));
}
 
Example #30
Source File: ServiceTicketImplTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test
public void verifyTicketGrantingTicket() {
    final Authentication a = TestUtils.getAuthentication();
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("test", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
    final ServiceTicket s = t.grantServiceTicket(this.uniqueTicketIdGenerator.getNewTicketId(ServiceTicket.PREFIX),
            TestUtils.getService(), new MultiTimeUseOrTimeoutExpirationPolicy(1, 5000), false);
    final TicketGrantingTicket t1 = s.grantTicketGrantingTicket(
            this.uniqueTicketIdGenerator.getNewTicketId(TicketGrantingTicket.PREFIX), a,
            new NeverExpiresExpirationPolicy());

    assertEquals(a, t1.getAuthentication());
}