From 1dde2d674df750e818fd8ac5e9363730a2422d9b Mon Sep 17 00:00:00 2001 From: tkellner Date: Mon, 11 Nov 2013 20:54:32 +0000 Subject: Allow SL redirects to work for other codes than 307 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1214 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../egiz/bku/binding/HTTPBindingProcessorImpl.java | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'bkucommon/src/main') diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessorImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessorImpl.java index 34e04b4d..d4ed4f1e 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessorImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessorImpl.java @@ -120,6 +120,8 @@ public class HTTPBindingProcessorImpl extends AbstractBindingProcessor implement public static final String USE_XADES_1_4 = "UseXAdES14"; + public static final String ALLOW_OTHER_REDIRECTS = "AllowOtherRedirects"; + public int getMaxDataUrlHops() { return configuration.getInt(DATAURLCLIENT_MAXHOPS, 10); } @@ -174,6 +176,10 @@ public class HTTPBindingProcessorImpl extends AbstractBindingProcessor implement public boolean getUseXAdES14() { return configuration.getBoolean(USE_XADES_1_4, false); } + + public boolean getAllowOtherRedirects() { + return configuration.getBoolean(ALLOW_OTHER_REDIRECTS, false); + } } /** @@ -440,9 +446,14 @@ public class HTTPBindingProcessorImpl extends AbstractBindingProcessor implement // process Dataurl response dataUrlResponse = conn.getResponse(); - log.debug("Received data url response code: {}.", dataUrlResponse.getResponseCode()); + int code = dataUrlResponse.getResponseCode(); + log.debug("Received data url response code: {}.", code); - switch (dataUrlResponse.getResponseCode()) { + if (configurationFacade.getAllowOtherRedirects() && + (code >= 301) && (code <= 303)) + code = 307; + + switch (code) { case 200: String contentType = dataUrlResponse.getContentType(); log.debug("Got dataurl response content type: {}.", contentType); @@ -492,8 +503,8 @@ public class HTTPBindingProcessorImpl extends AbstractBindingProcessor implement closeDataUrlConnection(); throw new SLBindingException(2007); } - break; + case 307: contentType = dataUrlResponse.getContentType(); if ((contentType != null) && (contentType.startsWith(HttpUtil.TXT_XML))) { @@ -521,16 +532,13 @@ public class HTTPBindingProcessorImpl extends AbstractBindingProcessor implement srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders() .get(HttpUtil.HTTP_HEADER_REFERER)); - } else { - log.debug( - "Received dataurl response code 307 non XML content: {}.", - dataUrlResponse.getContentType()); - resultContentType = dataUrlResponse.getContentType(); - currentState = State.FINISHED; + responseHeaders = dataUrlResponse.getResponseHeaders(); + responseCode = dataUrlResponse.getResponseCode(); + break; } - responseHeaders = dataUrlResponse.getResponseHeaders(); - responseCode = dataUrlResponse.getResponseCode(); - break; + log.debug("Received dataurl response code 307 with non XML content: {}.", + dataUrlResponse.getContentType()); + // Fall through to 301-303! case 301: case 302: -- cgit v1.2.3