public void authorize(final HttpServletResponse resp, PolicyEnforcementServiceImpl pes, SecuredServiceRequest secRequest, AuthenticationContext authCtx) { Transferable response; try { response = pes.doService(secRequest, authCtx); } catch (ServiceException e) { new TransferableServletWriter(e.getAsTransferable()).write(resp); return; } new TransferableServletWriter(response).write(resp); }
/** * sets all cache-relevant headers * * @param servletResponse the {@link HttpServletResponse} to add the headers to */ public void setCacheHeaders(HttpServletResponse servletResponse) { addHeader(servletResponse, getTransferable().getAttribute(HttpHeaderAttribute.HEADER_CACHE_CONTROL)); addHeader(servletResponse, getTransferable().getAttribute(HttpHeaderAttribute.HEADER_EXPIRES)); addHeader(servletResponse, getTransferable().getAttribute(HttpHeaderAttribute.HEADER_E_TAG)); addHeader(servletResponse, getTransferable().getAttribute(HttpHeaderAttribute.HEADER_LAST_MODIFIED)); }
setStatusCodeHeader(servletResponse); setContentTypeHeader(servletResponse); setCacheHeaders(servletResponse); addHeader(servletResponse, getTransferable().getAttribute(HttpHeaderAttribute.HEADER_LOCATION)); TransferAttribute contentEncoding = getTransferable().getAttribute(HttpHeaderAttribute.HEADER_NAME_CONTENT_ENCODING); boolean gzip = contentEncoding != null && "gzip".equalsIgnoreCase((String) contentEncoding.getValue()); if (gzip) { addHeader(servletResponse, contentEncoding); if (LOG.isDebugEnabled()) { LOG.debug("enable <gzip> compression!"); addHeader(servletResponse, getTransferable().getAttribute(HttpHeaderAttribute.HEADER_NAME_COOKIE)); OutputStream destinationStream; try { return; InputStream sourceStream = getTransferable().getPayload().getAsStream(); writeStream(sourceStream, destinationStream, gzip);
public void setStatusCodeHeader(HttpServletResponse servletResponse) { String httpCode = (String) getTransferable().getAttributeValue(HttpHeaderAttribute.RESPONSE_STATUS_CODE); if (httpCode != null && httpCode.length() > 0) { // write the correct status code servletResponse.setStatus(Integer.parseInt(httpCode)); } // Write only known HttpHeaders! }
public void authorize(final HttpServletResponse resp, PolicyEnforcementServiceImpl pes, SecuredServiceRequest secRequest) { AuthenticationContext authctx = AuthenticationContextUtil.getCurrentAuthenticationContext(); Transferable response; try { response = pes.doService(secRequest, authctx); } catch (ServiceException e) { new TransferableServletWriter(e.getAsTransferable()).write(resp); return; } new TransferableServletWriter(response).write(resp); }
public void setContentTypeHeader(HttpServletResponse servletResponse) { addHeader(servletResponse, getTransferable().getAttribute(HttpHeaderAttribute.HEADER_NAME_CONTENTTYPE)); }
throw new ServiceException("Could not create capabilities document", ServiceException.SERVICE_ERROR, e); new TransferableServletWriter(transferableCaps).write(m_servletResponse); throw new AuthenticationTerminationException("Returning WSS GetCapabilities response."); } else if ("GetSession".equalsIgnoreCase(m_wssParamOperation)) { AuthenticationContext authenticationContext = login(credential); SessionInfo sessionInfo = m_sessionService.createSession(authenticationContext); new TransferableServletWriter(sessionInfo.getAsTransferable()).write(m_servletResponse); throw new AuthenticationTerminationException("Returning WSS GetSession response."); } else if ("CloseSession".equalsIgnoreCase(m_wssParamOperation)) { new TransferableServletWriter(TransferableFactory.getInstance().createTextualTransferable("text/plain", "success", "UTF-8")).write(m_servletResponse); throw new AuthenticationTerminationException("Returning WSS CloseSession response."); } else if ("DoService".equalsIgnoreCase(m_wssParamOperation)) {
public AuthenticationContext authenticate(ServletRequestResponseContext requestCtx, AuthenticationService authService) throws AuthenticationException { m_servletRequest = requestCtx.getRequest(); m_servletResponse = requestCtx.getResponse(); m_wssRequestUrl = getWssRequestUrlFactory().getInstance(m_servletRequest); m_authenticationService = authService; try { assertHttpPostOrGetOrEmpty(); initWSSProtocolParameters(); extractWssParamOperation(); extractWssParamService(); extractWssParamVersion(); if (wssParamOperationNotNull()) { LOG.debug("Missing REQUEST parameter"); return m_authenticationService.createAuthenticationContext(); } AuthenticationContext authCtx = handleWSSOperation(); //We only get here if request was "DoService", cause otherwise handleWSSOperation threw an Exception. WSSHttpServletRequest wssRequest = wrapServletRequest(m_servletRequest); requestCtx.setRequest(wssRequest); return authCtx; } catch (ServiceException e) { new TransferableServletWriter(e.getAsTransferable()).write(m_servletResponse); // TODO Check what we really must return. return null; } }