summaryrefslogtreecommitdiff
path: root/bkucommon
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-11-11 20:54:32 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-11-11 20:54:32 +0000
commit1dde2d674df750e818fd8ac5e9363730a2422d9b (patch)
treedd095ba3e66d2ab898b639404cc52abe8f84de8b /bkucommon
parent4af1d0a0d6fb6f4784067d320e42504922710788 (diff)
downloadmocca-1dde2d674df750e818fd8ac5e9363730a2422d9b.tar.gz
mocca-1dde2d674df750e818fd8ac5e9363730a2422d9b.tar.bz2
mocca-1dde2d674df750e818fd8ac5e9363730a2422d9b.zip
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
Diffstat (limited to 'bkucommon')
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessorImpl.java32
1 files changed, 20 insertions, 12 deletions
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: