provider.setExpectedEncoded(true);
}
public Response handleRequest(Message message, ClassResourceInfo resourceClass) {
Form form = readFormData(message);
String assertion = form.getData().getFirst(SAML_ELEMENT);
handleToken(message, assertion);
// redirect if needed
String samlRequestURI = form.getData().getFirst(SAML_RELAY_STATE);
if (samlRequestURI != null) {
// RelayState may actually represent a reference to a transient local state
// containing the actual REQUEST URI client was using before being redirected
// back to IDP - at the moment assume it's URI
UriInfoImpl ui = new UriInfoImpl(message);
if (!samlRequestURI.startsWith(ui.getBaseUri().toString())) {
return Response.status(302).location(URI.create(samlRequestURI)).build();
}
}
// restore input stream
CachedOutputStream os = new CachedOutputStream();
form.getData().remove(SAML_ELEMENT);
form.getData().remove(SAML_RELAY_STATE);
try {
provider.writeTo(form, Form.class, Form.class, new Annotation[]{},
MediaType.APPLICATION_FORM_URLENCODED_TYPE, new MetadataMap<String, Object>(), os);
message.setContent(InputStream.class, os.getInputStream());
} catch (Exception ex) {