org.jasig.cas.client.validation.Cas30ServiceTicketValidator Java Examples

The following examples show how to use org.jasig.cas.client.validation.Cas30ServiceTicketValidator. 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: CasTicketValidatorUtils.java    From shiro-cas-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
protected static TicketValidator buildCas30TicketValidator(final ShiroCasProperties casProperties) {
      
      final boolean allowAnyProxy = casProperties.isAcceptAnyProxy();
final String allowedProxyChains = casProperties.getAllowedProxyChains();
final String casServerUrlPrefix = casProperties.getCasServerUrlPrefix();

final Class<? extends Cas20ServiceTicketValidator> ticketValidatorClass = StringUtils.hasText(casProperties.getTicketValidatorClass()) ? ReflectUtils.loadClass(casProperties.getTicketValidatorClass()) : null; 
final Cas20ServiceTicketValidator validator;

if (allowAnyProxy || CommonUtils.isNotBlank(allowedProxyChains)) {
	final Cas20ProxyTicketValidator v = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, Cas30ProxyTicketValidator.class);
	v.setAcceptAnyProxy(allowAnyProxy);
	v.setAllowedProxyChains(CommonUtils.createProxyList(allowedProxyChains));
	validator = v;
} else {
	validator = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, Cas30ServiceTicketValidator.class);
}
validator.setProxyCallbackUrl(casProperties.getProxyCallbackUrl());
validator.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);

HttpURLConnectionFactory factory = new HttpsURLConnectionFactory( HttpsURLConnection.getDefaultHostnameVerifier(), getSSLConfig(casProperties));

validator.setURLConnectionFactory(factory);

validator.setProxyRetriever(new Cas20ProxyRetriever(casServerUrlPrefix, casProperties.getEncoding(), factory));
validator.setRenew(casProperties.isRenew());
validator.setEncoding(casProperties.getEncoding());

      return validator;
      
  }
 
Example #2
Source File: ShibcasAuthServletTest.java    From shib-cas-authn3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoGetPassiveAndForced() throws Exception {
    //Mock some objects.
    final HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET_GATEWAY_ATTEMPTED, TICKET, "true");
    final HttpServletResponse response = createMockHttpServletResponse();
    final Assertion assertion = createMockAssertion();

    final Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas30ServiceTicketValidator.class);
    PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION_GATEWAY_ATTEMPTED)).thenReturn(assertion);

    PowerMockito.mockStatic(ExternalAuthentication.class);
    BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);

    //Prep our object
    final ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

    //Override the internal Cas30TicketValidator because we don't want it to call a real server
    MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

    //Passive and forced request/response
    BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("true");
    BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("true");
    shibcasAuthServlet.doGet(request, response);

    //Verify
    verify(request).setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, JDOE);
}
 
Example #3
Source File: ShibcasAuthServletTest.java    From shib-cas-authn3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoGetPassiveAndForced() throws Exception {
    //Mock some objects.
    final HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET_GATEWAY_ATTEMPTED, TICKET, "true");
    final HttpServletResponse response = createMockHttpServletResponse();
    final Assertion assertion = createMockAssertion();

    final Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas30ServiceTicketValidator.class);
    PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION_GATEWAY_ATTEMPTED)).thenReturn(assertion);

    PowerMockito.mockStatic(ExternalAuthentication.class);
    BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);

    //Prep our object
    final ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

    //Override the internal Cas30TicketValidator because we don't want it to call a real server
    MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

    //Passive and forced request/response
    BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("true");
    BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("true");
    shibcasAuthServlet.doGet(request, response);

    //Verify
    verify(request).setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, JDOE);
}
 
Example #4
Source File: CasSecuredApplication.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public TicketValidator ticketValidator() {
    return new Cas30ServiceTicketValidator("https://localhost:8443");
}