use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketAndBadFormat.
@Test
public void verifyValidServiceTicketAndBadFormat() throws Exception {
final Service svc = RegisteredServiceTestUtils.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(CasProtocolConstants.PARAMETER_SERVICE, svc.getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
request.addParameter(CasProtocolConstants.PARAMETER_FORMAT, "NOTHING");
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertTrue(modelAndView.getView().toString().contains("Success"));
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithDifferentEncoding.
/*
CAS10 Proxying Tests.
*/
@Test
public void verifyValidServiceTicketWithDifferentEncoding() throws Exception {
final Service svc = RegisteredServiceTestUtils.getService("http://www.jasig.org?param=hello+world");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
final String reqSvc = "http://www.jasig.org?param=hello%20world";
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(reqSvc).getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
assertTrue(this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketAndFormatAsJson.
@Test
public void verifyValidServiceTicketAndFormatAsJson() throws Exception {
final Service svc = RegisteredServiceTestUtils.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(CasProtocolConstants.PARAMETER_SERVICE, svc.getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
request.addParameter(CasProtocolConstants.PARAMETER_FORMAT, ValidationResponseType.JSON.name());
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertTrue(modelAndView.getView().toString().contains("Json"));
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase.
@Test
public void verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase() throws Exception {
final String origSvc = "http://www.jasig.org?param=hello+world";
final Service svc = RegisteredServiceTestUtils.getService(origSvc);
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
final String reqSvc = "http://WWW.JASIG.ORG?PARAM=hello%20world";
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(reqSvc).getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
assertTrue(this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class WSFederationAuthenticationServiceSelectionStrategy method getRealmAsParameter.
private static Optional<NameValuePair> getRealmAsParameter(final Service service) {
try {
final URIBuilder builder = new URIBuilder(service.getId());
final Optional param = builder.getQueryParams().stream().filter(p -> p.getName().equals(WSFederationConstants.WTREALM)).findFirst();
return param;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return Optional.empty();
}
Aggregations