summaryrefslogtreecommitdiff
path: root/bkucommon/src
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-10-30 10:33:29 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-10-30 10:33:29 +0000
commitc2ae3db1bc6dcb8ba3eb3461c05e293917c004ca (patch)
tree78151b3f5364daac73dc305f536fae2aa2998521 /bkucommon/src
parent687e55f5dbc25855c42757e3024a3c87126803e7 (diff)
downloadmocca-c2ae3db1bc6dcb8ba3eb3461c05e293917c004ca.tar.gz
mocca-c2ae3db1bc6dcb8ba3eb3461c05e293917c004ca.tar.bz2
mocca-c2ae3db1bc6dcb8ba3eb3461c05e293917c004ca.zip
Updated SMCC to use exclusive access and to throw exceptions upon locked or not activated cards. Improved locale support in the security layer request and response processing. Fixed issue in STAL which prevented the use of RSA-SHA1 signatures. Added additional parameters to the applet test pages.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@128 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'bkucommon/src')
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java3
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandContext.java17
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java4
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java42
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java2
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java8
-rw-r--r--bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java3
7 files changed, 57 insertions, 22 deletions
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 5e44e82b..4a22874c 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
@@ -564,6 +564,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
SLCommandContext commandCtx = new SLCommandContext();
commandCtx.setSTAL(getSTAL());
commandCtx.setURLDereferencerContext(new SimpleFormDataContextImpl(this));
+ commandCtx.setLocale(locale);
slCommand = SLCommandFactory.getInstance().createSLCommand(source,
commandCtx);
log.debug("Created new command: " + slCommand);
@@ -731,7 +732,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
protected void handleBindingProcessorError(OutputStream os, String encoding,
Templates templates) throws IOException {
log.debug("Writing error as result");
- ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError);
+ ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError, locale);
error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)), templates);
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandContext.java
index c95736bd..5af2afac 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandContext.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandContext.java
@@ -16,13 +16,17 @@
*/
package at.gv.egiz.bku.slcommands;
+import java.util.Locale;
+
import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
import at.gv.egiz.stal.STAL;
public class SLCommandContext {
private STAL stal;
- private URLDereferencerContext urlDerefCtx;
+ private URLDereferencerContext urlDerefCtx;
+
+ private Locale locale;
public void setSTAL(STAL aStal) {
this.stal = aStal;
@@ -38,5 +42,14 @@ public class SLCommandContext {
public URLDereferencerContext getURLDereferencerContext() {
return urlDerefCtx;
- }
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
} \ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java
index 628326cf..6462bcf6 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java
@@ -216,8 +216,8 @@ public class CreateXMLSignatureCommandImpl extends SLCommandImpl<CreateXMLSignat
return new CreateXMLSignatureResultImpl(signature.getDocument());
- } catch (SLException e) {
- return new ErrorResultImpl(e);
+ } catch (SLException e) {
+ return new ErrorResultImpl(e, cmdCtx.getLocale());
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
index 176ba001..5d0f0de0 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
@@ -16,6 +16,8 @@
*/
package at.gv.egiz.bku.slcommands.impl;
+import java.util.Locale;
+
import javax.xml.transform.Result;
import javax.xml.transform.Templates;
@@ -32,22 +34,34 @@ public class ErrorResultImpl extends SLResultImpl implements ErrorResult {
/**
* The exception containing information provided in the <code>ErrorResponse</code>.
*/
- protected SLException slException;
-
- /**
- * Creates a new instance of this ErrorResultImpl with the given
- * <code>slException</code> containing information provided in the
- * <code>ErrorResponse</code>.
- *
- * @param slException the exception
- */
- public ErrorResultImpl(SLException slException) {
- this.slException = slException;
- }
-
+ protected SLException slException;
+
+ /**
+ * The locale to be used for rendering an <code>ErrorResponse</code>.
+ */
+ protected Locale locale;
+
+ /**
+ * Creates a new instance of this ErrorResultImpl with the given
+ * <code>slException</code> containing information provided in the
+ * <code>ErrorResponse</code> and the <code>locale</code> for rendering
+ * the <code>ErrorResponse</code>.
+ *
+ * @param slException the exception
+ * @param locale the locale
+ */
+ public ErrorResultImpl(SLException slException, Locale locale) {
+ this.slException = slException;
+ this.locale = locale;
+ }
+
@Override
public void writeTo(Result result, Templates templates) {
- writeErrorTo(slException, result, templates);
+ if (locale == null) {
+ writeErrorTo(slException, result, templates);
+ } else {
+ writeErrorTo(slException, result, templates, locale);
+ }
}
} \ 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 d23c0598..c7bb5205 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
@@ -279,7 +279,7 @@ public class InfoboxReadCommandImpl extends SLCommandImpl<InfoboxReadRequestType
throw new SLCommandException(4000);
}
} catch (SLCommandException e) {
- return new ErrorResultImpl(e);
+ return new ErrorResultImpl(e, cmdCtx.getLocale());
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
index 57309182..7306b237 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
@@ -16,6 +16,8 @@
*/
package at.gv.egiz.bku.slcommands.impl;
+import java.util.Locale;
+
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
@@ -181,6 +183,10 @@ public abstract class SLResultImpl implements SLResult {
}
protected void writeErrorTo(SLException slException, Result result, Templates templates) {
+ writeErrorTo(slException, result, templates, Locale.getDefault());
+ }
+
+ protected void writeErrorTo(SLException slException, Result result, Templates templates, Locale locale) {
TransformerHandler transformerHandler = null;
if (templates != null) {
@@ -195,7 +201,7 @@ public abstract class SLResultImpl implements SLResult {
ObjectFactory factory = new ObjectFactory();
ErrorResponseType responseType = factory.createErrorResponseType();
responseType.setErrorCode(slException.getErrorCode());
- responseType.setInfo(slException.getDetailedMsg());
+ responseType.setInfo(slException.getLocalizedMessage(locale));
JAXBElement<ErrorResponseType> response = factory.createErrorResponse(responseType);
Marshaller marshaller = getMarshaller();
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java
index 8455e934..f10ca520 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java
@@ -17,6 +17,7 @@
package at.gv.egiz.bku.slcommands.impl;
import java.io.ByteArrayOutputStream;
+import java.util.Locale;
import javax.xml.transform.stream.StreamResult;
@@ -31,7 +32,7 @@ public class ErrorResultImplTest {
public void writeTo() {
SLException slException = new SLException(0,"test.noerror", null);
- ErrorResult errorResult = new ErrorResultImpl(slException);
+ ErrorResult errorResult = new ErrorResultImpl(slException, Locale.getDefault());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
StreamResult result = new StreamResult(stream);