use of org.apereo.cas.authentication.principal.WebApplicationService in project cas by apereo.
the class AbstractServiceValidateController method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final WebApplicationService service = this.argumentExtractor.extractService(request);
final String serviceTicketId = service != null ? service.getArtifactId() : null;
if (service == null || serviceTicketId == null) {
LOGGER.debug("Could not identify service and/or service ticket for service: [{}]", service);
return generateErrorView(CasProtocolConstants.ERROR_CODE_INVALID_REQUEST, null, request, service);
}
try {
return handleTicketValidation(request, service, serviceTicketId);
} catch (final AbstractTicketValidationException e) {
final String code = e.getCode();
return generateErrorView(code, new Object[] { serviceTicketId, e.getOriginalService().getId(), service.getId() }, request, service);
} catch (final AbstractTicketException e) {
return generateErrorView(e.getCode(), new Object[] { serviceTicketId }, request, service);
} catch (final UnauthorizedProxyingException e) {
return generateErrorView(CasProtocolConstants.ERROR_CODE_UNAUTHORIZED_SERVICE_PROXY, new Object[] { service.getId() }, request, service);
} catch (final UnauthorizedServiceException e) {
return generateErrorView(CasProtocolConstants.ERROR_CODE_UNAUTHORIZED_SERVICE, null, request, service);
}
}
use of org.apereo.cas.authentication.principal.WebApplicationService in project cas by apereo.
the class OAuthWebApplicationServiceTests method verifySerializeACompletePrincipalToJson.
@Test
public void verifySerializeACompletePrincipalToJson() throws IOException {
final AbstractRegisteredService service = new OAuthRegisteredService();
service.setName("checkCloning");
service.setServiceId("testId");
service.setTheme("theme");
service.setDescription("description");
final WebApplicationServiceFactory factory = new WebApplicationServiceFactory();
final WebApplicationService serviceWritten = factory.createService(service.getServiceId());
MAPPER.writeValue(JSON_FILE, serviceWritten);
final WebApplicationService serviceRead = MAPPER.readValue(JSON_FILE, WebApplicationService.class);
assertEquals(serviceWritten, serviceRead);
}
use of org.apereo.cas.authentication.principal.WebApplicationService in project cas by apereo.
the class OpenIdServiceFactoryTests method verifyServiceCreationSuccessfullyById.
@Test
public void verifyServiceCreationSuccessfullyById() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "test");
request.addParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "identity");
final OpenIdServiceFactory factory = new OpenIdServiceFactory("");
final WebApplicationService service = factory.createService(request);
assertNotNull(service);
}
use of org.apereo.cas.authentication.principal.WebApplicationService in project cas by apereo.
the class OpenIdServiceFactoryTests method verifyServiceCreationMissingId.
@Test
public void verifyServiceCreationMissingId() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "test");
final OpenIdServiceFactory factory = new OpenIdServiceFactory("");
final WebApplicationService service = factory.createService(request);
assertNull(service);
}
use of org.apereo.cas.authentication.principal.WebApplicationService in project cas by apereo.
the class OpenIdServiceFactoryTests method verifyServiceCreationMissingReturn.
@Test
public void verifyServiceCreationMissingReturn() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "identity");
final OpenIdServiceFactory factory = new OpenIdServiceFactory("");
final WebApplicationService service = factory.createService(request);
assertNull(service);
}
Aggregations