validationURL.addQueryParameter("pgtUrl", getServiceURL(request));
ClientResource serviceValidate = new ClientResource(validationURL);
try {
Representation validationResult = serviceValidate.get();
ServiceResponse serviceResponse = ServiceResponseParser.parse(validationResult.getStream());
if (serviceResponse instanceof AuthSuccess) {
AuthSuccess authSuccess = (AuthSuccess)serviceResponse;
request.getClientInfo().setUser(new User(authSuccess.getUser()));
logger.debug("Validated CAS-ticket for user '{}'", authSuccess.getUser());
if (authSuccess.getProxyGrantingTicket() != null) {
String pgtId = pgtIouMap.remove(authSuccess.getProxyGrantingTicket());
if (pgtId != null) {
ProxyGrantingTicketRegistry.storeProxyGrantingTicket(pgtId);
}
else {
logger.warn("pgtIou mapping missing for validated user '{}'", authSuccess.getUser());
}
}
return true;
}
else if (serviceResponse instanceof AuthFailure) {
AuthFailure authFailure = (AuthFailure)serviceResponse;
response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED, authFailure.getMessage());
}
else {
logger.warn("Unexpected response from CAS server ({}): {}", serviceResponse.getClass(),
serviceResponse);
response.setStatus(Status.SERVER_ERROR_INTERNAL, "CAS server communication problem");
}
}
catch (ResourceException e) {