protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException,
IOException {
EnforcementServiceRequest wssRequestUrl = getWssRequestUrlFactory().getInstance(ServletUtils.getServletLocation(req), req.getServletPath(), req.getPathInfo());
String authenticationScheme = getWssRequestUrlFactory().getAuthenticationScheme((WSSRequestUrl) wssRequestUrl);
String pesId = wssRequestUrl.getEnforcementPointId();
PolicyEnforcementServiceImpl pes = m_pesLocator.locate(pesId, authenticationScheme);
if (pes == null) {
String errorMessage =
String.format(
"No enforcement point configuration for id <%s>",
pesId);
resp.sendError(HttpServletResponse.SC_NOT_FOUND, errorMessage);
return;
}
ForwardingSecuredServiceRequestBuilder requestBuilder = new ForwardingSecuredServiceRequestBuilder(wssRequestUrl);
requestBuilder.setProtectedServiceEndpoint(new URL(pes.getEndpoint()));
requestBuilder.setRedirectionAuthenticationUrl(buildRedirectionUrl(wssRequestUrl, getWssRequestUrlFactory(), pes.getRedirectionAuthenticationScheme()));
SecuredServiceRequest secRequest = requestBuilder.build(req, resp);
secRequest.addAttribute(new SimpleTransferAttribute(HttpRequestForward.HTTP_CLIENT_FACTORY, getHttpClientFactory()));
authorize(resp, pes, secRequest);
}