use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class TicketsResourceTests method configureCasMockToCreateValidST.
private void configureCasMockToCreateValidST() throws Throwable {
final ServiceTicket st = mock(ServiceTicket.class);
when(st.getId()).thenReturn("ST-1");
when(this.casMock.grantServiceTicket(anyString(), any(Service.class), any(AuthenticationResult.class))).thenReturn(st);
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateController method handleProxyGrantingTicketDelivery.
/**
* Handle proxy granting ticket delivery.
*
* @param serviceTicketId the service ticket id
* @param credential the service credential
* @return the ticket granting ticket
*/
private TicketGrantingTicket handleProxyGrantingTicketDelivery(final String serviceTicketId, final Credential credential) throws AuthenticationException, AbstractTicketException {
final ServiceTicket serviceTicket = this.centralAuthenticationService.getTicket(serviceTicketId, ServiceTicket.class);
final AuthenticationResult authenticationResult = this.authenticationSystemSupport.handleAndFinalizeSingleAuthenticationTransaction(serviceTicket.getService(), credential);
final TicketGrantingTicket proxyGrantingTicketId = this.centralAuthenticationService.createProxyGrantingTicket(serviceTicketId, authenticationResult);
LOGGER.debug("Generated proxy-granting ticket [[{}]] off of service ticket [{}] and credential [{}]", proxyGrantingTicketId.getId(), serviceTicketId, credential);
return proxyGrantingTicketId;
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketAndFormatAsJson.
@Test
public void verifyValidServiceTicketAndFormatAsJson() throws Exception {
final Service svc = CoreAuthenticationTestUtils.getService("proxyService");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(SERVICE_PARAM, svc.getId());
request.addParameter(TICKET_PARAM, sId.getId());
request.addParameter("format", ValidationResponseType.JSON.name());
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertTrue(modelAndView.getView().toString().contains("Json"));
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithInvalidPgt.
@Test
public void verifyValidServiceTicketWithInvalidPgt() throws Exception {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), SERVICE);
this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(SERVICE_PARAM, SERVICE.getId());
request.addParameter(TICKET_PARAM, sId.getId());
request.addParameter(PGT_URL_PARAM, "duh");
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertTrue(modelAndView.getView().toString().contains(SUCCESS));
assertNull(modelAndView.getModel().get(PGT_IOU_PARAM));
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithValidPgtAndProxyHandlerFailing.
@Test
public void verifyValidServiceTicketWithValidPgtAndProxyHandlerFailing() throws Exception {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), SERVICE);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(SERVICE_PARAM, SERVICE.getId());
request.addParameter(TICKET_PARAM, sId.getId());
request.addParameter(PGT_URL_PARAM, GITHUB_URL);
this.serviceValidateController.setProxyHandler(new ProxyHandler() {
@Override
public String handle(final Credential credential, final TicketGrantingTicket proxyGrantingTicketId) {
return null;
}
@Override
public boolean canHandle(final Credential credential) {
return true;
}
});
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertFalse(modelAndView.getView().toString().contains(SUCCESS));
assertNull(modelAndView.getModel().get(PGT_IOU_PARAM));
}
Aggregations