summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwbauer <wbauer@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-09-25 07:29:47 +0000
committerwbauer <wbauer@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-09-25 07:29:47 +0000
commite21dd5249d5fa19c5619847922cf8cdea95e3145 (patch)
tree00756b302d7fe37a4912ff5da812e25e2a781d9b
parent55302f2bbe65d28a21d61822f3c316a7fafd1eff (diff)
downloadmocca-e21dd5249d5fa19c5619847922cf8cdea95e3145.tar.gz
mocca-e21dd5249d5fa19c5619847922cf8cdea95e3145.tar.bz2
mocca-e21dd5249d5fa19c5619847922cf8cdea95e3145.zip
improved robustness of http binding processor
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@70 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java6
-rw-r--r--BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/defaultConf.properties1
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java2
-rw-r--r--BKUOnline/src/main/webapp/META-INF/MANIFEST.MF7
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessor.java4
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java9
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java8
-rw-r--r--smcc/src/main/java/at/gv/egiz/smcc/utils/SingletonPINProvider.java38
-rw-r--r--utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java3
-rw-r--r--utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java30
10 files changed, 52 insertions, 56 deletions
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java
index 43dbf745..46668667 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java
@@ -128,10 +128,14 @@ public class SpringConfigurator extends Configurator implements
if ((proxy == null) || (proxy.equals(""))) {
log.info("No proxy configured");
} else {
- log.info("Setting proxy to: "+proxy+":"+portString);
+ log.info("Setting proxy to: " + proxy + ":" + portString);
System.setProperty("proxyHost", proxy);
System.setProperty("proxyPort", portString);
}
+ String timeout = getProperty("DefaultSocketTimeout");
+ if ((timeout != null) && (!timeout.equals(""))) {
+ System.setProperty("sun.net.client.defaultConnectTimeout", timeout);
+ }
}
private Set<TrustAnchor> getCACerts() throws IOException,
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/defaultConf.properties b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/defaultConf.properties
index 6d59ec21..29bdd1ed 100644
--- a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/defaultConf.properties
+++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/defaultConf.properties
@@ -54,6 +54,7 @@ ValidateHashDataInputs=true
HTTPProxyHost=
HTTPProxyPort=
+DefaultSocketTimeout=200
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
index 385888e9..d3d6c8db 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
@@ -248,6 +248,6 @@ public class STALServiceImpl implements STALPortType {
ServletContext sCtx = (ServletContext) mCtx.get(MessageContext.SERVLET_CONTEXT);
BindingProcessorManager bpMgr = (BindingProcessorManager) sCtx.getAttribute(BINDING_PROCESSOR_MANAGER);
BindingProcessor bp = bpMgr.getBindingProcessor(sessionId);
- return (bp == null) ? null : (STALRequestBroker) bp.getSTAL();
+ return (bp == null) ? null : (bp.isFinished() ? null : (STALRequestBroker) bp.getSTAL());
}
}
diff --git a/BKUOnline/src/main/webapp/META-INF/MANIFEST.MF b/BKUOnline/src/main/webapp/META-INF/MANIFEST.MF
index 5e949512..ca7c7604 100644
--- a/BKUOnline/src/main/webapp/META-INF/MANIFEST.MF
+++ b/BKUOnline/src/main/webapp/META-INF/MANIFEST.MF
@@ -1,3 +1,6 @@
Manifest-Version: 1.0
-Class-Path:
-
+Archiver-Version: Plexus Archiver
+Created-By: Apache Maven
+Built-By: wbauer
+Build-Jdk: 1.6.0_10-beta
+Implementation-Build: 1.0-SNAPSHOT-r31 \ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessor.java
index c386508d..2569bf85 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessor.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessor.java
@@ -71,5 +71,7 @@ public interface BindingProcessor extends Runnable {
* If the locale is not set the default locale will be used.
* @param locale must not be null.
*/
- public void setLocale(Locale locale);
+ public void setLocale(Locale locale);
+
+ public boolean isFinished();
} \ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
index 8f72c3ee..5e44e82b 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
@@ -115,6 +115,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
protected int responseCode = 200;
protected Map<String, String> responseHeaders = Collections.EMPTY_MAP;
protected Locale locale = Locale.getDefault();
+ protected boolean finished = false;
/**
*
@@ -246,6 +247,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
commandInvoker.setCommand(slCommand);
responseCode = 200;
responseHeaders = Collections.EMPTY_MAP;
+ dataUrlResponse = null;
try {
commandInvoker.invoke(srcContex);
} catch (SLException e) {
@@ -253,7 +255,6 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
bindingProcessorError = e;
currentState = State.TRANSFORM;
}
- dataUrlResponse = null;
if (getDataUrl() != null) {
log.debug("Data Url set to: " + getDataUrl());
currentState = State.DATAURL;
@@ -495,6 +496,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
sendSTALQuit();
log.info("Terminating Bindingprocessor; Thread: "
+ Thread.currentThread().getId());
+ finished = true;
}
// -- END Methods that handle the http binding activities as defined in the
@@ -620,6 +622,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
currentState = State.FINISHED;
}
log.debug("Terminated http binding processor");
+ finished = true;
}
@Override
@@ -805,4 +808,8 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
this.locale = locale;
}
+ @Override
+ public boolean isFinished() {
+ return finished;
+ }
} \ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
index 4d64ae36..b6c89e5b 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
@@ -371,12 +371,12 @@ public class InfoboxReadCommandImpl extends SLCommandImpl<InfoboxReadRequestType
infoboxReadRequest = new InfoboxReadRequest();
infoboxReadRequest.setInfoboxIdentifier("SecureSignatureKeypair");
stalRequests.add(infoboxReadRequest);
-
infoboxReadRequest = new InfoboxReadRequest();
infoboxReadRequest.setInfoboxIdentifier("CertifiedKeypair");
stalRequests.add(infoboxReadRequest);
requestSTAL(stalRequests);
+ log.trace("Got STAL response");
IdentityLink identityLink = getIdentityLinkFromResponses();
List<X509Certificate> certificates = getCertificatesFromResponses();
@@ -413,10 +413,12 @@ public class InfoboxReadCommandImpl extends SLCommandImpl<InfoboxReadRequestType
Result xmlResult = (isXMLEntity || identityLinkDomainIdentifier != null)
? result.getXmlResult(true)
: new StreamResult((resultBytes = new ByteArrayOutputStream()));
- try {
+ try {
+ log.trace("Trying to transform identitylink");
identityLinkTransformer.transformIdLink(issuerTemplate, new DOMSource(document), xmlResult);
} catch (IOException e) {
- // we should not get an IOException as we are writing into a DOMResult
+ // we should not get an IOException as we are writing into a DOMResult
+ log.warn("Failed to transform idlink",e);
throw new SLRuntimeException(e);
} catch (TransformerException e) {
log.info("Faild to transform CompressedIdentityLink.", e);
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/utils/SingletonPINProvider.java b/smcc/src/main/java/at/gv/egiz/smcc/utils/SingletonPINProvider.java
deleted file mode 100644
index e5030da2..00000000
--- a/smcc/src/main/java/at/gv/egiz/smcc/utils/SingletonPINProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.smcc.utils;
-
-import at.gv.egiz.smcc.PINProvider;
-import at.gv.egiz.smcc.PINSpec;
-
-public class SingletonPINProvider implements PINProvider {
-
- private String pin;
- private boolean pin_already_provided = false;
-
- public SingletonPINProvider(String pin) {
- this.pin = pin;
- }
-
- public String providePIN(PINSpec spec, int retries) {
- if (pin_already_provided)
- return null;
- pin_already_provided = true;
- return pin;
- }
-
-}
diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java
index 600e5605..8d01fad1 100644
--- a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java
+++ b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java
@@ -52,7 +52,8 @@ public class HTTPURLProtocolHandlerImpl implements URLProtocolHandler {
protected StreamData dereferenceHTTP(URL url) throws IOException {
log.debug("Dereferencing url: "+url);
- HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ log.trace("Successfully opened connection");
return new StreamData(url.toString(), httpConn.getContentType(), httpConn
.getInputStream());
}
diff --git a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java
index 060ccef5..98f8d1c1 100644
--- a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java
+++ b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java
@@ -35,13 +35,20 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.stream.StreamSource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
-public class IdentityLinkTransformer {
+public class IdentityLinkTransformer {
+
+ protected static Log log = LogFactory.getLog(IdentityLinkTransformer.class);
private class IdLTransformer {
@@ -101,11 +108,15 @@ public class IdentityLinkTransformer {
if (!"http".equalsIgnoreCase(url.getProtocol()) && !"https".equalsIgnoreCase(url.getProtocol())) {
throw new MalformedURLException("Protocol " + url.getProtocol() + " not supported for IssuerTemplate URL.");
- }
- StreamSource source = new StreamSource(url.openStream());
+ }
+
+ URLDereferencer dereferencer = URLDereferencer.getInstance();
+ StreamData data = dereferencer.dereference(url.toExternalForm(), null);
+ StreamSource source = new StreamSource(data.getStream());
+ log.trace("Trying to creating template from stylesheet");
templates = factory.newTemplates(source);
-
+ log.trace("Successfully created stylesheet template");
initTime = System.currentTimeMillis() - created;
}
@@ -233,7 +244,7 @@ public class IdentityLinkTransformer {
pool = new HashMap<String, List<IdLTransformer>>();
}
- private synchronized IdLTransformer getFreeTransfomer(String stylesheetURL) throws TransformerConfigurationException, IOException {
+ private IdLTransformer getFreeTransfomer(String stylesheetURL) throws TransformerConfigurationException, IOException {
IdLTransformer transformer = null;
@@ -260,9 +271,12 @@ public class IdentityLinkTransformer {
}
- public void transformIdLink(String stylesheetURL, Source source, Result result) throws IOException, TransformerException {
- IdLTransformer transformer = getFreeTransfomer(stylesheetURL);
- transformer.transform(source, result);
+ public void transformIdLink(String stylesheetURL, Source source, Result result) throws IOException, TransformerException {
+ log.trace("Trying to get free IdentityLinkTransformer for issuer template '" + stylesheetURL + "'.");
+ IdLTransformer transformer = getFreeTransfomer(stylesheetURL);
+ log.trace("Trying to transform IdentityLink.");
+ transformer.transform(source, result);
+ log.trace("IdentityLink transformed successfully. " + getStatistics());
}
public String getStatistics() {