private void addXForwardedForHeaderAttribute(HttpServletRequest servletRequest, SecuredServiceRequest secRequest) { // Insert to enable SinqleInquiry Interceptor secRequest.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_XFORWARDEDFOR, servletRequest.getRemoteAddr())); }
private void addReferrerHeaderAttribute(HttpServletRequest servletRequest, SecuredServiceRequest secRequest) { // insert referer String referer = servletRequest.getHeader(HttpHeaderAttribute.HEADER_NAME_REFERER); if (referer != null && referer.length() > 0) { secRequest.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_REFERER, referer)); } }
private void addContentTypeHeaderAttribute(HttpServletRequest servletRequest, SecuredServiceRequest secRequest) { if (servletRequest.getContentType() != null) { secRequest.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTTYPE, servletRequest.getContentType())); } }
private void addGzipHeaderIfAccepted(FacadeResponse facadeResponse, Transferable serverResponse) { if (facadeResponse.isGzipAccepted()) { serverResponse.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute(HttpHeaderAttribute.HEADER_NAME_CONTENT_ENCODING, "gzip")); } }
private void addContentCharsetHeaderAttribute(HttpServletRequest servletRequest, SecuredServiceRequest secRequest) { // this is obviously a misuse of the "Content-Encoding" header that // describes the encoding of the /content/ of the body // and not the body itself. However, it is added to imitate what is done // by the SecurityServiceServlet class. secRequest.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTCHARSET, getNullSafeEncoding(servletRequest))); }
public Transferable createTextualTransferable(final String pContentType, final String pPayLoad, final String pTargetCharset) { Transferable lTransferable = new TransferableImpl(); lTransferable.setPayload(new TextualPayload(pPayLoad, pTargetCharset)); if (pContentType != null) { String contentType = addCharset(pContentType, pTargetCharset); lTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTTYPE, contentType)); } if (pTargetCharset != null) { lTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTCHARSET, pTargetCharset)); } return lTransferable; }
public Transferable createStreamTransferable(final String pContentType, final InputStream pPayLoad, final String pCharset) throws IOException { Transferable lTransferable = new TransferableImpl(); lTransferable.setPayload(new StreamPayload(pPayLoad, pCharset)); if (pContentType != null) { String contentType = addCharset(pContentType, pCharset); lTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTTYPE, contentType)); } if (pCharset != null) { lTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTCHARSET, pCharset)); } return lTransferable; }
responseTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute(header.getKey(), headerValues.toString())); LOG.debug("Adding response header -> {}: {}", header.getKey(), header.getValue()); if (acceptEncoding != null && acceptEncoding.contains("gzip")) { responseTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENT_ENCODING, "gzip")); } else {
lRes.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute(key, headerValue)); if (LOG.isDebugEnabled()) { LOG.debug("Add Response HeaderAttribute -> " + key + " = " + headerValue);
private Transferable addCommonAttributes(Transferable request) { String pathInfo = getPathInfo(); String additionalPath = FacadeTools.extractAdditionalPathInfo(pathInfo); request.addAttribute(new SimpleTransferAttribute(TransferAttribute.PATHINFO_ATTR, additionalPath)); request.addAttribute(new SimpleTransferAttribute(TransferAttribute.REQUEST_IP_ATTR, getRemoteAddress())); // Is the "X-Forwarded-For" header already set? String headerXForwardedFor = getXForwardedForHeader(); // If not set, set caller's ip, otherwise append caller's ip headerXForwardedFor = (headerXForwardedFor == null) ? getRemoteAddress() : headerXForwardedFor .concat(" ," + getRemoteAddress()); // Create according TransferAttribute request.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_XFORWARDEDFOR, headerXForwardedFor)); String referrerHeader = getHttpReferrerHeader(); if (referrerHeader != null) { request.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute(HttpHeaderAttribute.HEADER_NAME_REFERER, referrerHeader)); } return request; }