From 32d17447a258188b2d534bcb0bf65a659ba7b7d0 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Fri, 29 Aug 2008 12:11:34 +0000
Subject: Initial import.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
bkucommon/src/main/java/META-INF/MANIFEST.MF | 3 +
.../egiz/bku/binding/AbstractBindingProcessor.java | 86 ++
.../at/gv/egiz/bku/binding/BindingProcessor.java | 75 ++
.../egiz/bku/binding/BindingProcessorManager.java | 102 ++
.../bku/binding/BindingProcessorManagerImpl.java | 258 +++++
.../main/java/at/gv/egiz/bku/binding/DataUrl.java | 62 ++
.../at/gv/egiz/bku/binding/DataUrlConnection.java | 79 ++
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 216 +++++
.../gv/egiz/bku/binding/DataUrlConnectionSPI.java | 42 +
.../at/gv/egiz/bku/binding/DataUrlResponse.java | 98 ++
.../java/at/gv/egiz/bku/binding/ExpiryRemover.java | 67 ++
.../gv/egiz/bku/binding/FixedFormParameters.java | 28 +
.../java/at/gv/egiz/bku/binding/FormParameter.java | 39 +
.../at/gv/egiz/bku/binding/FormParameterImpl.java | 93 ++
.../at/gv/egiz/bku/binding/FormParameterStore.java | 146 +++
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 820 ++++++++++++++++
.../main/java/at/gv/egiz/bku/binding/HttpUtil.java | 78 ++
.../src/main/java/at/gv/egiz/bku/binding/Id.java | 27 +
.../java/at/gv/egiz/bku/binding/IdFactory.java | 106 +++
.../main/java/at/gv/egiz/bku/binding/IdImpl.java | 80 ++
.../java/at/gv/egiz/bku/binding/InputDecoder.java | 41 +
.../gv/egiz/bku/binding/InputDecoderFactory.java | 89 ++
.../bku/binding/MultiPartFormDataInputDecoder.java | 133 +++
.../at/gv/egiz/bku/binding/RemovalStrategy.java | 26 +
.../gv/egiz/bku/binding/SLCommandInvokerImpl.java | 66 ++
.../egiz/bku/binding/XWWWFormUrlInputDecoder.java | 101 ++
.../binding/multipart/InputStreamPartSource.java | 66 ++
.../egiz/bku/binding/multipart/SLResultPart.java | 57 ++
.../bku/slcommands/AccessControlInvocation.java | 21 +
.../bku/slcommands/CreateXMLSignatureCommand.java | 25 +
.../bku/slcommands/CreateXMLSignatureResult.java | 20 +
.../at/gv/egiz/bku/slcommands/ErrorResult.java | 20 +
.../gv/egiz/bku/slcommands/InfoboxReadCommand.java | 20 +
.../gv/egiz/bku/slcommands/InfoboxReadResult.java | 20 +
.../gv/egiz/bku/slcommands/InvocationStrategy.java | 20 +
.../egiz/bku/slcommands/NullOperationCommand.java | 20 +
.../egiz/bku/slcommands/NullOperationResult.java | 20 +
.../java/at/gv/egiz/bku/slcommands/SLCommand.java | 31 +
.../gv/egiz/bku/slcommands/SLCommandContext.java | 42 +
.../gv/egiz/bku/slcommands/SLCommandFactory.java | 370 +++++++
.../gv/egiz/bku/slcommands/SLCommandInvoker.java | 45 +
.../java/at/gv/egiz/bku/slcommands/SLResult.java | 44 +
.../at/gv/egiz/bku/slcommands/SLSourceContext.java | 63 ++
.../at/gv/egiz/bku/slcommands/SLTargetContext.java | 50 +
.../impl/CreateXMLSignatureCommandImpl.java | 229 +++++
.../impl/CreateXMLSignatureResultImpl.java | 138 +++
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 60 ++
.../slcommands/impl/InfoboxReadCommandImpl.java | 409 ++++++++
.../bku/slcommands/impl/InfoboxReadResultImpl.java | 171 ++++
.../slcommands/impl/NullOperationCommandImpl.java | 43 +
.../slcommands/impl/NullOperationResultImpl.java | 47 +
.../gv/egiz/bku/slcommands/impl/SLCommandImpl.java | 162 ++++
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 117 +++
.../impl/xsect/AlgorithmMethodFactory.java | 79 ++
.../impl/xsect/AlgorithmMethodFactoryImpl.java | 125 +++
.../impl/xsect/ByteArrayDereferencer.java | 65 ++
.../egiz/bku/slcommands/impl/xsect/DataObject.java | 1006 ++++++++++++++++++++
.../bku/slcommands/impl/xsect/IdValueFactory.java | 37 +
.../slcommands/impl/xsect/IdValueFactoryImpl.java | 127 +++
.../slcommands/impl/xsect/LocRefDereferencer.java | 113 +++
.../bku/slcommands/impl/xsect/STALPrivateKey.java | 122 +++
.../bku/slcommands/impl/xsect/STALProvider.java | 64 ++
.../bku/slcommands/impl/xsect/STALSignature.java | 165 ++++
.../impl/xsect/STALSignatureException.java | 92 ++
.../egiz/bku/slcommands/impl/xsect/Signature.java | 935 ++++++++++++++++++
.../slcommands/impl/xsect/SignatureContext.java | 129 +++
.../slcommands/impl/xsect/SignatureLocation.java | 235 +++++
.../impl/xsect/SimpleDOMErrorHandler.java | 98 ++
.../impl/xsect/URIDereferncerAdapter.java | 103 ++
.../bku/slcommands/impl/xsect/XSECTReference.java | 112 +++
.../bku/slcommands/impl/xsect/XSECTTransforms.java | 124 +++
.../egiz/bku/slexceptions/SLBindingException.java | 31 +
.../egiz/bku/slexceptions/SLCanceledException.java | 26 +
.../egiz/bku/slexceptions/SLCommandException.java | 30 +
.../at/gv/egiz/bku/slexceptions/SLException.java | 88 ++
.../egiz/bku/slexceptions/SLExceptionMessages.java | 50 +
.../egiz/bku/slexceptions/SLRequestException.java | 30 +
.../egiz/bku/slexceptions/SLRuntimeException.java | 37 +
.../egiz/bku/slexceptions/SLViewerException.java | 25 +
.../at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd | 877 +++++++++++++++++
.../at/gv/egiz/bku/slcommands/schema/xml.xsd | 145 +++
.../bku/slcommands/schema/xmldsig-core-schema.xsd | 308 ++++++
.../bku/slcommands/schema/xmldsig-transforms.xsd | 41 +
.../slexceptions/SLExceptionMessages.properties | 97 ++
.../slexceptions/SLExceptionMessages_de.properties | 98 ++
85 files changed, 10905 insertions(+)
create mode 100644 bkucommon/src/main/java/META-INF/MANIFEST.MF
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessor.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlResponse.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/ExpiryRemover.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/FixedFormParameters.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameter.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterStore.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/IdFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoder.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoderFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/MultiPartFormDataInputDecoder.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/RemovalStrategy.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/AccessControlInvocation.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureCommand.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/ErrorResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InvocationStrategy.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationCommand.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommand.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandContext.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationCommandImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLCommandImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/AlgorithmMethodFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/AlgorithmMethodFactoryImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/ByteArrayDereferencer.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/IdValueFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/IdValueFactoryImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALProvider.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignatureException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureContext.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureLocation.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SimpleDOMErrorHandler.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/URIDereferncerAdapter.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTReference.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTTransforms.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLBindingException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCanceledException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCommandException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRequestException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRuntimeException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xml.xsd
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-core-schema.xsd
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-transforms.xsd
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/META-INF/MANIFEST.MF b/bkucommon/src/main/java/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..5e949512
--- /dev/null
+++ b/bkucommon/src/main/java/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java
new file mode 100644
index 00000000..17ce29ce
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java
@@ -0,0 +1,86 @@
+/*
+* 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.bku.binding;
+
+import java.io.InputStream;
+import java.util.Date;
+
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.stal.STAL;
+
+public abstract class AbstractBindingProcessor implements BindingProcessor {
+ protected Id id;
+ protected STAL stal;
+ protected SLCommandInvoker commandInvoker;
+ protected long lastAccessedTime = System.currentTimeMillis();
+
+ public AbstractBindingProcessor(String idString) {
+ this.id = IdFactory.getInstance().createId(idString);
+ }
+
+ /**
+ * @see java.lang.Thread#run()
+ */
+ public abstract void run();
+
+ /**
+ * The caller is advised to check the result in case an error occurred.
+ *
+ * @see #getResult()
+ */
+ public abstract void consumeRequestStream(InputStream aIs);
+
+ public Id getId() {
+ return id;
+ }
+
+ public STAL getSTAL() {
+ return stal;
+ }
+
+ public SLCommandInvoker getCommandInvoker() {
+ return commandInvoker;
+ }
+
+ public void updateLastAccessTime() {
+ lastAccessedTime = System.currentTimeMillis();
+ }
+
+ public Date getLastAccessTime() {
+ return new Date(lastAccessedTime);
+ }
+
+ /**
+ * To be called after object creation.
+ *
+ * @param aStal
+ * must not be null
+ * @param aCommandInvoker
+ * must not be null
+ */
+ public void init(STAL aStal, SLCommandInvoker aCommandInvoker) {
+ if (aStal == null) {
+ throw new NullPointerException("STAL must not be set to null");
+ }
+ if (aCommandInvoker == null) {
+ throw new NullPointerException("Commandinvoker must not be set to null");
+ }
+ stal = aStal;
+ commandInvoker = aCommandInvoker;
+ Thread.currentThread().setName("BPID#"+getId().toString());
+ }
+}
\ 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
new file mode 100644
index 00000000..c386508d
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessor.java
@@ -0,0 +1,75 @@
+/*
+* 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.bku.binding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Locale;
+
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.stal.STAL;
+
+/**
+ * Represents an single instance of a SL HTTP binding.
+ *
+ * @author wbauer
+ *
+ */
+public interface BindingProcessor extends Runnable {
+
+ /**
+ * The stream must be read completely within this method.
+ *
+ * The caller is advised to check the result in case an error occurred.
+ *
+ * @see #getResult()
+ */
+ public void consumeRequestStream(InputStream aIs);
+
+ /**
+ * The unique Id of this http binding instance.
+ * @return
+ */
+ public Id getId();
+
+ /**
+ * The used underlying STAL instance
+ * @return
+ */
+ public STAL getSTAL();
+
+ public SLCommandInvoker getCommandInvoker();
+
+ public Date getLastAccessTime();
+
+ public void updateLastAccessTime();
+
+ public String getResultContentType();
+
+ public void writeResultTo(OutputStream os, String encoding) throws IOException;
+
+ public void init(STAL aStal, SLCommandInvoker aCommandInvoker);
+
+ /**
+ * Sets the preferred locale for userinteraction.
+ * If the locale is not set the default locale will be used.
+ * @param locale must not be null.
+ */
+ public void setLocale(Locale locale);
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
new file mode 100644
index 00000000..a4e5bd90
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
@@ -0,0 +1,102 @@
+/*
+* 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.bku.binding;
+
+import java.util.Locale;
+import java.util.Set;
+
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.stal.STALFactory;
+
+/**
+ * Central player that handles the protocol binding.
+ *
+ * @author wbauer
+ *
+ */
+public interface BindingProcessorManager {
+
+ /**
+ * FactoryMethod creating a new BindingProcessor object.
+ * The created binding processor must be passed to the process method to execute.
+ *
+ * @param protcol
+ * the transport binding protocol
+ * @param aSessionId
+ * optional an external sessionId (e.g. http session) could be
+ * provided. This parameter may be null.
+ * @param locale the locale used for user interaction, may be null
+ */
+ public BindingProcessor createBindingProcessor(String protcol,
+ String aSessionId, Locale locale);
+
+ /**
+ * FactoryMethod creating a new BindingProcessor object.
+ * The created binding processor must be passed to the process method to execute.
+ *
+ * @param protcol
+ * the transport binding protocol
+ * @param aSessionId
+ * optional an external sessionId (e.g. http session) could be
+ * provided. This parameter may be null.
+ */
+ public BindingProcessor createBindingProcessor(String protcol,
+ String aSessionId);
+
+
+ /**
+ * Gets the binding processor with a certain id. The binding processor must be passed to the
+ * process method before it is managed and thus returned by this method.
+ * @param aId must not be null
+ * @return null if the binding processor was not "processed" before.
+ */
+ public BindingProcessor getBindingProcessor(Id aId);
+
+ /**
+ * Sets the STAL factory that is used for creating STAL objects that are used by BindingProcessor objects.
+ * For each new BindingProcessor a new STAL object is created.
+ * @param aStalFactory the factory to be used. Must not be null.
+ */
+ public void setSTALFactory(STALFactory aStalFactory);
+
+ /**
+ * Sets the invoker to be used.
+ * @param invoker
+ */
+ public void setSLCommandInvoker(SLCommandInvoker invoker);
+
+ /**
+ * Schedules the provided binding processor for processing and immediately returns.
+ *
+ * @param aBindingProcessor
+ */
+ public void process(BindingProcessor aBindingProcessor);
+
+ /**
+ * Removes a formerly added (by calling the process method) binding processor.
+ * @param bindingProcessor must not be null
+ */
+ public void removeBindingProcessor(Id sessionId);
+
+ /**
+ * A set of all managed binding processors.
+ * @return
+ */
+ public Set getManagedIds();
+
+ public void shutdown();
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
new file mode 100644
index 00000000..7a3b1bb9
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -0,0 +1,258 @@
+/*
+* 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.bku.binding;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.binding.Protocol;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALFactory;
+
+/**
+ * This class maintains all active BindingProcessor Objects. Currently, only
+ * HTTPBinding is supported.
+ */
+public class BindingProcessorManagerImpl implements BindingProcessorManager {
+
+ public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
+ Protocol.HTTPS };
+
+ private static Log log = LogFactory.getLog(BindingProcessorManagerImpl.class);
+
+ private RemovalStrategy removalStrategy;
+ private STALFactory stalFactory;
+ private SLCommandInvoker commandInvokerClass;
+ private ExecutorService executorService;
+ private Map bindingProcessorMap = Collections
+ .synchronizedMap(new HashMap());
+
+ /**
+ * Container to hold a Future and Bindingprocessor object as map value.
+ * @author wbauer
+ * @see BindingProcessorManagerImpl#bindingProcessorMap
+ */
+ static class MapEntityWrapper {
+ private Future> future;
+ private BindingProcessor bindingProcessor;
+
+ public MapEntityWrapper(Future> future, BindingProcessor bindingProcessor) {
+ if ((bindingProcessor == null) || (future == null)) {
+ throw new NullPointerException("Argument must not be null");
+ }
+ this.bindingProcessor = bindingProcessor;
+ this.future = future;
+ }
+
+ public Future> getFuture() {
+ return future;
+ }
+
+ public BindingProcessor getBindingProcessor() {
+ return bindingProcessor;
+ }
+
+ public int hashCode() {
+ return bindingProcessor.getId().hashCode();
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof MapEntityWrapper) {
+ MapEntityWrapper o = (MapEntityWrapper) other;
+ return (o.bindingProcessor.getId().equals(bindingProcessor.getId()));
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ *
+ * @param fab
+ * must not be null
+ * @param ci
+ * must not be null (prototype to generate new instances)
+ */
+ public BindingProcessorManagerImpl(STALFactory fab, SLCommandInvoker ci) {
+ if (fab == null) {
+ throw new NullPointerException("STALFactory must not be null");
+ }
+ stalFactory = fab;
+ if (ci == null) {
+ throw new NullPointerException("SLCommandInvoker must not be null");
+ }
+ commandInvokerClass = ci;
+ executorService = Executors.newCachedThreadPool();
+ }
+
+ /**
+ *
+ * @return the STALFactory currently used.
+ */
+ public STALFactory getStalFactory() {
+ return stalFactory;
+ }
+
+ /**
+ * Sets the STALFactory to be used.
+ * @param stalFactory
+ */
+ public void setStalFactory(STALFactory stalFactory) {
+ this.stalFactory = stalFactory;
+ }
+
+ /**
+ * Could be used to setup a new executor service during application stratup.
+ * @param executorService
+ */
+ public void setExecutorService(ExecutorService executorService) {
+ this.executorService = executorService;
+ }
+
+ public void setRemovalStrategy(RemovalStrategy aStrategy) {
+ removalStrategy = aStrategy;
+ }
+
+ public RemovalStrategy getRemovlaStrategy() {
+ return removalStrategy;
+ }
+
+ public void shutdown() {
+ log.info("Shutting down the BindingProcessorManager");
+ executorService.shutdown();
+ }
+
+ /**
+ * Uses the default locale
+ */
+ public BindingProcessor createBindingProcessor(String protocol,
+ String aSessionId) {
+ return createBindingProcessor(protocol, aSessionId, null);
+ }
+
+ /**
+ * FactoryMethod creating a new BindingProcessor object.
+ *
+ * @param protocol
+ * must not be null
+ */
+ public BindingProcessor createBindingProcessor(String protocol,
+ String aSessionId, Locale locale) {
+ String low = protocol.toLowerCase();
+ Protocol proto = null;
+ for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
+ if (SUPPORTED_PROTOCOLS[i].toString().equals(low)) {
+ proto = SUPPORTED_PROTOCOLS[i];
+ break;
+ }
+ }
+ if (proto == null) {
+ throw new UnsupportedOperationException();
+ }
+ BindingProcessor bindingProcessor = new HTTPBindingProcessor(aSessionId,
+ commandInvokerClass.newInstance(), proto);
+ STAL stal = stalFactory.createSTAL();
+ bindingProcessor.init(stal, commandInvokerClass.newInstance());
+ if (locale != null) {
+ bindingProcessor.setLocale(locale);
+ stal.setLocale(locale);
+ }
+ return bindingProcessor;
+ }
+
+ /**
+ * @return the bindingprocessor object for this id or null if no bindingprocessor was found.
+ */
+ public BindingProcessor getBindingProcessor(Id aId) {
+ if (bindingProcessorMap.get(aId) != null) {
+ return bindingProcessorMap.get(aId).getBindingProcessor();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ public void setSTALFactory(STALFactory aStalFactory) {
+ if (aStalFactory == null) {
+ throw new NullPointerException("Cannot set STALFactory to null");
+ }
+ stalFactory = aStalFactory;
+ }
+
+ /**
+ * Causes the BindingProcessorManager to manage the provided BindingProcessor
+ * @param aBindingProcessor must not be null
+ */
+ public void process(BindingProcessor aBindingProcessor) {
+ if (bindingProcessorMap.containsKey(aBindingProcessor.getId())) {
+ log.fatal("Clashing ids, cannot process bindingprocessor with id:"
+ + aBindingProcessor.getId());
+ throw new SLRuntimeException(
+ "Clashing ids, cannot process bindingprocessor with id:"
+ + aBindingProcessor.getId());
+ }
+ Future> f = executorService.submit(aBindingProcessor);
+ bindingProcessorMap.put(aBindingProcessor.getId(), new MapEntityWrapper(f,
+ aBindingProcessor));
+ }
+
+ @Override
+ public void setSLCommandInvoker(SLCommandInvoker invoker) {
+ commandInvokerClass = invoker;
+ }
+
+ @Override
+ public void removeBindingProcessor(Id sessionId) {
+ MapEntityWrapper wrapper = bindingProcessorMap
+ .get(sessionId);
+ if (wrapper == null) {
+ return;
+ }
+ Future> f = wrapper.getFuture();
+ if (!f.isDone()) {
+ f.cancel(true);
+ }
+ bindingProcessorMap.remove(sessionId);
+ }
+
+ @Override
+ public Set getManagedIds() {
+ Set result = new HashSet();
+ synchronized (bindingProcessorMap) {
+ for (Iterator it = bindingProcessorMap.keySet().iterator(); it
+ .hasNext();) {
+ result.add(it.next());
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
new file mode 100644
index 00000000..8eaeacbd
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
@@ -0,0 +1,62 @@
+/*
+* 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.bku.binding;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+/**
+ * Used to handle DataUrl connections as specified in the CCE's HTTP protocol binding.
+ *
+ */
+public class DataUrl {
+ private static DataUrlConnectionSPI defaultDataUrlConnection = new DataUrlConnectionImpl();
+ private static Log log = LogFactory.getLog(DataUrl.class);
+
+ private URL url;
+
+ /**
+ * Sets the default DataUrlConnection implementation
+ * @param aClass must not be null
+ */
+ public static void setDataUrlConnectionClass(DataUrlConnectionSPI dataUrlConnection) {
+ if (dataUrlConnection == null) {
+ throw new NullPointerException("Default dataurlconnection must not be set to null");
+ }
+ defaultDataUrlConnection = dataUrlConnection;
+ }
+
+ public DataUrl(String aUrlString) throws MalformedURLException {
+ url = new URL(aUrlString);
+ }
+
+ public DataUrlConnection openConnection() {
+ try {
+ DataUrlConnectionSPI retVal = defaultDataUrlConnection.newInstance();
+ retVal.init(url);
+ return retVal;
+ } catch (Exception e) {
+ log.error(e);
+ throw new SLRuntimeException("Cannot instantiate a dataurlconnection:",e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
new file mode 100644
index 00000000..e6d5e075
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
@@ -0,0 +1,79 @@
+/*
+* 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.bku.binding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.security.cert.X509Certificate;
+
+import at.gv.egiz.bku.slcommands.SLResult;
+
+/**
+ * Transmit a security layer result to DataURL via HTTP POST, encoded as multipart/form-data.
+ * The HTTP header user-agent is set to citizen-card-environment/1.2 BKU2 1.0.
+ * The form-parameter ResponseType is set to HTTP-Security-Layer-RESPONSE.
+ * All other headers/parameters are set by the caller.
+ *
+ * @author clemens
+ */
+public interface DataUrlConnection {
+
+ public static final String DEFAULT_USERAGENT = "citizen-card-environment/1.2 BKU2 1.0";
+ public static final String FORMPARAM_RESPONSETYPE = "ResponseType";
+ public static final String DEFAULT_RESPONSETYPE = "HTTP-Security-Layer-RESPONSE";
+ public static final String FORMPARAM_XMLRESPONSE = "XMLResponse";
+ public static final String FORMPARAM_BINARYRESPONSE = "BinaryResponse";
+
+ public static final String XML_RESPONSE_ENCODING = "UTF-8";
+
+ public String getProtocol();
+
+ /**
+ * Set a HTTP Header.
+ * @param key
+ * @param value multiple values are assumed to have the correct formatting (comma-separated list)
+ */
+ public void setHTTPHeader(String key, String value);
+
+ /**
+ * Set a form-parameter.
+ * @param name
+ * @param data
+ * @param contentType may be null
+ * @param charSet may be null
+ * @param transferEncoding may be null
+ */
+ public void setHTTPFormParameter(String name, InputStream data, String contentType, String charSet, String transferEncoding);
+
+ /**
+ * @pre httpHeaders != null
+ * @throws java.net.SocketTimeoutException
+ * @throws java.io.IOException
+ */
+ public void connect() throws SocketTimeoutException, IOException;
+
+ public X509Certificate getServerCertificate();
+
+ /**
+ * @pre connection != null
+ * @throws java.io.IOException
+ */
+ public void transmit(SLResult slResult) throws IOException;
+
+ public DataUrlResponse getResponse() throws IOException;
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
new file mode 100644
index 00000000..134d765e
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -0,0 +1,216 @@
+/*
+* 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.bku.binding;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
+
+import at.gv.egiz.bku.binding.multipart.InputStreamPartSource;
+import at.gv.egiz.bku.binding.multipart.SLResultPart;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.bku.utils.binding.Protocol;
+
+/**
+ * not thread-safe thus newInsance always returns a new object
+ *
+ */
+public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
+
+ public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
+ Protocol.HTTPS };
+ protected X509Certificate serverCertificate;
+ protected Protocol protocol;
+ protected URL url;
+ private HttpURLConnection connection;
+ protected Map requestHttpHeaders;
+ protected ArrayList formParams;
+ protected String boundary;
+
+ protected DataUrlResponse result;
+
+ public String getProtocol() {
+ if (protocol == null) {
+ return null;
+ }
+ return protocol.toString();
+ }
+
+ /**
+ * opens a connection sets the headers gets the server certificate
+ *
+ * @throws java.net.SocketTimeoutException
+ * @throws java.io.IOException
+ * @pre url != null
+ * @pre httpHeaders != null
+ */
+ public void connect() throws SocketTimeoutException, IOException {
+ connection = (HttpURLConnection) url.openConnection();
+
+ // FIXXME move this to config.
+ HttpURLConnection.setFollowRedirects(false);
+
+
+ connection.setDoOutput(true);
+ Set headers = requestHttpHeaders.keySet();
+ Iterator headerIt = headers.iterator();
+ while (headerIt.hasNext()) {
+ String name = headerIt.next();
+ connection.setRequestProperty(name, requestHttpHeaders.get(name));
+ }
+ connection.connect();
+ if (connection instanceof HttpsURLConnection) {
+ HttpsURLConnection ssl = (HttpsURLConnection) connection;
+ X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
+ if ((certs != null) && (certs.length >= 1)) {
+ serverCertificate = certs[0];
+ }
+ }
+ }
+
+ public X509Certificate getServerCertificate() {
+ return serverCertificate;
+ }
+
+ public void setHTTPHeader(String name, String value) {
+ if (name != null && value != null) {
+ requestHttpHeaders.put(name, value);
+ }
+ }
+
+ public void setHTTPFormParameter(String name, InputStream data,
+ String contentType, String charSet, String transferEncoding) {
+ InputStreamPartSource source = new InputStreamPartSource(null, data);
+ FilePart formParam = new FilePart(name, source, contentType, charSet);
+ if (transferEncoding != null) {
+ formParam.setTransferEncoding(transferEncoding);
+ } else {
+ formParam.setTransferEncoding(null);
+ }
+ formParams.add(formParam);
+ }
+
+ /**
+ * send all formParameters
+ *
+ * @throws java.io.IOException
+ */
+ public void transmit(SLResult slResult) throws IOException {
+ SLResultPart slResultPart = new SLResultPart(slResult,
+ XML_RESPONSE_ENCODING);
+ if (slResult.getResultType() == SLResultType.XML) {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ slResultPart.setCharSet(XML_RESPONSE_ENCODING);
+ } else {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ }
+ formParams.add(slResultPart);
+
+ OutputStream os = connection.getOutputStream();
+
+ Part[] parts = new Part[formParams.size()];
+ Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
+ os.close();
+ // MultipartRequestEntity PostMethod
+ result = new DataUrlResponse(url.toString(), connection.getResponseCode(),
+ connection.getInputStream());
+
+ Map responseHttpHeaders = new HashMap();
+ Map> httpHeaders = connection.getHeaderFields();
+ for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
+ .hasNext();) {
+ String key = keyIt.next();
+ StringBuffer value = new StringBuffer();
+ for (String val : httpHeaders.get(key)) {
+ value.append(val);
+ value.append(HttpUtil.SEPERATOR[0]);
+ }
+ String valString = value.substring(0, value.length() - 1);
+ if ((key != null)&&(value.length() > 0)) {
+ responseHttpHeaders.put(key, valString);
+ }
+ }
+ result.setResponseHttpHeaders(responseHttpHeaders);
+ }
+
+ @Override
+ public DataUrlResponse getResponse() throws IOException {
+ return result;
+ }
+
+ /**
+ * inits protocol, url, httpHeaders, formParams
+ *
+ * @param url
+ * must not be null
+ */
+ @Override
+ public void init(URL url) {
+
+ for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
+ if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) {
+ protocol = SUPPORTED_PROTOCOLS[i];
+ break;
+ }
+ }
+ if (protocol == null) {
+ throw new SLRuntimeException("Protocol " + url.getProtocol()
+ + " not supported for data url");
+ }
+ this.url = url;
+ boundary = "--" + IdFactory.getInstance().createId().toString();
+ requestHttpHeaders = new HashMap();
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, DEFAULT_USERAGENT);
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
+ HttpUtil.MULTIPART_FOTMDATA + HttpUtil.SEPERATOR[0]
+ + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY + "=" + boundary);
+
+ formParams = new ArrayList();
+ StringPart responseType = new StringPart(FORMPARAM_RESPONSETYPE,
+ DEFAULT_RESPONSETYPE);
+ responseType.setCharSet("UTF-8");
+ responseType.setTransferEncoding(null);
+ formParams.add(responseType);
+ }
+
+ @Override
+ public DataUrlConnectionSPI newInstance() {
+ return new DataUrlConnectionImpl();
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
new file mode 100644
index 00000000..9e5a66f8
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
@@ -0,0 +1,42 @@
+/*
+* 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.bku.binding;
+
+import java.net.URL;
+
+/**
+ * Prototype of a DataurlconnectionSPI
+ * @author wbauer
+ *
+ */
+public interface DataUrlConnectionSPI extends DataUrlConnection {
+
+ /**
+ * Returns a new instance of this class to handle a dataurl.
+ * Called by the factory each time the openConnection method is called.
+ * @return
+ */
+ public DataUrlConnectionSPI newInstance();
+
+ /**
+ * Initializes the DataUrlConnection
+ * @param url
+ */
+ public void init(URL url);
+
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlResponse.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlResponse.java
new file mode 100644
index 00000000..b75cb0f3
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlResponse.java
@@ -0,0 +1,98 @@
+/*
+* 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.bku.binding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+
+/**
+ * The response of a dataurl server.
+ * Additionally holds return code and response headers.
+ */
+public class DataUrlResponse extends StreamData {
+
+ public final static String OK = "";
+
+ protected Map responseHttpHeaders;
+
+ protected int responseCode = -1;
+
+ public DataUrlResponse(String url, int responseCode, InputStream stream) {
+ super(url, null, new PushbackInputStream(stream, 10));
+ this.responseCode = responseCode;
+ }
+
+ public String getContentType() {
+ if (contentType != null) {
+ return contentType;
+ }
+ if (responseHttpHeaders == null) {
+ return null;
+ }
+ for (Iterator keyIt = responseHttpHeaders.keySet().iterator(); keyIt
+ .hasNext();) {
+ String key = keyIt.next();
+ if (HttpUtil.HTTP_HEADER_CONTENT_TYPE.equalsIgnoreCase(key)) {
+ contentType = responseHttpHeaders.get(key);
+ return contentType;
+ }
+ }
+ return contentType;
+ }
+
+ public void setResponseHttpHeaders(Map responseHttpHeaders) {
+ this.responseHttpHeaders = responseHttpHeaders;
+ }
+
+ public Map getResponseHeaders() {
+ return responseHttpHeaders;
+ }
+
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+ /**
+ * Checks if the http response equals ""
+ *
+ * @throws IOException
+ */
+ public boolean isHttpResponseXMLOK() throws IOException {
+ String charset = HttpUtil.getCharset(contentType, true);
+ byte[] buffer = new byte[10];
+ int i = 0;
+ int read = 0;
+ while ((i < 10) && (read != -1)) {
+ read = inputStream.read(buffer, i, 10 - i);
+ if (read != -1) {
+ i += read;
+ }
+ }
+ PushbackInputStream pbis = (PushbackInputStream) inputStream;
+ pbis.unread(buffer, 0, i);
+ if (i < 5) {
+ return false;
+ }
+ String ok = new String(buffer, 0, i, charset);
+ return (OK.equals(ok));
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/ExpiryRemover.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ExpiryRemover.java
new file mode 100644
index 00000000..d17a27c2
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ExpiryRemover.java
@@ -0,0 +1,67 @@
+/*
+* 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.bku.binding;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class can be used to check the BindingProcessorManager for expired entries and remove them.
+ * Should be run periodically.
+ *
+ */
+public class ExpiryRemover implements RemovalStrategy {
+
+ private static Log log = LogFactory.getLog(ExpiryRemover.class);
+
+ protected BindingProcessorManager bindingProcessorManager;
+ // keep max 5 min.
+ protected long maxAcceptedAge = 1000 * 60 * 5;
+
+ @Override
+ public void execute() {
+ log.debug("Triggered Expiry Remover");
+ if (bindingProcessorManager == null) {
+ log.warn("Bindingprocessor not set, skipping removal");
+ return;
+ }
+ Set managedIds = bindingProcessorManager.getManagedIds();
+ for (Iterator it = managedIds.iterator(); it.hasNext();) {
+ Id bindId = it.next();
+ BindingProcessor bp = bindingProcessorManager.getBindingProcessor(bindId);
+ if (bp != null) {
+ if (bp.getLastAccessTime().getTime() < (System.currentTimeMillis() - maxAcceptedAge)) {
+ log.debug("Removing binding processor: " + bp.getId());
+ bindingProcessorManager.removeBindingProcessor(bp.getId());
+ }
+ }
+ }
+ }
+
+ public void setMaxAcceptedAge(long maxAcceptedAge) {
+ this.maxAcceptedAge = maxAcceptedAge;
+ }
+
+ @Override
+ public void setBindingProcessorManager(BindingProcessorManager bp) {
+ bindingProcessorManager = bp;
+ }
+
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/FixedFormParameters.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FixedFormParameters.java
new file mode 100644
index 00000000..cce3d720
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FixedFormParameters.java
@@ -0,0 +1,28 @@
+/*
+* 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.bku.binding;
+
+/**
+ * Form parameters with special meaning as defined in the CCE's http binding.
+ *
+ */
+public interface FixedFormParameters {
+ String XMLREQUEST = "XMLRequest";
+ String REDIRECTURL = "RedirectURL";
+ String DATAURL = "DataURL";
+ String STYLESHEETURL = "StylesheetURL";
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameter.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameter.java
new file mode 100644
index 00000000..93339451
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameter.java
@@ -0,0 +1,39 @@
+/*
+* 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.bku.binding;
+
+import java.io.InputStream;
+import java.util.Iterator;
+
+/**
+ * Interface to access form control contents from the http request.
+ * It's designed to be used for URL encoded and multipart-formdata requests.
+ * @author wbauer
+ *
+ */
+public interface FormParameter {
+
+ String getFormParameterName();
+
+ InputStream getFormParameterValue();
+
+ String getFormParameterContentType();
+
+ Iterator getHeaderNames();
+
+ String getHeaderValue(String headerName);
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterImpl.java
new file mode 100644
index 00000000..45aa9be6
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterImpl.java
@@ -0,0 +1,93 @@
+/*
+* 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.bku.binding;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.apache.commons.fileupload.FileItemHeaders;
+
+/**
+ * Simple wrapper to read data while consuming an stream within the http
+ * processor.
+ *
+ *
+ */
+public class FormParameterImpl implements FormParameter {
+
+ protected InputStream dataStream;
+ protected String contentType;
+ protected String formName;
+ protected FileItemHeaders headers;
+
+ public FormParameterImpl(String contentType, String formName, InputStream is,
+ FileItemHeaders header) {
+ this.contentType = contentType;
+ this.formName = formName;
+ this.dataStream = is;
+ this.headers = header;
+ }
+
+ @Override
+ public String getFormParameterContentType() {
+ return contentType;
+ }
+
+ @Override
+ public String getFormParameterName() {
+ return formName;
+ }
+
+ @Override
+ public InputStream getFormParameterValue() {
+ return dataStream;
+ }
+
+ @Override
+ public String getHeaderValue(String headerName) {
+ if (headers == null) {
+ return null;
+ }
+ return headers.getHeader(headerName);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterator getHeaderNames() {
+ if (headers == null) {
+ return Collections.EMPTY_LIST.iterator();
+ }
+ return headers.getHeaderNames();
+ }
+
+ public FileItemHeaders getHeaders() {
+ return headers;
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof FormParameter) {
+ FormParameter fp = (FormParameter) other;
+ return fp.getFormParameterName().equals(getFormParameterName());
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return getFormParameterName().hashCode();
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterStore.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterStore.java
new file mode 100644
index 00000000..8b6cd4b2
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/FormParameterStore.java
@@ -0,0 +1,146 @@
+/*
+* 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.bku.binding;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.apache.commons.fileupload.FileItemHeaders;
+import org.apache.commons.fileupload.util.FileItemHeadersImpl;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.StreamUtil;
+
+/**
+ * Simple store for form parameters based on a byte[]
+ *
+ * @author wbauer
+ *
+ */
+public class FormParameterStore implements FormParameter {
+
+ private byte[] dataBuffer;
+ private String contentType;
+ private String parameterName;
+ private boolean initialized = false;
+ protected FileItemHeaders headers;
+
+ /**
+ * Make sure to call init after creating a new instance.
+ */
+ public FormParameterStore() {
+ }
+
+ public void init(InputStream dataSource, String paramName,
+ String contentType, FileItemHeaders header) throws IOException {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ StreamUtil.copyStream(dataSource, os);
+ this.dataBuffer = os.toByteArray();
+ this.parameterName = paramName;
+ this.contentType = contentType;
+ initialized = true;
+ this.headers = header;
+ }
+
+ public void init(byte[] dataSource, String paramName,
+ String contentType, FileItemHeaders header) throws IOException {
+ this.dataBuffer = dataSource;
+ this.parameterName = paramName;
+ this.contentType = contentType;
+ initialized = true;
+ this.headers = header;
+ }
+
+ public void init(FormParameter fp) throws IOException {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ StreamUtil.copyStream(fp.getFormParameterValue(), os);
+ this.dataBuffer = os.toByteArray();
+ this.parameterName = fp.getFormParameterName();
+ this.contentType = fp.getFormParameterContentType();
+ if (fp instanceof FormParameterImpl) {
+ headers = ((FormParameterImpl) fp).getHeaders();
+ } else {
+ FileItemHeadersImpl headersImpl = new FileItemHeadersImpl();
+ for (Iterator i = fp.getHeaderNames(); i.hasNext();) {
+ String headerName = i.next();
+ headersImpl.addHeader(headerName, fp.getHeaderValue(headerName));
+ }
+ }
+ initialized = true;
+ }
+
+ protected void ensureInitialized() {
+ if (!initialized) {
+ throw new SLRuntimeException("FormParameterStore not initialized");
+ }
+ }
+
+ /**
+ * Reads all data from the stream and stores it internally. The stream will
+ * not be closed.
+ *
+ * @param datSource
+ * @param formName
+ * @param contentType
+ */
+ @Override
+ public String getFormParameterContentType() {
+ ensureInitialized();
+ return contentType;
+ }
+
+ @Override
+ public String getFormParameterName() {
+ ensureInitialized();
+ return parameterName;
+ }
+
+ /**
+ * May be called more than once.
+ */
+ @Override
+ public InputStream getFormParameterValue() {
+ return new ByteArrayInputStream(dataBuffer);
+ }
+
+ @Override
+ public String getHeaderValue(String name) {
+ if (headers == null) {
+ return null;
+ }
+ return headers.getHeader(name);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterator getHeaderNames() {
+ if (headers == null) {
+ return Collections.EMPTY_LIST.iterator();
+ }
+ return headers.getHeaderNames();
+ }
+
+ public boolean isEmpty() {
+ ensureInitialized();
+ return dataBuffer.length == 0;
+ }
+
+}
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
new file mode 100644
index 00000000..b79f7d55
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
@@ -0,0 +1,820 @@
+/*
+* 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.bku.binding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.net.ssl.SSLHandshakeException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLSourceContext;
+import at.gv.egiz.bku.slcommands.SLTargetContext;
+import at.gv.egiz.bku.slcommands.impl.ErrorResultImpl;
+import at.gv.egiz.bku.slexceptions.SLBindingException;
+import at.gv.egiz.bku.slexceptions.SLCanceledException;
+import at.gv.egiz.bku.slexceptions.SLException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.bku.utils.binding.Protocol;
+import at.gv.egiz.bku.utils.urldereferencer.FormDataURLSupplier;
+import at.gv.egiz.bku.utils.urldereferencer.SimpleFormDataContextImpl;
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+import at.gv.egiz.bku.utils.urldereferencer.URIResolverAdapter;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.stal.STALRequest;
+
+/**
+ * Class performing the HTTP binding as defined by the CCE specification.
+ * Currently a huge monolithic class.
+ * @TODO refactor
+ */
+@SuppressWarnings("unchecked")
+public class HTTPBindingProcessor extends AbstractBindingProcessor implements
+ FormDataURLSupplier {
+
+ private static Log log = LogFactory.getLog(HTTPBindingProcessor.class);
+
+ private static enum State {
+ INIT, PROCESS, DATAURL, TRANSFORM, FINISHED
+ };
+
+ public final static Collection XML_REQ_TRANSFER_ENCODING = Arrays
+ .asList(new String[] { "binary" });
+
+ /**
+ * Defines the maximum number of dataurl connects that are allowed within a
+ * single SL Request processing.
+ */
+ protected static int MAX_DATAURL_HOPS = 10;
+
+ protected static String XML_MIME_TYPE = "text/xml";
+ protected static String BINARY_MIME_TYPE = "application/octet-stream";
+
+ /**
+ * If null everything is ok and the result is taken from the command invoker.
+ */
+ protected SLException bindingProcessorError;
+ protected SLCommandInvoker commandInvoker;
+ protected DataUrlResponse dataUrlResponse;
+ protected Map headerMap = Collections.EMPTY_MAP;
+ protected SLCommand slCommand;
+ protected Map formParameterMap = new HashMap();
+ protected SLSourceContext srcContex = new SLSourceContext();
+ protected SLTargetContext targetContext = new SLTargetContext();
+ protected Protocol protocol;
+ protected State currentState = State.INIT;
+ protected Transformer transformer = null;
+ protected String resultContentType = null;
+ protected SLResult slResult = null;
+ protected int responseCode = 200;
+ protected Map responseHeaders = Collections.EMPTY_MAP;
+ protected Locale locale = Locale.getDefault();
+
+ /**
+ *
+ * @param id
+ * may be null. In this case a new session id will be created.
+ * @param cmdInvoker
+ * must not be null;
+ */
+ public HTTPBindingProcessor(String id, SLCommandInvoker cmdInvoker,
+ Protocol protocol) {
+ super(id);
+ if ((protocol != Protocol.HTTP) && (protocol != Protocol.HTTPS)) {
+ throw new SLRuntimeException("Protocol not supported: " + protocol);
+ }
+ if (cmdInvoker == null) {
+ throw new NullPointerException("Commandinvoker cannot be set to null");
+ }
+ commandInvoker = cmdInvoker;
+ this.protocol = protocol;
+ srcContex.setSourceProtocol(protocol);
+ srcContex.setSourceIsDataURL(false);
+ }
+
+ //----------------------------------------------------------------------------
+ // ----------- BEGIN CONVENIENCE METHODS -----------
+
+ protected void sendSTALQuit() {
+ log.info("Sending QUIT command to STAL");
+ List quit = new ArrayList(1);
+ quit.add(new QuitRequest());
+ getSTAL().handleRequest(quit);
+ }
+
+ protected String getFormParameterAsString(String formParameterName) {
+ FormParameter fp = formParameterMap.get(formParameterName);
+ return getFormParameterAsString(fp);
+ }
+
+ protected String getFormParameterAsString(FormParameter fp) {
+ if (fp == null) {
+ return null;
+ }
+ try {
+ return StreamUtil.asString(fp.getFormParameterValue(), HttpUtil
+ .getCharset(fp.getFormParameterContentType(), true));
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ protected String getDataUrl() {
+ return getFormParameterAsString(FixedFormParameters.DATAURL);
+ }
+
+ protected String getStyleSheetUrl() {
+ return getFormParameterAsString(FixedFormParameters.STYLESHEETURL);
+ }
+
+ protected List getFormParameters(String parameterNamePostfix) {
+ List resultList = new ArrayList();
+ for (Iterator fpi = formParameterMap.keySet().iterator(); fpi
+ .hasNext();) {
+ String paramName = fpi.next();
+ if (paramName.endsWith(parameterNamePostfix)) {
+ resultList.add(formParameterMap.get(paramName));
+ }
+ }
+ return resultList;
+ }
+
+ protected List getTransferHeaders() {
+ return getFormParameters("__");
+ }
+
+ protected List getTransferForms() {
+ List resultList = new ArrayList();
+ for (Iterator fpi = formParameterMap.keySet().iterator(); fpi
+ .hasNext();) {
+ String paramName = fpi.next();
+ if ((paramName.endsWith("_")) && (!paramName.endsWith("__"))) {
+ resultList.add(formParameterMap.get(paramName));
+ }
+ }
+ return resultList;
+ }
+
+ protected void closeDataUrlConnection() {
+ log.debug("Closing data url input stream");
+ if (dataUrlResponse == null) {
+ return;
+ }
+ InputStream is = dataUrlResponse.getStream();
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ log.info("Error closing input stream to dataurl server:" + e);
+ }
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ // ----------- END CONVENIENCE METHODS -----------
+
+ //----------------------------------------------------------------------------
+ // -- BEGIN Methods that handle the http binding activities as defined in the
+ // activity diagram --
+
+ protected void init() {
+ log.info("Starting Bindingprocessor in Thread: "
+ + Thread.currentThread().getId());
+ if (bindingProcessorError != null) {
+ log.debug("Detected binding processor error, sending quit command");
+ // sendSTALQuit();
+ currentState = State.FINISHED;
+ } else if (slCommand == null) {
+ log.error("SLCommand not set (consumeRequest not called ??)");
+ bindingProcessorError = new SLException(2000);
+ // sendSTALQuit();
+ currentState = State.FINISHED;
+ } else {
+ currentState = State.PROCESS;
+ }
+ }
+
+ protected void processRequest() {
+ log.debug("Entered State: " + State.PROCESS);
+ log.debug("Processing command: " + slCommand);
+ commandInvoker.setCommand(slCommand);
+ responseCode = 200;
+ responseHeaders = Collections.EMPTY_MAP;
+ try {
+ commandInvoker.invoke(srcContex);
+ } catch (SLCanceledException e) {
+ log.info("Caught exception: " + e);
+ bindingProcessorError = e;
+ currentState = State.TRANSFORM;
+ }
+ dataUrlResponse = null;
+ if (getDataUrl() != null) {
+ log.debug("Data Url set to: " + getDataUrl());
+ currentState = State.DATAURL;
+ } else {
+ log.debug("No data url set");
+ currentState = State.TRANSFORM;
+ }
+ }
+
+ protected void handleDataUrl() {
+ log.debug("Entered State: " + State.DATAURL);
+ try {
+ DataUrl dataUrl = new DataUrl(getDataUrl());
+ DataUrlConnection conn = dataUrl.openConnection();
+
+ // set transfer headers
+ for (FormParameter fp : getTransferHeaders()) {
+ String paramString = getFormParameterAsString(fp);
+ if (paramString == null) {
+ log.error("Got empty transfer header, ignoring this");
+ } else {
+ String[] keyVal = paramString.split(":", 2);
+ String key = keyVal[0];
+ String val = null;
+ if (keyVal.length == 2) {
+ val = keyVal[1];
+ }
+ val = val.trim();
+ log.debug("Setting header " + key + " to value " + val);
+ conn.setHTTPHeader(key, val);
+ }
+ }
+
+ // set transfer form parameters
+ for (FormParameter fp : getTransferForms()) {
+ String contentTransferEncoding = null;
+ String contentType = fp.getFormParameterContentType();
+ String charSet = HttpUtil.getCharset(contentType, false);
+ if (charSet != null) {
+ contentType = contentType.substring(0, contentType
+ .lastIndexOf(HttpUtil.SEPERATOR[0]));
+ }
+ for (Iterator header = fp.getHeaderNames(); header.hasNext();) {
+ if (HttpUtil.CONTENT_TRANSFER_ENCODING
+ .equalsIgnoreCase(header.next())) {
+ contentTransferEncoding = getFormParameterAsString(fp);
+ }
+ }
+ log.debug("Setting form: " + fp.getFormParameterName()
+ + " contentType: " + contentType + " charset: " + charSet
+ + " contentTransferEncoding: " + contentTransferEncoding);
+ conn.setHTTPFormParameter(fp.getFormParameterName(), fp
+ .getFormParameterValue(), contentType, charSet,
+ contentTransferEncoding);
+ }
+
+ // connect
+ conn.connect();
+ // fetch and set SL result
+ targetContext.setTargetIsDataURL(true);
+ targetContext.setTargetCertificate(conn.getServerCertificate());
+ targetContext.setTargetProtocol(conn.getProtocol());
+ SLResult result = commandInvoker.getResult(targetContext);
+
+ // transfer result
+ conn.transmit(result);
+
+ // process Dataurl response
+ dataUrlResponse = conn.getResponse();
+ log.debug("Received data url response code: "
+ + dataUrlResponse.getResponseCode());
+ protocol = Protocol.fromString(conn.getProtocol());
+
+ switch (dataUrlResponse.getResponseCode()) {
+ case 200:
+ String contentType = dataUrlResponse.getContentType();
+ log.debug("Got dataurl response content type: " + contentType);
+ if (contentType != null) {
+ if ((contentType.startsWith(HttpUtil.APPLICATION_URL_ENCODED))
+ || (contentType.startsWith(HttpUtil.MULTIPART_FOTMDATA))) {
+ log.debug("Detected SL Request in dataurl response");
+ // process headers and request
+ setHTTPHeaders(dataUrlResponse.getResponseHeaders());
+ consumeRequestStream(dataUrlResponse.getStream());
+ closeDataUrlConnection();
+ srcContex.setSourceCertificate(conn.getServerCertificate());
+ srcContex.setSourceIsDataURL(true);
+ srcContex
+ .setSourceProtocol(Protocol.fromString(conn.getProtocol()));
+ currentState = State.PROCESS;
+ } else if (((contentType.startsWith(HttpUtil.TXT_HTML))
+ || (contentType.startsWith(HttpUtil.TXT_PLAIN)) || (contentType
+ .startsWith(HttpUtil.TXT_XML)))
+ && (dataUrlResponse.isHttpResponseXMLOK())) {
+ log.info("Dataurl response matches with content type: "
+ + contentType);
+ currentState = State.TRANSFORM;
+
+ } else if ((contentType.startsWith(HttpUtil.TXT_XML))
+ && (!dataUrlResponse.isHttpResponseXMLOK())) {
+ log
+ .debug("Detected text/xml dataurl response with content != ");
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
+ assignXMLRequest(dataUrlResponse.getStream(), HttpUtil.getCharset(
+ contentType, true));
+ closeDataUrlConnection();
+ srcContex.setSourceCertificate(conn.getServerCertificate());
+ srcContex.setSourceIsDataURL(true);
+ srcContex
+ .setSourceProtocol(Protocol.fromString(conn.getProtocol()));
+ currentState = State.PROCESS;
+ // just to be complete, actually not used
+ srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders()
+ .get(HttpUtil.HTTP_HEADER_REFERER));
+ } else {
+ resultContentType = contentType;
+ responseHeaders = dataUrlResponse.getResponseHeaders();
+ responseCode = dataUrlResponse.getResponseCode();
+ currentState = State.FINISHED;
+ }
+ } else {
+ log.debug("Content type not set in dataurl response");
+ closeDataUrlConnection();
+ throw new SLBindingException(2007);
+ }
+
+ break;
+ case 307:
+ contentType = dataUrlResponse.getContentType();
+ if ((contentType != null) && (contentType.startsWith(HttpUtil.TXT_XML))) {
+ log.debug("Received dataurl response code 307 with XML content");
+ String location = dataUrlResponse.getResponseHeaders().get(
+ HttpUtil.HTTP_HEADER_LOCATION);
+ if (location == null) {
+ log
+ .error("Did not get a location header for a 307 data url response");
+ throw new SLBindingException(2003);
+ }
+ // consumeRequestStream(dataUrlResponse.getStream());
+ FormParameterStore fp = new FormParameterStore();
+ fp.init(location.getBytes(HttpUtil.DEFAULT_CHARSET),
+ FixedFormParameters.DATAURL, null, null);
+ formParameterMap.put(FixedFormParameters.DATAURL, fp);
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
+ assignXMLRequest(dataUrlResponse.getStream(), HttpUtil.getCharset(
+ dataUrlResponse.getContentType(), true));
+ closeDataUrlConnection();
+ srcContex.setSourceCertificate(conn.getServerCertificate());
+ srcContex.setSourceIsDataURL(true);
+ srcContex.setSourceProtocol(Protocol.fromString(conn.getProtocol()));
+ currentState = State.PROCESS;
+ // just to be complete, actually not used
+ 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;
+
+ case 301:
+ case 302:
+ case 303:
+ responseHeaders = dataUrlResponse.getResponseHeaders();
+ responseCode = dataUrlResponse.getResponseCode();
+ resultContentType = dataUrlResponse.getContentType();
+ currentState = State.FINISHED;
+ break;
+
+ default:
+ // issue error
+ log.info("Unexpected response code from dataurl server: "
+ + dataUrlResponse.getResponseCode());
+ throw new SLBindingException(2007);
+ }
+
+ } catch (SLException slx) {
+ bindingProcessorError = slx;
+ log.error("Error during dataurl communication");
+ resultContentType = HttpUtil.TXT_XML;
+ currentState = State.TRANSFORM;
+ } catch (SSLHandshakeException hx) {
+ bindingProcessorError = new SLException(2010);
+ log.info("Error during dataurl communication", hx);
+ resultContentType = HttpUtil.TXT_XML;
+ currentState = State.TRANSFORM;
+ } catch (IOException e) {
+ bindingProcessorError = new SLBindingException(2001);
+ log.error("Error while data url handling", e);
+ resultContentType = HttpUtil.TXT_XML;
+ currentState = State.TRANSFORM;
+ return;
+ }
+ }
+
+ protected void transformResult() {
+ log.debug("Entered State: " + State.TRANSFORM);
+ if (bindingProcessorError != null) {
+ resultContentType = HttpUtil.TXT_XML;
+ } else if (dataUrlResponse != null) {
+ resultContentType = dataUrlResponse.getContentType();
+ } else {
+ targetContext.setTargetIsDataURL(false);
+ targetContext.setTargetProtocol(protocol.toString());
+ try {
+ slResult = commandInvoker.getResult(targetContext);
+ resultContentType = slResult.getMimeType();
+ log
+ .debug("Successfully got SLResult from commandinvoker, setting mimetype to: "
+ + resultContentType);
+ } catch (SLCanceledException e) {
+ log.info("Cannot get result from invoker:", e);
+ bindingProcessorError = new SLException(6002);
+ resultContentType = HttpUtil.TXT_XML;
+ }
+ }
+ transformer = getTransformer(getStyleSheetUrl());
+ if (transformer != null) {
+ log.debug("Output transformation required");
+ resultContentType = transformer.getOutputProperty("media-type");
+ log.debug("Got media type from stylesheet: " + resultContentType);
+ if (resultContentType == null) {
+ log.debug("Setting to default text/xml result conent type");
+ resultContentType = "text/xml";
+ }
+ log.debug("Deferring sytylesheet processing");
+ }
+ currentState = State.FINISHED;
+ }
+
+ protected void finished() {
+ log.debug("Entered State: " + State.FINISHED);
+ if (bindingProcessorError != null) {
+ log.debug("Binding processor error, sending quit command");
+ resultContentType = HttpUtil.TXT_XML;
+ }
+ sendSTALQuit();
+ log.info("Terminating Bindingprocessor; Thread: "
+ + Thread.currentThread().getId());
+ }
+
+ // -- END Methods that handle the http binding activities as defined in the
+ // activity diagram --
+ //----------------------------------------------------------------------------
+
+ /**
+ * Sets the headers of the SL Request. IMPORTANT: make sure to set all headers
+ * before invoking {@link #consumeRequestStream(InputStream)}
+ *
+ * @param aHeaderMap
+ * if null all header will be cleared.
+ */
+ public void setHTTPHeaders(Map aHeaderMap) {
+ headerMap = new HashMap();
+ // ensure lowercase keys
+ if (aHeaderMap != null) {
+ for (String s : aHeaderMap.keySet()) {
+ if (s != null) {
+ headerMap.put(s.toLowerCase(), aHeaderMap.get(s));
+ if (s.equalsIgnoreCase(HttpUtil.HTTP_HEADER_REFERER)) {
+ String referer = aHeaderMap.get(s);
+ log.debug("Got referer header: " + referer);
+ srcContex.setSourceHTTPReferer(referer);
+ }
+ }
+ }
+ }
+ }
+
+ public void setSourceCertificate(X509Certificate aCert) {
+ srcContex.setSourceCertificate(aCert);
+ }
+
+ /**
+ * The HTTPBindingProcessor does not handle redirect URLs. It only provides
+ * the parameter.
+ *
+ * @return null if redirect url is not set.
+ */
+ public String getRedirectURL() {
+ return getFormParameterAsString(FixedFormParameters.REDIRECTURL);
+ }
+
+ public String getFormDataContentType(String aParameterName) {
+ FormParameter fp = formParameterMap.get(aParameterName);
+ if (fp != null) {
+ return fp.getFormParameterContentType();
+ }
+ return null;
+ }
+
+ public InputStream getFormData(String aParameterName) {
+ FormParameter fp = formParameterMap.get(aParameterName);
+ if (fp != null) {
+ return fp.getFormParameterValue();
+ }
+ return null;
+ }
+
+ protected void assignXMLRequest(InputStream is, String charset)
+ throws IOException, SLException {
+ Reader r = new InputStreamReader(is, charset);
+ StreamSource source = new StreamSource(r);
+ SLCommandContext commandCtx = new SLCommandContext();
+ commandCtx.setSTAL(getSTAL());
+ commandCtx.setURLDereferencerContext(new SimpleFormDataContextImpl(this));
+ slCommand = SLCommandFactory.getInstance().createSLCommand(source,
+ commandCtx);
+ log.debug("Created new command: " + slCommand);
+ }
+
+ @Override
+ public void run() {
+ boolean done = false;
+ int hopcounter = 0;
+ if (bindingProcessorError != null) {
+ currentState = State.FINISHED;
+ }
+ try {
+ while (!done) {
+ try {
+ switch (currentState) {
+ case INIT:
+ init();
+ break;
+ case PROCESS:
+ processRequest();
+ break;
+ case DATAURL:
+ handleDataUrl();
+ if (++hopcounter > MAX_DATAURL_HOPS) {
+ log.error("Maximum number of dataurl hops reached");
+ bindingProcessorError = new SLBindingException(2000);
+ currentState = State.FINISHED;
+ }
+ break;
+ case TRANSFORM:
+ transformResult();
+ break;
+ case FINISHED:
+ done = true;
+ finished();
+ break;
+ }
+ } catch (RuntimeException rte) {
+ throw rte;
+ } catch (Exception t) {
+ log.error("Caught unexpected exception", t);
+ responseCode = 200;
+ resultContentType = HttpUtil.TXT_XML;
+ responseHeaders = Collections.EMPTY_MAP;
+ bindingProcessorError = new SLException(2000);
+ currentState = State.FINISHED;
+ }
+ }
+ } catch (Throwable t) {
+ log.error("Caught unexpected exception", t);
+ responseCode = 200;
+ resultContentType = HttpUtil.TXT_XML;
+ responseHeaders = Collections.EMPTY_MAP;
+ bindingProcessorError = new SLException(2000);
+ currentState = State.FINISHED;
+ }
+ log.debug("Terminated http binding processor");
+ }
+
+ @Override
+ public void consumeRequestStream(InputStream is) {
+ try {
+ log.debug("Start consuming request stream");
+ formParameterMap.clear();
+ String cl = headerMap
+ .get(HttpUtil.HTTP_HEADER_CONTENT_TYPE.toLowerCase());
+ if (cl == null) {
+ log.info("No content type set in http header");
+ throw new SLBindingException(2006);
+ }
+ InputDecoder id = InputDecoderFactory.getDecoder(cl, is);
+ id.setContentType(cl);
+ if (id == null) {
+ log.error("Cannot get inputdecoder for is");
+ throw new SLException(2006);
+ }
+ for (Iterator fpi = id.getFormParameterIterator(); fpi
+ .hasNext();) {
+ FormParameter fp = fpi.next();
+ log.debug("Got request parameter with name: "
+ + fp.getFormParameterName());
+ if (fp.getFormParameterName().equals(FixedFormParameters.XMLREQUEST)) {
+ log.debug("Creating XML Request");
+ for (Iterator headerIterator = fp.getHeaderNames(); headerIterator
+ .hasNext();) {
+ String headerName = headerIterator.next();
+ if (HttpUtil.CONTENT_TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {
+ String transferEncoding = fp.getHeaderValue(headerName);
+ log.debug("Got transfer encoding for xmlrequest: "
+ + transferEncoding);
+ if (XML_REQ_TRANSFER_ENCODING.contains(transferEncoding)) {
+ log.debug("Supported transfer encoding: " + transferEncoding);
+ } else {
+ log
+ .error("Transferencoding not supported: "
+ + transferEncoding);
+ throw new SLBindingException(2005);
+ }
+ }
+ }
+ String charset = HttpUtil.getCharset(cl, true);
+ assignXMLRequest(fp.getFormParameterValue(), charset);
+ } else {
+ FormParameterStore fps = new FormParameterStore();
+ fps.init(fp);
+ if (!fps.isEmpty()) {
+ log.debug("Setting from parameter: " + fps.getFormParameterName());
+ formParameterMap.put(fps.getFormParameterName(), fps);
+ }
+ }
+ }
+ if (slCommand == null) {
+ throw new SLBindingException(2004);
+ }
+ if (is.read() != -1) {
+ log.error("Request input stream not completely read");
+ // consume rest of stream, should never occur
+ throw new SLRuntimeException(
+ "request input stream not consumed till end");
+ }
+ } catch (SLException slx) {
+ log.info("Error while consuming input stream " + slx);
+ bindingProcessorError = slx;
+ } catch (Throwable t) {
+ log.info("Error while consuming input stream " + t, t);
+ bindingProcessorError = new SLException(2000);
+ } finally {
+ try {
+ while (is.read() != -1)
+ ;
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+ }
+
+ @Override
+ public String getResultContentType() {
+ return resultContentType;
+ }
+
+ protected Transformer getTransformer(String styleSheetURL) {
+ if (styleSheetURL == null) {
+ log.debug("Stylesheet URL not set");
+ return null;
+ }
+ try {
+ URLDereferencerContext urlCtx = new SimpleFormDataContextImpl(this);
+ URIResolver resolver = new URIResolverAdapter(URLDereferencer
+ .getInstance(), urlCtx);
+ TransformerFactory factory = TransformerFactory.newInstance();
+ StreamData sd = URLDereferencer.getInstance().dereference(styleSheetURL,
+ urlCtx);
+ Transformer t = factory.newTransformer(new StreamSource(sd.getStream()));
+ t.setURIResolver(resolver);
+ return t;
+ } catch (Exception ex) {
+ log.info("Cannot instantiate transformer", ex);
+ bindingProcessorError = new SLException(2002);
+ return null;
+ }
+ }
+
+ protected void handleBindingProcessorError(OutputStream os, String encoding,
+ Transformer transformer) throws IOException {
+ log.debug("Writing error as result");
+ ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError);
+ try {
+ error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)),
+ transformer);
+ } catch (TransformerException e) {
+ log.fatal("Cannot write error result to stream", e);
+ }
+ }
+
+ @Override
+ public void writeResultTo(OutputStream os, String encoding)
+ throws IOException {
+ if (encoding == null) {
+ encoding = HttpUtil.DEFAULT_CHARSET;
+ }
+ if (bindingProcessorError != null) {
+ log.debug("Detected error in binding processor, writing error as result");
+ handleBindingProcessorError(os, encoding, transformer);
+ return;
+ } else if (dataUrlResponse != null) {
+ log.debug("Writing data url response as result");
+ String charEnc = HttpUtil.getCharset(dataUrlResponse.getContentType(),
+ true);
+ InputStreamReader isr = new InputStreamReader(
+ dataUrlResponse.getStream(), charEnc);
+ OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
+ if (transformer == null) {
+ StreamUtil.copyStream(isr, osw);
+ } else {
+ try {
+ transformer.transform(new StreamSource(isr), new StreamResult(osw));
+ } catch (TransformerException e) {
+ log.fatal("Exception occured during result transformation", e);
+ // bindingProcessorError = new SLException(2008);
+ // handleBindingProcessorError(os, encoding, null);
+ return;
+ }
+ }
+ osw.flush();
+ isr.close();
+ } else if (slResult == null) {
+ // result not yet assigned -> must be a cancel
+ bindingProcessorError = new SLException(6001);
+ handleBindingProcessorError(os, encoding, transformer);
+ return;
+ } else {
+ log.debug("Getting result from invoker");
+ OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
+ try {
+ slResult.writeTo(new StreamResult(osw), transformer);
+ } catch (TransformerException e) {
+ log.fatal("Cannot write result to stream", e);
+ // bindingProcessorError = new SLException(2008);
+ // handleBindingProcessorError(os, encoding, transformer);
+ }
+ osw.flush();
+ }
+ }
+
+ /**
+ * The response code from the dataurl server or 200 if no dataurl server
+ * created the result
+ *
+ * @return
+ */
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+ /**
+ * All headers from the data url server in case of a direct forward from the
+ * dataurl server.
+ *
+ * @return
+ */
+ public Map getResponseHeaders() {
+ return responseHeaders;
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ if (locale == null) {
+ throw new NullPointerException("Locale must not be set to null");
+ }
+ this.locale = locale;
+ }
+
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java
new file mode 100644
index 00000000..b11a4d85
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java
@@ -0,0 +1,78 @@
+/*
+* 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.bku.binding;
+
+import java.util.Map;
+
+import org.apache.commons.fileupload.ParameterParser;
+
+/**
+ * Placeholder for some HTTP related constants and helper method to extract the charset for a request.
+ *
+ */
+public class HttpUtil {
+
+ public final static String CHAR_SET = "charset";
+ public final static String DEFAULT_CHARSET = "ISO-8859-1";
+ public final static String HTTP_HEADER_CONTENT_TYPE = "Content-Type";
+ public static final String HTTP_HEADER_USER_AGENT = "User-Agent";
+ public final static String HTTP_HEADER_REFERER = "Referer";
+ public final static String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
+ public final static String MULTIPART_FOTMDATA = "multipart/form-data";
+ public final static String MULTIPART_FOTMDATA_BOUNDARY = "boundary";
+ public final static String TXT_XML = "text/xml";
+ public final static String TXT_PLAIN = "text/plain";
+ public final static String TXT_HTML = "text/html";
+ public final static String APPLICATION_URL_ENCODED = "application/x-www-form-urlencoded";
+ public final static String HTTP_HEADER_LOCATION = "Location";
+
+ public final static char[] SEPERATOR = { ';' };
+
+ /**
+ * Extracts charset from a content type header.
+ *
+ * @param contentType
+ * @param replaceNullWithDefault
+ * if true the method return the default charset if not set
+ * @return charset String or null if not present
+ */
+ @SuppressWarnings("unchecked")
+ public static String getCharset(String contentType,
+ boolean replaceNullWithDefault) {
+ ParameterParser pf = new ParameterParser();
+ pf.setLowerCaseNames(true);
+ Map map = pf.parse(contentType, SEPERATOR);
+ String retVal = (String) map.get(CHAR_SET);
+ if ((retVal == null) && (replaceNullWithDefault)) {
+ if (map.containsKey(APPLICATION_URL_ENCODED)) {
+ // default charset for url encoded data
+ return "UTF-8";
+ }
+ retVal = getDefaultCharset();
+ }
+ return retVal;
+ }
+
+ /**
+ *
+ * Not to be used for url encoded requests.
+ */
+ public static String getDefaultCharset() {
+ return DEFAULT_CHARSET;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java
new file mode 100644
index 00000000..93ab2e8b
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java
@@ -0,0 +1,27 @@
+/*
+* 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.bku.binding;
+
+/**
+ * The unique identifier for a BindingProcessor
+ * @author wbauer
+ *
+ */
+public interface Id {
+
+ public String toString();
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdFactory.java
new file mode 100644
index 00000000..60bf69a4
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdFactory.java
@@ -0,0 +1,106 @@
+/*
+* 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.bku.binding;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Creates or converts Ids for BindingProcessors.
+ * @author wbauer
+ *
+ */
+public class IdFactory {
+
+ public static int DEFAULT_NUMBER_OF_BITS = 168;
+
+ private static Log log = LogFactory.getLog(IdFactory.class);
+
+ private static IdFactory instance = new IdFactory();
+
+ private SecureRandom random;
+ private int numberOfBits = DEFAULT_NUMBER_OF_BITS;
+
+ private IdFactory() {
+ try {
+ random = SecureRandom.getInstance("SHA1PRNG");
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Cannot instantiate secure random" + e);
+ }
+ }
+
+ public static IdFactory getInstance() {
+ return instance;
+ }
+
+
+ /**
+ * set the secure random number generator to create secure ids.
+ *
+ * @param random
+ * must not be null
+ */
+ public void setSecureRandom(SecureRandom random) {
+ if (random == null) {
+ throw new NullPointerException("Cannot set secure random to null");
+ }
+ this.random = random;
+ }
+
+ /**
+ * Don't use this method unless you know exactly what you do !
+ * Be sure to use a sufficient large entropy
+ * @param numberOfBits >=1 (although this small entropy does not make sense)
+ */
+ public void setNumberOfBits(int numberOfBits) {
+ if (numberOfBits <1) {
+ throw new IllegalArgumentException("Cannot set number of bits < 1");
+ }
+ this.numberOfBits = numberOfBits;
+ }
+
+ public int getNumberOfBits() {
+ return numberOfBits;
+ }
+
+ /**
+ * Creates a new Id object with the factory's secure RNG and the set number of
+ * bits.
+ *
+ * @return
+ */
+ public Id createId() {
+ return new IdImpl(numberOfBits, random);
+ }
+
+ /**
+ * Creates an Id object for the provided String
+ *
+ * @param idString
+ * may be null in this case the method call creates a new Id.
+ * @return
+ */
+ public Id createId(String idString) {
+ if (idString == null) {
+ return createId();
+ }
+ return new IdImpl(idString);
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java
new file mode 100644
index 00000000..5523992a
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java
@@ -0,0 +1,80 @@
+/*
+* 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.bku.binding;
+
+import iaik.utils.Base64OutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.SecureRandom;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Implementation that uses a Base64 representation for self generated Ids.
+ * @author wbauer
+ *
+ */
+public class IdImpl implements at.gv.egiz.bku.binding.Id {
+ private static Log log = LogFactory.getLog(IdImpl.class);
+
+ private String idString;
+
+ public IdImpl(int bitNumber, SecureRandom random) {
+ int byteSize = bitNumber/8;
+ if (bitNumber % 8 != 0) {
+ byteSize++;
+ }
+ byte[] randomBytes = new byte[byteSize];
+ random.nextBytes(randomBytes);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Base64OutputStream b64 = new Base64OutputStream(baos);
+ try {
+ b64.write(randomBytes);
+ b64.flush();
+ b64.close();
+ idString = new String(baos.toByteArray());
+ } catch (IOException e) {
+ log.error("Cannot create secure id: "+e);
+ }
+ }
+
+ public IdImpl(String idString) {
+ if (idString == null) {
+ throw new NullPointerException("Provided idstring must not be null");
+ }
+ this.idString = idString;
+ }
+
+ public String toString() {
+ return idString;
+ }
+
+ public int hashCode() {
+ return idString.hashCode();
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof Id) {
+ Id otherId = (Id)other;
+ return otherId.toString().equals(idString);
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoder.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoder.java
new file mode 100644
index 00000000..e22e54f2
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoder.java
@@ -0,0 +1,41 @@
+/*
+* 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.bku.binding;
+
+import java.io.InputStream;
+import java.util.Iterator;
+
+/**
+ * Decodes http input stream (either url encoded or multipart formdata)
+ * @author wbauer
+ *
+ */
+public interface InputDecoder {
+ /**
+ * Called from Factory.
+ * @param contentType
+ */
+ void setContentType(String contentType);
+
+ /**
+ * Called from Factory.
+ * @param is the input must not be null
+ */
+ void setInputStream(InputStream is);
+
+ Iterator getFormParameterIterator();
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoderFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoderFactory.java
new file mode 100644
index 00000000..211deee7
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/InputDecoderFactory.java
@@ -0,0 +1,89 @@
+/*
+* 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.bku.binding;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Factory to get a matching instance for a encoded input stream when reading a http request.
+ *
+ */
+public class InputDecoderFactory {
+
+ public final static String MULTIPART_FORMDATA = "multipart/form-data";
+ public final static String URL_ENCODED = "application/x-www-form-urlencoded";
+
+ private static InputDecoderFactory instance = new InputDecoderFactory();
+ private static Log log = LogFactory.getLog(InputDecoderFactory.class);
+
+ private String defaultEncoding = URL_ENCODED;
+ private Map> decoderMap = new HashMap>();
+
+ private InputDecoderFactory() {
+ decoderMap.put(MULTIPART_FORMDATA, MultiPartFormDataInputDecoder.class);
+ decoderMap.put(URL_ENCODED, XWWWFormUrlInputDecoder.class);
+ }
+
+ public static InputDecoder getDefaultDecoder(InputStream is) {
+ return getDecoder(instance.defaultEncoding, is);
+ }
+
+ /**
+ *
+ * @param contentType
+ * @param is
+ * @return null if the content type is not supported
+ */
+ public static InputDecoder getDecoder(String contentType, InputStream is) {
+ String prefix = contentType.split(";")[0].trim().toLowerCase();
+ Class extends InputDecoder> dec = instance.decoderMap.get(prefix);
+ if (dec == null) {
+ log.info("Unknown encoding prefix " + contentType);
+ return null;
+ }
+ InputDecoder id;
+ try {
+ id = dec.newInstance();
+ id.setContentType(contentType);
+ id.setInputStream(is);
+ return id;
+ } catch (InstantiationException e) {
+ log.error(e);
+ throw new IllegalArgumentException(
+ "Cannot get an input decoder for content type: " + contentType);
+ } catch (IllegalAccessException e) {
+ log.error(e);
+ throw new IllegalArgumentException(
+ "Cannot get an input decoder for content type: " + contentType);
+ }
+ }
+
+ /**
+ * Allows to register decoders for special mime types.
+ * @param mimeType
+ * @param decoder
+ */
+ public static void registerDecoder(String mimeType,
+ Class extends InputDecoder> decoder) {
+ instance.decoderMap.put(mimeType.toLowerCase(), decoder);
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/MultiPartFormDataInputDecoder.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/MultiPartFormDataInputDecoder.java
new file mode 100644
index 00000000..f8b13553
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/MultiPartFormDataInputDecoder.java
@@ -0,0 +1,133 @@
+/*
+* 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.bku.binding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+
+import org.apache.commons.fileupload.FileItemIterator;
+import org.apache.commons.fileupload.FileItemStream;
+import org.apache.commons.fileupload.FileUpload;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.RequestContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+/**
+ * The code to detect the multipart boundary is based on
+ * org.apache.commons.fileupload.FileUploadBase of
+ * http://commons.apache.org/fileupload/
+ *
+ * @author wbauer
+ *
+ */
+public class MultiPartFormDataInputDecoder implements InputDecoder,
+ RequestContext {
+
+ private static Log log = LogFactory
+ .getLog(MultiPartFormDataInputDecoder.class);
+
+ private String contentType;
+ private InputStream stream;
+
+ @Override
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ return null;
+ }
+
+ @Override
+ public int getContentLength() {
+ return 0;
+ }
+
+ @Override
+ public String getContentType() {
+ return contentType;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return stream;
+ }
+
+ @Override
+ public Iterator getFormParameterIterator() {
+ try {
+ FileUpload fup = new FileUpload();
+ FileItemIterator fit = fup.getItemIterator(this);
+ return new IteratorDelegator(fit);
+ } catch (Exception iox) {
+ log.error("Cannot decode multipart form data stream " + iox);
+ throw new SLRuntimeException(iox);
+ }
+ }
+
+ @Override
+ public void setInputStream(InputStream is) {
+ stream = is;
+ }
+
+ static class IteratorDelegator implements Iterator {
+
+ private FileItemIterator fileItemIterator;
+
+ public IteratorDelegator(FileItemIterator fit) {
+ fileItemIterator = fit;
+ }
+
+ @Override
+ public boolean hasNext() {
+ try {
+ return fileItemIterator.hasNext();
+ } catch (FileUploadException e) {
+ log.error(e);
+ throw new SLRuntimeException(e);
+ } catch (IOException e) {
+ log.error(e);
+ throw new SLRuntimeException(e);
+ }
+ }
+
+ @Override
+ public FormParameter next() {
+ try {
+ FileItemStream item = fileItemIterator.next();
+ return new FormParameterImpl(item.getContentType(),
+ item.getFieldName(), item.openStream(), item.getHeaders());
+ } catch (FileUploadException e) {
+ log.error(e);
+ throw new SLRuntimeException(e);
+ } catch (IOException e) {
+ log.error(e);
+ throw new SLRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException("Remove not supported");
+ }
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/RemovalStrategy.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/RemovalStrategy.java
new file mode 100644
index 00000000..6c2dcb9f
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/RemovalStrategy.java
@@ -0,0 +1,26 @@
+/*
+* 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.bku.binding;
+
+/**
+ * Could be used to remove expired BindingProcessor objects from a BindingProcessorManager.
+ *
+ */
+public interface RemovalStrategy {
+ public void execute();
+ public void setBindingProcessorManager(BindingProcessorManager bp);
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java
new file mode 100644
index 00000000..ef2affd1
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java
@@ -0,0 +1,66 @@
+/*
+* 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.bku.binding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLSourceContext;
+import at.gv.egiz.bku.slcommands.SLTargetContext;
+
+/**
+ * This class implements the entry point for the CCEs security management.
+ *
+ * TODO the secuirty management is currently not implemented.
+ */
+public class SLCommandInvokerImpl implements SLCommandInvoker {
+
+ private static Log log = LogFactory.getLog(SLCommandInvokerImpl.class);
+
+ protected SLCommand command;
+ protected SLResult result;
+
+ /**
+ * Invokes a sl command.
+ */
+ public void invoke(SLSourceContext aContext) {
+ // FIXXME add security policy here.
+ log.warn("Security policy not implemented yet, invoking command: "+command);
+ result = command.execute();
+ }
+
+ public SLResult getResult(SLTargetContext aContext) {
+ // FIXXME
+ log.warn("Security policy not implemented yet, getting result of command: "+command);
+ return result;
+ }
+
+ public void setCommand(SLCommand aCmd) {
+ command = aCmd;
+ }
+
+ @Override
+ public SLCommandInvoker newInstance() {
+ SLCommandInvokerImpl cmdInv = new SLCommandInvokerImpl();
+ return cmdInv;
+ }
+
+
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java
new file mode 100644
index 00000000..f4ebe288
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java
@@ -0,0 +1,101 @@
+/*
+* 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.bku.binding;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLDecoder;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.fileupload.ParameterParser;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.StreamUtil;
+
+/**
+ * Implementation based on Java's URLDecoder class
+ *
+ */
+// FIXME replace this code by a streaming variant
+public class XWWWFormUrlInputDecoder implements InputDecoder {
+
+ public final static String CHAR_SET = "charset";
+ public final static String NAME_VAL_SEP = "=";
+ public final static String SEP = "\\&";
+
+ private String contentType;
+ private InputStream dataStream;
+ private String charset = "UTF-8";
+
+ protected List decodeInput(InputStream is) throws IOException {
+ List result = new LinkedList();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ StreamUtil.copyStream(is, bos);
+ String inputString = new String(bos.toByteArray());
+ String[] nameValuePairs = inputString.split(SEP);
+ //inputString = URLDecoder.decode(inputString, charset);
+ for (int i = 0; i < nameValuePairs.length; i++) {
+ String[] fields = nameValuePairs[i].split(NAME_VAL_SEP, 2);
+ if (fields.length != 2) {
+ throw new SLRuntimeException("Invalid form encoding, missing value");
+ }
+ String name = URLDecoder.decode(fields[0], charset);
+ String value =URLDecoder.decode(fields[1], charset);
+ ByteArrayInputStream bais = new ByteArrayInputStream(value
+ .getBytes(charset));
+ FormParameterImpl fpi = new FormParameterImpl(contentType, name, bais, null);
+ result.add(fpi);
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setContentType(String contentType) {
+ ParameterParser pp = new ParameterParser();
+ pp.setLowerCaseNames(true);
+ Map params = pp.parse(contentType, new char[] { ':', ';' });
+ if (!params.containsKey("application/x-www-form-urlencoded")) {
+ throw new IllegalArgumentException(
+ "not a url encoded content type specification: " + contentType);
+ }
+ String cs = params.get(CHAR_SET);
+ if (cs != null) {
+ charset = cs;
+ }
+ this.contentType = contentType;
+ }
+
+ @Override
+ public Iterator getFormParameterIterator() {
+ try {
+ return decodeInput(dataStream).iterator();
+ } catch (IOException e) {
+ throw new SLRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void setInputStream(InputStream is) {
+ dataStream = is;
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java
new file mode 100644
index 00000000..253f8ff5
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java
@@ -0,0 +1,66 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.binding.multipart;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.commons.httpclient.methods.multipart.PartSource;
+
+/**
+ * InputStream source for FilePart.
+ * DOES NOT RETURN A CORRECT LENGTH OF THE INPUT DATA. (but we don't care, since we use chunked encoding)
+ *
+ * @author clemens
+ */
+public class InputStreamPartSource implements PartSource {
+
+ protected String name;
+ protected InputStream data;
+
+ public InputStreamPartSource(String name, InputStream data) {
+ this.name = name;
+ this.data = data;
+ }
+
+ /**
+ * Just a dummy value to make Part work
+ * @return 42
+ */
+ @Override
+ public long getLength() {
+ //System.out.println("***********GETLENGTH");
+ return 42;
+ }
+
+ @Override
+ public String getFileName() {
+ return name;
+ }
+
+ @Override
+ public InputStream createInputStream() throws IOException {
+ if (data == null)
+ throw new IOException("Failed to get stream for part: no data was set.");
+ return data;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
new file mode 100644
index 00000000..566b77b3
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
@@ -0,0 +1,57 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.binding.multipart;
+
+import at.gv.egiz.bku.slcommands.SLResult;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+
+/**
+ *
+ * @author clemens
+ */
+public class SLResultPart extends FilePart {
+
+ protected SLResult slResult;
+ protected String encoding;
+
+ public SLResultPart(SLResult slResult, String encoding) {
+ super("XMLResponse",
+ new ByteArrayPartSource(null, "dummySource".getBytes()));
+ this.slResult = slResult;
+ this.encoding = encoding;
+ }
+
+ @Override
+ protected void sendData(OutputStream out) throws IOException {
+ slResult.writeTo(new StreamResult(new OutputStreamWriter(out, encoding)));
+ // slResult.writeTo(new StreamResult(new OutputStreamWriter(System.out,
+ // encoding)));
+ // super.sendData(out);
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/AccessControlInvocation.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/AccessControlInvocation.java
new file mode 100644
index 00000000..014b7fd7
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/AccessControlInvocation.java
@@ -0,0 +1,21 @@
+/*
+* 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.bku.slcommands;
+
+public class AccessControlInvocation implements
+ at.gv.egiz.bku.slcommands.InvocationStrategy {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureCommand.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureCommand.java
new file mode 100644
index 00000000..2d87c39f
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureCommand.java
@@ -0,0 +1,25 @@
+/*
+* 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.bku.slcommands;
+
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
+
+public interface CreateXMLSignatureCommand extends SLCommand {
+
+ public void prepareXMLSignature() throws SLCommandException, SLRequestException;
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureResult.java
new file mode 100644
index 00000000..4bc2820b
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/CreateXMLSignatureResult.java
@@ -0,0 +1,20 @@
+/*
+* 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.bku.slcommands;
+
+public interface CreateXMLSignatureResult extends SLResult {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/ErrorResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/ErrorResult.java
new file mode 100644
index 00000000..5d52c0ea
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/ErrorResult.java
@@ -0,0 +1,20 @@
+/*
+* 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.bku.slcommands;
+
+public interface ErrorResult extends SLResult {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java
new file mode 100644
index 00000000..77529a36
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java
@@ -0,0 +1,20 @@
+/*
+* 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.bku.slcommands;
+
+public interface InfoboxReadCommand extends SLCommand {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadResult.java
new file mode 100644
index 00000000..c6a51362
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadResult.java
@@ -0,0 +1,20 @@
+/*
+* 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.bku.slcommands;
+
+public interface InfoboxReadResult extends SLResult {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InvocationStrategy.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InvocationStrategy.java
new file mode 100644
index 00000000..6b410fac
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InvocationStrategy.java
@@ -0,0 +1,20 @@
+/*
+* 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.bku.slcommands;
+
+public interface InvocationStrategy {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationCommand.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationCommand.java
new file mode 100644
index 00000000..0651f882
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationCommand.java
@@ -0,0 +1,20 @@
+/*
+* 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.bku.slcommands;
+
+public interface NullOperationCommand extends SLCommand {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationResult.java
new file mode 100644
index 00000000..c36c879e
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/NullOperationResult.java
@@ -0,0 +1,20 @@
+/*
+* 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.bku.slcommands;
+
+public interface NullOperationResult extends SLResult {
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommand.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommand.java
new file mode 100644
index 00000000..a8625946
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommand.java
@@ -0,0 +1,31 @@
+/*
+* 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.bku.slcommands;
+
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+
+public interface SLCommand {
+
+ public final String NAMESPACE_URI = "http://www.buergerkarte.at/namespaces/securitylayer/1.2#";
+
+ public String getName();
+
+ public void init(SLCommandContext aCtx, Object aUnmarshalledRequest) throws SLCommandException;
+
+ public SLResult execute();
+
+}
\ No newline at end of file
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
new file mode 100644
index 00000000..c95736bd
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandContext.java
@@ -0,0 +1,42 @@
+/*
+* 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.bku.slcommands;
+
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+import at.gv.egiz.stal.STAL;
+
+public class SLCommandContext {
+
+ private STAL stal;
+ private URLDereferencerContext urlDerefCtx;
+
+ public void setSTAL(STAL aStal) {
+ this.stal = aStal;
+ }
+
+ public void setURLDereferencerContext(URLDereferencerContext aCtx) {
+ this.urlDerefCtx = aCtx;
+ }
+
+ public STAL getSTAL() {
+ return stal;
+ }
+
+ public URLDereferencerContext getURLDereferencerContext() {
+ return urlDerefCtx;
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
new file mode 100644
index 00000000..e13b29a1
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
@@ -0,0 +1,370 @@
+/*
+* 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.bku.slcommands;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.UnmarshalException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl;
+import at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl;
+import at.gv.egiz.bku.slcommands.impl.NullOperationCommandImpl;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.slbinding.RedirectEventFilter;
+import at.gv.egiz.slbinding.RedirectUnmarshallerListener;
+
+public class SLCommandFactory {
+
+ /**
+ * Schema files required for Security Layer command validation.
+ */
+ public static final String[] SCHEMA_FILES = new String[]{
+ "at/gv/egiz/bku/slcommands/schema/xml.xsd",
+ "at/gv/egiz/bku/slcommands/schema/xmldsig-core-schema.xsd",
+ "at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd"
+ };
+ /**
+ * Logging facility.
+ */
+ static Log log = LogFactory.getLog(SLCommandFactory.class);
+ /**
+ * The instance returned by {@link #getInstance()}.
+ */
+ private static SLCommandFactory instance;
+ /**
+ * Schema for Security Layer command validation.
+ */
+ private static Schema slSchema;
+ /**
+ * The JAXBContext.
+ */
+ private static JAXBContext jaxbContext;
+ /**
+ * The map of : to implementation class of the
+ * corresponding {@link SLCommand}.
+ */
+ private static Map> slRequestTypeMap = new HashMap>();
+
+
+ static {
+
+ // TODO: implement dynamic registration
+
+ // register all known implementation classes
+ putImplClass(SLCommand.NAMESPACE_URI, "NullOperationRequest",
+ NullOperationCommandImpl.class);
+ putImplClass(SLCommand.NAMESPACE_URI, "InfoboxReadRequest",
+ InfoboxReadCommandImpl.class);
+ putImplClass(SLCommand.NAMESPACE_URI, "CreateXMLSignatureRequest",
+ CreateXMLSignatureCommandImpl.class);
+ }
+
+ /**
+ * Register an {@link SLCommand} implementation class of a Security Layer
+ * command with the given namespaceUri and localname
+ * .
+ *
+ * @param namespaceUri
+ * the namespace URI of the Security Layer command
+ * @param localname
+ * the localname of the Security Layer command
+ * @param slCommandClass
+ * the implementation class, or null to deregister a
+ * currently registered class
+ */
+ public static void putImplClass(String namespaceUri, String localname,
+ Class extends SLCommand> slCommandClass) {
+ if (slCommandClass != null) {
+ slRequestTypeMap.put(namespaceUri + ":" + localname, slCommandClass);
+ } else {
+ slRequestTypeMap.remove(namespaceUri + ":" + localname);
+ }
+ }
+
+ /**
+ * Returns the implementation class of an {@link SLCommand} with the given
+ * name, or null if no such class is registered.
+ *
+ * @param name
+ * the QName of the Security Layer command
+ * @return the implementation class, or null if no class is
+ * registered for the given name
+ */
+ public static Class extends SLCommand> getImplClass(QName name) {
+ String namespaceURI = name.getNamespaceURI();
+ String localPart = name.getLocalPart();
+ return slRequestTypeMap.get(namespaceURI + ":" + localPart);
+ }
+
+ /**
+ * Sets the schema to validate Security Layer commands with.
+ *
+ * @param slSchema the schema to validate Security Layer commands with
+ */
+ public static void setSLSchema(Schema slSchema) {
+ SLCommandFactory.slSchema = slSchema;
+ }
+
+ /**
+ * @return the jaxbContext
+ */
+ public static JAXBContext getJaxbContext() {
+ ensureJaxbContext();
+ return jaxbContext;
+ }
+
+ /**
+ * @param jaxbContext the jaxbContext to set
+ */
+ public static void setJaxbContext(JAXBContext jaxbContext) {
+ SLCommandFactory.jaxbContext = jaxbContext;
+ }
+
+ /**
+ * Initialize the JAXBContext.
+ */
+ private synchronized static void ensureJaxbContext() {
+ if (jaxbContext == null) {
+ try {
+ String slPkg = at.buergerkarte.namespaces.securitylayer._1.ObjectFactory.class.getPackage().getName();
+ String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName();
+ setJaxbContext(JAXBContext.newInstance(slPkg + ":" + xmldsigPkg));
+ } catch (JAXBException e) {
+ log.error("Failed to setup JAXBContext security layer request.", e);
+ throw new SLRuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * Initialize the security layer schema.
+ */
+ private synchronized static void ensureSchema() {
+ if (slSchema == null) {
+ try {
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ ClassLoader cl = SLCommandFactory.class.getClassLoader();
+ Source[] sources = new Source[SCHEMA_FILES.length];
+ for (int i = 0; i < SCHEMA_FILES.length; i++) {
+ String schemaFile = SCHEMA_FILES[i];
+ URL schemaURL = cl.getResource(schemaFile);
+ if (schemaURL == null) {
+ throw new SLRuntimeException("Failed to load schema file " + schemaFile + ".");
+ }
+ log.debug("Schema location: " + schemaURL);
+ sources[i] = new StreamSource(schemaURL.openStream());
+ }
+ Schema schema = schemaFactory.newSchema(sources);
+ log.debug("Schema successfully created.");
+ SLCommandFactory.setSLSchema(schema);
+ } catch (SAXException e) {
+ log.error("Failed to load security layer schema.", e);
+ throw new SLRuntimeException("Failed to load security layer schema.", e);
+ } catch (IOException e) {
+ log.error("Failed to load security layer schema.", e);
+ throw new SLRuntimeException("Failed to load security layer schema.", e);
+ }
+
+ }
+ }
+
+ /**
+ * Get an instance of the SLCommandFactory.
+ */
+ public synchronized static SLCommandFactory getInstance() {
+ if (instance == null) {
+ ensureJaxbContext();
+ ensureSchema();
+ instance = new SLCommandFactory();
+ }
+ return instance;
+ }
+
+ /**
+ * Private constructor used by {@link #getInstance()}.
+ */
+ private SLCommandFactory() {
+ }
+
+ /**
+ * Unmarshalls from the given source.
+ *
+ * @see Unmarshaller#unmarshal(Source)
+ *
+ * Note:Could replace JAXB's unmarshal-time validation engine (see commented code), however,
+ * we need a redirect filter.
+ *
+ * @param source
+ * the source to unmarshal from
+ * @return the object returned by {@link Unmarshaller#unmarshal(Source)}
+ * @throws SLRequestException
+ * if unmarshalling fails
+ * @throws SLRuntimeException
+ * if an unexpected error occurs configuring the unmarshaller or if
+ * unmarshalling fails with an unexpected error
+ */
+ protected Object unmarshal(Source source) throws SLRuntimeException,
+ SLRequestException {
+
+ Object object;
+ try {
+
+// ValidatorHandler validator = slSchema.newValidatorHandler();
+// validator.getContentHandler();
+//
+// SAXParserFactory spf = SAXParserFactory.newInstance();
+// spf.setNamespaceAware(true);
+// XMLReader saxReader = spf.newSAXParser().getXMLReader();
+// //TODO extend validator to implement redirectContentHandler (validate+redirect)
+// saxReader.setContentHandler(validator);
+// //TODO get a InputSource
+// SAXSource saxSource = new SAXSource(saxReader, source);
+//
+// Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+// //turn off duplicate jaxb validation
+// unmarshaller.setSchema(null);
+// unmarshaller.setListener(listener);
+// unmarshaller.unmarshal(saxSource);
+
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLEventReader eventReader = inputFactory.createXMLEventReader(source);
+ RedirectEventFilter redirectEventFilter = new RedirectEventFilter();
+ XMLEventReader filteredReader = inputFactory.createFilteredReader(eventReader, redirectEventFilter);
+
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ unmarshaller.setListener(new RedirectUnmarshallerListener(redirectEventFilter));
+ if (slSchema != null) {
+ unmarshaller.setSchema(slSchema);
+ }
+ log.trace("Before unmarshal().");
+ object = unmarshaller.unmarshal(filteredReader);
+ log.trace("After unmarshal().");
+ } catch (UnmarshalException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to unmarshall security layer request.", e);
+ } else {
+ log.info("Failed to unmarshall security layer request." + e.getMessage());
+ }
+ Throwable cause = e.getCause();
+ if (cause instanceof SAXParseException) {
+ throw new SLRequestException(3000,
+ SLExceptionMessages.EC3000_UNCLASSIFIED, new Object[]{cause.getMessage()});
+ } else {
+ throw new SLRequestException(3000,
+ SLExceptionMessages.EC3000_UNCLASSIFIED, new Object[]{e});
+ }
+ } catch (JAXBException e) {
+ // unexpected error
+ log.error("Failed to unmarshall security layer request.", e);
+ throw new SLRuntimeException(e);
+ } catch (XMLStreamException e) {
+ // unexpected error
+ log.error("Failed to unmarshall security layer request.", e);
+ throw new SLRuntimeException(e);
+ }
+
+ return object;
+
+ }
+
+ /**
+ * Creates a new SLCommand from the given source and
+ * context.
+ *
+ * @param source
+ * the Source to unmarshall from
+ * @param context
+ * the context for the created SLCommand
+ * @return the SLCommand unmarshalled from the given
+ * source
+ * @throws SLRequestException
+ * if unmarshalling fails
+ * @throws SLCommandException
+ * if command ist not supported
+ * @throws SLRuntimeException
+ * if an unexpected error occurs configuring the unmarshaller, if
+ * unmarshalling fails with an unexpected error or if the
+ * corresponding SLCommand could not be instantiated
+ */
+ @SuppressWarnings("unchecked")
+ public SLCommand createSLCommand(Source source, SLCommandContext context)
+ throws SLCommandException, SLRuntimeException, SLRequestException {
+
+ Object object = unmarshal(source);
+ if (!(object instanceof JAXBElement)) {
+ // invalid request
+ log.info("Invalid security layer request. " + object.toString());
+ throw new SLRequestException(3002, SLExceptionMessages.EC3002_INVALID,
+ new Object[]{object.toString()});
+ }
+
+ QName qName = ((JAXBElement) object).getName();
+ Class extends SLCommand> implClass = getImplClass(qName);
+ if (implClass == null) {
+ // command not supported
+ log.info("Unsupported command received: " + qName.toString());
+ throw new SLCommandException(4011,
+ SLExceptionMessages.EC4011_NOTIMPLEMENTED, new Object[]{qName.toString()});
+ }
+
+ // try to instantiate
+ SLCommand slCommand;
+ try {
+ slCommand = implClass.newInstance();
+ log.debug("SLCommand " + slCommand.getName() + " created.");
+ } catch (InstantiationException e) {
+ // unexpected error
+ log.error("Failed to instantiate security layer command implementation.",
+ e);
+ throw new SLRuntimeException(e);
+ } catch (IllegalAccessException e) {
+ // unexpected error
+ log.error("Failed to instantiate security layer command implementation.",
+ e);
+ throw new SLRuntimeException(e);
+ }
+ slCommand.init(context, (JAXBElement) object);
+
+ return slCommand;
+
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java
new file mode 100644
index 00000000..30c6b68f
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java
@@ -0,0 +1,45 @@
+/*
+* 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.bku.slcommands;
+
+import at.gv.egiz.bku.slexceptions.SLCanceledException;
+
+public interface SLCommandInvoker {
+
+ /**
+ *
+ * @param aContext
+ * @throws SLCanceledException if the security management prevents execution of this command
+ */
+ public void invoke(SLSourceContext aContext) throws SLCanceledException;
+
+ /**
+ *
+ * @param aContext
+ * @return
+ * @throws SLCanceledException if the security management prevents execution of this command
+ */
+ public SLResult getResult(SLTargetContext aContext) throws SLCanceledException;
+
+ public void setCommand(at.gv.egiz.bku.slcommands.SLCommand aCmd);
+
+ /**
+ * Prototype creation
+ * @return
+ */
+ public SLCommandInvoker newInstance();
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
new file mode 100644
index 00000000..7cf43fda
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
@@ -0,0 +1,44 @@
+/*
+* 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.bku.slcommands;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+
+public interface SLResult {
+
+ public static enum SLResultType {BINARY, XML};
+
+ public SLResultType getResultType();
+
+ /**
+ * The MIME Type of the Result.
+ *
+ * @return may result null if unknown.
+ */
+ public String getMimeType();
+
+ public void writeTo(Result aResult);
+
+ /**
+ *
+ * @param result
+ * @param transformer may be null.
+ */
+ public void writeTo(Result result, Transformer transformer) throws TransformerException;
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java
new file mode 100644
index 00000000..ded55b2a
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java
@@ -0,0 +1,63 @@
+/*
+* 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.bku.slcommands;
+
+import java.security.cert.X509Certificate;
+
+import at.gv.egiz.bku.utils.binding.Protocol;
+
+
+public class SLSourceContext {
+
+ private Protocol sourceProtocol;
+ private boolean sourceIsDataURL;
+ private X509Certificate sourceCertificate;
+ private String sourceHTTPReferer;
+
+ public Protocol getSourceProtocol() {
+ return sourceProtocol;
+ }
+
+ public void setSourceProtocol(Protocol sourceProtocol) {
+ this.sourceProtocol = sourceProtocol;
+ }
+
+ public boolean isSourceIsDataURL() {
+ return sourceIsDataURL;
+ }
+
+ public void setSourceIsDataURL(boolean sourceIsDataURL) {
+ this.sourceIsDataURL = sourceIsDataURL;
+ }
+
+ public X509Certificate getSourceCertificate() {
+ return sourceCertificate;
+ }
+
+ public void setSourceCertificate(X509Certificate sourceCertificate) {
+ this.sourceCertificate = sourceCertificate;
+ }
+
+ public String getSourceHTTPReferer() {
+ return sourceHTTPReferer;
+ }
+
+ public void setSourceHTTPReferer(String sourceHTTPReferer) {
+ this.sourceHTTPReferer = sourceHTTPReferer;
+ }
+
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java
new file mode 100644
index 00000000..cf800406
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java
@@ -0,0 +1,50 @@
+/*
+* 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.bku.slcommands;
+
+import java.security.cert.X509Certificate;
+
+public class SLTargetContext {
+ private String targetProtocol;
+ private boolean targetIsDataURL;
+ private X509Certificate targetCertificate;
+
+ public String getTargetProtocol() {
+ return targetProtocol;
+ }
+
+ public void setTargetProtocol(String targetProtocol) {
+ this.targetProtocol = targetProtocol;
+ }
+
+ public boolean isTargetIsDataURL() {
+ return targetIsDataURL;
+ }
+
+ public void setTargetIsDataURL(boolean targetIsDataURL) {
+ this.targetIsDataURL = targetIsDataURL;
+ }
+
+ public X509Certificate getTargetCertificate() {
+ return targetCertificate;
+ }
+
+ public void setTargetCertificate(X509Certificate targetCertificate) {
+ this.targetCertificate = targetCertificate;
+ }
+
+}
\ 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
new file mode 100644
index 00000000..136fa6f3
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java
@@ -0,0 +1,229 @@
+/*
+* 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.bku.slcommands.impl;
+
+import java.io.ByteArrayInputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Collections;
+import java.util.Date;
+
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.URIReferenceException;
+import javax.xml.crypto.dsig.XMLSignatureException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSSerializer;
+
+import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.DataObjectInfoType;
+import at.gv.egiz.bku.slcommands.CreateXMLSignatureCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.impl.xsect.AlgorithmMethodFactory;
+import at.gv.egiz.bku.slcommands.impl.xsect.AlgorithmMethodFactoryImpl;
+import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactory;
+import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactoryImpl;
+import at.gv.egiz.bku.slcommands.impl.xsect.Signature;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.dom.DOMUtils;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.InfoboxReadResponse;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+
+/**
+ * This class implements the security layer command CreateXMLSignatureRequest.
+ *
+ * @author mcentner
+ */
+public class CreateXMLSignatureCommandImpl extends SLCommandImpl implements
+ CreateXMLSignatureCommand {
+
+ /**
+ * Logging facility.
+ */
+ protected static Log log = LogFactory.getLog(CreateXMLSignatureCommandImpl.class);
+
+ /**
+ * The signing certificate.
+ */
+ protected X509Certificate signingCertificate;
+
+ /**
+ * The keybox identifier of the key used for signing.
+ */
+ protected String keyboxIdentifier;
+
+ /**
+ * The to-be signed signature.
+ */
+ protected Signature signature;
+
+ @Override
+ public void init(SLCommandContext ctx, Object unmarshalledRequest)
+ throws SLCommandException {
+ super.init(ctx, unmarshalledRequest);
+ }
+
+ @Override
+ public void prepareXMLSignature() throws SLCommandException, SLRequestException {
+
+ CreateXMLSignatureRequestType request = getRequestValue();
+
+ // TODO: make configurable?
+ IdValueFactory idValueFactory = new IdValueFactoryImpl();
+
+ // TODO: make configurable?
+ AlgorithmMethodFactory algorithmMethodFactory;
+ try {
+ algorithmMethodFactory = new AlgorithmMethodFactoryImpl(signingCertificate);
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Failed to get DigestMethod.", e);
+ throw new SLCommandException(4006);
+ }
+
+ signature = new Signature(getCmdCtx().getURLDereferencerContext(), idValueFactory, algorithmMethodFactory);
+
+ // SigningTime
+ signature.setSigningTime(new Date());
+
+ // SigningCertificate
+ signature.setSignerCeritifcate(signingCertificate);
+
+ // SignatureInfo
+ if (request.getSignatureInfo() != null) {
+ signature.setSignatureInfo(request.getSignatureInfo());
+ }
+
+ // DataObjects
+ for (DataObjectInfoType dataObjectInfo : request.getDataObjectInfo()) {
+ signature.addDataObject(dataObjectInfo);
+ }
+
+ signature.buildXMLSignature();
+
+ }
+
+ /**
+ * Gets the signing certificate from STAL.
+ *
+ * @throws SLCommandException
+ * if getting the singing certificate fails
+ */
+ private void getSigningCertificate() throws SLCommandException {
+
+ CreateXMLSignatureRequestType request = getRequestValue();
+ keyboxIdentifier = request.getKeyboxIdentifier();
+
+ InfoboxReadRequest stalRequest = new InfoboxReadRequest();
+ stalRequest.setInfoboxIdentifier(keyboxIdentifier);
+
+ requestSTAL(Collections.singletonList((STALRequest) stalRequest));
+
+ STALResponse stalResponse = stalResponses.next();
+
+ if (stalResponse instanceof InfoboxReadResponse) {
+ byte[] infobox = ((InfoboxReadResponse) stalResponse).getInfoboxValue();
+
+ try {
+ CertificateFactory certFactory = CertificateFactory.getInstance("X509");
+ signingCertificate = (X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(infobox));
+ } catch (CertificateException e) {
+ log.info("Failed to decode signing certificate.", e);
+ // TODO: issue appropriate error
+ throw new SLCommandException(4000);
+ }
+
+ } else {
+ log.info("Failed to get signing certificate.");
+ // TODO: issue appropriate error
+ throw new SLCommandException(4000);
+ }
+
+ }
+
+ /**
+ * Signs the signature.
+ *
+ * @throws SLCommandException
+ * if signing the signature fails
+ */
+ private void signXMLSignature() throws SLCommandException {
+
+ try {
+ signature.sign(getCmdCtx().getSTAL(), keyboxIdentifier);
+ } catch (MarshalException e) {
+ log.error("Failed to marshall XMLSignature.", e);
+ throw new SLCommandException(4000);
+ } catch (XMLSignatureException e) {
+ if (e.getCause() instanceof URIReferenceException) {
+ URIReferenceException uriReferenceException = (URIReferenceException) e.getCause();
+ if (uriReferenceException.getCause() instanceof SLCommandException) {
+ throw (SLCommandException) uriReferenceException.getCause();
+ }
+ }
+ log.error("Failed to sign XMLSignature.", e);
+ throw new SLCommandException(4000);
+ }
+
+ }
+
+ @Override
+ public SLResult execute() {
+ try {
+
+ // get certificate in order to select appropriate algorithms for hashing and signing
+ getSigningCertificate();
+
+ // prepare the XMLSignature for signing
+ prepareXMLSignature();
+
+ // sign the XMLSignature
+ signXMLSignature();
+
+ if (log.isTraceEnabled()) {
+
+ DOMImplementationLS domImplLS = DOMUtils.getDOMImplementationLS();
+ LSSerializer serializer = domImplLS.createLSSerializer();
+ String debugString = serializer.writeToString(signature.getDocument());
+
+ log.trace(debugString);
+
+ }
+
+ return new CreateXMLSignatureResultImpl(signature.getDocument());
+
+ } catch (SLCommandException e) {
+ return new ErrorResultImpl(e);
+ } catch (SLRequestException e) {
+ return new ErrorResultImpl(e);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "CreateXMLSignatureRequest";
+ }
+
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
new file mode 100644
index 00000000..d2d2e678
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
@@ -0,0 +1,138 @@
+/*
+* 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.bku.slcommands.impl;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+/**
+ * This calls implements the result of the security layer command CreateXMLSignature.
+ *
+ * @author mcentner
+ */
+public class CreateXMLSignatureResultImpl extends SLResultImpl {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(CreateXMLSignatureResultImpl.class);
+
+ /**
+ * The document containing the XMLSignature.
+ */
+ protected Document doc;
+
+ /**
+ * Creates a new instance of this CreateXMLSignatureResultImpl with the given
+ * signature document.
+ *
+ * @param document the signature document
+ *
+ * @throws NullPointerException if document is null
+ */
+ public CreateXMLSignatureResultImpl(Document document) {
+ super();
+
+ if (document == null) {
+ throw new NullPointerException("Argument 'document' must not be null.");
+ }
+
+ this.doc = document;
+
+ marshallCreateXMLSignatureResponse();
+ }
+
+ /**
+ * Marshalls the CreateXMLSignatureResponse.
+ */
+ private void marshallCreateXMLSignatureResponse() {
+
+ ObjectFactory factory = new ObjectFactory();
+
+ CreateXMLSignatureResponseType createCreateXMLSignatureResponseType = factory.createCreateXMLSignatureResponseType();
+ JAXBElement createCreateXMLSignatureResponse = factory.createCreateXMLSignatureResponse(createCreateXMLSignatureResponseType);
+
+ DocumentFragment fragment = doc.createDocumentFragment();
+
+ JAXBContext jaxbContext = SLCommandFactory.getJaxbContext();
+ try {
+ Marshaller marshaller = jaxbContext.createMarshaller();
+ marshaller.marshal(createCreateXMLSignatureResponse, fragment);
+ } catch (JAXBException e) {
+ log.error("Failed to marshall 'CreateXMLSignatureResponse'", e);
+ throw new SLRuntimeException(e);
+ }
+
+ Node child = fragment.getFirstChild();
+ if (child instanceof Element) {
+ Node node = doc.replaceChild(child, doc.getDocumentElement());
+ child.appendChild(node);
+ }
+
+ }
+
+ @Override
+ public void writeTo(Result result) {
+
+ try {
+ writeTo(result, null);
+ } catch (TransformerException e) {
+ log.error(e);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.slcommands.impl.SLResultImpl#writeTo(javax.xml.transform.Result, javax.xml.transform.Transformer)
+ */
+ @Override
+ public void writeTo(Result result, Transformer transformer) throws TransformerException {
+
+ if (transformer == null) {
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ try {
+ transformer = transformerFactory.newTransformer();
+ } catch (TransformerConfigurationException e) {
+ log.error("Failed to create Transformer.", e);
+ throw new SLRuntimeException(e);
+ }
+ }
+ transformer.transform(new DOMSource(doc), result);
+
+ }
+
+}
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
new file mode 100644
index 00000000..555f83bd
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
@@ -0,0 +1,60 @@
+/*
+* 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.bku.slcommands.impl;
+
+import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.gv.egiz.bku.slcommands.ErrorResult;
+import at.gv.egiz.bku.slexceptions.SLException;
+
+import javax.xml.transform.Result;
+
+/**
+ * This class implements the security layer result ErrorResponse.
+ *
+ * @author mcentner
+ */
+public class ErrorResultImpl extends SLResultImpl implements ErrorResult {
+
+ /**
+ * The exception containing information provided in the ErrorResponse.
+ */
+ protected SLException slException;
+
+ /**
+ * Creates a new instance of this ErrorResultImpl with the given
+ * slException containing information provided in the
+ * ErrorResponse.
+ *
+ * @param slException the exception
+ */
+ public ErrorResultImpl(SLException slException) {
+ this.slException = slException;
+ }
+
+ @Override
+ public void writeTo(Result result) {
+
+ ObjectFactory factory = new ObjectFactory();
+ ErrorResponseType responseType = factory.createErrorResponseType();
+ responseType.setErrorCode(slException.getErrorCode());
+ responseType.setInfo(slException.getDetailedMsg());
+
+ writeTo(factory.createErrorResponse(responseType), result);
+
+ }
+}
\ 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
new file mode 100644
index 00000000..93131cf4
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
@@ -0,0 +1,409 @@
+/*
+* 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.bku.slcommands.impl;
+
+import iaik.asn1.CodingException;
+import iaik.asn1.DerCoder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType;
+import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.idlink.CompressedIdentityLinkFactory;
+import at.gv.egiz.idlink.IdentityLinkTransformer;
+import at.gv.egiz.idlink.ans1.IdentityLink;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.InfoboxReadResponse;
+import at.gv.egiz.stal.STALRequest;
+
+/**
+ * This class implements the security layer command
+ * InfoboxReadRequest.
+ *
+ * NOTE: Currently the only supported infobox identifier is '
+ * IdentityLink'.
+ *
+ *
+ * @author mcentner
+ */
+public class InfoboxReadCommandImpl extends SLCommandImpl implements
+ InfoboxReadCommand {
+
+ /**
+ * Logging facility.
+ */
+ protected static Log log = LogFactory.getLog(InfoboxReadCommandImpl.class);
+
+ public static final String INFOBOX_IDENTIFIER_CERTIFICATES = "Certificates";
+
+ public static final String BOX_SPECIFIC_PARAMETER_IDENTITY_LINK_DOMAIN_IDENTIFIER = "IdentityLinkDomainIdentifier";
+
+ public static final String INFOBOX_IDENTIFIER_IDENTITY_LINK = "IdentityLink";
+
+ /**
+ * The InfoboxIdentifier
+ */
+ protected String infoboxIdentifier;
+
+ /**
+ * The IdentityLinkDomainIdentifier value of an IdentyLink infobox.
+ */
+ protected String identityLinkDomainIdentifier;
+
+ /**
+ * Is content XML entity?
+ */
+ protected boolean isXMLEntity;
+
+ @Override
+ public String getName() {
+ return "InfoboxReadRequest";
+ }
+
+ /**
+ * @return the infoboxIdentifier
+ */
+ public String getInfoboxIdentifier() {
+ return infoboxIdentifier;
+ }
+
+ @Override
+ public void init(SLCommandContext ctx, Object request) throws SLCommandException {
+ super.init(ctx, request);
+
+ InfoboxReadRequestType req = getRequestValue();
+
+ infoboxIdentifier = req.getInfoboxIdentifier();
+
+ InfoboxReadParamsBinaryFileType binaryFileParameters = req.getBinaryFileParameters();
+ if (binaryFileParameters != null) {
+ isXMLEntity = binaryFileParameters.isContentIsXMLEntity();
+ log.debug("Got ContentIsXMLEntity=" + isXMLEntity + ".");
+ }
+
+ if (INFOBOX_IDENTIFIER_IDENTITY_LINK.equals(infoboxIdentifier)) {
+
+ if (req.getAssocArrayParameters() != null) {
+ log.info("Got AssocArrayParameters but Infobox type is BinaryFile.");
+ throw new SLCommandException(4010);
+ }
+
+
+ AnyChildrenType boxSpecificParameters = req.getBoxSpecificParameters();
+
+ if (boxSpecificParameters != null) {
+ // check BoxSpecificParameters
+ List
+ *
+ * @author mcentner
+ */
+public class IdValueFactoryImpl implements IdValueFactory {
+
+ /**
+ * A generator for xsd:Id-attribute values.
+ *
+ * @author mcentner
+ */
+ private class IdGenerator {
+
+ /**
+ * The salt.
+ */
+ private String salt;
+
+ /**
+ * The element name.
+ */
+ private String elementName;
+
+ /**
+ * The sequence number.
+ */
+ private int i = 0;
+
+ /**
+ * Creates a new instance of this IdGenerator with the given
+ * elementName and salt value.
+ *
+ * @param elementName the element name
+ * @param salt the salt valeu
+ */
+ private IdGenerator(String elementName, String salt) {
+ super();
+ this.elementName = elementName;
+ this.salt = salt;
+ }
+
+ /**
+ * @return returns the next xsd:Id-attribute value.
+ */
+ public String getNextId() {
+ return elementName + "-" + salt + "-" + Integer.toString(++i);
+ }
+
+ }
+
+ /**
+ * A map of element names to xsd:Id-value generators.
+ */
+ private Map generators = new HashMap();
+
+ /**
+ * The seed value.
+ */
+ private String seed;
+
+ /**
+ * Creates a new instance of this IdValueFactory.
+ */
+ public IdValueFactoryImpl() {
+
+ Random random = new Random();
+ int rand = random.nextInt();
+ seed = Integer.toHexString(rand);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.gv.egiz.bku.slcommands.impl.IdValueFactory#createIdValue(java.lang.String
+ * )
+ */
+ public String createIdValue(String elementName) {
+
+ IdGenerator generator = generators.get(elementName);
+ if (generator == null) {
+ generator = new IdGenerator(elementName, seed);
+ generators.put(elementName, generator);
+ }
+ return generator.getNextId();
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java
new file mode 100644
index 00000000..a6399c9b
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java
@@ -0,0 +1,113 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.crypto.Data;
+import javax.xml.crypto.OctetStreamData;
+import javax.xml.crypto.URIDereferencer;
+import javax.xml.crypto.URIReference;
+import javax.xml.crypto.URIReferenceException;
+import javax.xml.crypto.XMLCryptoContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+
+/**
+ * An URIDereferencer implementation that dereferences LocRef
+ * references.
+ *
+ * @author mcentner
+ */
+public class LocRefDereferencer implements URIDereferencer {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(LocRefDereferencer.class);
+
+ /**
+ * The LocRef-reference to be dereferenced by
+ * {@link #dereference(URIReference, XMLCryptoContext)}.
+ */
+ protected String locRef;
+
+ /**
+ * The context to be used for dereferencing.
+ */
+ protected URLDereferencerContext dereferencerContext;
+
+ /**
+ * Creates a new instance of this LocRefDereferencer with the given
+ * dereferencerContext and locRef reference.
+ *
+ * @param dereferencerContext
+ * the context to be used for dereferencing
+ * @param locRef
+ * the LocRef-reference (must be an absolute URI)
+ *
+ * @throws URISyntaxException
+ * if LocRef is not an absolute URI
+ */
+ public LocRefDereferencer(URLDereferencerContext dereferencerContext,
+ String locRef) throws URISyntaxException {
+
+ this.dereferencerContext = dereferencerContext;
+
+ URI locRefUri = new URI(locRef);
+ if (locRefUri.isAbsolute()) {
+ this.locRef = locRef;
+ } else {
+ throw new IllegalArgumentException(
+ "Parameter 'locRef' must be an absolut URI.");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.xml.crypto.URIDereferencer#dereference(javax.xml.crypto.URIReference,
+ * javax.xml.crypto.XMLCryptoContext)
+ */
+ @Override
+ public Data dereference(URIReference uriReference, XMLCryptoContext context)
+ throws URIReferenceException {
+
+ URLDereferencer dereferencer = URLDereferencer.getInstance();
+ StreamData streamData;
+ try {
+ streamData = dereferencer.dereference(locRef, dereferencerContext);
+ } catch (IOException e) {
+ log.info("Failed to dereference URI'" + locRef + "'. " + e.getMessage(),
+ e);
+ throw new URIReferenceException("Failed to dereference URI '" + locRef
+ + "'. " + e.getMessage(), e);
+ }
+
+ return new OctetStreamData(streamData.getStream(), locRef, streamData
+ .getContentType());
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java
new file mode 100644
index 00000000..64c758c9
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java
@@ -0,0 +1,122 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import java.security.PrivateKey;
+
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.HashDataInputCallback;
+
+/**
+ * This class implements a private key used by the {@link STALSignature} class.
+ *
+ * @author mcentner
+ */
+public class STALPrivateKey implements PrivateKey {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The STAL implementation.
+ */
+ private STAL stal;
+
+ /**
+ * The callback interface for obtaining the hash input data.
+ */
+ private HashDataInputCallback hashDataInputCallback;
+
+ /**
+ * The keybox identifier.
+ */
+ private String keyboxIdentifier;
+
+ /**
+ * The signature algorithm.
+ */
+ private String algorithm;
+
+ /**
+ * Creates a new instance of this STALPrivateKey with the given
+ * stal implementation, signature algorithm,
+ * keyboxIdentifier and hashDataInputCallback
+ * interface.
+ *
+ * @param stal
+ * the STAL implementation
+ * @param algorithm
+ * the signature algorithm
+ * @param keyboxIdentifier
+ * the keybox identifier
+ * @param hashDataInputCallback
+ * the interface for obtaining the has input data
+ */
+ public STALPrivateKey(STAL stal,
+ String algorithm, String keyboxIdentifier, HashDataInputCallback hashDataInputCallback) {
+ super();
+ this.keyboxIdentifier = keyboxIdentifier;
+ this.hashDataInputCallback = hashDataInputCallback;
+ this.stal = stal;
+ this.algorithm = algorithm;
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.Key#getAlgorithm()
+ */
+ @Override
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.Key#getEncoded()
+ */
+ @Override
+ public byte[] getEncoded() {
+ throw new UnsupportedOperationException("STALPrivateKey does not support the getEncoded() method.");
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.Key#getFormat()
+ */
+ @Override
+ public String getFormat() {
+ return null;
+ }
+
+ /**
+ * @return the STAL implementation
+ */
+ public STAL getStal() {
+ return stal;
+ }
+
+ /**
+ * @return the interface for obtaining the hash data input
+ */
+ public HashDataInputCallback getHashDataInputCallback() {
+ return hashDataInputCallback;
+ }
+
+ /**
+ * @return the keybox identifier
+ */
+ public String getKeyboxIdentifier() {
+ return keyboxIdentifier;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALProvider.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALProvider.java
new file mode 100644
index 00000000..0ab30530
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALProvider.java
@@ -0,0 +1,64 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import iaik.xml.crypto.XmldsigMore;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+import java.security.Signature;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.crypto.dsig.SignatureMethod;
+
+/**
+ * A security provider implementation that provides {@link Signature} implementations
+ * based on STAL.
+ *
+ * @author mcentner
+ */
+public class STALProvider extends Provider {
+
+ private static final long serialVersionUID = 1L;
+
+ private static String IMPL_PACKAGE_NAME = "at.gv.egiz.bku.slcommands.impl.xsect";
+
+ public STALProvider() {
+
+ super("STAL", 1.0, "Security Token Abstraction Layer Provider");
+
+ final Map map = new HashMap();
+
+ // TODO: register further algorithms
+ map.put("Signature." + SignatureMethod.RSA_SHA1,
+ IMPL_PACKAGE_NAME + ".STALSignature");
+ map.put("Signature." + XmldsigMore.SIGNATURE_ECDSA_SHA1,
+ IMPL_PACKAGE_NAME + ".STALSignature");
+
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Void run() {
+ putAll(map);
+ return null;
+ }
+ });
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
new file mode 100644
index 00000000..f0fcb891
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
@@ -0,0 +1,165 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import java.io.ByteArrayOutputStream;
+import java.security.InvalidKeyException;
+import java.security.InvalidParameterException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.SignatureSpi;
+import java.util.Collections;
+import java.util.List;
+
+import at.gv.egiz.stal.ErrorResponse;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.SignResponse;
+import at.gv.egiz.stal.HashDataInputCallback;
+
+/**
+ * A signature service provider implementation that uses STAL to sign.
+ *
+ * @author mcentner
+ */
+public class STALSignature extends SignatureSpi {
+
+ /**
+ * The private key.
+ */
+ protected STALPrivateKey privateKey;
+
+ /**
+ * The to-be signed data.
+ */
+ protected ByteArrayOutputStream data = new ByteArrayOutputStream();
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineGetParameter(java.lang.String)
+ */
+ @Override
+ protected Object engineGetParameter(String param)
+ throws InvalidParameterException {
+ throw new InvalidParameterException();
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineInitSign(java.security.PrivateKey)
+ */
+ @Override
+ protected void engineInitSign(PrivateKey privateKey)
+ throws InvalidKeyException {
+
+ if (!(privateKey instanceof STALPrivateKey)) {
+ throw new InvalidKeyException("STALSignature supports STALKeys only.");
+ }
+
+ this.privateKey = (STALPrivateKey) privateKey;
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineInitVerify(java.security.PublicKey)
+ */
+ @Override
+ protected void engineInitVerify(PublicKey publicKey)
+ throws InvalidKeyException {
+
+ throw new UnsupportedOperationException("STALSignature does not support signature verification.");
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineSetParameter(java.lang.String, java.lang.Object)
+ */
+ @Override
+ protected void engineSetParameter(String param, Object value)
+ throws InvalidParameterException {
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineSign()
+ */
+ @Override
+ protected byte[] engineSign() throws SignatureException {
+
+ STAL stal = privateKey.getStal();
+
+ if (stal == null) {
+ throw new SignatureException("STALSignature requires the STALPrivateKey " +
+ "to provide a STAL implementation reference.");
+ }
+
+ HashDataInputCallback signRefDataSupplier = privateKey.getHashDataInputCallback();
+
+ String keyboxIdentifier = privateKey.getKeyboxIdentifier();
+
+ if (keyboxIdentifier == null) {
+ throw new SignatureException("STALSignature requires the STALPrivateKey " +
+ "to provide a KeyboxIdentifier.");
+ }
+
+ SignRequest signRequest = new SignRequest();
+ signRequest.setKeyIdentifier(keyboxIdentifier);
+ signRequest.setSignedInfo(data.toByteArray());
+ signRequest.setHashDataInput(signRefDataSupplier);
+
+ List responses = stal.handleRequest(Collections.singletonList((STALRequest) signRequest));
+
+ if (responses == null || responses.size() != 1) {
+ throw new SignatureException("Failed to access STAL.");
+ }
+
+ STALResponse response = responses.get(0);
+ if (response instanceof SignResponse) {
+ return ((SignResponse) response).getSignatureValue();
+ } else if (response instanceof ErrorResponse) {
+ throw new STALSignatureException(((ErrorResponse) response).getErrorCode());
+ } else {
+ throw new SignatureException("Failed to access STAL.");
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineUpdate(byte)
+ */
+ @Override
+ protected void engineUpdate(byte b) throws SignatureException {
+ data.write(b);
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineUpdate(byte[], int, int)
+ */
+ @Override
+ protected void engineUpdate(byte[] b, int off, int len)
+ throws SignatureException {
+ data.write(b, off, len);
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineVerify(byte[])
+ */
+ @Override
+ protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
+ throw new UnsupportedOperationException("STALSignature des not support signature verification.");
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignatureException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignatureException.java
new file mode 100644
index 00000000..4e86b07c
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignatureException.java
@@ -0,0 +1,92 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import java.security.SignatureException;
+
+/**
+ * A SignatureException thrown by the {@link STALSignature}.
+ *
+ * @author mcentner
+ */
+public class STALSignatureException extends SignatureException {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The STAL error code.
+ */
+ private int errorCode;
+
+ /**
+ * Creates a new instance of this STALSignatureException.
+ */
+ public STALSignatureException() {
+ }
+
+ /**
+ * Creates a new instance of this STALSigantureException with
+ * the given errorCode.
+ *
+ * @param errorCode the error code
+ */
+ public STALSignatureException(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ /**
+ * Creates a new instance of this STALSignatureException with
+ * the given error msg.
+ *
+ * @param msg the error message
+ * @see SignatureException#SignatureException(String)
+ */
+ public STALSignatureException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates a new instance of this STALSignatureException with
+ * the given root cause.
+ *
+ * @param cause the cause
+ * @see SignatureException#SignatureException(Throwable)
+ */
+ public STALSignatureException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Creates a new instance of this STALSignautureException with
+ * the given error message and root cause.
+ *
+ * @param message the error message
+ * @param cause the cause
+ * @see SignatureException#SignatureException(String, Throwable)
+ */
+ public STALSignatureException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @return the error code
+ */
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
new file mode 100644
index 00000000..94a4a066
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
@@ -0,0 +1,935 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dom.DOMStructure;
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.crypto.dsig.Reference;
+import javax.xml.crypto.dsig.SignatureMethod;
+import javax.xml.crypto.dsig.SignedInfo;
+import javax.xml.crypto.dsig.XMLObject;
+import javax.xml.crypto.dsig.XMLSignature;
+import javax.xml.crypto.dsig.XMLSignatureException;
+import javax.xml.crypto.dsig.XMLSignatureFactory;
+import javax.xml.crypto.dsig.dom.DOMSignContext;
+import javax.xml.crypto.dsig.keyinfo.KeyInfo;
+import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
+import javax.xml.crypto.dsig.keyinfo.X509Data;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.etsi.uri._01903.v1_1.DataObjectFormatType;
+import org.etsi.uri._01903.v1_1.QualifyingPropertiesType;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSException;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSParser;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.w3c.dom.ls.LSSerializer;
+
+import at.buergerkarte.namespaces.securitylayer._1.Base64XMLLocRefReqRefContentType;
+import at.buergerkarte.namespaces.securitylayer._1.Base64XMLOptRefContentType;
+import at.buergerkarte.namespaces.securitylayer._1.DataObjectAssociationType;
+import at.buergerkarte.namespaces.securitylayer._1.DataObjectInfoType;
+import at.buergerkarte.namespaces.securitylayer._1.SignatureInfoCreationType;
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.utils.HexDump;
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+import at.gv.egiz.dom.DOMUtils;
+import at.gv.egiz.slbinding.impl.XMLContentType;
+import at.gv.egiz.stal.HashDataInputCallback;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.xades.QualifyingPropertiesException;
+import at.gv.egiz.xades.QualifyingPropertiesFactory;
+
+/**
+ * This class represents an XML-Signature as to be created by the
+ * security layer command CreateXMLSignatureRequest.
+ *
+ * @author mcentner
+ */
+public class Signature implements HashDataInputCallback {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(Signature.class);
+
+ /**
+ * The DOM implementation used.
+ */
+ private DOMImplementationLS domImplLS;
+
+ /**
+ * The SignatureContext for the XMLSignature.
+ */
+ private SignatureContext ctx;
+
+ /**
+ * The list of {@link DataObject}s for this signature.
+ */
+ private List dataObjects = new ArrayList();
+
+ /**
+ * A mapping from the Id-attribute values of this signature's
+ * ds:References to the corresponding {@link DataObject}s.
+ */
+ private Map dataObjectReferencIds = new HashMap();
+
+ /**
+ * The SignatureEnvironment for this signature.
+ */
+ private SignatureLocation signatureLocation;
+
+ /**
+ * The XML signature.
+ */
+ private XMLSignature xmlSignature;
+
+ /**
+ * A list of attributes of type xsd:ID to be registered in the {@link DOMSignContext}.
+ */
+ private List idAttributes = new ArrayList();
+
+ /**
+ * The signer's X509 certificate.
+ */
+ private X509Certificate signerCertificate;
+
+ /**
+ * The signing time.
+ */
+ private Date signingTime;
+
+ /**
+ * Creates a new SLXMLSignature instance.
+ */
+ public Signature(URLDereferencerContext dereferencerContext,
+ IdValueFactory idValueFactory,
+ AlgorithmMethodFactory algorithmMethodFactory) {
+
+ domImplLS = DOMUtils.getDOMImplementationLS();
+
+ ctx = new SignatureContext();
+
+ ctx.setSignatureFactory(XMLSignatureFactory.getInstance());
+
+ ctx.setDereferencerContext(dereferencerContext);
+ ctx.setIdValueFactory(idValueFactory);
+ ctx.setAlgorithmMethodFactory(algorithmMethodFactory);
+
+ }
+
+ /**
+ * @return the Document containing this Signature
+ */
+ public Document getDocument() {
+ return ctx.getDocument();
+ }
+
+ /**
+ * @return the parent Node for this Signature
+ */
+ public Node getParent() {
+ return (signatureLocation != null) ? signatureLocation.getParent() : null;
+ }
+
+ /**
+ * @return the next sibling Node for this Signature
+ */
+ public Node getNextSibling() {
+ return (signatureLocation != null) ? signatureLocation.getNextSibling() : null;
+ }
+
+ /**
+ * @return the XMLSignature
+ */
+ public XMLSignature getXMLSignature() {
+ return xmlSignature;
+ }
+
+ /**
+ * @return the list of {@link Reference}s of this Signature
+ */
+ @SuppressWarnings("unchecked")
+ public List getReferences() {
+ return (xmlSignature != null) ? xmlSignature.getSignedInfo().getReferences() : null;
+ }
+
+ /**
+ * @return the list of {@link XMLObject}s of this Signature
+ */
+ @SuppressWarnings("unchecked")
+ public List getXMLObjects() {
+ return (xmlSignature != null) ? xmlSignature.getObjects() : null;
+ }
+
+ /**
+ * Prepares the signature document with the information given by the
+ * signatureInfo provided.
+ *
+ * @param signatureInfo
+ * the SignatureInfo
+ *
+ * @throws SLCommandException
+ * if processing fails for any reason
+ * @throws IllegalStateException
+ * if the parent node has already been set
+ * @throws NullPointerException
+ * if signatureInfo is null
+ */
+ public void setSignatureInfo(SignatureInfoCreationType signatureInfo) throws SLCommandException {
+
+ if (signatureLocation != null) {
+ throw new IllegalStateException("SignatureEnvironment already set.");
+ }
+
+ Base64XMLOptRefContentType signatureEnvironment = signatureInfo.getSignatureEnvironment();
+
+ if (signatureEnvironment == null) {
+
+ // no SignatureEnvironment, so we use an empty document and the document as parent
+ ensureSignatureLocation();
+
+ } else {
+
+ // parse SignatureEnvrionment and use as document
+ Document document = parseSignatureEnvironment(signatureEnvironment, signatureInfo.getSupplement());
+ ctx.setDocument(document);
+
+ signatureLocation = new SignatureLocation(ctx);
+ signatureLocation.setSignatureInfo(signatureInfo);
+
+ }
+
+ }
+
+ /**
+ * Ensures a SignatureLocation for this Signature.
+ */
+ private void ensureSignatureLocation() {
+
+ if (signatureLocation == null) {
+ Document document = DOMUtils.createDocument();
+ ctx.setDocument(document);
+
+ signatureLocation = new SignatureLocation(ctx);
+ signatureLocation.setParent(document);
+ }
+
+ }
+
+ /**
+ * Adds a DataObject with the information given by the
+ * dataObjectInfo provided to this Signature.
+ *
+ * @param dataObjectInfo
+ * the DataObjectInfo element
+ *
+ * @throws SLCommandException
+ * if adding the DataObject fails
+ * @throws SLRequestException
+ * if the information provided by the given
+ * dataObjectInfo does not conform to the security
+ * layer specification
+ * @throws NullPointerException
+ * if dataObjectInfo is null
+ */
+ public void addDataObject(DataObjectInfoType dataObjectInfo) throws SLCommandException, SLRequestException {
+
+ ensureSignatureLocation();
+
+ DataObject dataObject = new DataObject(ctx);
+ dataObject.setDataObjectInfo(dataObjectInfo);
+
+ dataObjects.add(dataObject);
+
+ dataObjectReferencIds.put(dataObject.getReference().getId(), dataObject);
+
+ }
+
+ /**
+ * Sets the SigningTime qualifying property of this Signature.
+ *
+ * @param signingTime the signing time to set
+ */
+ public void setSigningTime(Date signingTime) {
+ this.signingTime = signingTime;
+ }
+
+ /**
+ * Sets the SignerCertificate qualifying property of this Signature.
+ *
+ * @param certificate the signer's certificate
+ */
+ public void setSignerCeritifcate(X509Certificate certificate) {
+ this.signerCertificate = certificate;
+ }
+
+ /**
+ * Builds the XMLSignature data structure of this Signature as configured by
+ * the various setter methods.
+ *
+ * @throws SLCommandException if building this signature fails
+ */
+ public void buildXMLSignature() throws SLCommandException {
+
+ List objects = new ArrayList();
+ List references = new ArrayList();
+
+ // add all data objects
+ for (DataObject dataObject : dataObjects) {
+ if (dataObject.getXmlObject() != null) {
+ objects.add(dataObject.getXmlObject());
+ }
+ if (dataObject.getReference() != null) {
+ references.add(dataObject.getReference());
+ }
+ }
+
+ addXAdESObjectAndReference(objects, references);
+
+ XMLSignatureFactory signatureFactory = ctx.getSignatureFactory();
+ AlgorithmMethodFactory algorithmMethodFactory = ctx.getAlgorithmMethodFactory();
+
+ CanonicalizationMethod cm;
+ SignatureMethod sm;
+ try {
+ cm = algorithmMethodFactory.createCanonicalizationMethod(ctx);
+ sm = algorithmMethodFactory.createSignatureMethod(ctx);
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Failed to get Canonicalization or Signature algorithm.", e);
+ throw new SLCommandException(4006);
+ } catch (InvalidAlgorithmParameterException e) {
+ log.error("Failed to get Canonicalization or Signature algorithm.", e);
+ throw new SLCommandException(4006);
+ }
+
+ String siId = ctx.getIdValueFactory().createIdValue("SignedInfo");
+
+ SignedInfo si = signatureFactory.newSignedInfo(cm, sm, references, siId);
+
+ KeyInfo ki = null;
+ if (signerCertificate != null) {
+ KeyInfoFactory kif = KeyInfoFactory.getInstance();
+ X509Data x509Data = kif.newX509Data(Collections.singletonList(signerCertificate));
+ ki = kif.newKeyInfo(Collections.singletonList(x509Data));
+ }
+
+ String signatureId = ctx.getIdValueFactory().createIdValue("Signature");
+ String signatureValueId = ctx.getIdValueFactory().createIdValue("SignatureValue");
+
+ xmlSignature = signatureFactory.newXMLSignature(si, ki, objects, signatureId, signatureValueId);
+
+ }
+
+ /**
+ * Sign this Signature using the given signContext.
+ *
+ * Call's {@link #buildXMLSignature()} if it has not been called yet.
+ *
+ *
+ * @param signContext
+ * the signing context
+ *
+ * @throws MarshalException
+ * if marshalling the XMLSignature fails
+ * @throws XMLSignatureException
+ * if signing the XMLSignature fails
+ * @throws SLCommandException
+ * if building the XMLSignature fails
+ * @throws NullPointerException
+ * if signContext is null
+ */
+ public void sign(DOMSignContext signContext) throws MarshalException, XMLSignatureException, SLCommandException {
+
+ if (xmlSignature == null) {
+ buildXMLSignature();
+ }
+
+ for (IdAttribute idAttribute : idAttributes) {
+ signContext.setIdAttributeNS(idAttribute.element, idAttribute.namespaceURI, idAttribute.localName);
+ }
+
+ // DO NOT USE:
+ // signContext.setProperty("iaik.xml.crypto.dsig.sign-over", Boolean.TRUE);
+
+ signContext.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
+
+ signContext.putNamespacePrefix(XMLSignature.XMLNS, "dsig");
+
+ signContext.setURIDereferencer(new URIDereferncerAdapter(ctx.getDereferencerContext()));
+
+ try {
+ xmlSignature.sign(signContext);
+ } catch (XMLSignatureException e) {
+ Throwable cause = e.getCause();
+ while (cause != null) {
+ if (cause instanceof STALSignatureException) {
+ int errorCode = ((STALSignatureException) cause).getErrorCode();
+ SLCommandException commandException = new SLCommandException(errorCode);
+ log.info("Failed to sign signature.", commandException);
+ throw commandException;
+ } else {
+ cause = cause.getCause();
+ }
+ }
+ throw e;
+ }
+
+ // debug
+ if (log.isTraceEnabled()) {
+ for (DataObject dataObject : dataObjects) {
+ Reference reference = dataObject.getReference();
+ InputStream digestInputStream = reference.getDigestInputStream();
+ if (digestInputStream != null) {
+ String mimeType = dataObject.getMimeType();
+ StringBuilder sb = new StringBuilder();
+ sb.append("DigestInput for Reference with id='");
+ sb.append(reference.getId());
+ sb.append("' (MIME-Type=");
+ sb.append(dataObject.getMimeType());
+ sb.append("):\n");
+ try {
+ if (mimeType != null && (
+ mimeType.startsWith("text") ||
+ "application/xhtml+xml".equals(mimeType))) {
+ byte[] b = new byte[512];
+ for (int l; (l = digestInputStream.read(b)) != -1;) {
+ sb.append(new String(b, 0, l));
+ }
+ } else {
+ sb.append(HexDump.hexDump(digestInputStream));
+ }
+ } catch (IOException e) {
+ log.error(e);
+ }
+ log.trace(sb.toString());
+ } else {
+ log.trace("Reference caching is not enabled.");
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Sign this Signature using the given stal implementation and
+ * keyboxIdentifier.
+ *
+ * This method configures an appropriate {@link DOMSignContext} and calls
+ * {@link #sign(DOMSignContext)}. If {@link #buildXMLSignature()} has not been
+ * called yet, it is called by this method.
+ *
+ *
+ * @param stal
+ * the STAL implementation to use
+ * @param keyboxIdentifier
+ * the KeyboxIdentifier to use
+ *
+ * @throws MarshalException
+ * if marshalling this Signature fails
+ * @throws XMLSignatureException
+ * if signing this Signature fails
+ * @throws SLCommandException
+ * if building this Signature fails
+ * @throws NullPointerException
+ * if stal or keyboxIdentifier is
+ * null
+ */
+ public void sign(STAL stal, String keyboxIdentifier) throws MarshalException, XMLSignatureException, SLCommandException {
+
+ if (stal == null) {
+ throw new NullPointerException("Argument 'stal' must not be null.");
+ }
+
+ if (keyboxIdentifier == null) {
+ throw new NullPointerException("Argument 'keyboxIdentifier' must not be null.");
+ }
+
+ if (xmlSignature == null) {
+ buildXMLSignature();
+ }
+
+ SignatureMethod signatureMethod = xmlSignature.getSignedInfo().getSignatureMethod();
+ String algorithm = signatureMethod.getAlgorithm();
+
+ PrivateKey privateKey = new STALPrivateKey(stal, algorithm, keyboxIdentifier, this);
+
+ DOMSignContext signContext;
+ if (getNextSibling() == null) {
+ signContext = new DOMSignContext(privateKey, getParent());
+ } else {
+ signContext = new DOMSignContext(privateKey, getParent(), getNextSibling());
+ }
+
+ sign(signContext);
+ }
+
+ @Override
+ public InputStream getHashDataInput(String referenceId) {
+
+ DataObject dataObject = dataObjectReferencIds.get(referenceId);
+ if (dataObject != null) {
+ return dataObject.getReference().getDigestInputStream();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Adds the XAdES QualifyingProperties as an
+ * ds:Object and a corresponding ds:Reference to
+ * it's SignedProperties element to this Signature.
+ *
+ * @param objects
+ * the list of ds:Objects to add the created
+ * ds:Object to
+ * @param references
+ * the list of ds:References to add the created
+ * ds:Reference to
+ *
+ * @throws SLCommandException
+ * if creating and adding the XAdES
+ * QualifyingProperties fails
+ * @throws NullPointerException
+ * if objects or references is
+ * null
+ */
+ private void addXAdESObjectAndReference(List objects, List references) throws SLCommandException {
+
+ QualifyingPropertiesFactory factory = QualifyingPropertiesFactory.getInstance();
+
+ String idValue = ctx.getIdValueFactory().createIdValue("SignedProperties");
+
+ Date date = (signingTime != null) ? signingTime : new Date();
+
+ List signingCertificates;
+ if (signerCertificate != null) {
+ signingCertificates = Collections.singletonList(signerCertificate);
+ } else {
+ signingCertificates = Collections.emptyList();
+ }
+
+ // TODO: report MOA-SP bug
+ //
+ // The security layer specification mandates the use of version 1.2.2. of the
+ // XAdES QualifyingProperties. However MOA-SP supports only version 1.1.1. Therefore,
+ // the version 1.1.1 is used in order to be compatible with current MOA-SP versions.
+
+ List dataObjectFormats = new ArrayList();
+ for (DataObject dataObject : dataObjects) {
+ if (dataObject.getMimeType() != null && dataObject.getReference() != null) {
+ Reference reference = dataObject.getReference();
+ if (reference.getId() != null) {
+ String objectReference = "#" + reference.getId();
+ dataObjectFormats.add(factory.createDataObjectFormatType(
+ objectReference, dataObject.getMimeType(), dataObject
+ .getDescription()));
+ }
+ }
+ }
+
+ JAXBElement qualifyingProperties;
+ try {
+ qualifyingProperties = factory.createQualifyingProperties111(date, signingCertificates, idValue, dataObjectFormats);
+ } catch (QualifyingPropertiesException e) {
+ log.error("Failed to create QualifyingProperties.", e);
+ throw new SLCommandException(4000);
+ }
+
+ DocumentFragment fragment = ctx.getDocument().createDocumentFragment();
+
+ try {
+ factory.marshallQualifyingProperties(qualifyingProperties, fragment);
+ } catch (JAXBException e) {
+ log.error("Failed to marshal QualifyingProperties.", e);
+ throw new SLCommandException(4000);
+ }
+
+ List content = Collections.singletonList(new DOMStructure(fragment.getFirstChild()));
+
+ String objectIdValue = ctx.getIdValueFactory().createIdValue("Object");
+
+ XMLObject object = ctx.getSignatureFactory().newXMLObject(content, objectIdValue, null, null);
+
+ objects.add(object);
+
+ // TODO: Report MOA-SP Bug
+ //
+ // Direct referencing of the SignedPorperties Id-attribute is not supported by MOA-SP
+ // because the QualifyingProperties are parsed without the XAdES schema. Therefore,
+ // the shorthand XPointer could not be resolved.
+ //
+ // The following workaround uses an XPointer to select the SignedProperties in order
+ // to allow the signature to be verified with MOA-SP.
+
+ String referenceURI = "#xmlns(xades=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('"
+ + objectIdValue
+ + "')/child::xades:QualifyingProperties/child::xades:SignedProperties)";
+ DigestMethod dm;
+ try {
+ dm = ctx.getAlgorithmMethodFactory().createDigestMethod(ctx);
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Failed to get DigestMethod algorithm.", e);
+ throw new SLCommandException(4006);
+ } catch (InvalidAlgorithmParameterException e) {
+ log.error("Failed to get DigestMethod algorithm.", e);
+ throw new SLCommandException(4006);
+ }
+
+ String referenceIdValue = ctx.getIdValueFactory().createIdValue("Reference");
+ String referenceType = QualifyingPropertiesFactory.SIGNED_PROPERTIES_REFERENCE_TYPE_V1_1_1;
+
+ Reference reference = ctx.getSignatureFactory().newReference(referenceURI, dm, null, referenceType, referenceIdValue);
+
+ references.add(reference);
+
+ Node child = fragment.getFirstChild();
+ if (child instanceof Element) {
+ NodeList nodes = ((Element) child).getElementsByTagNameNS(QualifyingPropertiesFactory.NS_URI_V1_1_1, "SignedProperties");
+ if (nodes.getLength() > 0) {
+ IdAttribute idAttribute = new IdAttribute();
+ idAttribute.element = (Element) nodes.item(0);
+ idAttribute.namespaceURI = null;
+ idAttribute.localName = "Id";
+ idAttributes.add(idAttribute);
+ }
+ }
+
+ }
+
+ /**
+ * Parse the SignatureEnvironment.
+ *
+ * @param signatureEnvironment
+ * the SignatureEnvironment element
+ * @param supplements
+ * an optional list of Supplements (may be
+ * null)
+ *
+ * @return the parsed SignatureEnvironment document
+ *
+ * @throws SLCommandException
+ * if parsing the SignatureEnvironment fails
+ * @throws NullPointerException
+ * if signatureEnvironment is null
+ */
+ private Document parseSignatureEnvironment(
+ Base64XMLOptRefContentType signatureEnvironment,
+ List supplements) throws SLCommandException {
+
+ if (signatureEnvironment == null) {
+ throw new NullPointerException("Argument 'signatureEnvironment' must not be null.");
+ }
+
+ LSInput input;
+ try {
+ if (signatureEnvironment.getReference() != null) {
+ log.debug("SignatureEnvironment contains Reference " + signatureEnvironment.getReference() + ".");
+ input = createLSInput(signatureEnvironment.getReference());
+ } else if (signatureEnvironment.getBase64Content() != null) {
+ log.debug("SignatureEnvironment contains Base64Content.");
+ input = createLSInput(signatureEnvironment.getBase64Content());
+ } else if (signatureEnvironment.getXMLContent() != null) {
+ log.debug("SignatureEnvironment contains XMLContent.");
+ input = createLSInput((XMLContentType) signatureEnvironment.getXMLContent());
+ } else {
+ // the schema does not allow us to reach this point
+ throw new SLCommandException(4000);
+ }
+ } catch (IOException e) {
+ log.info("XML document in which the signature is to be integrated cannot be resolved.", e);
+ throw new SLCommandException(4100);
+ } catch (XMLStreamException e) {
+ log.info("XML document in which the signature is to be integrated cannot be resolved.", e);
+ throw new SLCommandException(4100);
+ }
+
+ LSParser parser = domImplLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
+ DOMConfiguration domConfig = parser.getDomConfig();
+ SimpleDOMErrorHandler errorHandler = new SimpleDOMErrorHandler();
+ domConfig.setParameter("error-handler", errorHandler);
+ LSResourceResolverAdapter resourceResolver = new LSResourceResolverAdapter(supplements);
+ domConfig.setParameter("resource-resolver", resourceResolver);
+ domConfig.setParameter("validate", Boolean.TRUE);
+
+ Document doc;
+ try {
+ doc = parser.parse(input);
+ } catch (DOMException e) {
+ log.info("XML document in which the signature is to be integrated cannot be parsed.", e);
+ throw new SLCommandException(4101);
+ } catch (LSException e) {
+ log.info("XML document in which the signature is to be integrated cannot be parsed.", e);
+ throw new SLCommandException(4101);
+ }
+
+ if (resourceResolver.getError() != null) {
+ log.info("Failed to resolve resource while parsing SignatureEnvironment document.", resourceResolver.getError());
+ // we don't stop here, as we only _try_ to parse validating
+ }
+
+ if (errorHandler.hasFatalErrors()) {
+ // log fatal errors
+ if (log.isInfoEnabled()) {
+ List errorMessages = errorHandler.getErrorMessages();
+ StringBuffer sb = new StringBuffer();
+ for (String errorMessage : errorMessages) {
+ sb.append(" ");
+ sb.append(errorMessage);
+ }
+ log.info("XML document in which the signature is to be integrated cannot be parsed." + sb.toString());
+ }
+ throw new SLCommandException(4101);
+ }
+
+ // log parsed document
+ if (log.isTraceEnabled()) {
+
+ StringWriter writer = new StringWriter();
+
+ writer.write("SignatureEnvironment:\n");
+
+ LSOutput output = domImplLS.createLSOutput();
+ output.setCharacterStream(writer);
+ output.setEncoding("UTF-8");
+ LSSerializer serializer = domImplLS.createLSSerializer();
+ serializer.write(doc, output);
+
+ log.trace(writer.toString());
+ }
+
+ return doc;
+
+ }
+
+ /**
+ * Creates an LSInput from the given reference URI.
+ *
+ * @param reference
+ * the reference URL
+ *
+ * @return an LSInput from the given reference URI
+ *
+ * @throws IOException
+ * if dereferencing the given reference fails
+ */
+ private LSInput createLSInput(String reference) throws IOException {
+
+ URLDereferencer urlDereferencer = URLDereferencer.getInstance();
+ StreamData streamData = urlDereferencer.dereference(reference, ctx.getDereferencerContext());
+
+ String contentType = streamData.getContentType();
+ String charset = HttpUtil.getCharset(contentType, true);
+ InputStreamReader streamReader;
+ try {
+ streamReader = new InputStreamReader(streamData.getStream(), charset);
+ } catch (UnsupportedEncodingException e) {
+ log.info("Charset " + charset + " not supported. Using default.");
+ streamReader = new InputStreamReader(streamData.getStream());
+ }
+
+ LSInput input = domImplLS.createLSInput();
+ input = domImplLS.createLSInput();
+ input.setCharacterStream(streamReader);
+
+ return input;
+
+ }
+
+ /**
+ * Creates an LSInput from the given content bytes.
+ *
+ * @param content
+ * the content bytes
+ *
+ * @return an LSInput from the givne content bytes
+ */
+ private LSInput createLSInput(byte[] content) {
+
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
+ LSInput input = domImplLS.createLSInput();
+ input.setByteStream(inputStream);
+
+ return input;
+
+ }
+
+ /**
+ * Creates an LSInput from the given XML content.
+ *
+ * @param content
+ * the XML content
+ * @return an LSInput from the given XML content
+ *
+ * @throws XMLStreamException
+ * if reading the XMLStream from the given XML content fails
+ */
+ private LSInput createLSInput(XMLContentType content) throws XMLStreamException {
+
+ ByteArrayOutputStream redirectedStream = content.getRedirectedStream();
+ if (redirectedStream != null) {
+ LSInput input = domImplLS.createLSInput();
+ input.setByteStream(new ByteArrayInputStream(redirectedStream.toByteArray()));
+ return input;
+ } else {
+ return null;
+ }
+
+ }
+
+ /**
+ * Represents an xsd:Id-attribute value.
+ *
+ * @author mcentner
+ */
+ private class IdAttribute {
+
+ private Element element;
+
+ private String namespaceURI;
+
+ private String localName;
+
+ }
+
+ /**
+ * An implementation of the LSResourceResolver that uses a list of supplements
+ * to resolve resources.
+ *
+ * @author mcentner
+ */
+ private class LSResourceResolverAdapter implements LSResourceResolver {
+
+ List supplements;
+
+ private LSResourceResolverAdapter(
+ List supplements) {
+ this.supplements = supplements;
+ }
+
+ private Exception error;
+
+ /**
+ * @return the error
+ */
+ public Exception getError() {
+ return error;
+ }
+
+ @Override
+ public LSInput resolveResource(String type, String namespaceURI,
+ String publicId, String systemId, String baseURI) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("Resolve resource :" +
+ "\n type=" + type +
+ "\n namespaceURI=" + namespaceURI +
+ "\n publicId=" + publicId +
+ "\n systemId=" + systemId +
+ "\n baseURI=" + baseURI);
+ }
+
+ if (systemId != null) {
+
+ log.debug("Resolve resource '" + systemId + "'.");
+
+ for (DataObjectAssociationType supplement : supplements) {
+
+ Base64XMLLocRefReqRefContentType content = supplement.getContent();
+ if (content != null) {
+
+ String reference = content.getReference();
+ if (systemId.equals(reference)) {
+
+ try {
+ if (content.getLocRefContent() != null) {
+ log.trace("Resolved resource '" + reference + "' to supplement with LocRefContent.");
+ return createLSInput(content.getLocRefContent());
+ } else if (content.getBase64Content() != null) {
+ log.trace("Resolved resource '" + reference + "' to supplement with Base64Content.");
+ return createLSInput(content.getBase64Content());
+ } else if (content.getXMLContent() != null) {
+ log.trace("Resolved resource '" + reference + "' to supplement with XMLContent.");
+ return createLSInput((XMLContentType) content.getXMLContent());
+ } else {
+ return null;
+ }
+ } catch (IOException e) {
+ log.info("Failed to resolve resource '" + systemId + "' to supplement.", e);
+ error = e;
+ return null;
+ } catch (XMLStreamException e) {
+ log.info("Failed to resolve resource '" + systemId + "' to supplement.", e);
+ error = e;
+ return null;
+ }
+
+ }
+
+ }
+
+ }
+
+ log.info("Failed to resolve resource '" + systemId + "' to supplement. No such supplement.");
+
+ }
+
+ return null;
+
+ }
+
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureContext.java
new file mode 100644
index 00000000..0925f2fd
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureContext.java
@@ -0,0 +1,129 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.crypto.dsig.XMLSignatureFactory;
+
+import org.w3c.dom.Document;
+
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+
+/**
+ * An instance of this class carries context information for a XML-Signature
+ * created by the security layer command CreateXMLSignature.
+ *
+ * @author mcentner
+ */
+public class SignatureContext {
+
+ /**
+ * The document going to contain the XML signature.
+ */
+ private Document document;
+
+ /**
+ * The IdValueFactory used to create xsd:ID-attribute values.
+ */
+ private IdValueFactory idValueFactory;
+
+ /**
+ * The XMLSignatureFactory to create XML signature objects.
+ */
+ private XMLSignatureFactory signatureFactory;
+
+ /**
+ * The URLDereferencerContext for dereferencing URLs.
+ */
+ private URLDereferencerContext dereferencerContext;
+
+ /**
+ * The DigestMethodFactory to create {@link DigestMethod} objects.
+ */
+ private AlgorithmMethodFactory digestMethodFactory;
+
+ /**
+ * @return the document
+ */
+ public Document getDocument() {
+ return document;
+ }
+
+ /**
+ * @param document the document to set
+ */
+ public void setDocument(Document document) {
+ this.document = document;
+ }
+
+ /**
+ * @return the idValueFactory
+ */
+ public IdValueFactory getIdValueFactory() {
+ return idValueFactory;
+ }
+
+ /**
+ * @param idValueFactory the idValueFactory to set
+ */
+ public void setIdValueFactory(IdValueFactory idValueFactory) {
+ this.idValueFactory = idValueFactory;
+ }
+
+ /**
+ * @return the signatureFactory
+ */
+ public XMLSignatureFactory getSignatureFactory() {
+ return signatureFactory;
+ }
+
+ /**
+ * @param signatureFactory the signatureFactory to set
+ */
+ public void setSignatureFactory(XMLSignatureFactory signatureFactory) {
+ this.signatureFactory = signatureFactory;
+ }
+
+ /**
+ * @return the dereferencerContext
+ */
+ public URLDereferencerContext getDereferencerContext() {
+ return dereferencerContext;
+ }
+
+ /**
+ * @param dereferencerContext the dereferencerContext to set
+ */
+ public void setDereferencerContext(URLDereferencerContext dereferencerContext) {
+ this.dereferencerContext = dereferencerContext;
+ }
+
+ /**
+ * @return the digestMethodFactory
+ */
+ public AlgorithmMethodFactory getAlgorithmMethodFactory() {
+ return digestMethodFactory;
+ }
+
+ /**
+ * @param digestMethodFactory the digestMethodFactory to set
+ */
+ public void setAlgorithmMethodFactory(AlgorithmMethodFactory digestMethodFactory) {
+ this.digestMethodFactory = digestMethodFactory;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureLocation.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureLocation.java
new file mode 100644
index 00000000..5ec02893
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureLocation.java
@@ -0,0 +1,235 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import java.util.Iterator;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import at.buergerkarte.namespaces.securitylayer._1.SignatureInfoCreationType;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.slbinding.impl.SignatureLocationType;
+
+/**
+ * This class implements the SignatureLocation of an XML-Signature
+ * to be created by the security layer command CreateXMLSignature.
+ *
+ * @author mcentner
+ */
+public class SignatureLocation {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(SignatureLocation.class);
+
+ /**
+ * The SignatureContext for the XML signature
+ */
+ private SignatureContext ctx;
+
+ /**
+ * The parent node for the XML signature.
+ */
+ private Node parent;
+
+ /**
+ * The next sibling node for the XML signature.
+ */
+ private Node nextSibling;
+
+ /**
+ * Creates a new SignatureLocation with the given signatureContext
+ *
+ * @param signatureContext the context for the XML signature creation
+ */
+ public SignatureLocation(SignatureContext signatureContext) {
+ this.ctx = signatureContext;
+ }
+
+ /**
+ * @return the parent node for the XML signature
+ */
+ public Node getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent the parent for the XML signature
+ */
+ public void setParent(Node parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * @return the next sibling node for the XML signature
+ */
+ public Node getNextSibling() {
+ return nextSibling;
+ }
+
+ /**
+ * @param nextSibling the next sibling node for the XML signature
+ */
+ public void setNextSibling(Node nextSibling) {
+ this.nextSibling = nextSibling;
+ }
+
+ /**
+ * Configures this SignatureLocation with the information provided by the
+ * given SignatureInfo element.
+ *
+ * @param signatureInfo
+ * the SignatureInfo element
+ *
+ * @throws SLCommandException
+ * if configuring this SignatureLocation with given
+ * signatureInfofails
+ */
+ public void setSignatureInfo(SignatureInfoCreationType signatureInfo)
+ throws SLCommandException {
+
+ // evaluate signature location XPath ...
+ SignatureLocationType signatureLocation = (SignatureLocationType) signatureInfo
+ .getSignatureLocation();
+
+ NamespaceContext namespaceContext = new MOAIDWorkaroundNamespaceContext(
+ signatureLocation.getNamespaceContext());
+
+ parent = evaluateSignatureLocation(signatureInfo.getSignatureLocation()
+ .getValue(), namespaceContext, ctx.getDocument().getDocumentElement());
+
+ // ... and index
+ nextSibling = findNextSibling(parent, signatureInfo.getSignatureLocation()
+ .getIndex().intValue());
+
+ }
+
+ /**
+ * Evaluates the given xpath with the document element as context node
+ * and returns the resulting node.
+ *
+ * @param xpath the XPath expression
+ * @param nsContext the namespace context of the XPath expression
+ * @param contextNode the context node for the XPath evaluation
+ *
+ * @return the result of evaluating the XPath expression
+ *
+ * @throws SLCommandException
+ */
+ private Node evaluateSignatureLocation(String xpath, NamespaceContext nsContext, Node contextNode) throws SLCommandException {
+
+ Node node = null;
+ try {
+ XPathFactory xpathFactory = XPathFactory.newInstance();
+ XPath xPath = xpathFactory.newXPath();
+ xPath.setNamespaceContext(nsContext);
+ XPathExpression xpathExpr = xPath.compile(xpath);
+ node = (Node) xpathExpr.evaluate(contextNode, XPathConstants.NODE);
+ } catch (XPathExpressionException e) {
+ log.info("Failed to evaluate SignatureLocation XPath expression '" + xpath + "' on context node.", e);
+ throw new SLCommandException(4102);
+ }
+
+ if (node == null) {
+ log.info("Failed to evaluate SignatureLocation XPath expression '" + xpath + "'. Result is empty.");
+ throw new SLCommandException(4102);
+ }
+
+ return node;
+
+ }
+
+ /**
+ * Finds the next sibling node of the parent's n-th child node
+ * or null if there is no next sibling.
+ *
+ * @param parent the parent node
+ * @param n the index of the child node
+ *
+ * @return the next sibling node of the node specified by parent and index n,
+ * or null if there is no next sibling node.
+ *
+ * @throws SLCommandException if the n-th child of parent does not exist
+ */
+ private Node findNextSibling(Node parent, int n) throws SLCommandException {
+
+ NodeList childNodes = parent.getChildNodes();
+ Node childNode = childNodes.item(n);
+ if (childNode == null) {
+ log.info("SingatureLocation Index '" + n + "' not found in document.");
+ throw new SLCommandException(4102);
+ } else {
+ return childNode.getNextSibling();
+ }
+
+ }
+
+ /**
+ * Workaround for a missing namespace prefix declaration in MOA-ID.
+ *
+ * @author mcentner
+ */
+ private class MOAIDWorkaroundNamespaceContext implements NamespaceContext {
+
+ private NamespaceContext namespaceContext;
+
+ public MOAIDWorkaroundNamespaceContext(NamespaceContext namespaceContext) {
+ super();
+ this.namespaceContext = namespaceContext;
+ }
+
+ @Override
+ public String getNamespaceURI(String prefix) {
+
+ String namespaceURI = namespaceContext.getNamespaceURI(prefix);
+
+ if ((namespaceURI == null || XMLConstants.NULL_NS_URI.equals(namespaceURI)) && "saml".equals(prefix)) {
+ namespaceURI = "urn:oasis:names:tc:SAML:1.0:assertion";
+ log.debug("Namespace prefix '" + prefix + "' resolved to '" + namespaceURI + "' (MOA-ID Workaround).");
+ } else {
+ log.trace("Namespace prefix '" + prefix + "' resolved to '" + namespaceURI + "'.");
+ }
+
+ return namespaceURI;
+ }
+
+ @Override
+ public String getPrefix(String namespaceURI) {
+ return namespaceContext.getPrefix(namespaceURI);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterator getPrefixes(String namespaceURI) {
+ return namespaceContext.getPrefixes(namespaceURI);
+ }
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SimpleDOMErrorHandler.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SimpleDOMErrorHandler.java
new file mode 100644
index 00000000..0d54adce
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/SimpleDOMErrorHandler.java
@@ -0,0 +1,98 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.w3c.dom.DOMError;
+import org.w3c.dom.DOMErrorHandler;
+
+/**
+ * A simple DOMErrorHandler implementation.
+ *
+ * @author mcentner
+ */
+public class SimpleDOMErrorHandler implements DOMErrorHandler {
+
+ /**
+ * Have there been errors reported?
+ */
+ private boolean errors = false;
+
+ /**
+ * Have there been fatal error reported?
+ */
+ private boolean fatalErrors = false;
+
+ /**
+ * The list of error messages of reported errors.
+ */
+ private List errorMessages = new ArrayList();
+
+ /**
+ * @return true if errors have been reported, or false otherwise
+ */
+ public boolean hasErrors() {
+ return errors;
+ }
+
+ /**
+ * @return true if fatal errors have been reported, or false otherwise
+ */
+ public boolean hasFatalErrors() {
+ return fatalErrors;
+ }
+
+ /**
+ * @return a list of error messages that have been reported
+ */
+ public List getErrorMessages() {
+ return errorMessages;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.DOMErrorHandler#handleError(org.w3c.dom.DOMError)
+ */
+ @Override
+ public boolean handleError(DOMError error) {
+
+ switch (error.getSeverity()) {
+
+ case DOMError.SEVERITY_WARNING :
+// log.debug("[warning] " + error.getMessage());
+ return true;
+
+ case DOMError.SEVERITY_ERROR :
+// log.debug("[error] " + error.getMessage());
+ errorMessages.add(error.getMessage());
+ errors = true;
+ return false;
+
+ case DOMError.SEVERITY_FATAL_ERROR :
+// log.debug("[fatal error] " + error.getMessage());
+ errorMessages.add(error.getMessage());
+ fatalErrors = true;
+ return false;
+
+ default:
+ return false;
+ }
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/URIDereferncerAdapter.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/URIDereferncerAdapter.java
new file mode 100644
index 00000000..c94937be
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/URIDereferncerAdapter.java
@@ -0,0 +1,103 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import iaik.xml.crypto.utils.URIDereferencerImpl;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.crypto.Data;
+import javax.xml.crypto.OctetStreamData;
+import javax.xml.crypto.URIDereferencer;
+import javax.xml.crypto.URIReference;
+import javax.xml.crypto.URIReferenceException;
+import javax.xml.crypto.XMLCryptoContext;
+
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+
+/**
+ * An URIDereferencer implementation that uses an {@link URLDereferencer} to
+ * dereference.
+ *
+ * @author mcentner
+ */
+public class URIDereferncerAdapter implements URIDereferencer {
+
+ /**
+ * The context for dereferencing.
+ */
+ protected URLDereferencerContext urlDereferencerContext;
+
+ /**
+ * Creates a new URIDereferencerAdapter instance with the given
+ * urlDereferencerContext.
+ *
+ * @param urlDereferencerContext the context to be used for dereferencing
+ */
+ public URIDereferncerAdapter(URLDereferencerContext urlDereferencerContext) {
+ super();
+ this.urlDereferencerContext = urlDereferencerContext;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.crypto.URIDereferencer#dereference(javax.xml.crypto.URIReference, javax.xml.crypto.XMLCryptoContext)
+ */
+ @Override
+ public Data dereference(URIReference uriReference, XMLCryptoContext context)
+ throws URIReferenceException {
+
+ String uriString = uriReference.getURI();
+ if (uriString == null) {
+ return null;
+ }
+
+ URI uri;
+ try {
+ uri = new URI(uriString);
+ } catch (URISyntaxException e) {
+ throw new URIReferenceException(e.getMessage(), e);
+ }
+
+ if (uri.isAbsolute()) {
+
+ URLDereferencer dereferencer = URLDereferencer.getInstance();
+ StreamData streamData;
+ try {
+ streamData = dereferencer.dereference(uriString, urlDereferencerContext);
+ } catch (IOException e) {
+ throw new URIReferenceException(e.getMessage(), e);
+ }
+ return new OctetStreamData(streamData.getStream(), uriString, streamData.getContentType());
+
+ } else {
+
+ URIDereferencer uriDereferencer = context.getURIDereferencer();
+ if (uriDereferencer == null || uriDereferencer == this) {
+ uriDereferencer = new URIDereferencerImpl();
+ }
+
+ return uriDereferencer.dereference(uriReference, context);
+
+ }
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTReference.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTReference.java
new file mode 100644
index 00000000..6b388f2a
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTReference.java
@@ -0,0 +1,112 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import iaik.xml.crypto.dsig.DigestMethodImpl;
+import iaik.xml.crypto.dsig.DigestValueImpl;
+import iaik.xml.crypto.dsig.ReferenceImpl;
+import iaik.xml.crypto.dsig.TransformImpl;
+import iaik.xml.crypto.dsig.TransformsImpl;
+
+import javax.xml.crypto.Data;
+import javax.xml.crypto.URIDereferencer;
+import javax.xml.crypto.URIReferenceException;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.crypto.dsig.TransformException;
+
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+
+/**
+ * This class extends the XSECT ReferenceImpl to allow for the use
+ * of already marshalled ds:Transforms elements for initialization.
+ *
+ * @author mcentner
+ */
+public class XSECTReference extends ReferenceImpl {
+
+ /**
+ * The URIDereferencer to be used for dereferencing.
+ */
+ protected URIDereferencer dereferencer;
+
+ /**
+ * Creates a new instance of this XSECTReference with the given
+ * uri, digest method, transforms, type
+ * and id value.
+ *
+ * @param uri
+ * the URI-attribute value (may be null)
+ * @param dm
+ * the digest method
+ * @param transforms
+ * a TransformsImpl element (may be null)
+ * @param type
+ * the Type-attribute value (may be null)
+ * @param id
+ * the Id-attribute value (may be null)
+ *
+ * @throws NullPointerException
+ * if digestMethod is null
+ * @throws IllegalArgumentException
+ * if uri is not RFC 2396 compliant
+ * @throws ClassCastException
+ * if any of the transforms is not of type
+ * {@link TransformImpl}
+ */
+ public XSECTReference(String uri, DigestMethod dm, TransformsImpl transforms, String type,
+ String id) {
+ super(uri, transforms, type, id);
+ digestMethod_ = (DigestMethodImpl) dm;
+ digestValue_ = new DigestValueImpl();
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.xml.crypto.dsig.ReferenceType#dereference(javax.xml.crypto.XMLCryptoContext)
+ */
+ @Override
+ public Data dereference(XMLCryptoContext context) throws TransformException,
+ URIReferenceException {
+ if (dereferencer != null) {
+ return dereferencer.dereference(this, context);
+ } else {
+ try {
+ return super.dereference(context);
+ } catch (URIReferenceException e) {
+ SLCommandException commandException = new SLCommandException(4003,
+ SLExceptionMessages.EC4003_NOT_RESOLVED, new Object[] { getURI() });
+ throw new URIReferenceException("Failed to dereference data to-be signed.", commandException);
+ }
+ }
+ }
+
+ /**
+ * @return the dereferencer to be used for dereferencing this reference
+ */
+ public URIDereferencer getDereferencer() {
+ return dereferencer;
+ }
+
+ /**
+ * @param dereferencer the dereferencer to be used for dereferencing this reference
+ */
+ public void setDereferencer(URIDereferencer dereferencer) {
+ this.dereferencer = dereferencer;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTTransforms.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTTransforms.java
new file mode 100644
index 00000000..a98e4236
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/XSECTTransforms.java
@@ -0,0 +1,124 @@
+/*
+* 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.bku.slcommands.impl.xsect;
+
+import iaik.xml.crypto.dsig.TransformImpl;
+import iaik.xml.crypto.dsig.TransformsImpl;
+
+import java.util.List;
+
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dsig.Transform;
+
+import org.w3c.dom.Node;
+
+/**
+ * This class extends the XSECT TransformsImpl to allow for the use of an
+ * unmarshalled ds:Transforms element for initalization.
+ *
+ * @author mcentner
+ */
+public class XSECTTransforms extends TransformsImpl {
+
+ /**
+ * Creates a new XSECTTransforms with the given list of transforms.
+ *
+ * @param transforms a list of {@link TransformImpl}s
+ * @see TransformsImpl#TransformsImpl(List)
+ */
+ @SuppressWarnings("unchecked")
+ public XSECTTransforms(List transforms) {
+ super(transforms);
+ }
+
+ /**
+ * Creates a new XSECTTransforms and initializes it from the given
+ * ds:Transforms node.
+ *
+ * @param context the context used for unmarshalling
+ * @param node the ds:Transforms node
+ *
+ * @throws MarshalException if unmarshalling the ds:Transforms fails
+ */
+ public XSECTTransforms(DOMCryptoContext context, Node node)
+ throws MarshalException {
+ super(context, node);
+ }
+
+ /**
+ * Inserts the given transform at the top of the
+ * transform list.
+ *
+ * @param transform the ds:Transform to instert
+ */
+ @SuppressWarnings("unchecked")
+ public void insertTransform(Transform transform) {
+ if (transform == null) {
+ throw new NullPointerException("Parameter 'transform' must not be null.");
+ }
+ if (!(transform instanceof TransformImpl)) {
+ throw new ClassCastException("Transform 'transform' must be of type '" + TransformImpl.class.getName() + "'.");
+ }
+ transforms_.add(0, transform);
+ }
+
+ /**
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private List getTransformImpls() {
+ return transforms_;
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.xml.crypto.dsig.TransformsType#marshal(javax.xml.crypto.dom.DOMCryptoContext, org.w3c.dom.Node, org.w3c.dom.Node)
+ */
+ @Override
+ public Node marshal(DOMCryptoContext context, Node parent, Node nextSibling)
+ throws MarshalException {
+
+ if (getNode() != null) {
+ // If this TransformsImpl has been unmarshalled from exiting nodes,
+ // we don't want to re-marshal ...
+ state_ = STATE_MARSHALED;
+
+ // ... but append the existing node to the parent ...
+ Node transformsNode = parent.insertBefore(getNode(), nextSibling);
+
+ // ... and marshal any Transforms not yet marshalled (e.g. that
+ // have been added via insertTransform().
+ Node transformNextSibling = transformsNode.getFirstChild();
+ List transforms = getTransformImpls();
+ for (int i = 0; i < transforms.size(); i++) {
+ TransformImpl transform = transforms.get(i);
+ Node transformNode = transform.getNode();
+ if (transformNode == null) {
+ // marshall TransformImpl
+ transformNode = transform.marshal(context, transformsNode, transformNextSibling);
+ }
+ transformNextSibling = transformNode.getNextSibling();
+ }
+
+ return transformsNode;
+ } else {
+ return super.marshal(context, parent, nextSibling);
+ }
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLBindingException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLBindingException.java
new file mode 100644
index 00000000..3f1732ba
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLBindingException.java
@@ -0,0 +1,31 @@
+/*
+* 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.bku.slexceptions;
+
+/**
+ * Error in the binding to the transport protocol (2xxx)
+ */
+public class SLBindingException extends SLException {
+
+ public SLBindingException(int errorCode) {
+ super(errorCode);
+ }
+
+ public SLBindingException(int errorCode, String msg, Object[] args) {
+ super(errorCode, msg, args);
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCanceledException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCanceledException.java
new file mode 100644
index 00000000..8136a093
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCanceledException.java
@@ -0,0 +1,26 @@
+/*
+* 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.bku.slexceptions;
+
+public class SLCanceledException extends
+ at.gv.egiz.bku.slexceptions.SLException {
+
+ public SLCanceledException(int errorCode, String msg, Object[] args) {
+ super(errorCode, msg, args);
+ // TODO Auto-generated constructor stub
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCommandException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCommandException.java
new file mode 100644
index 00000000..73ae3325
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLCommandException.java
@@ -0,0 +1,30 @@
+/*
+* 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.bku.slexceptions;
+
+public class SLCommandException extends at.gv.egiz.bku.slexceptions.SLException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SLCommandException(int errorCode) {
+ super(errorCode);
+ }
+
+ public SLCommandException(int errorCode, String msg, Object[] args) {
+ super(errorCode, msg, args);
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLException.java
new file mode 100644
index 00000000..4b541deb
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLException.java
@@ -0,0 +1,88 @@
+/*
+* 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.bku.slexceptions;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class SLException extends Exception {
+
+ private static String RESOURCE_BUNDLE_BASE_NAME = "at.gv.egiz.bku.slexceptions.SLExceptionMessages";
+
+ private static String MISSING_RESOURCE_PATTERN = "MISSING RESOURCE FOR ERROR MESSAGE: {0} ({1})";
+
+ private static String ILLEGAL_ARGUMENT_MESSAGE = "MESSAGE FORMAT FAILED";
+
+ private static final long serialVersionUID = 1L;
+
+ private int errorCode;
+
+ private String message;
+
+ private Object[] arguments;
+
+ public SLException(int errorCode) {
+ this.errorCode = errorCode;
+ this.message = SLExceptionMessages.STANDARD_PREFIX + Integer.toString(errorCode);
+ }
+
+ public SLException(int errorCode, String message, Object[] arguments) {
+ this.errorCode = errorCode;
+ this.message = message;
+ this.arguments = arguments;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public String getDetailedMsg() {
+ return getLocalizedMessage();
+ }
+
+ @Override
+ public String getLocalizedMessage() {
+ return getLocalizedMessage(Locale.getDefault());
+ }
+
+ public String getLocalizedMessage(Locale locale) {
+
+ String pattern;
+ Object[] arguments = this.arguments;
+ try {
+ ResourceBundle bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE_NAME, locale);
+ pattern = bundle.getString(message);
+ } catch (MissingResourceException e) {
+ pattern = MISSING_RESOURCE_PATTERN;
+ arguments = new Object[]{message, e.getMessage()};
+ }
+
+ String localizedMessage;
+ try {
+ localizedMessage = MessageFormat.format(pattern, arguments);
+ } catch (IllegalArgumentException e) {
+ localizedMessage = ILLEGAL_ARGUMENT_MESSAGE + ": " + pattern;
+ }
+
+ return localizedMessage;
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java
new file mode 100644
index 00000000..5ce5cba1
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java
@@ -0,0 +1,50 @@
+/*
+* 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.bku.slexceptions;
+
+public final class SLExceptionMessages {
+
+ private SLExceptionMessages() {
+ }
+
+ public static final String STANDARD_PREFIX = "ec";
+
+ //
+ // 3xxx
+ //
+ // Error in the XML structure of the command request
+
+ public static final String EC3000_UNCLASSIFIED = "ec3000.unclassified";
+
+ public static final String EC3002_INVALID = "ec3002.invalid";
+
+ //
+ // 4xxx
+ //
+ // Error during command execution
+
+ public static final String EC4000_UNCLASSIFIED_INFOBOX_INVALID = "ec4000.infobox.invalid";
+
+ public static final String EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED = "ec4000.idlink.transfomation.failed";
+
+ public static final String EC4002_INFOBOX_UNKNOWN = "ec4002.infobox.unknown";
+
+ public static final String EC4003_NOT_RESOLVED = "ec4003.not.resolved";
+
+ public static final String EC4011_NOTIMPLEMENTED = "ec4011.notimplemented";
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRequestException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRequestException.java
new file mode 100644
index 00000000..548732e6
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRequestException.java
@@ -0,0 +1,30 @@
+/*
+* 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.bku.slexceptions;
+
+public class SLRequestException extends SLException {
+
+ public SLRequestException(int errorCode) {
+ super(errorCode);
+ // TODO Auto-generated constructor stub
+ }
+
+ public SLRequestException(int errorCode, String msg, Object[] args) {
+ super(errorCode, msg, args);
+ // TODO Auto-generated constructor stub
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRuntimeException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRuntimeException.java
new file mode 100644
index 00000000..d09ca418
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLRuntimeException.java
@@ -0,0 +1,37 @@
+/*
+* 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.bku.slexceptions;
+
+public class SLRuntimeException extends RuntimeException {
+
+ public SLRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SLRuntimeException(String message) {
+ super(message);
+ }
+
+ public SLRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ public SLRuntimeException() {
+ }
+
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java
new file mode 100644
index 00000000..1d128a00
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java
@@ -0,0 +1,25 @@
+/*
+* 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.bku.slexceptions;
+
+public class SLViewerException extends SLException {
+
+ public SLViewerException(int errorCode, String msg, Object[] args) {
+ super(errorCode, msg, args);
+ // TODO Auto-generated constructor stub
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd
new file mode 100644
index 00000000..594e4415
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd
@@ -0,0 +1,877 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xml.xsd b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xml.xsd
new file mode 100644
index 00000000..eeb9db56
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xml.xsd
@@ -0,0 +1,145 @@
+
+
+
+
+
+ See http://www.w3.org/XML/1998/namespace.html and
+ http://www.w3.org/TR/REC-xml for information about this namespace.
+
+ This schema document describes the XML namespace, in a form
+ suitable for import by other schema documents.
+
+ Note that local names in this namespace are intended to be defined
+ only by the World Wide Web Consortium or its subgroups. The
+ following names are currently defined in this namespace and should
+ not be used with conflicting semantics by any Working Group,
+ specification, or document instance:
+
+ base (as an attribute name): denotes an attribute whose value
+ provides a URI to be used as the base for interpreting any
+ relative URIs in the scope of the element on which it
+ appears; its value is inherited. This name is reserved
+ by virtue of its definition in the XML Base specification.
+
+ id (as an attribute name): denotes an attribute whose value
+ should be interpreted as if declared to be of type ID.
+ This name is reserved by virtue of its definition in the
+ xml:id specification.
+
+ lang (as an attribute name): denotes an attribute whose value
+ is a language code for the natural language of the content of
+ any element; its value is inherited. This name is reserved
+ by virtue of its definition in the XML specification.
+
+ space (as an attribute name): denotes an attribute whose
+ value is a keyword indicating what whitespace processing
+ discipline is intended for the content of the element; its
+ value is inherited. This name is reserved by virtue of its
+ definition in the XML specification.
+
+ Father (in any context at all): denotes Jon Bosak, the chair of
+ the original XML Working Group. This name is reserved by
+ the following decision of the W3C XML Plenary and
+ XML Coordination groups:
+
+ In appreciation for his vision, leadership and dedication
+ the W3C XML Plenary on this 10th day of February, 2000
+ reserves for Jon Bosak in perpetuity the XML name
+ xml:Father
+
+
+
+
+ This schema defines attributes and an attribute group
+ suitable for use by
+ schemas wishing to allow xml:base, xml:lang, xml:space or xml:id
+ attributes on elements they define.
+
+ To enable this, such a schema must import this schema
+ for the XML namespace, e.g. as follows:
+ <schema . . .>
+ . . .
+ <import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+
+ Subsequently, qualified reference to any of the attributes
+ or the group defined below will have the desired effect, e.g.
+
+ <type . . .>
+ . . .
+ <attributeGroup ref="xml:specialAttrs"/>
+
+ will define a type which will schema-validate an instance
+ element with any of those attributes
+
+
+
+ In keeping with the XML Schema WG's standard versioning
+ policy, this schema document will persist at
+ http://www.w3.org/2007/08/xml.xsd.
+ At the date of issue it can also be found at
+ http://www.w3.org/2001/xml.xsd.
+ The schema document at that URI may however change in the future,
+ in order to remain compatible with the latest version of XML Schema
+ itself, or with the XML namespace itself. In other words, if the XML
+ Schema or XML namespaces change, the version of this document at
+ http://www.w3.org/2001/xml.xsd will change
+ accordingly; the version at
+ http://www.w3.org/2007/08/xml.xsd will not change.
+
+
+
+
+
+ Attempting to install the relevant ISO 2- and 3-letter
+ codes as the enumerated possible values is probably never
+ going to be a realistic possibility. See
+ RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry
+ at http://www.iana.org/assignments/lang-tag-apps.htm for
+ further information.
+
+ The union allows for the 'un-declaration' of xml:lang with
+ the empty string.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ See http://www.w3.org/TR/xmlbase/ for
+ information about this attribute.
+
+
+
+
+
+ See http://www.w3.org/TR/xml-id/ for
+ information about this attribute.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-core-schema.xsd b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-core-schema.xsd
new file mode 100644
index 00000000..8422fdfa
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-core-schema.xsd
@@ -0,0 +1,308 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-transforms.xsd b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-transforms.xsd
new file mode 100644
index 00000000..25fdec88
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/xmldsig-transforms.xsd
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
new file mode 100644
index 00000000..8e0a09bc
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
@@ -0,0 +1,97 @@
+# 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.
+
+test.noerror=This is a test error-message. No error occurred.
+
+ec1000=Unclassified error.
+ec2000=Unclassified error in the transport binding.
+ec2001=HTTP/HTTPS binding: DataURL cannot be resolved.
+ec2002=HTTP/HTTPS binding: StylesheetURL cannot be resolved.
+ec2003=HTTP/HTTPS binding: RedirectURL cannot be resolved.
+ec2004=HTTP/HTTPS binding: XMLRequest parameter missing.
+ec2005=HTTP/HTTPS binding: Unknown parameter encoding.
+ec2006=HTTP/HTTPS binding: Incorrect parameter encoding.
+ec2007=HTTP/HTTPS binding: DataURL server transmits error or unexpected response.
+ec2008=HTTP/HTTPS binding: Error in stylesheet obtained from the StylesheetURL.
+ec2009=HTTP/HTTPS binding: HTTP request to local CCE directed to unauthorised URL.
+ec2010=HTTPS binding: Error while establishing the TLS connection.
+ec3000=Unclassified error in the XML structure of the command request.
+ec3001=XML structure of the command request is not well formed.
+ec3002=XML structure of the command request does not comply with the Security Layer schema.
+ec3003=XML structure of the command request contains an invalid combination of optional elements or attributes.
+ec3004=XML structure contains an element or attribute whose syntax does not match the Security Layer specification.
+ec3005=Protocol version of Security Layer not supported.
+ec4000=Unclassified error while processing command.
+ec4001=Unknown key box identifier.
+ec4002=Unknown info box identifier.
+ec4003=Date to be signed cannot be resolved.
+ec4004=Supplementary object cannot be resolved.
+ec4005=Date to be encrypted cannot be resolved.
+ec4006=Algorithm (signature, encryption, digest, canonicalisation, transformation) not supported.
+ec4007=Error while executing algorithm (signature, encryption, digest, canonicalisation, transformation).
+ec4008=Error while parsing CMS message
+ec4009=No matching decryption key.
+ec4010=Info box command parameters do not match info box type.
+ec4011=Command not implemented.
+ec4100=XML document in which the signature is to be integrated cannot be resolved.
+ec4101=XML document in which the signature is to be integrated cannot be parsed.
+ec4102=Signature cannot be integrated in the existing XML document at the specified location.
+ec4103=Signature certificate not contained in the CMS signature.
+ec4104=Signed data not contained in the CMS signature or XML request.
+ec4105=XML document containing the signature to be verified cannot be resolved.
+ec4106=XML document containing the signature to be verified cannot be parsed.
+ec4107=There is no XML signature at the specified location within the XML document.
+ec4108=Encrypted date cannot be inserted in the existing XML document at the specified location.
+ec4109=Existing XML document is required but missing.
+ec4110=Existing XML document cannot be resolved.
+ec4111=Existing XML document cannot be parsed.
+ec4112=Encrypted data encryption keys cannot be inserted in the existing XML document at the specified location.
+ec4113=Data to be decrypted not contained in either the CMS message or XML request.
+ec4114=XML document to be decrypted cannot be resolved.
+ec4115=XML document to be decrypted cannot be parsed.
+ec4116=At least one specified encryption element cannot be found in the XML document to be decrypted.
+ec4117=No encryption element for binary response.
+ec4118=Date to be hashed cannot be resolved.
+ec4119=Date for which the hash value is to be verified cannot be resolved.
+ec4120=Selected info box identifier already allocated.
+ec4121=Info box with specified identifier does not exist.
+ec4122=Contents of the selected info box cannot be displayed as XML.
+ec4123=Associative array: No entry for the specified key.
+ec5000=Unclassified error in the viewer component.
+ec5001=Display of data of the mime type specified in the command request not supported.
+ec5002=Character encoding of the data to be displayed is invalid or not supported.
+ec5003=Data to be displayed contains unsupported characters.
+ec5004=Standard display format: HTML does not conform to specification.
+ec5005=Standard display format: CSS does not conform to specification.
+ec5006=Standard display format: Format of an embedded image does not conform to specification.
+ec5007=Standard display format: Signature for embedded images missing or does not conform to specification.
+ec6000=Unclassified cancelling by the citizen.
+ec6001=Cancelled by the citizen via the user interface.
+ec6002=Cancelled because of insufficient rights to execute command.
+
+# 3xxx
+#
+
+ec3000.unclassified=Error in the XML structure of the command request. {0}
+ec3002.invalid=XML structure of the command request does not comply with the Security Layer schema. {0}
+
+# 4xxx
+#
+
+ec4000.infobox.invalid=The infobox '{0}' contains invalid content.
+ec4000.idlink.transfomation.failed=Failed to transform CompressedIdentityLink with Stylesheet {0}.
+ec4002.infobox.unknown=Unknown info box identifier {0}.
+ec4003.not.resolved=Data to be signed cannot be resolved from URI={0}.
+ec4011.notimplemented=Command {0} not implemented.
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties
new file mode 100644
index 00000000..cf52a4c3
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties
@@ -0,0 +1,98 @@
+# 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.
+
+test.noerror=Das ist eine Test-Fehlermeldung. Es ist kein Fehler aufgetreten.
+
+ec1000=Unklassifizierter Fehler.
+ec2000=Unklassifizierter Fehler in der Transportbindung.
+ec2001=HTTP/HTTPS-Bindung: DataURL kann nicht aufgelöst werden.
+ec2002=HTTP/HTTPS-Bindung: StylesheetURL kann nicht aufgelöst werden.
+ec2003=HTTP/HTTPS-Bindung: RedirectURL kann nicht aufgelöst werden.
+ec2004=HTTP/HTTPS-Bindung: Parameter XMLRequest fehlt.
+ec2005=HTTP/HTTPS-Bindung: Unbekannte Kodierung der Parameter.
+ec2006=HTTP/HTTPS-Bindung: Fehlerhafte Kodierung der Parameter.
+ec2007=HTTP/HTTPS-Bindung: DataURL-Server sendet Fehler oder unerwartete Antwort.
+ec2008=HTTP/HTTPS-Bindung: Fehler im Stylesheet, der von der StylesheetURL bezogen wurde.
+ec2009=HTTP/HTTPS-Bindung: HTTP-Anfrage an lokale BKU wurde an unerlaubte URL gerichtet.
+ec2010=HTTPS-Bindung: Fehler beim Aufbau der TLS-Verbindung.
+ec3000=Unklassifizierter Fehler in der XML-Struktur der Befehlsanfrage.
+ec3001=XML-Struktur der Befehlsanfrage ist nicht wohlgeformt.
+ec3002=XML-Struktur der Befehlsanfrage entspricht nicht dem Schema des Security-Layers.
+ec3003=XML-Struktur der Befehlsanfrage enthält eine unerlaubte Kombination aus optionalen Elementen oder Attributen.
+ec3004=XML-Struktur enthält ein Element oder Attribut, dessen Syntax nicht der Spezifikation des Security-Layer entspricht.
+ec3005=Protokollversion des Security-Layer wird nicht unterstützt.
+ec4000=Unklassifizierter Fehler in der Befehlsabarbeitung.
+ec4001=Unbekannter Keyboxbezeichner.
+ec4002=Unbekannter Infoboxbezeichner.
+ec4003=Zu signierendes Datum kann nicht aufgelöst werden.
+ec4004=Ergänzungsobjekt kann nicht aufgelöst werden.
+ec4005=Zu verschlüsselndes Datum kann nicht aufgelöst werden.
+ec4006=Algorithmus (Signatur, Verschlüsselung, Digest, Kanonisierung, Transformation) wird nicht unterstützt.
+ec4007=Fehler bei der Algorithmusausführung (Signatur, Verschlüsselung, Digest, Kanonisierung, Transformation).
+ec4008=Fehler beim Parsen der CMS-Nachricht.
+ec4009=Kein passender Entschlüsselungsschlüssel vorhanden.
+ec4010=Parameter des Infobox-Befehls passen nicht zum Typ der Infobox.
+ec4011=Befehl ist nicht implementiert.
+ec4100=XML-Dokument, in das die Signatur integriert werden soll, kann nicht aufgelöst werden.
+ec4101=XML-Dokument, in das die Signatur integriert werden soll, kann nicht geparst werden.
+ec4102=Signatur kann nicht am spezifizierten Ort in das bestehende XML-Dokument integriert werden.
+ec4103=Signatorzertifikat ist nicht in der CMS-Signatur enthalten.
+ec4104=Signierte Daten sind weder in der CMS-Signatur noch im XML-Request enthalten.
+ec4105=XML-Dokument, das die zu prüfende Signatur enthält, kann nicht aufgelöst werden.
+ec4106=XML-Dokument, das die zu prüfende Signatur enthält, kann nicht geparst werden.
+ec4107=Am spezifizierten Ort innerhalb des XML-Dokuments befindet sich keine XML-Signatur.
+ec4108=Verschlüsseltes Datum kann nicht am spezifizierten Ort in das bestehende XML-Dokument eingefügt werden.
+ec4109=Bestehendes XML-Dokument ist notwendig, aber nicht vorhanden.
+ec4110=Bestehendes XML-Dokument kann nicht aufgelöst werden.
+ec4111=Bestehendes XML-Dokument kann nicht geparst werden.
+ec4112=Verschlüsselte Datenverschlüsselungsschlüssel können nicht am spezifizierten Ort in das bestehende XML-Dokument eingefügt werden.
+ec4113=Zu entschlüsselnde Daten sind weder in der CMS-Nachricht noch im XML-Request enthalten.
+ec4114=Zu entschlüsselndes XML-Dokument kann nicht aufgelöst werden.
+ec4115=Zu entschlüsselndes XML-Dokument kann nicht geparst werden.
+ec4116=Zumindest ein spezifiziertes Verschlüsselungselement kann nicht im zu entschlüsselnden XML-Dokument gefunden werden.
+ec4117=Kein Verschlüsselungselement für Binärantwort vorhanden.
+ec4118=Zu hashendes Datum kann nicht aufgelöst werden.
+ec4119=Datum, für das der Hashwert zu prüfen ist, kann nicht aufgelöst werden.
+ec4120=Gewählter Infoboxbezeichner bereits vergeben.
+ec4121=Infobox mit spezifiziertem Bezeichner existiert nicht.
+ec4122=Inhalt der ausgewählten Infobox kann nicht als XML dargestellt werden.
+ec4123=Assoziatives Array: Zum spezifizierten Schlüssel existiert kein Eintrag.
+ec5000=Unklassifizierter Fehler in der Anzeigekomponente.
+ec5001=Anzeige von Daten des in der Befehlsanfrage angegebenen Mime-Types wird nicht unterstützt.
+ec5002=Zeichenkodierung der anzuzeigenden Daten ist fehlerhaft oder wird nicht unterstützt.
+ec5003=Anzuzeigende Daten enhalten nicht unterstützte Zeichen.
+ec5004=Standardanzeigeformat: HTML ist nicht spezifikationskonform.
+ec5005=Standardanzeigeformat: CSS ist nicht spezifikationskonform.
+ec5006=Standardanzeigeformat: Format eines eingebundenen Bildes ist nicht spezifikationskonform.
+ec5007=Standardanzeigeformat: Signatur über eingebundene Bilder fehlt oder ist nicht spezifikationskonform.
+ec6000=Unklassifizierter Abbruch durch den Bürger.
+ec6001=Abbruch durch den Bürger über die Benutzerschnittstelle.
+ec6002=Abbruch auf Grund mangelnder Rechte zur Befehlsausführung.
+
+# 3xxx
+#
+
+ec3000.unclassified=Unklassifizierter Fehler in der XML-Struktur der Befehlsanfrage. {0}
+ec3002.invalid=XML-Struktur der Befehlsanfrage entspricht nicht dem Schema des Security-Layers. {0}
+
+# 4xxx
+#
+
+ec4000.infobox.invalid=Die Infobox '{0}' enthält ungültige Daten.
+ec4000.idlink.transfomation.failed=Die komprimierte Personenbindung konnte mit dem Stylesheet {0} nicht transformiert werden.
+ec4002.infobox.unknown=Unbekannter Infoboxbezeichner {0}.
+ec4003.not.resolved=Zu signierendes Datum kann nicht aufgelöst werden (URI={0}).
+ec4011.notimplemented=Befehl {0} ist nicht implementiert.
+
--
cgit v1.2.3
From 03d4206918ca3db9554e78bf8070a11503f083d9 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Wed, 3 Sep 2008 12:59:26 +0000
Subject: Added skeleton for the access controller classes.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@8 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../egiz/bku/accesscontroller/AccessChecker.java | 7 +++
.../bku/accesscontroller/AccessCheckerContext.java | 27 ++++++++
.../accesscontroller/AccessControllerFactory.java | 39 ++++++++++++
.../at/gv/egiz/bku/accesscontroller/Action.java | 19 ++++++
.../bku/accesscontroller/AuthenticationClass.java | 21 +++++++
.../accesscontroller/AuthenticationClassifier.java | 63 +++++++++++++++++++
.../gv/egiz/bku/accesscontroller/ChainChecker.java | 71 ++++++++++++++++++++++
.../gv/egiz/bku/accesscontroller/ChainResult.java | 32 ++++++++++
.../gv/egiz/bku/accesscontroller/RuleChecker.java | 69 +++++++++++++++++++++
.../gv/egiz/bku/accesscontroller/RuleResult.java | 16 +++++
.../gv/egiz/bku/accesscontroller/UserAction.java | 20 ++++++
11 files changed, 384 insertions(+)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessChecker.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessCheckerContext.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/Action.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClass.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/UserAction.java
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessChecker.java
new file mode 100644
index 00000000..81bf1795
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessChecker.java
@@ -0,0 +1,7 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import at.gv.egiz.bku.slexceptions.SLException;
+
+public interface AccessChecker {
+ public ChainResult check(AccessCheckerContext checkCtx) throws SLException;
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessCheckerContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessCheckerContext.java
new file mode 100644
index 00000000..1206c022
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessCheckerContext.java
@@ -0,0 +1,27 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import at.gv.egiz.bku.slcommands.SLCommand;
+
+public class AccessCheckerContext {
+ private SLCommand command;
+ private AuthenticationClass authenticationClass;
+ private String peerUrl;
+
+ public AccessCheckerContext(SLCommand cmd, AuthenticationClass ac, String url) {
+ this.command = cmd;
+ this.authenticationClass = ac;
+ this.peerUrl = url;
+ }
+
+ public SLCommand getCommand() {
+ return command;
+ }
+
+ public AuthenticationClass getAuthenticationClass() {
+ return authenticationClass;
+ }
+
+ public String getPeerUrl() {
+ return peerUrl;
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
new file mode 100644
index 00000000..9b3e563d
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
@@ -0,0 +1,39 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import java.util.Hashtable;
+
+public class AccessControllerFactory {
+
+ private static AccessControllerFactory instance;
+
+ private Hashtable chainTable = new Hashtable();
+
+ private AccessControllerFactory() {
+ }
+
+ public static AccessControllerFactory getInstance() {
+ return instance;
+ }
+
+ /**
+ *
+ * @param id
+ * @return null if there is no chain with this id.
+ */
+ public ChainChecker getChainChecker(String id) {
+ return chainTable.get(id);
+ }
+
+ public ChainChecker createChainChecker(String id, boolean register) {
+ ChainChecker cc = new ChainChecker(id);
+ if (register) {
+ chainTable.put(id, cc);
+ }
+ return cc;
+ }
+
+ public void registerChainChecker(ChainChecker cc) {
+ chainTable.put(cc.getId(), cc);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/Action.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/Action.java
new file mode 100644
index 00000000..11a22c99
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/Action.java
@@ -0,0 +1,19 @@
+package at.gv.egiz.bku.accesscontroller;
+
+public enum Action {
+ ALLOW("allow"), DENY("deny");
+ private String name;
+
+ Action(String name) {
+ this.name = name;
+ }
+
+ public static Action fromString(String s) {
+ for (Action ac : values()) {
+ if (ac.name.equals(s)) {
+ return ac;
+ }
+ }
+ return null;
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClass.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClass.java
new file mode 100644
index 00000000..4d58df78
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClass.java
@@ -0,0 +1,21 @@
+package at.gv.egiz.bku.accesscontroller;
+
+public enum AuthenticationClass {
+ ANONYMOUS("anonymous"), PSEUDO_ANONYMOUS("pseudoanonymous"), CERTIFIED(
+ "certified"), CERTIFIED_GOV_AGENCY("certifiedGovAgency");
+
+ private String name;
+
+ AuthenticationClass(String name) {
+ this.name = name;
+ }
+
+ public static AuthenticationClass fromString(String s) {
+ for (AuthenticationClass ac : values()) {
+ if (ac.name.equals(s)) {
+ return ac;
+ }
+ }
+ return null;
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
new file mode 100644
index 00000000..2e856f06
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
@@ -0,0 +1,63 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.ANONYMOUS;
+import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.CERTIFIED;
+import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.PSEUDO_ANONYMOUS;
+import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.CERTIFIED_GOV_AGENCY;
+
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.security.cert.X509Certificate;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class AuthenticationClassifier {
+ private static AuthenticationClassifier instance = new AuthenticationClassifier();
+ private static Log log = LogFactory.getLog(AuthenticationClassifier.class);
+ private final static String GOV_DOMAIN = ".gv.at";
+
+ private AuthenticationClassifier() {
+ }
+
+ /**
+ * Client Certificates are currently not supported
+ *
+ */
+ protected AuthenticationClass getMyAuthenticationClass(boolean isDataUrl,
+ URL url, X509Certificate cert) {
+ if (isDataUrl) {
+ if (url.getProtocol().equalsIgnoreCase("https")) {
+ try {
+ if (InetAddress.getByName(url.getHost()).getCanonicalHostName()
+ .endsWith(GOV_DOMAIN)) {
+ return CERTIFIED_GOV_AGENCY;
+ }
+ } catch (UnknownHostException e) {
+ log.error("Cannot determine host name", e);
+ }
+ if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
+ return CERTIFIED_GOV_AGENCY;
+ }
+ return CERTIFIED;
+ } else {
+ return PSEUDO_ANONYMOUS;
+ }
+ } else {
+ return ANONYMOUS;
+ }
+ }
+
+ /**
+ *
+ * @param isDataUrl
+ * @param url if the url's protocol is https a cert parameter must be provided.
+ * @param cert
+ * @return
+ */
+ public static AuthenticationClass getAuthenticationClass(boolean isDataUrl,
+ URL url, X509Certificate cert) {
+ return instance.getMyAuthenticationClass(isDataUrl, url, cert);
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java
new file mode 100644
index 00000000..242d9b02
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java
@@ -0,0 +1,71 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slexceptions.SLException;
+
+public class ChainChecker implements AccessChecker {
+ private static Log log = LogFactory.getLog(ChainChecker.class);
+
+ private String id;
+ private List rules = new LinkedList();
+
+ /**
+ *
+ * @param id must not be null
+ */
+ public ChainChecker(String id) {
+ if (id == null) {
+ throw new NullPointerException("Id argument must not be null");
+ }
+ this.id = id;
+ }
+
+
+ public String getId() {
+ return id;
+ }
+
+ public void addRule(RuleChecker rule) {
+ if (rule != null) {
+ rules.add(rule);
+ }
+ }
+
+ @Override
+ public ChainResult check(AccessCheckerContext checkCtx) throws SLException {
+ log.debug("Processing chain: "+id);
+ for (RuleChecker rule : rules) {
+ log.trace("Checking rule: "+rule.getId());
+ RuleResult result = rule.check(checkCtx);
+ if (result.matchFound()) {
+ log.debug("Found matching rule: "+rule.getId());
+ if (result.getDelegateChainId() != null) {
+ // process chain
+ ChainChecker cc = AccessControllerFactory.getInstance().getChainChecker(result.getDelegateChainId());
+ if (cc == null) {
+ log.error("Cannot delegate to chain. Unknown chain id: "+result.getDelegateChainId());
+ throw new SLException(4000);
+ }
+ ChainResult cr = cc.check(checkCtx);
+ if (cr.matchFound()) {
+ return cr;
+ }
+ // if chain does not contain matching rule
+ // cont. here.
+ } else {
+ return result;
+ }
+ }
+ }
+ log.debug("Did not find a matching rule here");
+ return new ChainResult(null, null, false);
+ }
+
+
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java
new file mode 100644
index 00000000..a534f4e5
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java
@@ -0,0 +1,32 @@
+package at.gv.egiz.bku.accesscontroller;
+
+/**
+ * Result of the access controller
+ *
+ */
+public class ChainResult {
+ private UserAction userAction;
+ private Action action;
+ private boolean matchFound;
+
+ public ChainResult(Action action, UserAction userAction, boolean matchFound) {
+ this.action = action;
+ this.userAction = userAction;
+ }
+
+ public Action getAction() {
+ return action;
+ }
+
+ public UserAction getUserAction() {
+ return userAction;
+ }
+
+ /**
+ *
+ * @return true if a matching rule has been found
+ */
+ public boolean matchFound() {
+ return matchFound;
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
new file mode 100644
index 00000000..bf46034d
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
@@ -0,0 +1,69 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+public class RuleChecker implements AccessChecker {
+
+ private static Log log = LogFactory.getLog(RuleChecker.class);
+
+ public static enum PEER_TYPE {HOST, IP, URL};
+
+ protected String id;
+ protected AuthenticationClass authenticationClass;
+ protected String commandName;
+ protected String peerId;
+ protected PEER_TYPE peerType;
+ protected Action action;
+ protected UserAction userAction;
+
+ public RuleChecker(String id) {
+ if (id == null) {
+ throw new NullPointerException("Id argument must not be null");
+ }
+ this.id = id;
+ }
+
+ public void setAuthenticationClass(String ac) {
+ AuthenticationClass tmp = AuthenticationClass.fromString(ac);
+ if (tmp == null) {
+ throw new SLRuntimeException("Unknown authentication class "+ac);
+ }
+ authenticationClass = tmp;
+ }
+
+ public void setAction(String ac) {
+ Action tmp = Action.fromString(ac);
+ if (tmp == null) {
+ throw new SLRuntimeException("Unknown action "+ac);
+ }
+ action = tmp;
+ }
+
+ public void setUserAction(String uac) {
+ UserAction tmp = UserAction.fromString(uac);
+ if (tmp == null) {
+ throw new SLRuntimeException("Unknown user action "+uac);
+ }
+ userAction = tmp;
+ }
+
+ public void setPeerId(String peerId, PEER_TYPE type) {
+ this.peerType = type;
+ this.peerId = peerId;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public RuleResult check(AccessCheckerContext checkCtx) {
+ log.debug("Processing rule: "+id);
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleResult.java
new file mode 100644
index 00000000..26f42db0
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleResult.java
@@ -0,0 +1,16 @@
+package at.gv.egiz.bku.accesscontroller;
+
+
+public class RuleResult extends ChainResult {
+ private String chainId;
+
+ public RuleResult(Action action, UserAction userAction, boolean matchFound, String chainId) {
+ super(action, userAction, matchFound);
+ this.chainId = chainId;
+ }
+
+ public String getDelegateChainId() {
+ return chainId;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/UserAction.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/UserAction.java
new file mode 100644
index 00000000..307ec1e5
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/UserAction.java
@@ -0,0 +1,20 @@
+package at.gv.egiz.bku.accesscontroller;
+
+public enum UserAction {
+ NONE("none"), INFO("info"), CONFIRM("confirm"), CONFIRM_WITH_SECRET("confirmWithSecret");
+
+ private String name;
+
+ UserAction(String name) {
+ this.name = name;
+ }
+
+ public static UserAction fromString(String s) {
+ for (UserAction ac : values()) {
+ if (ac.name.equals(s)) {
+ return ac;
+ }
+ }
+ return null;
+ }
+}
--
cgit v1.2.3
From 13976eb3a430f319e0fdb0a6c75b58881512fba5 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 3 Sep 2008 13:53:13 +0000
Subject: accesscontrol config
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@9 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../bku/accesscontrol/config/AccessControl.java | 71 +++++
.../gv/egiz/bku/accesscontrol/config/Action.java | 110 +++++++
.../at/gv/egiz/bku/accesscontrol/config/Chain.java | 106 +++++++
.../gv/egiz/bku/accesscontrol/config/Chains.java | 78 +++++
.../gv/egiz/bku/accesscontrol/config/Command.java | 108 +++++++
.../bku/accesscontrol/config/ObjectFactory.java | 134 ++++++++
.../at/gv/egiz/bku/accesscontrol/config/Param.java | 101 ++++++
.../at/gv/egiz/bku/accesscontrol/config/Rule.java | 342 +++++++++++++++++++++
.../at/gv/egiz/bku/accesscontrol/config/Rules.java | 78 +++++
9 files changed, 1128 insertions(+)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chain.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chains.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rule.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java
new file mode 100644
index 00000000..c9efaca6
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java
@@ -0,0 +1,71 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
+// See http://java.sun.com/xml/jaxb
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.09.03 at 01:53:08 PM GMT
+//
+
+
+package at.gv.egiz.bku.accesscontrol.config;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ *
Java class for anonymous complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "chain"
+})
+@XmlRootElement(name = "Chains")
+public class Chains {
+
+ @XmlElement(name = "Chain", required = true)
+ protected List chain;
+
+ /**
+ * Gets the value of the chain property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set method for the chain property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getChain().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link Chain }
+ *
+ *
+ */
+ public List getChain() {
+ if (chain == null) {
+ chain = new ArrayList();
+ }
+ return this.chain;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java
new file mode 100644
index 00000000..fcba969f
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java
@@ -0,0 +1,108 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
+// See http://java.sun.com/xml/jaxb
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.09.03 at 01:53:08 PM GMT
+//
+
+
+package at.gv.egiz.bku.accesscontrol.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ *
Java class for anonymous complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set method for the param property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getParam().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link Param }
+ *
+ *
+ */
+ public List getParam() {
+ if (param == null) {
+ param = new ArrayList();
+ }
+ return this.param;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java
new file mode 100644
index 00000000..7291d759
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java
@@ -0,0 +1,134 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
+// See http://java.sun.com/xml/jaxb
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.09.03 at 01:53:08 PM GMT
+//
+
+
+package at.gv.egiz.bku.accesscontrol.config;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the at.gv.egiz.bku.accesscontrol.config package.
+ *
An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _UserInteraction_QNAME = new QName("", "UserInteraction");
+ private final static QName _AuthClass_QNAME = new QName("", "AuthClass");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: at.gv.egiz.bku.accesscontrol.config
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link AccessControl }
+ *
+ */
+ public AccessControl createAccessControl() {
+ return new AccessControl();
+ }
+
+ /**
+ * Create an instance of {@link Chain }
+ *
+ */
+ public Chain createChain() {
+ return new Chain();
+ }
+
+ /**
+ * Create an instance of {@link Command }
+ *
+ */
+ public Command createCommand() {
+ return new Command();
+ }
+
+ /**
+ * Create an instance of {@link Chains }
+ *
+ */
+ public Chains createChains() {
+ return new Chains();
+ }
+
+ /**
+ * Create an instance of {@link Rule }
+ *
+ */
+ public Rule createRule() {
+ return new Rule();
+ }
+
+ /**
+ * Create an instance of {@link Rule.AnyPeer }
+ *
+ */
+ public Rule.AnyPeer createRuleAnyPeer() {
+ return new Rule.AnyPeer();
+ }
+
+ /**
+ * Create an instance of {@link Rules }
+ *
+ */
+ public Rules createRules() {
+ return new Rules();
+ }
+
+ /**
+ * Create an instance of {@link Param }
+ *
+ */
+ public Param createParam() {
+ return new Param();
+ }
+
+ /**
+ * Create an instance of {@link Action }
+ *
+ */
+ public Action createAction() {
+ return new Action();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "", name = "UserInteraction")
+ public JAXBElement createUserInteraction(String value) {
+ return new JAXBElement(_UserInteraction_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "", name = "AuthClass")
+ public JAXBElement createAuthClass(String value) {
+ return new JAXBElement(_AuthClass_QNAME, String.class, null, value);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java
new file mode 100644
index 00000000..44afc196
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java
@@ -0,0 +1,101 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
+// See http://java.sun.com/xml/jaxb
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.09.03 at 01:53:08 PM GMT
+//
+
+
+package at.gv.egiz.bku.accesscontrol.config;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ *
Java class for anonymous complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "authClass",
+ "anyPeer",
+ "domainName",
+ "iPv4Address",
+ "url",
+ "command",
+ "action",
+ "userInteraction"
+})
+@XmlRootElement(name = "Rule")
+public class Rule {
+
+ @XmlElement(name = "AuthClass", required = true)
+ protected String authClass;
+ @XmlElement(name = "AnyPeer")
+ protected Rule.AnyPeer anyPeer;
+ @XmlElement(name = "DomainName")
+ protected String domainName;
+ @XmlElement(name = "IPv4Address")
+ protected String iPv4Address;
+ @XmlElement(name = "URL")
+ protected String url;
+ @XmlElement(name = "Command")
+ protected Command command;
+ @XmlElement(name = "Action", required = true)
+ protected List action;
+ @XmlElement(name = "UserInteraction", required = true)
+ protected String userInteraction;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the authClass property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAuthClass() {
+ return authClass;
+ }
+
+ /**
+ * Sets the value of the authClass property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAuthClass(String value) {
+ this.authClass = value;
+ }
+
+ /**
+ * Gets the value of the anyPeer property.
+ *
+ * @return
+ * possible object is
+ * {@link Rule.AnyPeer }
+ *
+ */
+ public Rule.AnyPeer getAnyPeer() {
+ return anyPeer;
+ }
+
+ /**
+ * Sets the value of the anyPeer property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Rule.AnyPeer }
+ *
+ */
+ public void setAnyPeer(Rule.AnyPeer value) {
+ this.anyPeer = value;
+ }
+
+ /**
+ * Gets the value of the domainName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDomainName() {
+ return domainName;
+ }
+
+ /**
+ * Sets the value of the domainName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDomainName(String value) {
+ this.domainName = value;
+ }
+
+ /**
+ * Gets the value of the iPv4Address property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getIPv4Address() {
+ return iPv4Address;
+ }
+
+ /**
+ * Sets the value of the iPv4Address property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setIPv4Address(String value) {
+ this.iPv4Address = value;
+ }
+
+ /**
+ * Gets the value of the url property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURL() {
+ return url;
+ }
+
+ /**
+ * Sets the value of the url property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURL(String value) {
+ this.url = value;
+ }
+
+ /**
+ * Gets the value of the command property.
+ *
+ * @return
+ * possible object is
+ * {@link Command }
+ *
+ */
+ public Command getCommand() {
+ return command;
+ }
+
+ /**
+ * Sets the value of the command property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Command }
+ *
+ */
+ public void setCommand(Command value) {
+ this.command = value;
+ }
+
+ /**
+ * Gets the value of the action property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set method for the action property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getAction().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link Action }
+ *
+ *
+ */
+ public List getAction() {
+ if (action == null) {
+ action = new ArrayList();
+ }
+ return this.action;
+ }
+
+ /**
+ * Gets the value of the userInteraction property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getUserInteraction() {
+ return userInteraction;
+ }
+
+ /**
+ * Sets the value of the userInteraction property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setUserInteraction(String value) {
+ this.userInteraction = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+
+ /**
+ *
Java class for anonymous complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "")
+ public static class AnyPeer {
+
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java
new file mode 100644
index 00000000..5a5fa11f
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java
@@ -0,0 +1,78 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
+// See http://java.sun.com/xml/jaxb
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.09.03 at 01:53:08 PM GMT
+//
+
+
+package at.gv.egiz.bku.accesscontrol.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ *
Java class for anonymous complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "rule"
+})
+@XmlRootElement(name = "Rules")
+public class Rules {
+
+ @XmlElement(name = "Rule", required = true)
+ protected List rule;
+
+ /**
+ * Gets the value of the rule property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set method for the rule property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getRule().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link Rule }
+ *
+ *
+ */
+ public List getRule() {
+ if (rule == null) {
+ rule = new ArrayList();
+ }
+ return this.rule;
+ }
+
+}
--
cgit v1.2.3
From 838aaacdd713d262801aa99ff161866a8939ec11 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 3 Sep 2008 14:53:43 +0000
Subject: accesscontrol config
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@10 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../bku/accesscontrol/config/AccessControl.java | 2 +-
.../gv/egiz/bku/accesscontrol/config/Action.java | 2 +-
.../at/gv/egiz/bku/accesscontrol/config/Chain.java | 2 +-
.../gv/egiz/bku/accesscontrol/config/Chains.java | 2 +-
.../gv/egiz/bku/accesscontrol/config/Command.java | 2 +-
.../bku/accesscontrol/config/ObjectFactory.java | 52 +++++-----
.../at/gv/egiz/bku/accesscontrol/config/Param.java | 2 +-
.../at/gv/egiz/bku/accesscontrol/config/Rule.java | 108 ++++-----------------
.../at/gv/egiz/bku/accesscontrol/config/Rules.java | 2 +-
9 files changed, 50 insertions(+), 124 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java
index c9efaca6..90271231 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/AccessControl.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java
index 8d457d1c..b9c8fa83 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chain.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chain.java
index aa0b920b..1408c8d8 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chain.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chain.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chains.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chains.java
index f75c8dba..d58f7bad 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chains.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Chains.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java
index fcba969f..0d25ca1c 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Command.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java
index 7291d759..0efa4beb 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/ObjectFactory.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
@@ -42,19 +42,19 @@ public class ObjectFactory {
}
/**
- * Create an instance of {@link AccessControl }
+ * Create an instance of {@link Param }
*
*/
- public AccessControl createAccessControl() {
- return new AccessControl();
+ public Param createParam() {
+ return new Param();
}
/**
- * Create an instance of {@link Chain }
+ * Create an instance of {@link AccessControl }
*
*/
- public Chain createChain() {
- return new Chain();
+ public AccessControl createAccessControl() {
+ return new AccessControl();
}
/**
@@ -66,51 +66,43 @@ public class ObjectFactory {
}
/**
- * Create an instance of {@link Chains }
- *
- */
- public Chains createChains() {
- return new Chains();
- }
-
- /**
- * Create an instance of {@link Rule }
+ * Create an instance of {@link Rules }
*
*/
- public Rule createRule() {
- return new Rule();
+ public Rules createRules() {
+ return new Rules();
}
/**
- * Create an instance of {@link Rule.AnyPeer }
+ * Create an instance of {@link Action }
*
*/
- public Rule.AnyPeer createRuleAnyPeer() {
- return new Rule.AnyPeer();
+ public Action createAction() {
+ return new Action();
}
/**
- * Create an instance of {@link Rules }
+ * Create an instance of {@link Chains }
*
*/
- public Rules createRules() {
- return new Rules();
+ public Chains createChains() {
+ return new Chains();
}
/**
- * Create an instance of {@link Param }
+ * Create an instance of {@link Chain }
*
*/
- public Param createParam() {
- return new Param();
+ public Chain createChain() {
+ return new Chain();
}
/**
- * Create an instance of {@link Action }
+ * Create an instance of {@link Rule }
*
*/
- public Action createAction() {
- return new Action();
+ public Rule createRule() {
+ return new Rule();
}
/**
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java
index 44afc196..94e190ff 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Param.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rule.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rule.java
index 3c85f256..512cced9 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rule.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rule.java
@@ -2,14 +2,12 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
package at.gv.egiz.bku.accesscontrol.config;
-import java.util.ArrayList;
-import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@@ -33,21 +31,13 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{}AuthClass"/>
- * <choice>
- * <element name="AnyPeer">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
+ * <choice minOccurs="0">
* <element name="DomainName" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="IPv4Address" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="URL" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </choice>
* <element ref="{}Command" minOccurs="0"/>
- * <element ref="{}Action" maxOccurs="unbounded"/>
+ * <element ref="{}Action"/>
* <element ref="{}UserInteraction"/>
* </sequence>
* <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
@@ -61,7 +51,6 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"authClass",
- "anyPeer",
"domainName",
"iPv4Address",
"url",
@@ -74,8 +63,6 @@ public class Rule {
@XmlElement(name = "AuthClass", required = true)
protected String authClass;
- @XmlElement(name = "AnyPeer")
- protected Rule.AnyPeer anyPeer;
@XmlElement(name = "DomainName")
protected String domainName;
@XmlElement(name = "IPv4Address")
@@ -85,7 +72,7 @@ public class Rule {
@XmlElement(name = "Command")
protected Command command;
@XmlElement(name = "Action", required = true)
- protected List action;
+ protected Action action;
@XmlElement(name = "UserInteraction", required = true)
protected String userInteraction;
@XmlAttribute(name = "Id")
@@ -118,30 +105,6 @@ public class Rule {
this.authClass = value;
}
- /**
- * Gets the value of the anyPeer property.
- *
- * @return
- * possible object is
- * {@link Rule.AnyPeer }
- *
- */
- public Rule.AnyPeer getAnyPeer() {
- return anyPeer;
- }
-
- /**
- * Sets the value of the anyPeer property.
- *
- * @param value
- * allowed object is
- * {@link Rule.AnyPeer }
- *
- */
- public void setAnyPeer(Rule.AnyPeer value) {
- this.anyPeer = value;
- }
-
/**
* Gets the value of the domainName property.
*
@@ -241,30 +204,25 @@ public class Rule {
/**
* Gets the value of the action property.
*
- *
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a set method for the action property.
- *
- *
- * For example, to add a new item, do as follows:
- *
- * getAction().add(newItem);
- *
- *
- *
- *
- * Objects of the following type(s) are allowed in the list
- * {@link Action }
- *
+ * @return
+ * possible object is
+ * {@link Action }
+ *
+ */
+ public Action getAction() {
+ return action;
+ }
+
+ /**
+ * Sets the value of the action property.
*
+ * @param value
+ * allowed object is
+ * {@link Action }
+ *
*/
- public List getAction() {
- if (action == null) {
- action = new ArrayList();
- }
- return this.action;
+ public void setAction(Action value) {
+ this.action = value;
}
/**
@@ -315,28 +273,4 @@ public class Rule {
this.id = value;
}
-
- /**
- *
Java class for anonymous complex type.
- *
- *
The following schema fragment specifies the expected content contained within this class.
- *
- *
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- public static class AnyPeer {
-
-
- }
-
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java
index 5a5fa11f..6429e58a 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Rules.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 01:53:08 PM GMT
+// Generated on: 2008.09.03 at 02:52:44 PM GMT
//
--
cgit v1.2.3
From 3099f0f157d6a1f6c9df2183833b3279b44211f0 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 3 Sep 2008 15:06:39 +0000
Subject: accesscontrol config
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@11 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/accesscontrol/config/Action.java | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java
index b9c8fa83..b4ae938c 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontrol/config/Action.java
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.09.03 at 02:52:44 PM GMT
+// Generated on: 2008.09.03 at 03:06:11 PM GMT
//
@@ -11,9 +11,7 @@ package at.gv.egiz.bku.accesscontrol.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
@@ -27,7 +25,7 @@ import javax.xml.bind.annotation.XmlType;
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <choice>
- * <element name="ChainRef" type="{http://www.w3.org/2001/XMLSchema}IDREF"/>
+ * <element name="ChainRef" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="RuleAction">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
@@ -53,9 +51,7 @@ import javax.xml.bind.annotation.XmlType;
public class Action {
@XmlElement(name = "ChainRef")
- @XmlIDREF
- @XmlSchemaType(name = "IDREF")
- protected Object chainRef;
+ protected String chainRef;
@XmlElement(name = "RuleAction")
protected String ruleAction;
@@ -64,10 +60,10 @@ public class Action {
*
* @return
* possible object is
- * {@link Object }
+ * {@link String }
*
*/
- public Object getChainRef() {
+ public String getChainRef() {
return chainRef;
}
@@ -76,10 +72,10 @@ public class Action {
*
* @param value
* allowed object is
- * {@link Object }
+ * {@link String }
*
*/
- public void setChainRef(Object value) {
+ public void setChainRef(String value) {
this.chainRef = value;
}
--
cgit v1.2.3
From 2f029b9cb3ebc11abe28e0b2801bacc40cb584b1 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Wed, 3 Sep 2008 15:19:48 +0000
Subject: Just a backup of updated accesscontroller files
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@12 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../accesscontroller/AccessControllerFactory.java | 68 ++++++++++++-
.../gv/egiz/bku/accesscontroller/ChainResult.java | 1 +
.../bku/accesscontroller/InfoboxRuleChecker.java | 14 +++
.../gv/egiz/bku/accesscontroller/RuleChecker.java | 112 ++++++++++++++++++---
.../gv/egiz/bku/accesscontroller/ConfigTest.java | 17 ++++
.../egiz/bku/accesscontroller/RuleCheckerTest.java | 87 ++++++++++++++++
.../bku/accesscontroller/AccessControlConfig.xml | 78 ++++++++++++++
7 files changed, 361 insertions(+), 16 deletions(-)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java
create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/ConfigTest.java
create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/RuleCheckerTest.java
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
index 9b3e563d..3b75a5f2 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
@@ -1,10 +1,38 @@
package at.gv.egiz.bku.accesscontroller;
+import java.io.InputStream;
import java.util.Hashtable;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.accesscontrol.config.AccessControl;
+import at.gv.egiz.bku.accesscontrol.config.Chain;
+import at.gv.egiz.bku.accesscontrol.config.Command;
+import at.gv.egiz.bku.accesscontrol.config.ObjectFactory;
+import at.gv.egiz.bku.accesscontrol.config.Rule;
+import at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
public class AccessControllerFactory {
- private static AccessControllerFactory instance;
+ private static AccessControllerFactory instance = new AccessControllerFactory();
+ private static Log log = LogFactory.getLog(AccessControllerFactory.class);
+ private static JAXBContext jaxbContext;
+
+ static {
+ try {
+ jaxbContext = JAXBContext.newInstance(ObjectFactory.class.getPackage()
+ .getName());
+ } catch (JAXBException e) {
+ log.fatal("Cannot init jaxbContext", e);
+ }
+ }
private Hashtable chainTable = new Hashtable();
@@ -35,5 +63,43 @@ public class AccessControllerFactory {
public void registerChainChecker(ChainChecker cc) {
chainTable.put(cc.getId(), cc);
}
+
+ public RuleChecker createRuleChecker(Rule rule) {
+ RuleChecker rc;
+ Command cmd = rule.getCommand();
+ if (cmd != null) {
+ if ((cmd.getParam() != null) && (cmd.getParam().size()>0)) {
+ if (cmd.getName().startsWith("Infobox")) {
+ rc = new InfoboxRuleChecker(rule.getId());
+ } else {
+ throw new SLRuntimeException("Cannot handle parameters for command "+cmd.getName());
+ }
+ } else {
+ rc = new RuleChecker(rule.getId());
+ }
+ } else {
+ rc = new RuleChecker(rule.getId());
+ }
+ // FIXME TODO cont. here
+
+
+ return rc;
+ }
+
+
+ public void init(InputStream is) throws JAXBException {
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ AccessControl ac = (AccessControl) unmarshaller.unmarshal(is);
+ List chainList = ac.getChains().getChain();
+ log.debug("Found "+chainList.size()+" chains in config");
+ for (Chain chain : chainList) {
+ List ruleList = chain.getRules().getRule();
+ log.debug("Found "+ruleList.size()+" rules in chain "+chain.getId());
+ for (Rule rule : ruleList) {
+ //rule.g
+ }
+ }
+
+ }
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java
index a534f4e5..a8fb789e 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainResult.java
@@ -12,6 +12,7 @@ public class ChainResult {
public ChainResult(Action action, UserAction userAction, boolean matchFound) {
this.action = action;
this.userAction = userAction;
+ this.matchFound = matchFound;
}
public Action getAction() {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java
new file mode 100644
index 00000000..2981d24e
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java
@@ -0,0 +1,14 @@
+package at.gv.egiz.bku.accesscontroller;
+
+/**
+ * Adds infobox parameter checks
+ * @author wbauer
+ *
+ */
+public class InfoboxRuleChecker extends RuleChecker {
+
+ public InfoboxRuleChecker(String id) {
+ super(id);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
index bf46034d..c59f5b70 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
@@ -1,23 +1,36 @@
package at.gv.egiz.bku.accesscontroller;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import at.gv.egiz.bku.slcommands.SLCommand;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
public class RuleChecker implements AccessChecker {
-
+
private static Log log = LogFactory.getLog(RuleChecker.class);
-
- public static enum PEER_TYPE {HOST, IP, URL};
+
+ public static enum PEER_TYPE {
+ HOST, IP, URL
+ };
protected String id;
protected AuthenticationClass authenticationClass;
protected String commandName;
+ protected Pattern commandNamePattern;
protected String peerId;
+ protected Pattern peerIdPattern;
protected PEER_TYPE peerType;
protected Action action;
protected UserAction userAction;
+ protected String chainId;
public RuleChecker(String id) {
if (id == null) {
@@ -27,43 +40,112 @@ public class RuleChecker implements AccessChecker {
}
public void setAuthenticationClass(String ac) {
- AuthenticationClass tmp = AuthenticationClass.fromString(ac);
+ AuthenticationClass tmp = AuthenticationClass.fromString(ac);
if (tmp == null) {
- throw new SLRuntimeException("Unknown authentication class "+ac);
+ throw new SLRuntimeException("Unknown authentication class " + ac);
}
authenticationClass = tmp;
}
-
+
public void setAction(String ac) {
Action tmp = Action.fromString(ac);
if (tmp == null) {
- throw new SLRuntimeException("Unknown action "+ac);
+ throw new SLRuntimeException("Unknown action " + ac);
}
action = tmp;
}
-
+
public void setUserAction(String uac) {
- UserAction tmp = UserAction.fromString(uac);
+ UserAction tmp = UserAction.fromString(uac);
if (tmp == null) {
- throw new SLRuntimeException("Unknown user action "+uac);
+ throw new SLRuntimeException("Unknown user action " + uac);
}
userAction = tmp;
}
-
+
+ public void setChainId(String chainId) {
+ this.chainId = chainId;
+ }
+
public void setPeerId(String peerId, PEER_TYPE type) {
this.peerType = type;
this.peerId = peerId;
+ peerIdPattern = Pattern.compile(peerId);
}
-
+
+ public void setCommandName(String commandName) {
+ this.commandName = commandName;
+ commandNamePattern = Pattern.compile(commandName);
+ }
+
public String getId() {
return id;
}
+ protected boolean matchAuthenticationClass(AuthenticationClass cls) {
+ if (this.authenticationClass == null) {
+ return true;
+ }
+ return this.authenticationClass.compareTo(cls) <= 0;
+ }
+
+ protected boolean matchCommandName(SLCommand cmd) {
+ if (commandName == null) {
+ return true;
+ }
+ Matcher matcher = commandNamePattern.matcher(cmd.getName());
+ return matcher.matches();
+ }
+
+ protected boolean matchPeerId(String peerUrl) {
+ if (peerId == null) {
+ return true;
+ }
+ if (peerType == PEER_TYPE.URL) {
+ Matcher matcher = peerIdPattern.matcher(peerUrl);
+ return matcher.matches();
+ } else {
+ try {
+ URL url = new URL(peerUrl);
+ if (peerType == PEER_TYPE.HOST) {
+ try {
+ String host = url.getHost();
+ String hostName = InetAddress.getByName(host).getCanonicalHostName();
+ Matcher matcher = peerIdPattern.matcher(hostName);
+ return matcher.matches();
+ } catch (UnknownHostException e) {
+ log.error("Cannot resolve hostname", e);
+ return false;
+ }
+ } else {
+ try {
+ String hostAddr = InetAddress.getByName(url.getHost())
+ .getHostAddress();
+ Matcher matcher = peerIdPattern.matcher(hostAddr);
+ return matcher.matches();
+ } catch (UnknownHostException e) {
+ log.error("Cannot resolve host address", e);
+ return false;
+ }
+ }
+ } catch (MalformedURLException e) {
+ log.error("Cannot parse url", e);
+ return false;
+ }
+ }
+ }
+
@Override
public RuleResult check(AccessCheckerContext checkCtx) {
- log.debug("Processing rule: "+id);
- // TODO Auto-generated method stub
- return null;
+ log.debug("Processing rule: " + id);
+ if (matchAuthenticationClass(checkCtx.getAuthenticationClass())
+ && matchCommandName(checkCtx.getCommand())
+ && matchPeerId(checkCtx.getPeerUrl())) {
+ log.debug("Match found for rule: " + id);
+ return new RuleResult(action, userAction, true, chainId);
+ }
+ log.debug("No match found for rule: " + id);
+ return new RuleResult(action, userAction, false, chainId);
}
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/ConfigTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/ConfigTest.java
new file mode 100644
index 00000000..b53db264
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/ConfigTest.java
@@ -0,0 +1,17 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import javax.xml.bind.JAXBException;
+
+import org.junit.Test;
+
+public class ConfigTest {
+
+ public final static String RESOURCE = "at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml";
+
+ @Test
+ public void testUnmarshall() throws JAXBException {
+ AccessControllerFactory.getInstance().init(
+ getClass().getClassLoader().getResourceAsStream(RESOURCE));
+ }
+
+}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/RuleCheckerTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/RuleCheckerTest.java
new file mode 100644
index 00000000..88f1490c
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/RuleCheckerTest.java
@@ -0,0 +1,87 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import at.gv.egiz.bku.accesscontroller.RuleChecker.PEER_TYPE;
+import at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl;
+import at.gv.egiz.bku.slcommands.impl.NullOperationCommandImpl;
+import static org.junit.Assert.*;
+
+public class RuleCheckerTest {
+
+ protected RuleChecker onlyAuthChecker;
+ protected RuleChecker onlyCmdChecker;
+ protected RuleChecker onlyPeerChecker;
+
+ @Before
+ public void setUp() {
+ onlyAuthChecker = new RuleChecker("OnlyAuthChecker");
+ onlyAuthChecker.setAction("allow");
+ onlyAuthChecker.setUserAction("none");
+ onlyAuthChecker.setAuthenticationClass("pseudoanonymous");
+ onlyCmdChecker = new RuleChecker("OnlyCmdChecker");
+ onlyCmdChecker.setAction("allow");
+ onlyCmdChecker.setCommandName("InfoboxReadRequest");
+ onlyPeerChecker = new RuleChecker("OnlyPeerChecker");
+ onlyPeerChecker.setAction("allow");
+ onlyPeerChecker.setPeerId("https://129.27.142..*", PEER_TYPE.URL);
+ }
+
+ @Test
+ public void testAuthClass() {
+ AccessCheckerContext ctx = new AccessCheckerContext(null,
+ AuthenticationClass.ANONYMOUS, null);
+ RuleResult rr = onlyAuthChecker.check(ctx);
+ assertFalse(rr.matchFound());
+ ctx = new AccessCheckerContext(null, AuthenticationClass.PSEUDO_ANONYMOUS,
+ null);
+ rr = onlyAuthChecker.check(ctx);
+ assertTrue(rr.matchFound());
+ ctx = new AccessCheckerContext(null, AuthenticationClass.CERTIFIED, null);
+ rr = onlyAuthChecker.check(ctx);
+ assertTrue(rr.matchFound());
+ }
+
+ @Test
+ public void testCmd() {
+ AccessCheckerContext ctx = new AccessCheckerContext(
+ new InfoboxReadCommandImpl(), null, null);
+ RuleResult rr = onlyCmdChecker.check(ctx);
+ assertTrue(rr.matchFound());
+ onlyCmdChecker.setCommandName("Info.*");
+ rr = onlyCmdChecker.check(ctx);
+ assertTrue(rr.matchFound());
+ ctx = new AccessCheckerContext(new NullOperationCommandImpl(), null, null);
+ rr = onlyCmdChecker.check(ctx);
+ assertFalse(rr.matchFound());
+ onlyCmdChecker.setCommandName(".*");
+ rr = onlyCmdChecker.check(ctx);
+ assertTrue(rr.matchFound());
+ }
+
+ @Test
+ public void testPeerId() {
+ AccessCheckerContext ctx = new AccessCheckerContext(null, null,
+ "https://129.27.142.20:80/index.html");
+ RuleResult rr = onlyPeerChecker.check(ctx);
+ assertTrue(rr.matchFound());
+
+ ctx = new AccessCheckerContext(null, null,
+ "https://129.27.14.20:80/index.html");
+ rr = onlyPeerChecker.check(ctx);
+ assertFalse(rr.matchFound());
+
+ onlyPeerChecker.setPeerId(".*.iaik..*", PEER_TYPE.HOST);
+ ctx = new AccessCheckerContext(null, null,
+ "https://129.27.142.20:80/index.html");
+ rr = onlyPeerChecker.check(ctx);
+ assertTrue(rr.matchFound());
+
+ onlyPeerChecker.setPeerId("129.27.142..*", PEER_TYPE.IP);
+ ctx = new AccessCheckerContext(null, null, "https://www.iaik.tugraz.at:80/");
+ rr = onlyPeerChecker.check(ctx);
+ assertTrue(rr.matchFound());
+ }
+
+}
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml
new file mode 100644
index 00000000..2455d68d
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+ certifiedGovAgency
+
+
+ allow
+
+ confirm
+
+
+ pseudoanonymous
+
+
+ Command
+
+ none
+
+
+ anonymous
+ 127.0.0.1
+
+ Command
+
+ none
+
+
+ anonymous
+ *.gv.at
+
+ allow
+
+ confirm
+
+
+
+
+
+
+ certified
+
+
+ IdentityLink
+ *
+
+
+ allow
+
+ confirm
+
+
+ certified
+ https://finanzonline.bmf.gv.at/*
+
+ Mandates
+ *
+
+
+ allow
+
+ info
+
+
+ certified
+
+
+
+ allow
+
+ none
+
+
+
+
+
--
cgit v1.2.3
From e0f2c64ad6360e2ecec983cb5e0a60f812672106 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Thu, 4 Sep 2008 14:56:54 +0000
Subject: finished access controller, accessed it from command invoker and
configured everything within onlinebku
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@14 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../egiz/bku/local/webapp/BKURequestHandler.java | 194 ++-
.../accesscontroller/SpringSecurityManager.java | 48 +
.../at/gv/egiz/bku/online/conf/Configurator.java | 47 +-
.../egiz/bku/online/conf/SpringConfigurator.java | 27 +
.../egiz/bku/online/webapp/BKURequestHandler.java | 177 ++-
.../egiz/bku/online/conf/accessControlConfig.xml | 98 ++
.../gv/egiz/bku/online/conf/defaultConf.properties | 3 +
.../src/main/webapp/WEB-INF/applicationContext.xml | 92 +-
.../main/webapp/applet/BKUApplet-1.0-SNAPSHOT.jar | Bin 0 -> 132767 bytes
.../main/webapp/applet/commons-logging-1.1.1.jar | Bin 0 -> 60686 bytes
.../src/main/webapp/applet/iaik_jce_me4se-3.04.jar | Bin 0 -> 99061 bytes
STALService/META-INF/MANIFEST.MF | 3 +
.../accesscontroller/AccessControllerFactory.java | 76 +-
.../gv/egiz/bku/accesscontroller/ChainChecker.java | 6 +-
.../bku/accesscontroller/CommandParamChecker.java | 52 +
.../bku/accesscontroller/InfoboxParamChecker.java | 58 +
.../bku/accesscontroller/InfoboxRuleChecker.java | 14 -
.../gv/egiz/bku/accesscontroller/RuleChecker.java | 72 +-
.../accesscontroller/SecurityManagerFacade.java | 102 ++
.../egiz/bku/binding/BindingProcessorManager.java | 15 +-
.../bku/binding/BindingProcessorManagerImpl.java | 20 +-
.../at/gv/egiz/bku/binding/DataUrlConnection.java | 17 +-
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 7 +-
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 1634 ++++++++++----------
.../gv/egiz/bku/binding/SLCommandInvokerImpl.java | 157 +-
.../gv/egiz/bku/slcommands/InfoboxReadCommand.java | 10 +-
.../gv/egiz/bku/slcommands/SLCommandInvoker.java | 7 +-
.../at/gv/egiz/bku/slcommands/SLSourceContext.java | 11 +-
.../at/gv/egiz/bku/slcommands/SLTargetContext.java | 13 +-
.../slcommands/impl/InfoboxReadCommandImpl.java | 7 +-
.../gv/egiz/bku/accesscontroller/ConfigTest.java | 91 +-
.../bku/binding/BindingProcessorManagerTest.java | 12 +-
.../gv/egiz/bku/binding/DataUrlConnectionTest.java | 22 +-
.../at/gv/egiz/bku/binding/ExpiryRemoverTest.java | 10 +-
.../egiz/bku/binding/HttpBindingProcessorTest.java | 2 +-
.../egiz/bku/binding/MultipartSLRequestTest.java | 5 +-
.../at/gv/egiz/bku/binding/NullOperationTest.java | 5 +-
.../gv/egiz/bku/binding/TestDataUrlConnection.java | 7 +-
.../bku/accesscontroller/AccessControlConfig.xml | 6 +-
.../egiz/bku/accesscontroller/SimpleChainTest.xml | 39 +
40 files changed, 1907 insertions(+), 1259 deletions(-)
create mode 100644 BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
create mode 100644 BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
create mode 100644 BKUOnline/src/main/webapp/applet/BKUApplet-1.0-SNAPSHOT.jar
create mode 100644 BKUOnline/src/main/webapp/applet/commons-logging-1.1.1.jar
create mode 100644 BKUOnline/src/main/webapp/applet/iaik_jce_me4se-3.04.jar
create mode 100644 STALService/META-INF/MANIFEST.MF
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/CommandParamChecker.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxParamChecker.java
delete mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/SecurityManagerFacade.java
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/SimpleChainTest.xml
(limited to 'bkucommon/src/main')
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
index 8529949d..f19b86b5 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
@@ -1,100 +1,96 @@
/*
-* 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.bku.local.webapp;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.web.HttpRequestHandler;
-
-import at.gv.egiz.bku.binding.BindingProcessorManager;
-import at.gv.egiz.bku.binding.HTTPBindingProcessor;
-import at.gv.egiz.bku.binding.HttpUtil;
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
-
-public abstract class BKURequestHandler extends HttpServlet {
-
- public final static String ENCODING = "UTF-8";
-
- protected Log log = LogFactory.getLog(BKURequestHandler.class);
-
- protected abstract BindingProcessorManager getBindingProcessorManager();
-
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, java.io.IOException {
- log.debug("Got new request");
- String lang = req.getHeader("Accept-Language");
- Locale locale = AcceptLanguage.getLocale(lang);
- log.debug("Using locale: "+locale);
- HTTPBindingProcessor bindingProcessor;
- if (req.isSecure()) {
- bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
- .createBindingProcessor("https", null, locale);
- } else {
- bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
- .createBindingProcessor("http", null, locale);
- }
- Map headerMap = new HashMap();
- for (Enumeration headerName = req.getHeaderNames(); headerName
- .hasMoreElements();) {
- String header = headerName.nextElement();
- if (header != null) {
- headerMap.put(header, req.getHeader(header));
- }
- }
- headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, req.getContentType()+";"+req.getCharacterEncoding());
- bindingProcessor.setHTTPHeaders(headerMap);
- bindingProcessor.consumeRequestStream(req.getInputStream());
-
- // fixxme just for testing
- bindingProcessor.run();
- if (bindingProcessor.getRedirectURL() != null) {
- resp.sendRedirect(bindingProcessor.getRedirectURL());
- return;
- }
- resp.setStatus(bindingProcessor.getResponseCode());
- for (Iterator it = bindingProcessor.getResponseHeaders().keySet()
- .iterator(); it.hasNext();) {
- String header = it.next();
- resp.setHeader(header, bindingProcessor.getResponseHeaders().get(header));
- }
- resp.setContentType(bindingProcessor.getResultContentType());
- resp.setCharacterEncoding(ENCODING);
- bindingProcessor.writeResultTo(resp.getOutputStream(), ENCODING);
- req.getInputStream().close();
- resp.getOutputStream().flush();
- resp.getOutputStream().close();
- log.debug("Finished Request");
- }
-
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, java.io.IOException {
- doPost(req, resp);
- }
-}
+ * 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.bku.local.webapp;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.web.HttpRequestHandler;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.binding.HTTPBindingProcessor;
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
+
+public abstract class BKURequestHandler extends HttpServlet {
+
+ public final static String ENCODING = "UTF-8";
+
+ protected Log log = LogFactory.getLog(BKURequestHandler.class);
+
+ protected abstract BindingProcessorManager getBindingProcessorManager();
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ log.debug("Got new request");
+ String lang = req.getHeader("Accept-Language");
+ Locale locale = AcceptLanguage.getLocale(lang);
+ log.debug("Using locale: " + locale);
+ HTTPBindingProcessor bindingProcessor;
+ bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
+ .createBindingProcessor(req.getRequestURL().toString(), null, locale);
+ Map headerMap = new HashMap();
+ for (Enumeration headerName = req.getHeaderNames(); headerName
+ .hasMoreElements();) {
+ String header = headerName.nextElement();
+ if (header != null) {
+ headerMap.put(header, req.getHeader(header));
+ }
+ }
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, req.getContentType() + ";"
+ + req.getCharacterEncoding());
+ bindingProcessor.setHTTPHeaders(headerMap);
+ bindingProcessor.consumeRequestStream(req.getInputStream());
+
+ // fixxme just for testing
+ bindingProcessor.run();
+ if (bindingProcessor.getRedirectURL() != null) {
+ resp.sendRedirect(bindingProcessor.getRedirectURL());
+ return;
+ }
+ resp.setStatus(bindingProcessor.getResponseCode());
+ for (Iterator it = bindingProcessor.getResponseHeaders().keySet()
+ .iterator(); it.hasNext();) {
+ String header = it.next();
+ resp.setHeader(header, bindingProcessor.getResponseHeaders().get(header));
+ }
+ resp.setContentType(bindingProcessor.getResultContentType());
+ resp.setCharacterEncoding(ENCODING);
+ bindingProcessor.writeResultTo(resp.getOutputStream(), ENCODING);
+ req.getInputStream().close();
+ resp.getOutputStream().flush();
+ resp.getOutputStream().close();
+ log.debug("Finished Request");
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ doPost(req, resp);
+ }
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
new file mode 100644
index 00000000..404e254e
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
@@ -0,0 +1,48 @@
+package at.gv.egiz.bku.online.accesscontroller;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+
+import at.gv.egiz.bku.accesscontroller.SecurityManagerFacade;
+import at.gv.egiz.bku.online.conf.Configurator;
+
+public class SpringSecurityManager extends SecurityManagerFacade implements
+ ResourceLoaderAware {
+
+ private ResourceLoader resourceLoader;
+
+ private static Log log = LogFactory.getLog(SpringSecurityManager.class);
+
+ protected Configurator config;
+
+ public void setConfig(Configurator config) {
+ this.config = config;
+ }
+
+ public void init() {
+ String noMatch = config.getProperty("AccessController.acceptNoMatch");
+ if (noMatch != null) {
+ log.debug("Setting allow now match to: " + noMatch);
+ setAllowUnmatched(Boolean.getBoolean(noMatch));
+ }
+ String policy = config.getProperty("AccessController.policyResource");
+ log.info("Loading resource: " + policy);
+ try {
+ Resource res = resourceLoader.getResource(policy);
+ init(res.getInputStream());
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+
+ @Override
+ public void setResourceLoader(ResourceLoader loader) {
+ this.resourceLoader = loader;
+ }
+
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
index 0cb717c4..f51335e1 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
@@ -16,29 +16,31 @@
*/
package at.gv.egiz.bku.online.conf;
-import iaik.security.ecc.provider.ECCProvider;
-import iaik.xml.crypto.XSecProvider;
-
-import java.net.HttpURLConnection;
-import java.security.Provider;
-import java.security.Security;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
+import iaik.security.ecc.provider.ECCProvider;
+import iaik.xml.crypto.XSecProvider;
+
+import java.net.HttpURLConnection;
+import java.security.Provider;
+import java.security.Security;
+import java.util.Properties;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
/**
*
* TODO currently only the code to get started.
*/
public class Configurator {
- private Log log = LogFactory.getLog(Configurator.class);
+ private Log log = LogFactory.getLog(Configurator.class);
+
+ protected Properties properties;
public Configurator() {
- configure();
}
protected void configUrlConnections() {
@@ -63,7 +65,18 @@ public class Configurator {
public void configure() {
configureProviders();
configUrlConnections();
-
}
-
+
+ public void setConfiguration(Properties props) {
+ this.properties = props;
+ configure();
+ }
+
+ public String getProperty(String key) {
+ if (properties != null) {
+ return properties.getProperty(key);
+ }
+ return null;
+ }
+
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
new file mode 100644
index 00000000..96588d7d
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
@@ -0,0 +1,27 @@
+package at.gv.egiz.bku.online.conf;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.Resource;
+
+public class SpringConfigurator extends Configurator {
+
+ private final static Log log = LogFactory.getLog(SpringConfigurator.class);
+
+ public void setResource(Resource resource) {
+ log.debug("Loading config from: " + resource);
+ if (resource != null) {
+ Properties props = new Properties();
+ try {
+ props.load(resource.getInputStream());
+ super.setConfiguration(props);
+ } catch (IOException e) {
+ log.error("Cannot load config", e);
+ }
+ }
+ }
+
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
index 53a7c164..20320d8e 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
@@ -1,91 +1,88 @@
/*
-* 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.bku.online.webapp;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.binding.HTTPBindingProcessor;
-import at.gv.egiz.bku.binding.HttpUtil;
-import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
-
-/**
- * Handles SL requests and instantiates BindingProcessors
- *
- */
-public class BKURequestHandler extends SpringBKUServlet {
-
- public final static String REDIRECT_URL ="appletPage.jsp";
-
- protected Log log = LogFactory.getLog(BKURequestHandler.class);
-
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, java.io.IOException {
- log.debug("Got new request");
- String lang = req.getHeader("Accept-Language");
- Locale locale = AcceptLanguage.getLocale(lang);
- log.debug("Using locale: "+locale);
- HttpSession session = req.getSession();
- if (session != null) {
- session.invalidate();
- }
- String id = req.getSession(true).getId();
- log.debug("Using session id: "+id);
- HTTPBindingProcessor bindingProcessor;
- if (req.isSecure()) {
- bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
- .createBindingProcessor("https", id, locale);
- } else {
- bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
- .createBindingProcessor("http", id, locale);
- }
- Map headerMap = new HashMap();
- for (Enumeration headerName = req.getHeaderNames(); headerName
- .hasMoreElements();) {
- String header = headerName.nextElement();
- if (header != null) {
- headerMap.put(header, req.getHeader(header));
- }
- }
- String charset = req.getCharacterEncoding();
- String contentType = req.getContentType();
- if (charset != null) {
- contentType += ";"+charset;
- }
- headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
- bindingProcessor.setHTTPHeaders(headerMap);
- bindingProcessor.consumeRequestStream(req.getInputStream());
- req.getInputStream().close();
- getBindingProcessorManager().process(bindingProcessor);
- resp.sendRedirect(REDIRECT_URL);
- }
-
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, java.io.IOException {
- doPost(req, resp);
- }
-}
+ * 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.bku.online.webapp;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.binding.HTTPBindingProcessor;
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
+
+/**
+ * Handles SL requests and instantiates BindingProcessors
+ *
+ */
+public class BKURequestHandler extends SpringBKUServlet {
+
+ public final static String REDIRECT_URL = "appletPage.jsp";
+
+ protected Log log = LogFactory.getLog(BKURequestHandler.class);
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ log.debug("Got new request");
+ String lang = req.getHeader("Accept-Language");
+ Locale locale = AcceptLanguage.getLocale(lang);
+ log.debug("Using locale: " + locale);
+ HttpSession session = req.getSession();
+ if (session != null) {
+ session.invalidate();
+ }
+ String id = req.getSession(true).getId();
+ log.debug("Using session id: " + id);
+ HTTPBindingProcessor bindingProcessor;
+
+ bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
+ .createBindingProcessor(req.getRequestURL().toString(), id, locale);
+
+ Map headerMap = new HashMap();
+ for (Enumeration headerName = req.getHeaderNames(); headerName
+ .hasMoreElements();) {
+ String header = headerName.nextElement();
+ if (header != null) {
+ headerMap.put(header, req.getHeader(header));
+ }
+ }
+ String charset = req.getCharacterEncoding();
+ String contentType = req.getContentType();
+ if (charset != null) {
+ contentType += ";" + charset;
+ }
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
+ bindingProcessor.setHTTPHeaders(headerMap);
+ bindingProcessor.consumeRequestStream(req.getInputStream());
+ req.getInputStream().close();
+ getBindingProcessorManager().process(bindingProcessor);
+ resp.sendRedirect(REDIRECT_URL);
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ doPost(req, resp);
+ }
+}
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
new file mode 100644
index 00000000..15d62155
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+ certifiedGovAgency
+
+
+ allow
+
+ confirm
+
+
+ pseudoanonymous
+
+
+ Command
+
+ none
+
+
+ anonymous
+ 127.0.0.1
+
+ Command
+
+ none
+
+
+ anonymous
+ $.gv.at
+
+ allow
+
+ confirm
+
+
+
+
+
+
+ certified
+
+
+ IdentityLink
+ .*
+
+
+ allow
+
+ confirm
+
+
+ certified
+ https://finanzonline.bmf.gv.at/*
+
+
+ Mandates
+ .*
+
+
+ allow
+
+ info
+
+
+ certified
+
+
+
+ allow
+
+ none
+
+
+ anonymous
+
+
+ 127.0.0.1
+
+ allow
+
+ none
+
+
+
+
+
+
+
+ allow
+
+
+
+
+
+
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
new file mode 100644
index 00000000..12deac35
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
@@ -0,0 +1,3 @@
+# Configuration for online CCE
+AccessController.acceptUnmatched=false
+AccessController.policyResource=classpath:at/gv/egiz/bku/online/conf/accessControlConfig.xml
\ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index 7a2f12b8..c5da25c0 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -1,43 +1,53 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/applet/BKUApplet-1.0-SNAPSHOT.jar b/BKUOnline/src/main/webapp/applet/BKUApplet-1.0-SNAPSHOT.jar
new file mode 100644
index 00000000..986842db
Binary files /dev/null and b/BKUOnline/src/main/webapp/applet/BKUApplet-1.0-SNAPSHOT.jar differ
diff --git a/BKUOnline/src/main/webapp/applet/commons-logging-1.1.1.jar b/BKUOnline/src/main/webapp/applet/commons-logging-1.1.1.jar
new file mode 100644
index 00000000..1deef144
Binary files /dev/null and b/BKUOnline/src/main/webapp/applet/commons-logging-1.1.1.jar differ
diff --git a/BKUOnline/src/main/webapp/applet/iaik_jce_me4se-3.04.jar b/BKUOnline/src/main/webapp/applet/iaik_jce_me4se-3.04.jar
new file mode 100644
index 00000000..f2173562
Binary files /dev/null and b/BKUOnline/src/main/webapp/applet/iaik_jce_me4se-3.04.jar differ
diff --git a/STALService/META-INF/MANIFEST.MF b/STALService/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..5e949512
--- /dev/null
+++ b/STALService/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
index 3b75a5f2..cd837cd7 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AccessControllerFactory.java
@@ -15,8 +15,9 @@ import at.gv.egiz.bku.accesscontrol.config.AccessControl;
import at.gv.egiz.bku.accesscontrol.config.Chain;
import at.gv.egiz.bku.accesscontrol.config.Command;
import at.gv.egiz.bku.accesscontrol.config.ObjectFactory;
+import at.gv.egiz.bku.accesscontrol.config.Param;
import at.gv.egiz.bku.accesscontrol.config.Rule;
-import at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl;
+import at.gv.egiz.bku.accesscontroller.RuleChecker.PEER_TYPE;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
public class AccessControllerFactory {
@@ -24,6 +25,8 @@ public class AccessControllerFactory {
private static AccessControllerFactory instance = new AccessControllerFactory();
private static Log log = LogFactory.getLog(AccessControllerFactory.class);
private static JAXBContext jaxbContext;
+ public static String INPUT_CHAIN = "InputChain";
+ public static String OUTPUT_CHAIN = "OutputChain";
static {
try {
@@ -63,43 +66,72 @@ public class AccessControllerFactory {
public void registerChainChecker(ChainChecker cc) {
chainTable.put(cc.getId(), cc);
}
-
+
+ public CommandParamChecker createParamChecker(String cmd) {
+ if ((cmd != null) && (cmd.startsWith("Infobox"))) {
+ return new InfoboxParamChecker();
+ } else {
+ return null;
+ }
+ }
+
public RuleChecker createRuleChecker(Rule rule) {
RuleChecker rc;
+ rc = new RuleChecker(rule.getId());
Command cmd = rule.getCommand();
if (cmd != null) {
- if ((cmd.getParam() != null) && (cmd.getParam().size()>0)) {
- if (cmd.getName().startsWith("Infobox")) {
- rc = new InfoboxRuleChecker(rule.getId());
- } else {
- throw new SLRuntimeException("Cannot handle parameters for command "+cmd.getName());
- }
- } else {
- rc = new RuleChecker(rule.getId());
+ rc.setCommandName(cmd.getName());
+ for (Param p : cmd.getParam()) {
+ rc.addParameter(p.getName(), p.getValue());
}
- } else {
- rc = new RuleChecker(rule.getId());
}
- // FIXME TODO cont. here
-
-
- return rc;
+ rc.setAuthenticationClass(rule.getAuthClass());
+ if (rule.getIPv4Address() != null) {
+ rc.setPeerId(rule.getIPv4Address(), PEER_TYPE.IP);
+ } else if (rule.getDomainName() != null) {
+ rc.setPeerId(rule.getDomainName(), PEER_TYPE.HOST);
+ } else if (rule.getURL() != null) {
+ rc.setPeerId(rule.getURL(), PEER_TYPE.URL);
+ }
+ rc.setAction(rule.getAction().getRuleAction());
+ rc.setChainId(rule.getAction().getChainRef());
+ rc.setUserAction(rule.getUserInteraction());
+ return rc;
}
-
-
+
public void init(InputStream is) throws JAXBException {
+ chainTable.clear();
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
AccessControl ac = (AccessControl) unmarshaller.unmarshal(is);
List chainList = ac.getChains().getChain();
- log.debug("Found "+chainList.size()+" chains in config");
+ log.debug("Found " + chainList.size() + " chains in config");
for (Chain chain : chainList) {
+ log.trace("Creating chain: " + chain.getId());
+ ChainChecker cc = createChainChecker(chain.getId(), false);
List ruleList = chain.getRules().getRule();
- log.debug("Found "+ruleList.size()+" rules in chain "+chain.getId());
+ log
+ .debug("Found " + ruleList.size() + " rules in chain "
+ + chain.getId());
for (Rule rule : ruleList) {
- //rule.g
+ log.trace("Creating rule: " + rule.getId());
+ cc.addRule(createRuleChecker(rule));
+ }
+ registerChainChecker(cc);
+ }
+ validate();
+ }
+
+ private void validate() {
+ for (ChainChecker chain : chainTable.values()) {
+ for (RuleChecker rule : chain.getRules()) {
+ if (rule.getChainId() != null) {
+ log.trace("Checking reference to chain: "+rule.getChainId());
+ if (getChainChecker(rule.getChainId()) == null) {
+ throw new SLRuntimeException("Invalid reference to unknown chain: "+rule.getChainId());
+ }
+ }
}
}
-
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java
index 242d9b02..a290fe8d 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/ChainChecker.java
@@ -1,5 +1,6 @@
package at.gv.egiz.bku.accesscontroller;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -35,6 +36,10 @@ public class ChainChecker implements AccessChecker {
rules.add(rule);
}
}
+
+ public List getRules() {
+ return Collections.unmodifiableList(rules);
+ }
@Override
public ChainResult check(AccessCheckerContext checkCtx) throws SLException {
@@ -43,7 +48,6 @@ public class ChainChecker implements AccessChecker {
log.trace("Checking rule: "+rule.getId());
RuleResult result = rule.check(checkCtx);
if (result.matchFound()) {
- log.debug("Found matching rule: "+rule.getId());
if (result.getDelegateChainId() != null) {
// process chain
ChainChecker cc = AccessControllerFactory.getInstance().getChainChecker(result.getDelegateChainId());
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/CommandParamChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/CommandParamChecker.java
new file mode 100644
index 00000000..3927c3c9
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/CommandParamChecker.java
@@ -0,0 +1,52 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import at.gv.egiz.bku.slcommands.SLCommand;
+
+public abstract class CommandParamChecker {
+
+ protected List> paramList = new LinkedList>();
+
+ public static class Tupel {
+ private T key;
+ private Q val;
+
+ public Tupel(T key, Q val) {
+ if ((key == null) || (val == null)) {
+ throw new NullPointerException("Tupel key and value must not be null");
+ }
+ this.key = key;
+ this.val = val;
+ }
+
+ public T getKey() {
+ return key;
+ }
+
+ public Q getVal() {
+ return val;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean equals(Object other) {
+ if (other instanceof Tupel) {
+ Tupel ot = (Tupel) other;
+ return (key.equals(ot.key) && val.equals(ot.val));
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return key.hashCode();
+ }
+ }
+
+ public void addParameter(String key, String value) {
+ paramList.add(new Tupel(key, value));
+ }
+
+ public abstract boolean checkParameter(SLCommand cmd);
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxParamChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxParamChecker.java
new file mode 100644
index 00000000..33689ae0
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxParamChecker.java
@@ -0,0 +1,58 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+public class InfoboxParamChecker extends CommandParamChecker {
+ private static Log log = LogFactory.getLog(InfoboxParamChecker.class);
+
+ public final static String INFOBOX_ID = "InfoboxIdentifier";
+ public final static String PERSON_ID = "PersonIdentifier";
+ public final static String DERIVED = "derived";
+
+ @Override
+ public boolean checkParameter(SLCommand cmd) {
+ if (paramList.size() == 0) {
+ return true;
+ }
+
+ if (cmd instanceof InfoboxReadCommand) {
+ InfoboxReadCommand irc = (InfoboxReadCommand) cmd;
+ for (Tupel param : paramList) {
+ if (param.getKey().equals(INFOBOX_ID)) {
+ if (!param.getVal().equals(irc.getInfoboxIdentifier())) {
+ return false;
+ }
+ } else if (param.getKey().equals(PERSON_ID)) {
+ if (param.getVal().equals(DERIVED)) {
+ if (irc.getIdentityLinkDomainId() == null) {
+ return false;
+ }
+ } else {
+ Pattern p = Pattern.compile(param.getVal());
+ Matcher m = p.matcher(irc.getIdentityLinkDomainId());
+ if (!m.matches()) {
+ return false;
+ }
+ }
+
+ } else {
+ throw new SLRuntimeException("Cannot handle parameter "
+ + param.getKey());
+ }
+ }
+ return true;
+ } else {
+ log.error("Cannot handle parameter for command: " + cmd.getName());
+ throw new SLRuntimeException("Cannot handle parameters for command: "
+ + cmd.getName());
+ }
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java
deleted file mode 100644
index 2981d24e..00000000
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/InfoboxRuleChecker.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package at.gv.egiz.bku.accesscontroller;
-
-/**
- * Adds infobox parameter checks
- * @author wbauer
- *
- */
-public class InfoboxRuleChecker extends RuleChecker {
-
- public InfoboxRuleChecker(String id) {
- super(id);
- }
-
-}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
index c59f5b70..b0bf7fac 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/RuleChecker.java
@@ -31,6 +31,7 @@ public class RuleChecker implements AccessChecker {
protected Action action;
protected UserAction userAction;
protected String chainId;
+ protected CommandParamChecker paramChecker;
public RuleChecker(String id) {
if (id == null) {
@@ -40,27 +41,33 @@ public class RuleChecker implements AccessChecker {
}
public void setAuthenticationClass(String ac) {
- AuthenticationClass tmp = AuthenticationClass.fromString(ac);
- if (tmp == null) {
- throw new SLRuntimeException("Unknown authentication class " + ac);
+ if (ac != null) {
+ AuthenticationClass tmp = AuthenticationClass.fromString(ac);
+ if (tmp == null) {
+ throw new SLRuntimeException("Unknown authentication class " + ac);
+ }
+ authenticationClass = tmp;
}
- authenticationClass = tmp;
}
public void setAction(String ac) {
- Action tmp = Action.fromString(ac);
- if (tmp == null) {
- throw new SLRuntimeException("Unknown action " + ac);
+ if (ac != null) {
+ Action tmp = Action.fromString(ac);
+ if (tmp == null) {
+ throw new SLRuntimeException("Unknown action " + ac);
+ }
+ action = tmp;
}
- action = tmp;
}
public void setUserAction(String uac) {
- UserAction tmp = UserAction.fromString(uac);
- if (tmp == null) {
- throw new SLRuntimeException("Unknown user action " + uac);
+ if (uac != null) {
+ UserAction tmp = UserAction.fromString(uac);
+ if (tmp == null) {
+ throw new SLRuntimeException("Unknown user action " + uac);
+ }
+ userAction = tmp;
}
- userAction = tmp;
}
public void setChainId(String chainId) {
@@ -76,6 +83,22 @@ public class RuleChecker implements AccessChecker {
public void setCommandName(String commandName) {
this.commandName = commandName;
commandNamePattern = Pattern.compile(commandName);
+ paramChecker = AccessControllerFactory.getInstance().createParamChecker(
+ commandName);
+ }
+
+ /**
+ * Make sure to set the commandName first
+ *
+ * @param key
+ * @param value
+ */
+ public void addParameter(String key, String value) {
+ if (paramChecker == null) {
+ throw new IllegalArgumentException("Cannot set parameters for command "
+ + commandName);
+ }
+ paramChecker.addParameter(key, value);
}
public String getId() {
@@ -83,22 +106,30 @@ public class RuleChecker implements AccessChecker {
}
protected boolean matchAuthenticationClass(AuthenticationClass cls) {
- if (this.authenticationClass == null) {
+ if ((this.authenticationClass == null) || (cls == null)) {
return true;
}
return this.authenticationClass.compareTo(cls) <= 0;
}
protected boolean matchCommandName(SLCommand cmd) {
- if (commandName == null) {
+ if ((commandName == null) || (cmd == null)) {
return true;
}
Matcher matcher = commandNamePattern.matcher(cmd.getName());
- return matcher.matches();
+ if (matcher.matches()) {
+ if (paramChecker != null) {
+ return paramChecker.checkParameter(cmd);
+ } else {
+ return true;
+ }
+ } else {
+ return false;
+ }
}
protected boolean matchPeerId(String peerUrl) {
- if (peerId == null) {
+ if ((peerId == null) || (peerUrl == null)) {
return true;
}
if (peerType == PEER_TYPE.URL) {
@@ -110,7 +141,8 @@ public class RuleChecker implements AccessChecker {
if (peerType == PEER_TYPE.HOST) {
try {
String host = url.getHost();
- String hostName = InetAddress.getByName(host).getCanonicalHostName();
+ String hostName = InetAddress.getByName(host)
+ .getCanonicalHostName();
Matcher matcher = peerIdPattern.matcher(hostName);
return matcher.matches();
} catch (UnknownHostException e) {
@@ -143,9 +175,13 @@ public class RuleChecker implements AccessChecker {
&& matchPeerId(checkCtx.getPeerUrl())) {
log.debug("Match found for rule: " + id);
return new RuleResult(action, userAction, true, chainId);
- }
+ }
log.debug("No match found for rule: " + id);
return new RuleResult(action, userAction, false, chainId);
}
+ public String getChainId() {
+ return chainId;
+ }
+
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/SecurityManagerFacade.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/SecurityManagerFacade.java
new file mode 100644
index 00000000..32242772
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/SecurityManagerFacade.java
@@ -0,0 +1,102 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLSourceContext;
+import at.gv.egiz.bku.slcommands.SLTargetContext;
+
+/**
+ * Facade for the access controller
+ */
+public class SecurityManagerFacade {
+
+ private static Log log = LogFactory.getLog(SecurityManagerFacade.class);
+
+ private boolean allowUnmatched = false;
+ private ChainChecker inputFilter = null;
+ private ChainChecker outputFilter = null;
+
+ public boolean mayInvokeCommand(SLCommand cmd, SLSourceContext ctx) {
+ if (inputFilter != null) {
+ AuthenticationClass ac = AuthenticationClassifier.getAuthenticationClass(
+ ctx.isSourceIsDataURL(), ctx.getSourceUrl(), ctx
+ .getSourceCertificate());
+ AccessCheckerContext acc = new AccessCheckerContext(cmd, ac, ctx
+ .getSourceUrl().toString());
+ try {
+ ChainResult cr = inputFilter.check(acc);
+ if (cr.matchFound()) {
+ if (cr.getAction() == Action.ALLOW) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return allowUnmatched;
+ }
+ } catch (Exception e) {
+ log.error(e);
+ return false;
+ }
+ } else {
+ log.warn("No input chain defined");
+ return allowUnmatched;
+ }
+ }
+
+ public boolean maySendResult(SLCommand cmd, SLTargetContext ctx) {
+ if (outputFilter != null) {
+ AuthenticationClass ac = AuthenticationClassifier.getAuthenticationClass(
+ ctx.isTargetIsDataURL(), ctx.getTargetUrl(), ctx
+ .getTargetCertificate());
+ AccessCheckerContext acc = new AccessCheckerContext(cmd, ac, ctx
+ .getTargetUrl().toString());
+ try {
+ ChainResult cr = outputFilter.check(acc);
+ if (cr.matchFound()) {
+ if (cr.getAction() == Action.ALLOW) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return allowUnmatched;
+ }
+ } catch (Exception e) {
+ log.error(e);
+ return false;
+ }
+ } else {
+ log.warn("No output chain defined");
+ return allowUnmatched;
+ }
+ }
+
+ /**
+ * Default policy if not match was found
+ *
+ * @param allow
+ */
+ public void setAllowUnmatched(boolean allow) {
+ this.allowUnmatched = allow;
+ }
+
+ public void init(InputStream is) {
+ inputFilter = null;
+ outputFilter = null;
+ AccessControllerFactory fab = AccessControllerFactory.getInstance();
+ try {
+ fab.init(is);
+ } catch (JAXBException e) {
+ log.error(e);
+ }
+ inputFilter = fab.getChainChecker(AccessControllerFactory.INPUT_CHAIN);
+ outputFilter = fab.getChainChecker(AccessControllerFactory.OUTPUT_CHAIN);
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
index a4e5bd90..ed37f08f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
@@ -16,6 +16,7 @@
*/
package at.gv.egiz.bku.binding;
+import java.net.MalformedURLException;
import java.util.Locale;
import java.util.Set;
@@ -34,28 +35,28 @@ public interface BindingProcessorManager {
* FactoryMethod creating a new BindingProcessor object.
* The created binding processor must be passed to the process method to execute.
*
- * @param protcol
- * the transport binding protocol
+ * @param urlString
+ * the source url
* @param aSessionId
* optional an external sessionId (e.g. http session) could be
* provided. This parameter may be null.
* @param locale the locale used for user interaction, may be null
*/
- public BindingProcessor createBindingProcessor(String protcol,
- String aSessionId, Locale locale);
+ public BindingProcessor createBindingProcessor(String urlString,
+ String aSessionId, Locale locale) throws MalformedURLException;
/**
* FactoryMethod creating a new BindingProcessor object.
* The created binding processor must be passed to the process method to execute.
*
* @param protcol
- * the transport binding protocol
+ * the source url
* @param aSessionId
* optional an external sessionId (e.g. http session) could be
* provided. This parameter may be null.
*/
- public BindingProcessor createBindingProcessor(String protcol,
- String aSessionId);
+ public BindingProcessor createBindingProcessor(String urlString,
+ String aSessionId) throws MalformedURLException;
/**
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 7a3b1bb9..6f5ca2d2 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -16,6 +16,8 @@
*/
package at.gv.egiz.bku.binding;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -152,20 +154,22 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
/**
* Uses the default locale
*/
- public BindingProcessor createBindingProcessor(String protocol,
- String aSessionId) {
- return createBindingProcessor(protocol, aSessionId, null);
+ public BindingProcessor createBindingProcessor(String srcUrl,
+ String aSessionId) throws MalformedURLException {
+ return createBindingProcessor(srcUrl, aSessionId, null);
}
/**
* FactoryMethod creating a new BindingProcessor object.
*
* @param protocol
- * must not be null
+ * must not be null
+ * @throws MalformedURLException
*/
- public BindingProcessor createBindingProcessor(String protocol,
- String aSessionId, Locale locale) {
- String low = protocol.toLowerCase();
+ public BindingProcessor createBindingProcessor(String srcUrl,
+ String aSessionId, Locale locale) throws MalformedURLException {
+ URL url = new URL(srcUrl);
+ String low = url.getProtocol().toLowerCase();
Protocol proto = null;
for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
if (SUPPORTED_PROTOCOLS[i].toString().equals(low)) {
@@ -177,7 +181,7 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
throw new UnsupportedOperationException();
}
BindingProcessor bindingProcessor = new HTTPBindingProcessor(aSessionId,
- commandInvokerClass.newInstance(), proto);
+ commandInvokerClass.newInstance(), url);
STAL stal = stalFactory.createSTAL();
bindingProcessor.init(stal, commandInvokerClass.newInstance());
if (locale != null) {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
index e6d5e075..6d654639 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
@@ -16,12 +16,13 @@
*/
package at.gv.egiz.bku.binding;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.SocketTimeoutException;
-import java.security.cert.X509Certificate;
-
-import at.gv.egiz.bku.slcommands.SLResult;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+
+import at.gv.egiz.bku.slcommands.SLResult;
/**
* Transmit a security layer result to DataURL via HTTP POST, encoded as multipart/form-data.
@@ -41,7 +42,9 @@ public interface DataUrlConnection {
public static final String XML_RESPONSE_ENCODING = "UTF-8";
- public String getProtocol();
+ public String getProtocol();
+
+ public URL getUrl();
/**
* Set a HTTP Header.
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
index 134d765e..9f5d70cb 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -212,5 +212,10 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
@Override
public DataUrlConnectionSPI newInstance() {
return new DataUrlConnectionImpl();
- }
+ }
+
+ @Override
+ public URL getUrl() {
+ return url;
+ }
}
\ 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 b79f7d55..19f22126 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
@@ -1,820 +1,818 @@
/*
-* 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.bku.binding;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.net.ssl.SSLHandshakeException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandContext;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
-import at.gv.egiz.bku.slcommands.SLCommandInvoker;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slcommands.SLSourceContext;
-import at.gv.egiz.bku.slcommands.SLTargetContext;
-import at.gv.egiz.bku.slcommands.impl.ErrorResultImpl;
-import at.gv.egiz.bku.slexceptions.SLBindingException;
-import at.gv.egiz.bku.slexceptions.SLCanceledException;
-import at.gv.egiz.bku.slexceptions.SLException;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.bku.utils.binding.Protocol;
-import at.gv.egiz.bku.utils.urldereferencer.FormDataURLSupplier;
-import at.gv.egiz.bku.utils.urldereferencer.SimpleFormDataContextImpl;
-import at.gv.egiz.bku.utils.urldereferencer.StreamData;
-import at.gv.egiz.bku.utils.urldereferencer.URIResolverAdapter;
-import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
-import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
-import at.gv.egiz.stal.QuitRequest;
-import at.gv.egiz.stal.STALRequest;
-
-/**
- * Class performing the HTTP binding as defined by the CCE specification.
- * Currently a huge monolithic class.
- * @TODO refactor
- */
-@SuppressWarnings("unchecked")
-public class HTTPBindingProcessor extends AbstractBindingProcessor implements
- FormDataURLSupplier {
-
- private static Log log = LogFactory.getLog(HTTPBindingProcessor.class);
-
- private static enum State {
- INIT, PROCESS, DATAURL, TRANSFORM, FINISHED
- };
-
- public final static Collection XML_REQ_TRANSFER_ENCODING = Arrays
- .asList(new String[] { "binary" });
-
- /**
- * Defines the maximum number of dataurl connects that are allowed within a
- * single SL Request processing.
- */
- protected static int MAX_DATAURL_HOPS = 10;
-
- protected static String XML_MIME_TYPE = "text/xml";
- protected static String BINARY_MIME_TYPE = "application/octet-stream";
-
- /**
- * If null everything is ok and the result is taken from the command invoker.
- */
- protected SLException bindingProcessorError;
- protected SLCommandInvoker commandInvoker;
- protected DataUrlResponse dataUrlResponse;
- protected Map headerMap = Collections.EMPTY_MAP;
- protected SLCommand slCommand;
- protected Map formParameterMap = new HashMap();
- protected SLSourceContext srcContex = new SLSourceContext();
- protected SLTargetContext targetContext = new SLTargetContext();
- protected Protocol protocol;
- protected State currentState = State.INIT;
- protected Transformer transformer = null;
- protected String resultContentType = null;
- protected SLResult slResult = null;
- protected int responseCode = 200;
- protected Map responseHeaders = Collections.EMPTY_MAP;
- protected Locale locale = Locale.getDefault();
-
- /**
- *
- * @param id
- * may be null. In this case a new session id will be created.
- * @param cmdInvoker
- * must not be null;
- */
- public HTTPBindingProcessor(String id, SLCommandInvoker cmdInvoker,
- Protocol protocol) {
- super(id);
- if ((protocol != Protocol.HTTP) && (protocol != Protocol.HTTPS)) {
- throw new SLRuntimeException("Protocol not supported: " + protocol);
- }
- if (cmdInvoker == null) {
- throw new NullPointerException("Commandinvoker cannot be set to null");
- }
- commandInvoker = cmdInvoker;
- this.protocol = protocol;
- srcContex.setSourceProtocol(protocol);
- srcContex.setSourceIsDataURL(false);
- }
-
- //----------------------------------------------------------------------------
- // ----------- BEGIN CONVENIENCE METHODS -----------
-
- protected void sendSTALQuit() {
- log.info("Sending QUIT command to STAL");
- List quit = new ArrayList(1);
- quit.add(new QuitRequest());
- getSTAL().handleRequest(quit);
- }
-
- protected String getFormParameterAsString(String formParameterName) {
- FormParameter fp = formParameterMap.get(formParameterName);
- return getFormParameterAsString(fp);
- }
-
- protected String getFormParameterAsString(FormParameter fp) {
- if (fp == null) {
- return null;
- }
- try {
- return StreamUtil.asString(fp.getFormParameterValue(), HttpUtil
- .getCharset(fp.getFormParameterContentType(), true));
- } catch (IOException e) {
- return null;
- }
- }
-
- protected String getDataUrl() {
- return getFormParameterAsString(FixedFormParameters.DATAURL);
- }
-
- protected String getStyleSheetUrl() {
- return getFormParameterAsString(FixedFormParameters.STYLESHEETURL);
- }
-
- protected List getFormParameters(String parameterNamePostfix) {
- List resultList = new ArrayList();
- for (Iterator fpi = formParameterMap.keySet().iterator(); fpi
- .hasNext();) {
- String paramName = fpi.next();
- if (paramName.endsWith(parameterNamePostfix)) {
- resultList.add(formParameterMap.get(paramName));
- }
- }
- return resultList;
- }
-
- protected List getTransferHeaders() {
- return getFormParameters("__");
- }
-
- protected List getTransferForms() {
- List resultList = new ArrayList();
- for (Iterator fpi = formParameterMap.keySet().iterator(); fpi
- .hasNext();) {
- String paramName = fpi.next();
- if ((paramName.endsWith("_")) && (!paramName.endsWith("__"))) {
- resultList.add(formParameterMap.get(paramName));
- }
- }
- return resultList;
- }
-
- protected void closeDataUrlConnection() {
- log.debug("Closing data url input stream");
- if (dataUrlResponse == null) {
- return;
- }
- InputStream is = dataUrlResponse.getStream();
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- log.info("Error closing input stream to dataurl server:" + e);
- }
- }
- }
-
- //----------------------------------------------------------------------------
- // ----------- END CONVENIENCE METHODS -----------
-
- //----------------------------------------------------------------------------
- // -- BEGIN Methods that handle the http binding activities as defined in the
- // activity diagram --
-
- protected void init() {
- log.info("Starting Bindingprocessor in Thread: "
- + Thread.currentThread().getId());
- if (bindingProcessorError != null) {
- log.debug("Detected binding processor error, sending quit command");
- // sendSTALQuit();
- currentState = State.FINISHED;
- } else if (slCommand == null) {
- log.error("SLCommand not set (consumeRequest not called ??)");
- bindingProcessorError = new SLException(2000);
- // sendSTALQuit();
- currentState = State.FINISHED;
- } else {
- currentState = State.PROCESS;
- }
- }
-
- protected void processRequest() {
- log.debug("Entered State: " + State.PROCESS);
- log.debug("Processing command: " + slCommand);
- commandInvoker.setCommand(slCommand);
- responseCode = 200;
- responseHeaders = Collections.EMPTY_MAP;
- try {
- commandInvoker.invoke(srcContex);
- } catch (SLCanceledException e) {
- log.info("Caught exception: " + e);
- bindingProcessorError = e;
- currentState = State.TRANSFORM;
- }
- dataUrlResponse = null;
- if (getDataUrl() != null) {
- log.debug("Data Url set to: " + getDataUrl());
- currentState = State.DATAURL;
- } else {
- log.debug("No data url set");
- currentState = State.TRANSFORM;
- }
- }
-
- protected void handleDataUrl() {
- log.debug("Entered State: " + State.DATAURL);
- try {
- DataUrl dataUrl = new DataUrl(getDataUrl());
- DataUrlConnection conn = dataUrl.openConnection();
-
- // set transfer headers
- for (FormParameter fp : getTransferHeaders()) {
- String paramString = getFormParameterAsString(fp);
- if (paramString == null) {
- log.error("Got empty transfer header, ignoring this");
- } else {
- String[] keyVal = paramString.split(":", 2);
- String key = keyVal[0];
- String val = null;
- if (keyVal.length == 2) {
- val = keyVal[1];
- }
- val = val.trim();
- log.debug("Setting header " + key + " to value " + val);
- conn.setHTTPHeader(key, val);
- }
- }
-
- // set transfer form parameters
- for (FormParameter fp : getTransferForms()) {
- String contentTransferEncoding = null;
- String contentType = fp.getFormParameterContentType();
- String charSet = HttpUtil.getCharset(contentType, false);
- if (charSet != null) {
- contentType = contentType.substring(0, contentType
- .lastIndexOf(HttpUtil.SEPERATOR[0]));
- }
- for (Iterator header = fp.getHeaderNames(); header.hasNext();) {
- if (HttpUtil.CONTENT_TRANSFER_ENCODING
- .equalsIgnoreCase(header.next())) {
- contentTransferEncoding = getFormParameterAsString(fp);
- }
- }
- log.debug("Setting form: " + fp.getFormParameterName()
- + " contentType: " + contentType + " charset: " + charSet
- + " contentTransferEncoding: " + contentTransferEncoding);
- conn.setHTTPFormParameter(fp.getFormParameterName(), fp
- .getFormParameterValue(), contentType, charSet,
- contentTransferEncoding);
- }
-
- // connect
- conn.connect();
- // fetch and set SL result
- targetContext.setTargetIsDataURL(true);
- targetContext.setTargetCertificate(conn.getServerCertificate());
- targetContext.setTargetProtocol(conn.getProtocol());
- SLResult result = commandInvoker.getResult(targetContext);
-
- // transfer result
- conn.transmit(result);
-
- // process Dataurl response
- dataUrlResponse = conn.getResponse();
- log.debug("Received data url response code: "
- + dataUrlResponse.getResponseCode());
- protocol = Protocol.fromString(conn.getProtocol());
-
- switch (dataUrlResponse.getResponseCode()) {
- case 200:
- String contentType = dataUrlResponse.getContentType();
- log.debug("Got dataurl response content type: " + contentType);
- if (contentType != null) {
- if ((contentType.startsWith(HttpUtil.APPLICATION_URL_ENCODED))
- || (contentType.startsWith(HttpUtil.MULTIPART_FOTMDATA))) {
- log.debug("Detected SL Request in dataurl response");
- // process headers and request
- setHTTPHeaders(dataUrlResponse.getResponseHeaders());
- consumeRequestStream(dataUrlResponse.getStream());
- closeDataUrlConnection();
- srcContex.setSourceCertificate(conn.getServerCertificate());
- srcContex.setSourceIsDataURL(true);
- srcContex
- .setSourceProtocol(Protocol.fromString(conn.getProtocol()));
- currentState = State.PROCESS;
- } else if (((contentType.startsWith(HttpUtil.TXT_HTML))
- || (contentType.startsWith(HttpUtil.TXT_PLAIN)) || (contentType
- .startsWith(HttpUtil.TXT_XML)))
- && (dataUrlResponse.isHttpResponseXMLOK())) {
- log.info("Dataurl response matches with content type: "
- + contentType);
- currentState = State.TRANSFORM;
-
- } else if ((contentType.startsWith(HttpUtil.TXT_XML))
- && (!dataUrlResponse.isHttpResponseXMLOK())) {
- log
- .debug("Detected text/xml dataurl response with content != ");
- headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
- assignXMLRequest(dataUrlResponse.getStream(), HttpUtil.getCharset(
- contentType, true));
- closeDataUrlConnection();
- srcContex.setSourceCertificate(conn.getServerCertificate());
- srcContex.setSourceIsDataURL(true);
- srcContex
- .setSourceProtocol(Protocol.fromString(conn.getProtocol()));
- currentState = State.PROCESS;
- // just to be complete, actually not used
- srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders()
- .get(HttpUtil.HTTP_HEADER_REFERER));
- } else {
- resultContentType = contentType;
- responseHeaders = dataUrlResponse.getResponseHeaders();
- responseCode = dataUrlResponse.getResponseCode();
- currentState = State.FINISHED;
- }
- } else {
- log.debug("Content type not set in dataurl response");
- closeDataUrlConnection();
- throw new SLBindingException(2007);
- }
-
- break;
- case 307:
- contentType = dataUrlResponse.getContentType();
- if ((contentType != null) && (contentType.startsWith(HttpUtil.TXT_XML))) {
- log.debug("Received dataurl response code 307 with XML content");
- String location = dataUrlResponse.getResponseHeaders().get(
- HttpUtil.HTTP_HEADER_LOCATION);
- if (location == null) {
- log
- .error("Did not get a location header for a 307 data url response");
- throw new SLBindingException(2003);
- }
- // consumeRequestStream(dataUrlResponse.getStream());
- FormParameterStore fp = new FormParameterStore();
- fp.init(location.getBytes(HttpUtil.DEFAULT_CHARSET),
- FixedFormParameters.DATAURL, null, null);
- formParameterMap.put(FixedFormParameters.DATAURL, fp);
- headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
- assignXMLRequest(dataUrlResponse.getStream(), HttpUtil.getCharset(
- dataUrlResponse.getContentType(), true));
- closeDataUrlConnection();
- srcContex.setSourceCertificate(conn.getServerCertificate());
- srcContex.setSourceIsDataURL(true);
- srcContex.setSourceProtocol(Protocol.fromString(conn.getProtocol()));
- currentState = State.PROCESS;
- // just to be complete, actually not used
- 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;
-
- case 301:
- case 302:
- case 303:
- responseHeaders = dataUrlResponse.getResponseHeaders();
- responseCode = dataUrlResponse.getResponseCode();
- resultContentType = dataUrlResponse.getContentType();
- currentState = State.FINISHED;
- break;
-
- default:
- // issue error
- log.info("Unexpected response code from dataurl server: "
- + dataUrlResponse.getResponseCode());
- throw new SLBindingException(2007);
- }
-
- } catch (SLException slx) {
- bindingProcessorError = slx;
- log.error("Error during dataurl communication");
- resultContentType = HttpUtil.TXT_XML;
- currentState = State.TRANSFORM;
- } catch (SSLHandshakeException hx) {
- bindingProcessorError = new SLException(2010);
- log.info("Error during dataurl communication", hx);
- resultContentType = HttpUtil.TXT_XML;
- currentState = State.TRANSFORM;
- } catch (IOException e) {
- bindingProcessorError = new SLBindingException(2001);
- log.error("Error while data url handling", e);
- resultContentType = HttpUtil.TXT_XML;
- currentState = State.TRANSFORM;
- return;
- }
- }
-
- protected void transformResult() {
- log.debug("Entered State: " + State.TRANSFORM);
- if (bindingProcessorError != null) {
- resultContentType = HttpUtil.TXT_XML;
- } else if (dataUrlResponse != null) {
- resultContentType = dataUrlResponse.getContentType();
- } else {
- targetContext.setTargetIsDataURL(false);
- targetContext.setTargetProtocol(protocol.toString());
- try {
- slResult = commandInvoker.getResult(targetContext);
- resultContentType = slResult.getMimeType();
- log
- .debug("Successfully got SLResult from commandinvoker, setting mimetype to: "
- + resultContentType);
- } catch (SLCanceledException e) {
- log.info("Cannot get result from invoker:", e);
- bindingProcessorError = new SLException(6002);
- resultContentType = HttpUtil.TXT_XML;
- }
- }
- transformer = getTransformer(getStyleSheetUrl());
- if (transformer != null) {
- log.debug("Output transformation required");
- resultContentType = transformer.getOutputProperty("media-type");
- log.debug("Got media type from stylesheet: " + resultContentType);
- if (resultContentType == null) {
- log.debug("Setting to default text/xml result conent type");
- resultContentType = "text/xml";
- }
- log.debug("Deferring sytylesheet processing");
- }
- currentState = State.FINISHED;
- }
-
- protected void finished() {
- log.debug("Entered State: " + State.FINISHED);
- if (bindingProcessorError != null) {
- log.debug("Binding processor error, sending quit command");
- resultContentType = HttpUtil.TXT_XML;
- }
- sendSTALQuit();
- log.info("Terminating Bindingprocessor; Thread: "
- + Thread.currentThread().getId());
- }
-
- // -- END Methods that handle the http binding activities as defined in the
- // activity diagram --
- //----------------------------------------------------------------------------
-
- /**
- * Sets the headers of the SL Request. IMPORTANT: make sure to set all headers
- * before invoking {@link #consumeRequestStream(InputStream)}
- *
- * @param aHeaderMap
- * if null all header will be cleared.
- */
- public void setHTTPHeaders(Map aHeaderMap) {
- headerMap = new HashMap();
- // ensure lowercase keys
- if (aHeaderMap != null) {
- for (String s : aHeaderMap.keySet()) {
- if (s != null) {
- headerMap.put(s.toLowerCase(), aHeaderMap.get(s));
- if (s.equalsIgnoreCase(HttpUtil.HTTP_HEADER_REFERER)) {
- String referer = aHeaderMap.get(s);
- log.debug("Got referer header: " + referer);
- srcContex.setSourceHTTPReferer(referer);
- }
- }
- }
- }
- }
-
- public void setSourceCertificate(X509Certificate aCert) {
- srcContex.setSourceCertificate(aCert);
- }
-
- /**
- * The HTTPBindingProcessor does not handle redirect URLs. It only provides
- * the parameter.
- *
- * @return null if redirect url is not set.
- */
- public String getRedirectURL() {
- return getFormParameterAsString(FixedFormParameters.REDIRECTURL);
- }
-
- public String getFormDataContentType(String aParameterName) {
- FormParameter fp = formParameterMap.get(aParameterName);
- if (fp != null) {
- return fp.getFormParameterContentType();
- }
- return null;
- }
-
- public InputStream getFormData(String aParameterName) {
- FormParameter fp = formParameterMap.get(aParameterName);
- if (fp != null) {
- return fp.getFormParameterValue();
- }
- return null;
- }
-
- protected void assignXMLRequest(InputStream is, String charset)
- throws IOException, SLException {
- Reader r = new InputStreamReader(is, charset);
- StreamSource source = new StreamSource(r);
- SLCommandContext commandCtx = new SLCommandContext();
- commandCtx.setSTAL(getSTAL());
- commandCtx.setURLDereferencerContext(new SimpleFormDataContextImpl(this));
- slCommand = SLCommandFactory.getInstance().createSLCommand(source,
- commandCtx);
- log.debug("Created new command: " + slCommand);
- }
-
- @Override
- public void run() {
- boolean done = false;
- int hopcounter = 0;
- if (bindingProcessorError != null) {
- currentState = State.FINISHED;
- }
- try {
- while (!done) {
- try {
- switch (currentState) {
- case INIT:
- init();
- break;
- case PROCESS:
- processRequest();
- break;
- case DATAURL:
- handleDataUrl();
- if (++hopcounter > MAX_DATAURL_HOPS) {
- log.error("Maximum number of dataurl hops reached");
- bindingProcessorError = new SLBindingException(2000);
- currentState = State.FINISHED;
- }
- break;
- case TRANSFORM:
- transformResult();
- break;
- case FINISHED:
- done = true;
- finished();
- break;
- }
- } catch (RuntimeException rte) {
- throw rte;
- } catch (Exception t) {
- log.error("Caught unexpected exception", t);
- responseCode = 200;
- resultContentType = HttpUtil.TXT_XML;
- responseHeaders = Collections.EMPTY_MAP;
- bindingProcessorError = new SLException(2000);
- currentState = State.FINISHED;
- }
- }
- } catch (Throwable t) {
- log.error("Caught unexpected exception", t);
- responseCode = 200;
- resultContentType = HttpUtil.TXT_XML;
- responseHeaders = Collections.EMPTY_MAP;
- bindingProcessorError = new SLException(2000);
- currentState = State.FINISHED;
- }
- log.debug("Terminated http binding processor");
- }
-
- @Override
- public void consumeRequestStream(InputStream is) {
- try {
- log.debug("Start consuming request stream");
- formParameterMap.clear();
- String cl = headerMap
- .get(HttpUtil.HTTP_HEADER_CONTENT_TYPE.toLowerCase());
- if (cl == null) {
- log.info("No content type set in http header");
- throw new SLBindingException(2006);
- }
- InputDecoder id = InputDecoderFactory.getDecoder(cl, is);
- id.setContentType(cl);
- if (id == null) {
- log.error("Cannot get inputdecoder for is");
- throw new SLException(2006);
- }
- for (Iterator fpi = id.getFormParameterIterator(); fpi
- .hasNext();) {
- FormParameter fp = fpi.next();
- log.debug("Got request parameter with name: "
- + fp.getFormParameterName());
- if (fp.getFormParameterName().equals(FixedFormParameters.XMLREQUEST)) {
- log.debug("Creating XML Request");
- for (Iterator headerIterator = fp.getHeaderNames(); headerIterator
- .hasNext();) {
- String headerName = headerIterator.next();
- if (HttpUtil.CONTENT_TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {
- String transferEncoding = fp.getHeaderValue(headerName);
- log.debug("Got transfer encoding for xmlrequest: "
- + transferEncoding);
- if (XML_REQ_TRANSFER_ENCODING.contains(transferEncoding)) {
- log.debug("Supported transfer encoding: " + transferEncoding);
- } else {
- log
- .error("Transferencoding not supported: "
- + transferEncoding);
- throw new SLBindingException(2005);
- }
- }
- }
- String charset = HttpUtil.getCharset(cl, true);
- assignXMLRequest(fp.getFormParameterValue(), charset);
- } else {
- FormParameterStore fps = new FormParameterStore();
- fps.init(fp);
- if (!fps.isEmpty()) {
- log.debug("Setting from parameter: " + fps.getFormParameterName());
- formParameterMap.put(fps.getFormParameterName(), fps);
- }
- }
- }
- if (slCommand == null) {
- throw new SLBindingException(2004);
- }
- if (is.read() != -1) {
- log.error("Request input stream not completely read");
- // consume rest of stream, should never occur
- throw new SLRuntimeException(
- "request input stream not consumed till end");
- }
- } catch (SLException slx) {
- log.info("Error while consuming input stream " + slx);
- bindingProcessorError = slx;
- } catch (Throwable t) {
- log.info("Error while consuming input stream " + t, t);
- bindingProcessorError = new SLException(2000);
- } finally {
- try {
- while (is.read() != -1)
- ;
- } catch (IOException e) {
- log.error(e);
- }
- }
- }
-
- @Override
- public String getResultContentType() {
- return resultContentType;
- }
-
- protected Transformer getTransformer(String styleSheetURL) {
- if (styleSheetURL == null) {
- log.debug("Stylesheet URL not set");
- return null;
- }
- try {
- URLDereferencerContext urlCtx = new SimpleFormDataContextImpl(this);
- URIResolver resolver = new URIResolverAdapter(URLDereferencer
- .getInstance(), urlCtx);
- TransformerFactory factory = TransformerFactory.newInstance();
- StreamData sd = URLDereferencer.getInstance().dereference(styleSheetURL,
- urlCtx);
- Transformer t = factory.newTransformer(new StreamSource(sd.getStream()));
- t.setURIResolver(resolver);
- return t;
- } catch (Exception ex) {
- log.info("Cannot instantiate transformer", ex);
- bindingProcessorError = new SLException(2002);
- return null;
- }
- }
-
- protected void handleBindingProcessorError(OutputStream os, String encoding,
- Transformer transformer) throws IOException {
- log.debug("Writing error as result");
- ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError);
- try {
- error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)),
- transformer);
- } catch (TransformerException e) {
- log.fatal("Cannot write error result to stream", e);
- }
- }
-
- @Override
- public void writeResultTo(OutputStream os, String encoding)
- throws IOException {
- if (encoding == null) {
- encoding = HttpUtil.DEFAULT_CHARSET;
- }
- if (bindingProcessorError != null) {
- log.debug("Detected error in binding processor, writing error as result");
- handleBindingProcessorError(os, encoding, transformer);
- return;
- } else if (dataUrlResponse != null) {
- log.debug("Writing data url response as result");
- String charEnc = HttpUtil.getCharset(dataUrlResponse.getContentType(),
- true);
- InputStreamReader isr = new InputStreamReader(
- dataUrlResponse.getStream(), charEnc);
- OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
- if (transformer == null) {
- StreamUtil.copyStream(isr, osw);
- } else {
- try {
- transformer.transform(new StreamSource(isr), new StreamResult(osw));
- } catch (TransformerException e) {
- log.fatal("Exception occured during result transformation", e);
- // bindingProcessorError = new SLException(2008);
- // handleBindingProcessorError(os, encoding, null);
- return;
- }
- }
- osw.flush();
- isr.close();
- } else if (slResult == null) {
- // result not yet assigned -> must be a cancel
- bindingProcessorError = new SLException(6001);
- handleBindingProcessorError(os, encoding, transformer);
- return;
- } else {
- log.debug("Getting result from invoker");
- OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
- try {
- slResult.writeTo(new StreamResult(osw), transformer);
- } catch (TransformerException e) {
- log.fatal("Cannot write result to stream", e);
- // bindingProcessorError = new SLException(2008);
- // handleBindingProcessorError(os, encoding, transformer);
- }
- osw.flush();
- }
- }
-
- /**
- * The response code from the dataurl server or 200 if no dataurl server
- * created the result
- *
- * @return
- */
- public int getResponseCode() {
- return responseCode;
- }
-
- /**
- * All headers from the data url server in case of a direct forward from the
- * dataurl server.
- *
- * @return
- */
- public Map getResponseHeaders() {
- return responseHeaders;
- }
-
- @Override
- public void setLocale(Locale locale) {
- if (locale == null) {
- throw new NullPointerException("Locale must not be set to null");
- }
- this.locale = locale;
- }
-
+ * 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.bku.binding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.net.ssl.SSLHandshakeException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLSourceContext;
+import at.gv.egiz.bku.slcommands.SLTargetContext;
+import at.gv.egiz.bku.slcommands.impl.ErrorResultImpl;
+import at.gv.egiz.bku.slexceptions.SLBindingException;
+import at.gv.egiz.bku.slexceptions.SLException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.bku.utils.binding.Protocol;
+import at.gv.egiz.bku.utils.urldereferencer.FormDataURLSupplier;
+import at.gv.egiz.bku.utils.urldereferencer.SimpleFormDataContextImpl;
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+import at.gv.egiz.bku.utils.urldereferencer.URIResolverAdapter;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.stal.STALRequest;
+
+/**
+ * Class performing the HTTP binding as defined by the CCE specification.
+ * Currently a huge monolithic class.
+ *
+ * @TODO refactor
+ */
+@SuppressWarnings("unchecked")
+public class HTTPBindingProcessor extends AbstractBindingProcessor implements
+ FormDataURLSupplier {
+
+ private static Log log = LogFactory.getLog(HTTPBindingProcessor.class);
+
+ private static enum State {
+ INIT, PROCESS, DATAURL, TRANSFORM, FINISHED
+ };
+
+ public final static Collection XML_REQ_TRANSFER_ENCODING = Arrays
+ .asList(new String[] { "binary" });
+
+ /**
+ * Defines the maximum number of dataurl connects that are allowed within a
+ * single SL Request processing.
+ */
+ protected static int MAX_DATAURL_HOPS = 10;
+
+ protected static String XML_MIME_TYPE = "text/xml";
+ protected static String BINARY_MIME_TYPE = "application/octet-stream";
+
+ /**
+ * If null everything is ok and the result is taken from the command invoker.
+ */
+ protected SLException bindingProcessorError;
+ protected SLCommandInvoker commandInvoker;
+ protected DataUrlResponse dataUrlResponse;
+ protected Map headerMap = Collections.EMPTY_MAP;
+ protected SLCommand slCommand;
+ protected Map formParameterMap = new HashMap();
+ protected SLSourceContext srcContex = new SLSourceContext();
+ protected SLTargetContext targetContext = new SLTargetContext();
+ protected URL srcUrl;
+ protected State currentState = State.INIT;
+ protected Transformer transformer = null;
+ protected String resultContentType = null;
+ protected SLResult slResult = null;
+ protected int responseCode = 200;
+ protected Map responseHeaders = Collections.EMPTY_MAP;
+ protected Locale locale = Locale.getDefault();
+
+ /**
+ *
+ * @param id
+ * may be null. In this case a new session id will be created.
+ * @param cmdInvoker
+ * must not be null;
+ */
+ public HTTPBindingProcessor(String id, SLCommandInvoker cmdInvoker, URL source) {
+ super(id);
+ this.srcUrl = source;
+ Protocol protocol = Protocol.fromString(source.getProtocol());
+ if ((protocol != Protocol.HTTP) && (protocol != Protocol.HTTPS)) {
+ throw new SLRuntimeException("Protocol not supported: " + protocol);
+ }
+ if (cmdInvoker == null) {
+ throw new NullPointerException("Commandinvoker cannot be set to null");
+ }
+ commandInvoker = cmdInvoker;
+ srcContex.setSourceUrl(source);
+ srcContex.setSourceIsDataURL(false);
+ }
+
+ //----------------------------------------------------------------------------
+ // ----------- BEGIN CONVENIENCE METHODS -----------
+
+ protected void sendSTALQuit() {
+ log.info("Sending QUIT command to STAL");
+ List quit = new ArrayList(1);
+ quit.add(new QuitRequest());
+ getSTAL().handleRequest(quit);
+ }
+
+ protected String getFormParameterAsString(String formParameterName) {
+ FormParameter fp = formParameterMap.get(formParameterName);
+ return getFormParameterAsString(fp);
+ }
+
+ protected String getFormParameterAsString(FormParameter fp) {
+ if (fp == null) {
+ return null;
+ }
+ try {
+ return StreamUtil.asString(fp.getFormParameterValue(), HttpUtil
+ .getCharset(fp.getFormParameterContentType(), true));
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ protected String getDataUrl() {
+ return getFormParameterAsString(FixedFormParameters.DATAURL);
+ }
+
+ protected String getStyleSheetUrl() {
+ return getFormParameterAsString(FixedFormParameters.STYLESHEETURL);
+ }
+
+ protected List getFormParameters(String parameterNamePostfix) {
+ List resultList = new ArrayList();
+ for (Iterator fpi = formParameterMap.keySet().iterator(); fpi
+ .hasNext();) {
+ String paramName = fpi.next();
+ if (paramName.endsWith(parameterNamePostfix)) {
+ resultList.add(formParameterMap.get(paramName));
+ }
+ }
+ return resultList;
+ }
+
+ protected List getTransferHeaders() {
+ return getFormParameters("__");
+ }
+
+ protected List getTransferForms() {
+ List resultList = new ArrayList();
+ for (Iterator fpi = formParameterMap.keySet().iterator(); fpi
+ .hasNext();) {
+ String paramName = fpi.next();
+ if ((paramName.endsWith("_")) && (!paramName.endsWith("__"))) {
+ resultList.add(formParameterMap.get(paramName));
+ }
+ }
+ return resultList;
+ }
+
+ protected void closeDataUrlConnection() {
+ log.debug("Closing data url input stream");
+ if (dataUrlResponse == null) {
+ return;
+ }
+ InputStream is = dataUrlResponse.getStream();
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ log.info("Error closing input stream to dataurl server:" + e);
+ }
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ // ----------- END CONVENIENCE METHODS -----------
+
+ //----------------------------------------------------------------------------
+ // -- BEGIN Methods that handle the http binding activities as defined in the
+ // activity diagram --
+
+ protected void init() {
+ log.info("Starting Bindingprocessor in Thread: "
+ + Thread.currentThread().getId());
+ if (bindingProcessorError != null) {
+ log.debug("Detected binding processor error, sending quit command");
+ // sendSTALQuit();
+ currentState = State.FINISHED;
+ } else if (slCommand == null) {
+ log.error("SLCommand not set (consumeRequest not called ??)");
+ bindingProcessorError = new SLException(2000);
+ // sendSTALQuit();
+ currentState = State.FINISHED;
+ } else {
+ currentState = State.PROCESS;
+ }
+ }
+
+ protected void processRequest() {
+ log.debug("Entered State: " + State.PROCESS);
+ log.debug("Processing command: " + slCommand);
+ commandInvoker.setCommand(slCommand);
+ responseCode = 200;
+ responseHeaders = Collections.EMPTY_MAP;
+ try {
+ commandInvoker.invoke(srcContex);
+ } catch (SLException e) {
+ log.info("Caught exception: " + e);
+ bindingProcessorError = e;
+ currentState = State.TRANSFORM;
+ }
+ dataUrlResponse = null;
+ if (getDataUrl() != null) {
+ log.debug("Data Url set to: " + getDataUrl());
+ currentState = State.DATAURL;
+ } else {
+ log.debug("No data url set");
+ currentState = State.TRANSFORM;
+ }
+ }
+
+ protected void handleDataUrl() {
+ log.debug("Entered State: " + State.DATAURL);
+ try {
+ DataUrl dataUrl = new DataUrl(getDataUrl());
+ DataUrlConnection conn = dataUrl.openConnection();
+
+ // set transfer headers
+ for (FormParameter fp : getTransferHeaders()) {
+ String paramString = getFormParameterAsString(fp);
+ if (paramString == null) {
+ log.error("Got empty transfer header, ignoring this");
+ } else {
+ String[] keyVal = paramString.split(":", 2);
+ String key = keyVal[0];
+ String val = null;
+ if (keyVal.length == 2) {
+ val = keyVal[1];
+ }
+ val = val.trim();
+ log.debug("Setting header " + key + " to value " + val);
+ conn.setHTTPHeader(key, val);
+ }
+ }
+
+ // set transfer form parameters
+ for (FormParameter fp : getTransferForms()) {
+ String contentTransferEncoding = null;
+ String contentType = fp.getFormParameterContentType();
+ String charSet = HttpUtil.getCharset(contentType, false);
+ if (charSet != null) {
+ contentType = contentType.substring(0, contentType
+ .lastIndexOf(HttpUtil.SEPERATOR[0]));
+ }
+ for (Iterator header = fp.getHeaderNames(); header.hasNext();) {
+ if (HttpUtil.CONTENT_TRANSFER_ENCODING
+ .equalsIgnoreCase(header.next())) {
+ contentTransferEncoding = getFormParameterAsString(fp);
+ }
+ }
+ log.debug("Setting form: " + fp.getFormParameterName()
+ + " contentType: " + contentType + " charset: " + charSet
+ + " contentTransferEncoding: " + contentTransferEncoding);
+ conn.setHTTPFormParameter(fp.getFormParameterName(), fp
+ .getFormParameterValue(), contentType, charSet,
+ contentTransferEncoding);
+ }
+
+ // connect
+ conn.connect();
+ // fetch and set SL result
+ targetContext.setTargetIsDataURL(true);
+ targetContext.setTargetCertificate(conn.getServerCertificate());
+ targetContext.setTargetUrl(conn.getUrl());
+ SLResult result = commandInvoker.getResult(targetContext);
+
+ // transfer result
+ conn.transmit(result);
+
+ // process Dataurl response
+ dataUrlResponse = conn.getResponse();
+ log.debug("Received data url response code: "
+ + dataUrlResponse.getResponseCode());
+
+ switch (dataUrlResponse.getResponseCode()) {
+ case 200:
+ String contentType = dataUrlResponse.getContentType();
+ log.debug("Got dataurl response content type: " + contentType);
+ if (contentType != null) {
+ if ((contentType.startsWith(HttpUtil.APPLICATION_URL_ENCODED))
+ || (contentType.startsWith(HttpUtil.MULTIPART_FOTMDATA))) {
+ log.debug("Detected SL Request in dataurl response");
+ // process headers and request
+ setHTTPHeaders(dataUrlResponse.getResponseHeaders());
+ consumeRequestStream(dataUrlResponse.getStream());
+ closeDataUrlConnection();
+ srcContex.setSourceCertificate(conn.getServerCertificate());
+ srcContex.setSourceIsDataURL(true);
+ srcContex.setSourceUrl(conn.getUrl());
+ currentState = State.PROCESS;
+ } else if (((contentType.startsWith(HttpUtil.TXT_HTML))
+ || (contentType.startsWith(HttpUtil.TXT_PLAIN)) || (contentType
+ .startsWith(HttpUtil.TXT_XML)))
+ && (dataUrlResponse.isHttpResponseXMLOK())) {
+ log.info("Dataurl response matches with content type: "
+ + contentType);
+ currentState = State.TRANSFORM;
+
+ } else if ((contentType.startsWith(HttpUtil.TXT_XML))
+ && (!dataUrlResponse.isHttpResponseXMLOK())) {
+ log
+ .debug("Detected text/xml dataurl response with content != ");
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
+ assignXMLRequest(dataUrlResponse.getStream(), HttpUtil.getCharset(
+ contentType, true));
+ closeDataUrlConnection();
+ srcContex.setSourceCertificate(conn.getServerCertificate());
+ srcContex.setSourceIsDataURL(true);
+ srcContex.setSourceUrl(conn.getUrl());
+ currentState = State.PROCESS;
+ // just to be complete, actually not used
+ srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders()
+ .get(HttpUtil.HTTP_HEADER_REFERER));
+ } else {
+ resultContentType = contentType;
+ responseHeaders = dataUrlResponse.getResponseHeaders();
+ responseCode = dataUrlResponse.getResponseCode();
+ currentState = State.FINISHED;
+ }
+ } else {
+ log.debug("Content type not set in dataurl response");
+ closeDataUrlConnection();
+ throw new SLBindingException(2007);
+ }
+
+ break;
+ case 307:
+ contentType = dataUrlResponse.getContentType();
+ if ((contentType != null) && (contentType.startsWith(HttpUtil.TXT_XML))) {
+ log.debug("Received dataurl response code 307 with XML content");
+ String location = dataUrlResponse.getResponseHeaders().get(
+ HttpUtil.HTTP_HEADER_LOCATION);
+ if (location == null) {
+ log
+ .error("Did not get a location header for a 307 data url response");
+ throw new SLBindingException(2003);
+ }
+ // consumeRequestStream(dataUrlResponse.getStream());
+ FormParameterStore fp = new FormParameterStore();
+ fp.init(location.getBytes(HttpUtil.DEFAULT_CHARSET),
+ FixedFormParameters.DATAURL, null, null);
+ formParameterMap.put(FixedFormParameters.DATAURL, fp);
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
+ assignXMLRequest(dataUrlResponse.getStream(), HttpUtil.getCharset(
+ dataUrlResponse.getContentType(), true));
+ closeDataUrlConnection();
+ srcContex.setSourceCertificate(conn.getServerCertificate());
+ srcContex.setSourceIsDataURL(true);
+ srcContex.setSourceUrl(conn.getUrl());
+ currentState = State.PROCESS;
+ // just to be complete, actually not used
+ 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;
+
+ case 301:
+ case 302:
+ case 303:
+ responseHeaders = dataUrlResponse.getResponseHeaders();
+ responseCode = dataUrlResponse.getResponseCode();
+ resultContentType = dataUrlResponse.getContentType();
+ currentState = State.FINISHED;
+ break;
+
+ default:
+ // issue error
+ log.info("Unexpected response code from dataurl server: "
+ + dataUrlResponse.getResponseCode());
+ throw new SLBindingException(2007);
+ }
+
+ } catch (SLException slx) {
+ bindingProcessorError = slx;
+ log.error("Error during dataurl communication");
+ resultContentType = HttpUtil.TXT_XML;
+ currentState = State.TRANSFORM;
+ } catch (SSLHandshakeException hx) {
+ bindingProcessorError = new SLException(2010);
+ log.info("Error during dataurl communication", hx);
+ resultContentType = HttpUtil.TXT_XML;
+ currentState = State.TRANSFORM;
+ } catch (IOException e) {
+ bindingProcessorError = new SLBindingException(2001);
+ log.error("Error while data url handling", e);
+ resultContentType = HttpUtil.TXT_XML;
+ currentState = State.TRANSFORM;
+ return;
+ }
+ }
+
+ protected void transformResult() {
+ log.debug("Entered State: " + State.TRANSFORM);
+ if (bindingProcessorError != null) {
+ resultContentType = HttpUtil.TXT_XML;
+ } else if (dataUrlResponse != null) {
+ resultContentType = dataUrlResponse.getContentType();
+ } else {
+ targetContext.setTargetIsDataURL(false);
+ targetContext.setTargetUrl(srcUrl);
+ try {
+ slResult = commandInvoker.getResult(targetContext);
+ resultContentType = slResult.getMimeType();
+ log
+ .debug("Successfully got SLResult from commandinvoker, setting mimetype to: "
+ + resultContentType);
+ } catch (SLException e) {
+ log.info("Cannot get result from invoker:", e);
+ bindingProcessorError = new SLException(6002);
+ resultContentType = HttpUtil.TXT_XML;
+ }
+ }
+ transformer = getTransformer(getStyleSheetUrl());
+ if (transformer != null) {
+ log.debug("Output transformation required");
+ resultContentType = transformer.getOutputProperty("media-type");
+ log.debug("Got media type from stylesheet: " + resultContentType);
+ if (resultContentType == null) {
+ log.debug("Setting to default text/xml result conent type");
+ resultContentType = "text/xml";
+ }
+ log.debug("Deferring sytylesheet processing");
+ }
+ currentState = State.FINISHED;
+ }
+
+ protected void finished() {
+ log.debug("Entered State: " + State.FINISHED);
+ if (bindingProcessorError != null) {
+ log.debug("Binding processor error, sending quit command");
+ resultContentType = HttpUtil.TXT_XML;
+ }
+ sendSTALQuit();
+ log.info("Terminating Bindingprocessor; Thread: "
+ + Thread.currentThread().getId());
+ }
+
+ // -- END Methods that handle the http binding activities as defined in the
+ // activity diagram --
+ //----------------------------------------------------------------------------
+
+ /**
+ * Sets the headers of the SL Request. IMPORTANT: make sure to set all headers
+ * before invoking {@link #consumeRequestStream(InputStream)}
+ *
+ * @param aHeaderMap
+ * if null all header will be cleared.
+ */
+ public void setHTTPHeaders(Map aHeaderMap) {
+ headerMap = new HashMap();
+ // ensure lowercase keys
+ if (aHeaderMap != null) {
+ for (String s : aHeaderMap.keySet()) {
+ if (s != null) {
+ headerMap.put(s.toLowerCase(), aHeaderMap.get(s));
+ if (s.equalsIgnoreCase(HttpUtil.HTTP_HEADER_REFERER)) {
+ String referer = aHeaderMap.get(s);
+ log.debug("Got referer header: " + referer);
+ srcContex.setSourceHTTPReferer(referer);
+ }
+ }
+ }
+ }
+ }
+
+ public void setSourceCertificate(X509Certificate aCert) {
+ srcContex.setSourceCertificate(aCert);
+ }
+
+ /**
+ * The HTTPBindingProcessor does not handle redirect URLs. It only provides
+ * the parameter.
+ *
+ * @return null if redirect url is not set.
+ */
+ public String getRedirectURL() {
+ return getFormParameterAsString(FixedFormParameters.REDIRECTURL);
+ }
+
+ public String getFormDataContentType(String aParameterName) {
+ FormParameter fp = formParameterMap.get(aParameterName);
+ if (fp != null) {
+ return fp.getFormParameterContentType();
+ }
+ return null;
+ }
+
+ public InputStream getFormData(String aParameterName) {
+ FormParameter fp = formParameterMap.get(aParameterName);
+ if (fp != null) {
+ return fp.getFormParameterValue();
+ }
+ return null;
+ }
+
+ protected void assignXMLRequest(InputStream is, String charset)
+ throws IOException, SLException {
+ Reader r = new InputStreamReader(is, charset);
+ StreamSource source = new StreamSource(r);
+ SLCommandContext commandCtx = new SLCommandContext();
+ commandCtx.setSTAL(getSTAL());
+ commandCtx.setURLDereferencerContext(new SimpleFormDataContextImpl(this));
+ slCommand = SLCommandFactory.getInstance().createSLCommand(source,
+ commandCtx);
+ log.debug("Created new command: " + slCommand);
+ }
+
+ @Override
+ public void run() {
+ boolean done = false;
+ int hopcounter = 0;
+ if (bindingProcessorError != null) {
+ currentState = State.FINISHED;
+ }
+ try {
+ while (!done) {
+ try {
+ switch (currentState) {
+ case INIT:
+ init();
+ break;
+ case PROCESS:
+ processRequest();
+ break;
+ case DATAURL:
+ handleDataUrl();
+ if (++hopcounter > MAX_DATAURL_HOPS) {
+ log.error("Maximum number of dataurl hops reached");
+ bindingProcessorError = new SLBindingException(2000);
+ currentState = State.FINISHED;
+ }
+ break;
+ case TRANSFORM:
+ transformResult();
+ break;
+ case FINISHED:
+ done = true;
+ finished();
+ break;
+ }
+ } catch (RuntimeException rte) {
+ throw rte;
+ } catch (Exception t) {
+ log.error("Caught unexpected exception", t);
+ responseCode = 200;
+ resultContentType = HttpUtil.TXT_XML;
+ responseHeaders = Collections.EMPTY_MAP;
+ bindingProcessorError = new SLException(2000);
+ currentState = State.FINISHED;
+ }
+ }
+ } catch (Throwable t) {
+ log.error("Caught unexpected exception", t);
+ responseCode = 200;
+ resultContentType = HttpUtil.TXT_XML;
+ responseHeaders = Collections.EMPTY_MAP;
+ bindingProcessorError = new SLException(2000);
+ currentState = State.FINISHED;
+ }
+ log.debug("Terminated http binding processor");
+ }
+
+ @Override
+ public void consumeRequestStream(InputStream is) {
+ try {
+ log.debug("Start consuming request stream");
+ formParameterMap.clear();
+ String cl = headerMap
+ .get(HttpUtil.HTTP_HEADER_CONTENT_TYPE.toLowerCase());
+ if (cl == null) {
+ log.info("No content type set in http header");
+ throw new SLBindingException(2006);
+ }
+ InputDecoder id = InputDecoderFactory.getDecoder(cl, is);
+ id.setContentType(cl);
+ if (id == null) {
+ log.error("Cannot get inputdecoder for is");
+ throw new SLException(2006);
+ }
+ for (Iterator fpi = id.getFormParameterIterator(); fpi
+ .hasNext();) {
+ FormParameter fp = fpi.next();
+ log.debug("Got request parameter with name: "
+ + fp.getFormParameterName());
+ if (fp.getFormParameterName().equals(FixedFormParameters.XMLREQUEST)) {
+ log.debug("Creating XML Request");
+ for (Iterator headerIterator = fp.getHeaderNames(); headerIterator
+ .hasNext();) {
+ String headerName = headerIterator.next();
+ if (HttpUtil.CONTENT_TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {
+ String transferEncoding = fp.getHeaderValue(headerName);
+ log.debug("Got transfer encoding for xmlrequest: "
+ + transferEncoding);
+ if (XML_REQ_TRANSFER_ENCODING.contains(transferEncoding)) {
+ log.debug("Supported transfer encoding: " + transferEncoding);
+ } else {
+ log
+ .error("Transferencoding not supported: "
+ + transferEncoding);
+ throw new SLBindingException(2005);
+ }
+ }
+ }
+ String charset = HttpUtil.getCharset(cl, true);
+ assignXMLRequest(fp.getFormParameterValue(), charset);
+ } else {
+ FormParameterStore fps = new FormParameterStore();
+ fps.init(fp);
+ if (!fps.isEmpty()) {
+ log.debug("Setting from parameter: " + fps.getFormParameterName());
+ formParameterMap.put(fps.getFormParameterName(), fps);
+ }
+ }
+ }
+ if (slCommand == null) {
+ throw new SLBindingException(2004);
+ }
+ if (is.read() != -1) {
+ log.error("Request input stream not completely read");
+ // consume rest of stream, should never occur
+ throw new SLRuntimeException(
+ "request input stream not consumed till end");
+ }
+ } catch (SLException slx) {
+ log.info("Error while consuming input stream " + slx);
+ bindingProcessorError = slx;
+ } catch (Throwable t) {
+ log.info("Error while consuming input stream " + t, t);
+ bindingProcessorError = new SLException(2000);
+ } finally {
+ try {
+ while (is.read() != -1)
+ ;
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+ }
+
+ @Override
+ public String getResultContentType() {
+ return resultContentType;
+ }
+
+ protected Transformer getTransformer(String styleSheetURL) {
+ if (styleSheetURL == null) {
+ log.debug("Stylesheet URL not set");
+ return null;
+ }
+ try {
+ URLDereferencerContext urlCtx = new SimpleFormDataContextImpl(this);
+ URIResolver resolver = new URIResolverAdapter(URLDereferencer
+ .getInstance(), urlCtx);
+ TransformerFactory factory = TransformerFactory.newInstance();
+ StreamData sd = URLDereferencer.getInstance().dereference(styleSheetURL,
+ urlCtx);
+ Transformer t = factory.newTransformer(new StreamSource(sd.getStream()));
+ t.setURIResolver(resolver);
+ return t;
+ } catch (Exception ex) {
+ log.info("Cannot instantiate transformer", ex);
+ bindingProcessorError = new SLException(2002);
+ return null;
+ }
+ }
+
+ protected void handleBindingProcessorError(OutputStream os, String encoding,
+ Transformer transformer) throws IOException {
+ log.debug("Writing error as result");
+ ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError);
+ try {
+ error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)),
+ transformer);
+ } catch (TransformerException e) {
+ log.fatal("Cannot write error result to stream", e);
+ }
+ }
+
+ @Override
+ public void writeResultTo(OutputStream os, String encoding)
+ throws IOException {
+ if (encoding == null) {
+ encoding = HttpUtil.DEFAULT_CHARSET;
+ }
+ if (bindingProcessorError != null) {
+ log.debug("Detected error in binding processor, writing error as result");
+ handleBindingProcessorError(os, encoding, transformer);
+ return;
+ } else if (dataUrlResponse != null) {
+ log.debug("Writing data url response as result");
+ String charEnc = HttpUtil.getCharset(dataUrlResponse.getContentType(),
+ true);
+ InputStreamReader isr = new InputStreamReader(
+ dataUrlResponse.getStream(), charEnc);
+ OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
+ if (transformer == null) {
+ StreamUtil.copyStream(isr, osw);
+ } else {
+ try {
+ transformer.transform(new StreamSource(isr), new StreamResult(osw));
+ } catch (TransformerException e) {
+ log.fatal("Exception occured during result transformation", e);
+ // bindingProcessorError = new SLException(2008);
+ // handleBindingProcessorError(os, encoding, null);
+ return;
+ }
+ }
+ osw.flush();
+ isr.close();
+ } else if (slResult == null) {
+ // result not yet assigned -> must be a cancel
+ bindingProcessorError = new SLException(6001);
+ handleBindingProcessorError(os, encoding, transformer);
+ return;
+ } else {
+ log.debug("Getting result from invoker");
+ OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
+ try {
+ slResult.writeTo(new StreamResult(osw), transformer);
+ } catch (TransformerException e) {
+ log.fatal("Cannot write result to stream", e);
+ // bindingProcessorError = new SLException(2008);
+ // handleBindingProcessorError(os, encoding, transformer);
+ }
+ osw.flush();
+ }
+ }
+
+ /**
+ * The response code from the dataurl server or 200 if no dataurl server
+ * created the result
+ *
+ * @return
+ */
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+ /**
+ * All headers from the data url server in case of a direct forward from the
+ * dataurl server.
+ *
+ * @return
+ */
+ public Map getResponseHeaders() {
+ return responseHeaders;
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ if (locale == null) {
+ throw new NullPointerException("Locale must not be set to null");
+ }
+ this.locale = locale;
+ }
+
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java
index ef2affd1..a23d96e8 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/SLCommandInvokerImpl.java
@@ -1,66 +1,95 @@
/*
-* 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.bku.binding;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandInvoker;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slcommands.SLSourceContext;
-import at.gv.egiz.bku.slcommands.SLTargetContext;
-
-/**
- * This class implements the entry point for the CCEs security management.
- *
- * TODO the secuirty management is currently not implemented.
- */
-public class SLCommandInvokerImpl implements SLCommandInvoker {
-
- private static Log log = LogFactory.getLog(SLCommandInvokerImpl.class);
-
- protected SLCommand command;
- protected SLResult result;
-
- /**
- * Invokes a sl command.
- */
- public void invoke(SLSourceContext aContext) {
- // FIXXME add security policy here.
- log.warn("Security policy not implemented yet, invoking command: "+command);
- result = command.execute();
- }
-
- public SLResult getResult(SLTargetContext aContext) {
- // FIXXME
- log.warn("Security policy not implemented yet, getting result of command: "+command);
- return result;
- }
-
- public void setCommand(SLCommand aCmd) {
- command = aCmd;
- }
-
- @Override
- public SLCommandInvoker newInstance() {
- SLCommandInvokerImpl cmdInv = new SLCommandInvokerImpl();
- return cmdInv;
- }
-
-
+ * 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.bku.binding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.accesscontroller.SecurityManagerFacade;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLSourceContext;
+import at.gv.egiz.bku.slcommands.SLTargetContext;
+import at.gv.egiz.bku.slexceptions.SLException;
+
+/**
+ * This class implements the entry point for the CCEs security management.
+ *
+ */
+public class SLCommandInvokerImpl implements SLCommandInvoker {
+
+ private static Log log = LogFactory.getLog(SLCommandInvokerImpl.class);
+
+ protected SLCommand command;
+ protected SLResult result;
+ protected SecurityManagerFacade securityManager;
+
+ /**
+ * Invokes a sl command.
+ *
+ * @throws SLException
+ */
+ public void invoke(SLSourceContext aContext) throws SLException {
+ if (securityManager == null) {
+ log.warn("Security policy not implemented yet, invoking command: "
+ + command);
+ result = command.execute();
+ } else {
+ if (securityManager.mayInvokeCommand(command, aContext)) {
+ result = command.execute();
+ } else {
+ throw new SLException(6002);
+ }
+ }
+ }
+
+ public SLResult getResult(SLTargetContext aContext) throws SLException {
+ if (securityManager == null) {
+ log
+ .warn("Security policy not implemented yet, getting result of command: "
+ + command);
+ return result;
+ } else {
+ if (securityManager.maySendResult(command, aContext)) {
+ return result;
+ } else {
+ throw new SLException(6002);
+ }
+ }
+ }
+
+ public void setCommand(SLCommand aCmd) {
+ command = aCmd;
+ }
+
+ @Override
+ public SLCommandInvoker newInstance() {
+ SLCommandInvokerImpl cmdInv = new SLCommandInvokerImpl();
+ cmdInv.setSecurityManager(securityManager);
+ return cmdInv;
+ }
+
+ public SecurityManagerFacade getSecurityManager() {
+ return securityManager;
+ }
+
+ public void setSecurityManager(SecurityManagerFacade securityManager) {
+ this.securityManager = securityManager;
+ }
+
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java
index 77529a36..73fddf1f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxReadCommand.java
@@ -16,5 +16,13 @@
*/
package at.gv.egiz.bku.slcommands;
-public interface InfoboxReadCommand extends SLCommand {
+public interface InfoboxReadCommand extends SLCommand {
+ public String getInfoboxIdentifier();
+
+ /**
+ * Convenience method to get the domain identifier if the infobox
+ * referes to a Identitylink.
+ * @return the domain id or null if the Infobox is not of type Identitylink or no domain parameter was specified
+ */
+ public String getIdentityLinkDomainId();
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java
index 30c6b68f..c28288c9 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandInvoker.java
@@ -16,7 +16,8 @@
*/
package at.gv.egiz.bku.slcommands;
-import at.gv.egiz.bku.slexceptions.SLCanceledException;
+import at.gv.egiz.bku.slexceptions.SLCanceledException;
+import at.gv.egiz.bku.slexceptions.SLException;
public interface SLCommandInvoker {
@@ -25,7 +26,7 @@ public interface SLCommandInvoker {
* @param aContext
* @throws SLCanceledException if the security management prevents execution of this command
*/
- public void invoke(SLSourceContext aContext) throws SLCanceledException;
+ public void invoke(SLSourceContext aContext) throws SLException;
/**
*
@@ -33,7 +34,7 @@ public interface SLCommandInvoker {
* @return
* @throws SLCanceledException if the security management prevents execution of this command
*/
- public SLResult getResult(SLTargetContext aContext) throws SLCanceledException;
+ public SLResult getResult(SLTargetContext aContext) throws SLException;
public void setCommand(at.gv.egiz.bku.slcommands.SLCommand aCmd);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java
index ded55b2a..f25a0ea4 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLSourceContext.java
@@ -16,6 +16,7 @@
*/
package at.gv.egiz.bku.slcommands;
+import java.net.URL;
import java.security.cert.X509Certificate;
import at.gv.egiz.bku.utils.binding.Protocol;
@@ -23,17 +24,17 @@ import at.gv.egiz.bku.utils.binding.Protocol;
public class SLSourceContext {
- private Protocol sourceProtocol;
+ private URL sourceUrl;
private boolean sourceIsDataURL;
private X509Certificate sourceCertificate;
private String sourceHTTPReferer;
- public Protocol getSourceProtocol() {
- return sourceProtocol;
+ public URL getSourceUrl() {
+ return sourceUrl;
}
- public void setSourceProtocol(Protocol sourceProtocol) {
- this.sourceProtocol = sourceProtocol;
+ public void setSourceUrl(URL sourceProtocol) {
+ this.sourceUrl = sourceProtocol;
}
public boolean isSourceIsDataURL() {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java
index cf800406..f9df3ced 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLTargetContext.java
@@ -16,19 +16,20 @@
*/
package at.gv.egiz.bku.slcommands;
-import java.security.cert.X509Certificate;
+import java.net.URL;
+import java.security.cert.X509Certificate;
public class SLTargetContext {
- private String targetProtocol;
+ private URL targetUrl;
private boolean targetIsDataURL;
private X509Certificate targetCertificate;
- public String getTargetProtocol() {
- return targetProtocol;
+ public URL getTargetUrl() {
+ return targetUrl;
}
- public void setTargetProtocol(String targetProtocol) {
- this.targetProtocol = targetProtocol;
+ public void setTargetUrl(URL targetUrl) {
+ this.targetUrl = targetUrl;
}
public boolean isTargetIsDataURL() {
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 93131cf4..b6745e1f 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
@@ -405,5 +405,10 @@ public class InfoboxReadCommandImpl extends SLCommandImpl headers = new HashMap();
headers.put("Content-Type", InputDecoderFactory.MULTIPART_FORMDATA
+ ";boundary=---------------------------2330864292941");
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java
index 41c69a1d..61729567 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/ExpiryRemoverTest.java
@@ -16,16 +16,18 @@
*/
package at.gv.egiz.bku.binding;
+import java.net.MalformedURLException;
+
import org.junit.Test;
import static org.junit.Assert.*;
public class ExpiryRemoverTest {
@Test
- public void testMe() throws InterruptedException {
+ public void testMe() throws InterruptedException, MalformedURLException {
BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(),
new SLCommandInvokerImpl());
- BindingProcessor bp = manager.createBindingProcessor("http", null);
+ BindingProcessor bp = manager.createBindingProcessor("http://www.at", null);
ExpiryRemover remover = new ExpiryRemover();
remover.setBindingProcessorManager(manager);
remover.execute();
@@ -42,10 +44,10 @@ public class ExpiryRemoverTest {
}
@Test
- public void testMe2() throws InterruptedException {
+ public void testMe2() throws InterruptedException, MalformedURLException {
BindingProcessorManager manager = new BindingProcessorManagerImpl(new DummyStalFactory(),
new SLCommandInvokerImpl());
- BindingProcessor bp = manager.createBindingProcessor("http", null);
+ BindingProcessor bp = manager.createBindingProcessor("http://www.iaik.at", null);
ExpiryRemover remover = new ExpiryRemover();
remover.setBindingProcessorManager(manager);
remover.execute();
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java
index 38f61aa2..6a0792d5 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java
@@ -93,7 +93,7 @@ public class HttpBindingProcessorTest {
manager = new BindingProcessorManagerImpl(new DummyStalFactory(),
new SLCommandInvokerImpl());
bindingProcessor = (HTTPBindingProcessor) manager.createBindingProcessor(
- "http", null);
+ "http://www.iaik.at", null);
clientHeaderMap = new HashMap();
clientHeaderMap.put("Content-Type",
"application/x-www-form-urlencoded;charset=utf8");
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java
index 7ef1a9bf..2c48bf4e 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/MultipartSLRequestTest.java
@@ -17,6 +17,7 @@
package at.gv.egiz.bku.binding;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -34,11 +35,11 @@ public class MultipartSLRequestTest {
protected BindingProcessorManager manager;
@Before
- public void setUp() {
+ public void setUp() throws MalformedURLException {
manager = new BindingProcessorManagerImpl(new DummyStalFactory(),
new SLCommandInvokerImpl());
HTTPBindingProcessor http = (HTTPBindingProcessor) manager
- .createBindingProcessor("http", null);
+ .createBindingProcessor("http://www.at/", null);
Map headers = new HashMap();
headers.put("Content-Type", InputDecoderFactory.MULTIPART_FORMDATA
+ ";boundary=---------------------------2330864292941");
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java
index 66b9dffb..b2a7d387 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/NullOperationTest.java
@@ -17,6 +17,7 @@
package at.gv.egiz.bku.binding;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
@@ -32,9 +33,9 @@ public class NullOperationTest {
protected BindingProcessorManager manager;
@Before
- public void setUp() {
+ public void setUp() throws MalformedURLException {
manager = new BindingProcessorManagerImpl(new DummyStalFactory(), new SLCommandInvokerImpl());
- HTTPBindingProcessor http = (HTTPBindingProcessor) manager.createBindingProcessor("http", null);
+ HTTPBindingProcessor http = (HTTPBindingProcessor) manager.createBindingProcessor("http://www.at/", null);
Map headers = new HashMap();
headers.put("Content-Type", "application/x-www-form-urlencoded");
http.setHTTPHeaders(headers);
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
index e644f964..45e38674 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
@@ -119,5 +119,10 @@ public class TestDataUrlConnection implements DataUrlConnectionSPI {
@Override
public DataUrlConnectionSPI newInstance() {
return this;
- }
+ }
+
+ @Override
+ public URL getUrl() {
+ return url;
+ }
}
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml
index 2455d68d..22f9e4a5 100644
--- a/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/AccessControlConfig.xml
@@ -29,7 +29,7 @@
anonymous
- *.gv.at
+ $.gv.atallow
@@ -44,7 +44,7 @@
IdentityLink
- *
+ .*
allow
@@ -56,7 +56,7 @@
https://finanzonline.bmf.gv.at/*
Mandates
- *
+ .*
allow
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/SimpleChainTest.xml b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/SimpleChainTest.xml
new file mode 100644
index 00000000..92490fb2
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/SimpleChainTest.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+ pseudoanonymous
+
+ DelegateFilter
+
+
+
+
+
+
+
+
+ certified
+
+ IdentityLink
+ derived
+
+
+ allow
+
+
+
+ certified
+
+ IdentityLink
+
+
+ deny
+
+
+
+
+
+
\ No newline at end of file
--
cgit v1.2.3
From 14d74dd27c32a02b5301a0755f3fe174d7e3c9f6 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Fri, 5 Sep 2008 12:05:55 +0000
Subject: added file headers
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@17 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../accesscontroller/SpringSecurityManager.java | 16 +++++++++++++++
.../egiz/bku/online/conf/SpringConfigurator.java | 16 +++++++++++++++
.../egiz/bku/online/conf/accessControlConfig.xml | 12 +++++++++++
.../gv/egiz/bku/online/conf/defaultConf.properties | 18 ++++++++++++++++
.../bku/accesscontrol/config/AccessControl.java | 24 ++++++++++++++--------
.../gv/egiz/bku/accesscontrol/config/Action.java | 24 ++++++++++++++--------
.../at/gv/egiz/bku/accesscontrol/config/Chain.java | 23 ++++++++++++++-------
.../gv/egiz/bku/accesscontrol/config/Chains.java | 24 ++++++++++++++--------
.../gv/egiz/bku/accesscontrol/config/Command.java | 24 ++++++++++++++--------
.../bku/accesscontrol/config/ObjectFactory.java | 23 ++++++++++++++-------
.../at/gv/egiz/bku/accesscontrol/config/Param.java | 24 ++++++++++++++--------
.../at/gv/egiz/bku/accesscontrol/config/Rule.java | 23 ++++++++++++++-------
.../at/gv/egiz/bku/accesscontrol/config/Rules.java | 24 ++++++++++++++--------
.../egiz/bku/accesscontroller/AccessChecker.java | 16 +++++++++++++++
.../bku/accesscontroller/AccessCheckerContext.java | 16 +++++++++++++++
.../accesscontroller/AccessControllerFactory.java | 16 +++++++++++++++
.../at/gv/egiz/bku/accesscontroller/Action.java | 16 +++++++++++++++
.../bku/accesscontroller/AuthenticationClass.java | 16 +++++++++++++++
.../accesscontroller/AuthenticationClassifier.java | 16 +++++++++++++++
.../gv/egiz/bku/accesscontroller/ChainChecker.java | 16 +++++++++++++++
.../gv/egiz/bku/accesscontroller/ChainResult.java | 16 +++++++++++++++
.../bku/accesscontroller/CommandParamChecker.java | 16 +++++++++++++++
.../bku/accesscontroller/InfoboxParamChecker.java | 16 +++++++++++++++
.../gv/egiz/bku/accesscontroller/RuleChecker.java | 16 +++++++++++++++
.../gv/egiz/bku/accesscontroller/RuleResult.java | 16 +++++++++++++++
.../accesscontroller/SecurityManagerFacade.java | 16 +++++++++++++++
.../gv/egiz/bku/accesscontroller/UserAction.java | 16 +++++++++++++++
27 files changed, 430 insertions(+), 69 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
index 404e254e..3d0df8c4 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
@@ -1,3 +1,19 @@
+/*
+* 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.bku.online.accesscontroller;
import java.io.IOException;
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
index 768bedea..545a69c9 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
@@ -1,3 +1,19 @@
+/*
+* 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.bku.online.conf;
import java.io.File;
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
index e12d1abe..69b45d1b 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
@@ -1,4 +1,16 @@
+
org.apache.maven.pluginsmaven-surefire-plugin
- true
+ true
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
new file mode 100644
index 00000000..49d3c63f
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
@@ -0,0 +1,42 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.bku.slcommands.impl;
+
+import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
+import at.gv.egiz.stal.HashDataInput;
+import java.io.InputStream;
+
+/**
+ *
+ * @author clemens
+ */
+public class HashDataInputImpl implements HashDataInput {
+
+ String refId;
+ String mimeType;
+ InputStream hashDataInput;
+
+ public HashDataInputImpl(DataObject dataObject) {
+ refId = dataObject.getReference().getId();
+ mimeType = dataObject.getMimeType();
+ hashDataInput = dataObject.getReference().getDigestInputStream();
+ }
+
+ @Override
+ public String getReferenceId() {
+ return refId;
+ }
+
+ @Override
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ @Override
+ public InputStream getHashDataInput() {
+ return hashDataInput;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java
index 64c758c9..25e2d4e5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALPrivateKey.java
@@ -14,109 +14,115 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.slcommands.impl.xsect;
-
-import java.security.PrivateKey;
-
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.stal.HashDataInputCallback;
-
-/**
- * This class implements a private key used by the {@link STALSignature} class.
- *
- * @author mcentner
- */
-public class STALPrivateKey implements PrivateKey {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * The STAL implementation.
- */
- private STAL stal;
-
- /**
- * The callback interface for obtaining the hash input data.
- */
- private HashDataInputCallback hashDataInputCallback;
-
- /**
- * The keybox identifier.
- */
- private String keyboxIdentifier;
-
- /**
- * The signature algorithm.
- */
- private String algorithm;
-
- /**
- * Creates a new instance of this STALPrivateKey with the given
- * stal implementation, signature algorithm,
- * keyboxIdentifier and hashDataInputCallback
- * interface.
- *
- * @param stal
- * the STAL implementation
- * @param algorithm
- * the signature algorithm
- * @param keyboxIdentifier
- * the keybox identifier
- * @param hashDataInputCallback
- * the interface for obtaining the has input data
- */
- public STALPrivateKey(STAL stal,
- String algorithm, String keyboxIdentifier, HashDataInputCallback hashDataInputCallback) {
- super();
- this.keyboxIdentifier = keyboxIdentifier;
- this.hashDataInputCallback = hashDataInputCallback;
- this.stal = stal;
- this.algorithm = algorithm;
- }
-
- /* (non-Javadoc)
- * @see java.security.Key#getAlgorithm()
- */
- @Override
- public String getAlgorithm() {
- return algorithm;
- }
-
- /* (non-Javadoc)
- * @see java.security.Key#getEncoded()
- */
- @Override
- public byte[] getEncoded() {
- throw new UnsupportedOperationException("STALPrivateKey does not support the getEncoded() method.");
- }
-
- /* (non-Javadoc)
- * @see java.security.Key#getFormat()
- */
- @Override
- public String getFormat() {
- return null;
- }
-
- /**
- * @return the STAL implementation
- */
- public STAL getStal() {
- return stal;
- }
-
- /**
- * @return the interface for obtaining the hash data input
- */
- public HashDataInputCallback getHashDataInputCallback() {
- return hashDataInputCallback;
- }
-
- /**
- * @return the keybox identifier
- */
- public String getKeyboxIdentifier() {
- return keyboxIdentifier;
- }
-
-}
+package at.gv.egiz.bku.slcommands.impl.xsect;
+
+import at.gv.egiz.stal.HashDataInput;
+import java.security.PrivateKey;
+
+import at.gv.egiz.stal.STAL;
+//import at.gv.egiz.stal.HashDataInputCallback;
+import java.util.List;
+
+/**
+ * This class implements a private key used by the {@link STALSignature} class.
+ *
+ * @author mcentner
+ */
+public class STALPrivateKey implements PrivateKey {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The STAL implementation.
+ */
+ private STAL stal;
+
+ /**
+ * The callback interface for obtaining the hash input data.
+ */
+// private HashDataInputCallback hashDataInputCallback;
+
+
+ private List dataObjects;
+
+ /**
+ * The keybox identifier.
+ */
+ private String keyboxIdentifier;
+
+ /**
+ * The signature algorithm.
+ */
+ private String algorithm;
+
+ /**
+ * Creates a new instance of this STALPrivateKey with the given
+ * stal implementation, signature algorithm,
+ * keyboxIdentifier and hashDataInputCallback
+ * interface.
+ *
+ * @param stal
+ * the STAL implementation
+ * @param algorithm
+ * the signature algorithm
+ * @param keyboxIdentifier
+ * the keybox identifier
+ * @param hashDataInputCallback
+ * the interface for obtaining the has input data
+ */
+ public STALPrivateKey(STAL stal,
+ String algorithm, String keyboxIdentifier, List dataObjects) {
+ super();
+ this.keyboxIdentifier = keyboxIdentifier;
+ this.dataObjects = dataObjects;
+ this.stal = stal;
+ this.algorithm = algorithm;
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.Key#getAlgorithm()
+ */
+ @Override
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.Key#getEncoded()
+ */
+ @Override
+ public byte[] getEncoded() {
+ throw new UnsupportedOperationException("STALPrivateKey does not support the getEncoded() method.");
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.Key#getFormat()
+ */
+ @Override
+ public String getFormat() {
+ return null;
+ }
+
+ /**
+ * @return the STAL implementation
+ */
+ public STAL getStal() {
+ return stal;
+ }
+
+ /**
+ * @return the interface for obtaining the hash data input
+ */
+ public List getDataObjects() {
+
+ return dataObjects;
+ }
+
+ /**
+ * @return the keybox identifier
+ */
+ public String getKeyboxIdentifier() {
+ return keyboxIdentifier;
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
index f0fcb891..eba1d96d 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
@@ -14,152 +14,164 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.slcommands.impl.xsect;
-
-import java.io.ByteArrayOutputStream;
-import java.security.InvalidKeyException;
-import java.security.InvalidParameterException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.SignatureSpi;
-import java.util.Collections;
-import java.util.List;
-
-import at.gv.egiz.stal.ErrorResponse;
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
-import at.gv.egiz.stal.SignRequest;
-import at.gv.egiz.stal.SignResponse;
-import at.gv.egiz.stal.HashDataInputCallback;
-
-/**
- * A signature service provider implementation that uses STAL to sign.
- *
- * @author mcentner
- */
-public class STALSignature extends SignatureSpi {
-
- /**
- * The private key.
- */
- protected STALPrivateKey privateKey;
-
- /**
- * The to-be signed data.
- */
- protected ByteArrayOutputStream data = new ByteArrayOutputStream();
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineGetParameter(java.lang.String)
- */
- @Override
- protected Object engineGetParameter(String param)
- throws InvalidParameterException {
- throw new InvalidParameterException();
- }
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineInitSign(java.security.PrivateKey)
- */
- @Override
- protected void engineInitSign(PrivateKey privateKey)
- throws InvalidKeyException {
-
- if (!(privateKey instanceof STALPrivateKey)) {
- throw new InvalidKeyException("STALSignature supports STALKeys only.");
- }
-
- this.privateKey = (STALPrivateKey) privateKey;
-
- }
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineInitVerify(java.security.PublicKey)
- */
- @Override
- protected void engineInitVerify(PublicKey publicKey)
- throws InvalidKeyException {
-
- throw new UnsupportedOperationException("STALSignature does not support signature verification.");
- }
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineSetParameter(java.lang.String, java.lang.Object)
- */
- @Override
- protected void engineSetParameter(String param, Object value)
- throws InvalidParameterException {
- }
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineSign()
- */
- @Override
- protected byte[] engineSign() throws SignatureException {
-
- STAL stal = privateKey.getStal();
-
- if (stal == null) {
- throw new SignatureException("STALSignature requires the STALPrivateKey " +
- "to provide a STAL implementation reference.");
- }
-
- HashDataInputCallback signRefDataSupplier = privateKey.getHashDataInputCallback();
-
- String keyboxIdentifier = privateKey.getKeyboxIdentifier();
-
- if (keyboxIdentifier == null) {
- throw new SignatureException("STALSignature requires the STALPrivateKey " +
- "to provide a KeyboxIdentifier.");
- }
-
- SignRequest signRequest = new SignRequest();
- signRequest.setKeyIdentifier(keyboxIdentifier);
- signRequest.setSignedInfo(data.toByteArray());
- signRequest.setHashDataInput(signRefDataSupplier);
-
- List responses = stal.handleRequest(Collections.singletonList((STALRequest) signRequest));
-
- if (responses == null || responses.size() != 1) {
- throw new SignatureException("Failed to access STAL.");
- }
-
- STALResponse response = responses.get(0);
- if (response instanceof SignResponse) {
- return ((SignResponse) response).getSignatureValue();
- } else if (response instanceof ErrorResponse) {
- throw new STALSignatureException(((ErrorResponse) response).getErrorCode());
- } else {
- throw new SignatureException("Failed to access STAL.");
- }
-
- }
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineUpdate(byte)
- */
- @Override
- protected void engineUpdate(byte b) throws SignatureException {
- data.write(b);
- }
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineUpdate(byte[], int, int)
- */
- @Override
- protected void engineUpdate(byte[] b, int off, int len)
- throws SignatureException {
- data.write(b, off, len);
- }
-
- /* (non-Javadoc)
- * @see java.security.SignatureSpi#engineVerify(byte[])
- */
- @Override
- protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
- throw new UnsupportedOperationException("STALSignature des not support signature verification.");
- }
-
-}
+package at.gv.egiz.bku.slcommands.impl.xsect;
+
+import at.gv.egiz.bku.slcommands.impl.HashDataInputImpl;
+import java.io.ByteArrayOutputStream;
+import java.security.InvalidKeyException;
+import java.security.InvalidParameterException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.SignatureSpi;
+import java.util.Collections;
+import java.util.List;
+
+import at.gv.egiz.stal.ErrorResponse;
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.SignResponse;
+//import at.gv.egiz.stal.HashDataInputCallback;
+import java.util.ArrayList;
+
+/**
+ * A signature service provider implementation that uses STAL to sign.
+ *
+ * @author mcentner
+ */
+public class STALSignature extends SignatureSpi {
+
+// private static final Log log = LogFactory.getLog(STALSignature.class);
+
+ /**
+ * The private key.
+ */
+ protected STALPrivateKey privateKey;
+
+ /**
+ * The to-be signed data.
+ */
+ protected ByteArrayOutputStream data = new ByteArrayOutputStream();
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineGetParameter(java.lang.String)
+ */
+ @Override
+ protected Object engineGetParameter(String param)
+ throws InvalidParameterException {
+ throw new InvalidParameterException();
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineInitSign(java.security.PrivateKey)
+ */
+ @Override
+ protected void engineInitSign(PrivateKey privateKey)
+ throws InvalidKeyException {
+
+ if (!(privateKey instanceof STALPrivateKey)) {
+ throw new InvalidKeyException("STALSignature supports STALKeys only.");
+ }
+
+ this.privateKey = (STALPrivateKey) privateKey;
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineInitVerify(java.security.PublicKey)
+ */
+ @Override
+ protected void engineInitVerify(PublicKey publicKey)
+ throws InvalidKeyException {
+
+ throw new UnsupportedOperationException("STALSignature does not support signature verification.");
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineSetParameter(java.lang.String, java.lang.Object)
+ */
+ @Override
+ protected void engineSetParameter(String param, Object value)
+ throws InvalidParameterException {
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineSign()
+ */
+ @Override
+ protected byte[] engineSign() throws SignatureException {
+
+ STAL stal = privateKey.getStal();
+
+ if (stal == null) {
+ throw new SignatureException("STALSignature requires the STALPrivateKey " +
+ "to provide a STAL implementation reference.");
+ }
+
+ String keyboxIdentifier = privateKey.getKeyboxIdentifier();
+
+ if (keyboxIdentifier == null) {
+ throw new SignatureException("STALSignature requires the STALPrivateKey " +
+ "to provide a KeyboxIdentifier.");
+ }
+
+ // get hashDataInputs (DigestInputStreams) once slcommands.impl.xsect.Signature::sign() was called
+ List dataObjects = privateKey.getDataObjects();
+// log.debug("got " + dataObjects.size() + " DataObjects, passing HashDataInputs to STAL SignRequest");
+
+ List hashDataInputs = new ArrayList();
+ for (DataObject dataObject : dataObjects) {
+ hashDataInputs.add(new HashDataInputImpl(dataObject));
+ }
+
+ SignRequest signRequest = new SignRequest();
+ signRequest.setKeyIdentifier(keyboxIdentifier);
+ signRequest.setSignedInfo(data.toByteArray());
+ signRequest.setHashDataInput(hashDataInputs);
+
+ List responses = stal.handleRequest(Collections.singletonList((STALRequest) signRequest));
+
+ if (responses == null || responses.size() != 1) {
+ throw new SignatureException("Failed to access STAL.");
+ }
+
+ STALResponse response = responses.get(0);
+ if (response instanceof SignResponse) {
+ return ((SignResponse) response).getSignatureValue();
+ } else if (response instanceof ErrorResponse) {
+ throw new STALSignatureException(((ErrorResponse) response).getErrorCode());
+ } else {
+ throw new SignatureException("Failed to access STAL.");
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineUpdate(byte)
+ */
+ @Override
+ protected void engineUpdate(byte b) throws SignatureException {
+ data.write(b);
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineUpdate(byte[], int, int)
+ */
+ @Override
+ protected void engineUpdate(byte[] b, int off, int len)
+ throws SignatureException {
+ data.write(b, off, len);
+ }
+
+ /* (non-Javadoc)
+ * @see java.security.SignatureSpi#engineVerify(byte[])
+ */
+ @Override
+ protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
+ throw new UnsupportedOperationException("STALSignature des not support signature verification.");
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
index 94a4a066..191f8371 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
@@ -14,922 +14,939 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.slcommands.impl.xsect;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.dom.DOMStructure;
-import javax.xml.crypto.dsig.CanonicalizationMethod;
-import javax.xml.crypto.dsig.DigestMethod;
-import javax.xml.crypto.dsig.Reference;
-import javax.xml.crypto.dsig.SignatureMethod;
-import javax.xml.crypto.dsig.SignedInfo;
-import javax.xml.crypto.dsig.XMLObject;
-import javax.xml.crypto.dsig.XMLSignature;
-import javax.xml.crypto.dsig.XMLSignatureException;
-import javax.xml.crypto.dsig.XMLSignatureFactory;
-import javax.xml.crypto.dsig.dom.DOMSignContext;
-import javax.xml.crypto.dsig.keyinfo.KeyInfo;
-import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
-import javax.xml.crypto.dsig.keyinfo.X509Data;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.etsi.uri._01903.v1_1.DataObjectFormatType;
-import org.etsi.uri._01903.v1_1.QualifyingPropertiesType;
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSException;
-import org.w3c.dom.ls.LSInput;
-import org.w3c.dom.ls.LSOutput;
-import org.w3c.dom.ls.LSParser;
-import org.w3c.dom.ls.LSResourceResolver;
-import org.w3c.dom.ls.LSSerializer;
-
-import at.buergerkarte.namespaces.securitylayer._1.Base64XMLLocRefReqRefContentType;
-import at.buergerkarte.namespaces.securitylayer._1.Base64XMLOptRefContentType;
-import at.buergerkarte.namespaces.securitylayer._1.DataObjectAssociationType;
-import at.buergerkarte.namespaces.securitylayer._1.DataObjectInfoType;
-import at.buergerkarte.namespaces.securitylayer._1.SignatureInfoCreationType;
-import at.gv.egiz.bku.binding.HttpUtil;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLRequestException;
-import at.gv.egiz.bku.utils.HexDump;
-import at.gv.egiz.bku.utils.urldereferencer.StreamData;
-import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
-import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
-import at.gv.egiz.dom.DOMUtils;
-import at.gv.egiz.slbinding.impl.XMLContentType;
-import at.gv.egiz.stal.HashDataInputCallback;
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.xades.QualifyingPropertiesException;
-import at.gv.egiz.xades.QualifyingPropertiesFactory;
-
-/**
- * This class represents an XML-Signature as to be created by the
- * security layer command CreateXMLSignatureRequest.
- *
- * @author mcentner
- */
-public class Signature implements HashDataInputCallback {
-
- /**
- * Logging facility.
- */
- private static Log log = LogFactory.getLog(Signature.class);
-
- /**
- * The DOM implementation used.
- */
- private DOMImplementationLS domImplLS;
-
- /**
- * The SignatureContext for the XMLSignature.
- */
- private SignatureContext ctx;
-
- /**
- * The list of {@link DataObject}s for this signature.
- */
- private List dataObjects = new ArrayList();
-
- /**
- * A mapping from the Id-attribute values of this signature's
- * ds:References to the corresponding {@link DataObject}s.
- */
- private Map dataObjectReferencIds = new HashMap();
-
- /**
- * The SignatureEnvironment for this signature.
- */
- private SignatureLocation signatureLocation;
-
- /**
- * The XML signature.
- */
- private XMLSignature xmlSignature;
-
- /**
- * A list of attributes of type xsd:ID to be registered in the {@link DOMSignContext}.
- */
- private List idAttributes = new ArrayList();
-
- /**
- * The signer's X509 certificate.
- */
- private X509Certificate signerCertificate;
-
- /**
- * The signing time.
- */
- private Date signingTime;
-
- /**
- * Creates a new SLXMLSignature instance.
- */
- public Signature(URLDereferencerContext dereferencerContext,
- IdValueFactory idValueFactory,
- AlgorithmMethodFactory algorithmMethodFactory) {
-
- domImplLS = DOMUtils.getDOMImplementationLS();
-
- ctx = new SignatureContext();
-
- ctx.setSignatureFactory(XMLSignatureFactory.getInstance());
-
- ctx.setDereferencerContext(dereferencerContext);
- ctx.setIdValueFactory(idValueFactory);
- ctx.setAlgorithmMethodFactory(algorithmMethodFactory);
-
- }
-
- /**
- * @return the Document containing this Signature
- */
- public Document getDocument() {
- return ctx.getDocument();
- }
-
- /**
- * @return the parent Node for this Signature
- */
- public Node getParent() {
- return (signatureLocation != null) ? signatureLocation.getParent() : null;
- }
-
- /**
- * @return the next sibling Node for this Signature
- */
- public Node getNextSibling() {
- return (signatureLocation != null) ? signatureLocation.getNextSibling() : null;
- }
-
- /**
- * @return the XMLSignature
- */
- public XMLSignature getXMLSignature() {
- return xmlSignature;
- }
-
- /**
- * @return the list of {@link Reference}s of this Signature
- */
- @SuppressWarnings("unchecked")
- public List getReferences() {
- return (xmlSignature != null) ? xmlSignature.getSignedInfo().getReferences() : null;
- }
-
- /**
- * @return the list of {@link XMLObject}s of this Signature
- */
- @SuppressWarnings("unchecked")
- public List getXMLObjects() {
- return (xmlSignature != null) ? xmlSignature.getObjects() : null;
- }
-
- /**
- * Prepares the signature document with the information given by the
- * signatureInfo provided.
- *
- * @param signatureInfo
- * the SignatureInfo
- *
- * @throws SLCommandException
- * if processing fails for any reason
- * @throws IllegalStateException
- * if the parent node has already been set
- * @throws NullPointerException
- * if signatureInfo is null
- */
- public void setSignatureInfo(SignatureInfoCreationType signatureInfo) throws SLCommandException {
-
- if (signatureLocation != null) {
- throw new IllegalStateException("SignatureEnvironment already set.");
- }
-
- Base64XMLOptRefContentType signatureEnvironment = signatureInfo.getSignatureEnvironment();
-
- if (signatureEnvironment == null) {
-
- // no SignatureEnvironment, so we use an empty document and the document as parent
- ensureSignatureLocation();
-
- } else {
-
- // parse SignatureEnvrionment and use as document
- Document document = parseSignatureEnvironment(signatureEnvironment, signatureInfo.getSupplement());
- ctx.setDocument(document);
-
- signatureLocation = new SignatureLocation(ctx);
- signatureLocation.setSignatureInfo(signatureInfo);
-
- }
-
- }
-
- /**
- * Ensures a SignatureLocation for this Signature.
- */
- private void ensureSignatureLocation() {
-
- if (signatureLocation == null) {
- Document document = DOMUtils.createDocument();
- ctx.setDocument(document);
-
- signatureLocation = new SignatureLocation(ctx);
- signatureLocation.setParent(document);
- }
-
- }
-
- /**
- * Adds a DataObject with the information given by the
- * dataObjectInfo provided to this Signature.
- *
- * @param dataObjectInfo
- * the DataObjectInfo element
- *
- * @throws SLCommandException
- * if adding the DataObject fails
- * @throws SLRequestException
- * if the information provided by the given
- * dataObjectInfo does not conform to the security
- * layer specification
- * @throws NullPointerException
- * if dataObjectInfo is null
- */
- public void addDataObject(DataObjectInfoType dataObjectInfo) throws SLCommandException, SLRequestException {
-
- ensureSignatureLocation();
-
- DataObject dataObject = new DataObject(ctx);
- dataObject.setDataObjectInfo(dataObjectInfo);
-
- dataObjects.add(dataObject);
-
- dataObjectReferencIds.put(dataObject.getReference().getId(), dataObject);
-
- }
-
- /**
- * Sets the SigningTime qualifying property of this Signature.
- *
- * @param signingTime the signing time to set
- */
- public void setSigningTime(Date signingTime) {
- this.signingTime = signingTime;
- }
-
- /**
- * Sets the SignerCertificate qualifying property of this Signature.
- *
- * @param certificate the signer's certificate
- */
- public void setSignerCeritifcate(X509Certificate certificate) {
- this.signerCertificate = certificate;
- }
-
- /**
- * Builds the XMLSignature data structure of this Signature as configured by
- * the various setter methods.
- *
- * @throws SLCommandException if building this signature fails
- */
- public void buildXMLSignature() throws SLCommandException {
-
- List objects = new ArrayList();
- List references = new ArrayList();
-
- // add all data objects
- for (DataObject dataObject : dataObjects) {
- if (dataObject.getXmlObject() != null) {
- objects.add(dataObject.getXmlObject());
- }
- if (dataObject.getReference() != null) {
- references.add(dataObject.getReference());
- }
- }
-
- addXAdESObjectAndReference(objects, references);
-
- XMLSignatureFactory signatureFactory = ctx.getSignatureFactory();
- AlgorithmMethodFactory algorithmMethodFactory = ctx.getAlgorithmMethodFactory();
-
- CanonicalizationMethod cm;
- SignatureMethod sm;
- try {
- cm = algorithmMethodFactory.createCanonicalizationMethod(ctx);
- sm = algorithmMethodFactory.createSignatureMethod(ctx);
- } catch (NoSuchAlgorithmException e) {
- log.error("Failed to get Canonicalization or Signature algorithm.", e);
- throw new SLCommandException(4006);
- } catch (InvalidAlgorithmParameterException e) {
- log.error("Failed to get Canonicalization or Signature algorithm.", e);
- throw new SLCommandException(4006);
- }
-
- String siId = ctx.getIdValueFactory().createIdValue("SignedInfo");
-
- SignedInfo si = signatureFactory.newSignedInfo(cm, sm, references, siId);
-
- KeyInfo ki = null;
- if (signerCertificate != null) {
- KeyInfoFactory kif = KeyInfoFactory.getInstance();
- X509Data x509Data = kif.newX509Data(Collections.singletonList(signerCertificate));
- ki = kif.newKeyInfo(Collections.singletonList(x509Data));
- }
-
- String signatureId = ctx.getIdValueFactory().createIdValue("Signature");
- String signatureValueId = ctx.getIdValueFactory().createIdValue("SignatureValue");
-
- xmlSignature = signatureFactory.newXMLSignature(si, ki, objects, signatureId, signatureValueId);
-
- }
-
- /**
- * Sign this Signature using the given signContext.
- *
- * Call's {@link #buildXMLSignature()} if it has not been called yet.
- *
- *
- * @param signContext
- * the signing context
- *
- * @throws MarshalException
- * if marshalling the XMLSignature fails
- * @throws XMLSignatureException
- * if signing the XMLSignature fails
- * @throws SLCommandException
- * if building the XMLSignature fails
- * @throws NullPointerException
- * if signContext is null
- */
- public void sign(DOMSignContext signContext) throws MarshalException, XMLSignatureException, SLCommandException {
-
- if (xmlSignature == null) {
- buildXMLSignature();
- }
-
- for (IdAttribute idAttribute : idAttributes) {
- signContext.setIdAttributeNS(idAttribute.element, idAttribute.namespaceURI, idAttribute.localName);
- }
-
- // DO NOT USE:
- // signContext.setProperty("iaik.xml.crypto.dsig.sign-over", Boolean.TRUE);
-
- signContext.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
-
- signContext.putNamespacePrefix(XMLSignature.XMLNS, "dsig");
-
- signContext.setURIDereferencer(new URIDereferncerAdapter(ctx.getDereferencerContext()));
-
- try {
- xmlSignature.sign(signContext);
- } catch (XMLSignatureException e) {
- Throwable cause = e.getCause();
- while (cause != null) {
- if (cause instanceof STALSignatureException) {
- int errorCode = ((STALSignatureException) cause).getErrorCode();
- SLCommandException commandException = new SLCommandException(errorCode);
- log.info("Failed to sign signature.", commandException);
- throw commandException;
- } else {
- cause = cause.getCause();
- }
- }
- throw e;
- }
-
- // debug
- if (log.isTraceEnabled()) {
- for (DataObject dataObject : dataObjects) {
- Reference reference = dataObject.getReference();
- InputStream digestInputStream = reference.getDigestInputStream();
- if (digestInputStream != null) {
- String mimeType = dataObject.getMimeType();
- StringBuilder sb = new StringBuilder();
- sb.append("DigestInput for Reference with id='");
- sb.append(reference.getId());
- sb.append("' (MIME-Type=");
- sb.append(dataObject.getMimeType());
- sb.append("):\n");
- try {
- if (mimeType != null && (
- mimeType.startsWith("text") ||
- "application/xhtml+xml".equals(mimeType))) {
- byte[] b = new byte[512];
- for (int l; (l = digestInputStream.read(b)) != -1;) {
- sb.append(new String(b, 0, l));
- }
- } else {
- sb.append(HexDump.hexDump(digestInputStream));
- }
- } catch (IOException e) {
- log.error(e);
- }
- log.trace(sb.toString());
- } else {
- log.trace("Reference caching is not enabled.");
- }
- }
- }
-
- }
-
- /**
- * Sign this Signature using the given stal implementation and
- * keyboxIdentifier.
- *
- * This method configures an appropriate {@link DOMSignContext} and calls
- * {@link #sign(DOMSignContext)}. If {@link #buildXMLSignature()} has not been
- * called yet, it is called by this method.
- *
- *
- * @param stal
- * the STAL implementation to use
- * @param keyboxIdentifier
- * the KeyboxIdentifier to use
- *
- * @throws MarshalException
- * if marshalling this Signature fails
- * @throws XMLSignatureException
- * if signing this Signature fails
- * @throws SLCommandException
- * if building this Signature fails
- * @throws NullPointerException
- * if stal or keyboxIdentifier is
- * null
- */
- public void sign(STAL stal, String keyboxIdentifier) throws MarshalException, XMLSignatureException, SLCommandException {
-
- if (stal == null) {
- throw new NullPointerException("Argument 'stal' must not be null.");
- }
-
- if (keyboxIdentifier == null) {
- throw new NullPointerException("Argument 'keyboxIdentifier' must not be null.");
- }
-
- if (xmlSignature == null) {
- buildXMLSignature();
- }
-
- SignatureMethod signatureMethod = xmlSignature.getSignedInfo().getSignatureMethod();
- String algorithm = signatureMethod.getAlgorithm();
-
- PrivateKey privateKey = new STALPrivateKey(stal, algorithm, keyboxIdentifier, this);
-
- DOMSignContext signContext;
- if (getNextSibling() == null) {
- signContext = new DOMSignContext(privateKey, getParent());
- } else {
- signContext = new DOMSignContext(privateKey, getParent(), getNextSibling());
- }
-
- sign(signContext);
- }
-
- @Override
- public InputStream getHashDataInput(String referenceId) {
-
- DataObject dataObject = dataObjectReferencIds.get(referenceId);
- if (dataObject != null) {
- return dataObject.getReference().getDigestInputStream();
- } else {
- return null;
- }
- }
-
- /**
- * Adds the XAdES QualifyingProperties as an
- * ds:Object and a corresponding ds:Reference to
- * it's SignedProperties element to this Signature.
- *
- * @param objects
- * the list of ds:Objects to add the created
- * ds:Object to
- * @param references
- * the list of ds:References to add the created
- * ds:Reference to
- *
- * @throws SLCommandException
- * if creating and adding the XAdES
- * QualifyingProperties fails
- * @throws NullPointerException
- * if objects or references is
- * null
- */
- private void addXAdESObjectAndReference(List objects, List references) throws SLCommandException {
-
- QualifyingPropertiesFactory factory = QualifyingPropertiesFactory.getInstance();
-
- String idValue = ctx.getIdValueFactory().createIdValue("SignedProperties");
-
- Date date = (signingTime != null) ? signingTime : new Date();
-
- List signingCertificates;
- if (signerCertificate != null) {
- signingCertificates = Collections.singletonList(signerCertificate);
- } else {
- signingCertificates = Collections.emptyList();
- }
-
- // TODO: report MOA-SP bug
- //
- // The security layer specification mandates the use of version 1.2.2. of the
- // XAdES QualifyingProperties. However MOA-SP supports only version 1.1.1. Therefore,
- // the version 1.1.1 is used in order to be compatible with current MOA-SP versions.
-
- List dataObjectFormats = new ArrayList();
- for (DataObject dataObject : dataObjects) {
- if (dataObject.getMimeType() != null && dataObject.getReference() != null) {
- Reference reference = dataObject.getReference();
- if (reference.getId() != null) {
- String objectReference = "#" + reference.getId();
- dataObjectFormats.add(factory.createDataObjectFormatType(
- objectReference, dataObject.getMimeType(), dataObject
- .getDescription()));
- }
- }
- }
-
- JAXBElement qualifyingProperties;
- try {
- qualifyingProperties = factory.createQualifyingProperties111(date, signingCertificates, idValue, dataObjectFormats);
- } catch (QualifyingPropertiesException e) {
- log.error("Failed to create QualifyingProperties.", e);
- throw new SLCommandException(4000);
- }
-
- DocumentFragment fragment = ctx.getDocument().createDocumentFragment();
-
- try {
- factory.marshallQualifyingProperties(qualifyingProperties, fragment);
- } catch (JAXBException e) {
- log.error("Failed to marshal QualifyingProperties.", e);
- throw new SLCommandException(4000);
- }
-
- List content = Collections.singletonList(new DOMStructure(fragment.getFirstChild()));
-
- String objectIdValue = ctx.getIdValueFactory().createIdValue("Object");
-
- XMLObject object = ctx.getSignatureFactory().newXMLObject(content, objectIdValue, null, null);
-
- objects.add(object);
-
- // TODO: Report MOA-SP Bug
- //
- // Direct referencing of the SignedPorperties Id-attribute is not supported by MOA-SP
- // because the QualifyingProperties are parsed without the XAdES schema. Therefore,
- // the shorthand XPointer could not be resolved.
- //
- // The following workaround uses an XPointer to select the SignedProperties in order
- // to allow the signature to be verified with MOA-SP.
-
- String referenceURI = "#xmlns(xades=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('"
- + objectIdValue
- + "')/child::xades:QualifyingProperties/child::xades:SignedProperties)";
- DigestMethod dm;
- try {
- dm = ctx.getAlgorithmMethodFactory().createDigestMethod(ctx);
- } catch (NoSuchAlgorithmException e) {
- log.error("Failed to get DigestMethod algorithm.", e);
- throw new SLCommandException(4006);
- } catch (InvalidAlgorithmParameterException e) {
- log.error("Failed to get DigestMethod algorithm.", e);
- throw new SLCommandException(4006);
- }
-
- String referenceIdValue = ctx.getIdValueFactory().createIdValue("Reference");
- String referenceType = QualifyingPropertiesFactory.SIGNED_PROPERTIES_REFERENCE_TYPE_V1_1_1;
-
- Reference reference = ctx.getSignatureFactory().newReference(referenceURI, dm, null, referenceType, referenceIdValue);
-
- references.add(reference);
-
- Node child = fragment.getFirstChild();
- if (child instanceof Element) {
- NodeList nodes = ((Element) child).getElementsByTagNameNS(QualifyingPropertiesFactory.NS_URI_V1_1_1, "SignedProperties");
- if (nodes.getLength() > 0) {
- IdAttribute idAttribute = new IdAttribute();
- idAttribute.element = (Element) nodes.item(0);
- idAttribute.namespaceURI = null;
- idAttribute.localName = "Id";
- idAttributes.add(idAttribute);
- }
- }
-
- }
-
- /**
- * Parse the SignatureEnvironment.
- *
- * @param signatureEnvironment
- * the SignatureEnvironment element
- * @param supplements
- * an optional list of Supplements (may be
- * null)
- *
- * @return the parsed SignatureEnvironment document
- *
- * @throws SLCommandException
- * if parsing the SignatureEnvironment fails
- * @throws NullPointerException
- * if signatureEnvironment is null
- */
- private Document parseSignatureEnvironment(
- Base64XMLOptRefContentType signatureEnvironment,
- List supplements) throws SLCommandException {
-
- if (signatureEnvironment == null) {
- throw new NullPointerException("Argument 'signatureEnvironment' must not be null.");
- }
-
- LSInput input;
- try {
- if (signatureEnvironment.getReference() != null) {
- log.debug("SignatureEnvironment contains Reference " + signatureEnvironment.getReference() + ".");
- input = createLSInput(signatureEnvironment.getReference());
- } else if (signatureEnvironment.getBase64Content() != null) {
- log.debug("SignatureEnvironment contains Base64Content.");
- input = createLSInput(signatureEnvironment.getBase64Content());
- } else if (signatureEnvironment.getXMLContent() != null) {
- log.debug("SignatureEnvironment contains XMLContent.");
- input = createLSInput((XMLContentType) signatureEnvironment.getXMLContent());
- } else {
- // the schema does not allow us to reach this point
- throw new SLCommandException(4000);
- }
- } catch (IOException e) {
- log.info("XML document in which the signature is to be integrated cannot be resolved.", e);
- throw new SLCommandException(4100);
- } catch (XMLStreamException e) {
- log.info("XML document in which the signature is to be integrated cannot be resolved.", e);
- throw new SLCommandException(4100);
- }
-
- LSParser parser = domImplLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
- DOMConfiguration domConfig = parser.getDomConfig();
- SimpleDOMErrorHandler errorHandler = new SimpleDOMErrorHandler();
- domConfig.setParameter("error-handler", errorHandler);
- LSResourceResolverAdapter resourceResolver = new LSResourceResolverAdapter(supplements);
- domConfig.setParameter("resource-resolver", resourceResolver);
- domConfig.setParameter("validate", Boolean.TRUE);
-
- Document doc;
- try {
- doc = parser.parse(input);
- } catch (DOMException e) {
- log.info("XML document in which the signature is to be integrated cannot be parsed.", e);
- throw new SLCommandException(4101);
- } catch (LSException e) {
- log.info("XML document in which the signature is to be integrated cannot be parsed.", e);
- throw new SLCommandException(4101);
- }
-
- if (resourceResolver.getError() != null) {
- log.info("Failed to resolve resource while parsing SignatureEnvironment document.", resourceResolver.getError());
- // we don't stop here, as we only _try_ to parse validating
- }
-
- if (errorHandler.hasFatalErrors()) {
- // log fatal errors
- if (log.isInfoEnabled()) {
- List errorMessages = errorHandler.getErrorMessages();
- StringBuffer sb = new StringBuffer();
- for (String errorMessage : errorMessages) {
- sb.append(" ");
- sb.append(errorMessage);
- }
- log.info("XML document in which the signature is to be integrated cannot be parsed." + sb.toString());
- }
- throw new SLCommandException(4101);
- }
-
- // log parsed document
- if (log.isTraceEnabled()) {
-
- StringWriter writer = new StringWriter();
-
- writer.write("SignatureEnvironment:\n");
-
- LSOutput output = domImplLS.createLSOutput();
- output.setCharacterStream(writer);
- output.setEncoding("UTF-8");
- LSSerializer serializer = domImplLS.createLSSerializer();
- serializer.write(doc, output);
-
- log.trace(writer.toString());
- }
-
- return doc;
-
- }
-
- /**
- * Creates an LSInput from the given reference URI.
- *
- * @param reference
- * the reference URL
- *
- * @return an LSInput from the given reference URI
- *
- * @throws IOException
- * if dereferencing the given reference fails
- */
- private LSInput createLSInput(String reference) throws IOException {
-
- URLDereferencer urlDereferencer = URLDereferencer.getInstance();
- StreamData streamData = urlDereferencer.dereference(reference, ctx.getDereferencerContext());
-
- String contentType = streamData.getContentType();
- String charset = HttpUtil.getCharset(contentType, true);
- InputStreamReader streamReader;
- try {
- streamReader = new InputStreamReader(streamData.getStream(), charset);
- } catch (UnsupportedEncodingException e) {
- log.info("Charset " + charset + " not supported. Using default.");
- streamReader = new InputStreamReader(streamData.getStream());
- }
-
- LSInput input = domImplLS.createLSInput();
- input = domImplLS.createLSInput();
- input.setCharacterStream(streamReader);
-
- return input;
-
- }
-
- /**
- * Creates an LSInput from the given content bytes.
- *
- * @param content
- * the content bytes
- *
- * @return an LSInput from the givne content bytes
- */
- private LSInput createLSInput(byte[] content) {
-
- ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
- LSInput input = domImplLS.createLSInput();
- input.setByteStream(inputStream);
-
- return input;
-
- }
-
- /**
- * Creates an LSInput from the given XML content.
- *
- * @param content
- * the XML content
- * @return an LSInput from the given XML content
- *
- * @throws XMLStreamException
- * if reading the XMLStream from the given XML content fails
- */
- private LSInput createLSInput(XMLContentType content) throws XMLStreamException {
-
- ByteArrayOutputStream redirectedStream = content.getRedirectedStream();
- if (redirectedStream != null) {
- LSInput input = domImplLS.createLSInput();
- input.setByteStream(new ByteArrayInputStream(redirectedStream.toByteArray()));
- return input;
- } else {
- return null;
- }
-
- }
-
- /**
- * Represents an xsd:Id-attribute value.
- *
- * @author mcentner
- */
- private class IdAttribute {
-
- private Element element;
-
- private String namespaceURI;
-
- private String localName;
-
- }
-
- /**
- * An implementation of the LSResourceResolver that uses a list of supplements
- * to resolve resources.
- *
- * @author mcentner
- */
- private class LSResourceResolverAdapter implements LSResourceResolver {
-
- List supplements;
-
- private LSResourceResolverAdapter(
- List supplements) {
- this.supplements = supplements;
- }
-
- private Exception error;
-
- /**
- * @return the error
- */
- public Exception getError() {
- return error;
- }
-
- @Override
- public LSInput resolveResource(String type, String namespaceURI,
- String publicId, String systemId, String baseURI) {
-
- if (log.isTraceEnabled()) {
- log.trace("Resolve resource :" +
- "\n type=" + type +
- "\n namespaceURI=" + namespaceURI +
- "\n publicId=" + publicId +
- "\n systemId=" + systemId +
- "\n baseURI=" + baseURI);
- }
-
- if (systemId != null) {
-
- log.debug("Resolve resource '" + systemId + "'.");
-
- for (DataObjectAssociationType supplement : supplements) {
-
- Base64XMLLocRefReqRefContentType content = supplement.getContent();
- if (content != null) {
-
- String reference = content.getReference();
- if (systemId.equals(reference)) {
-
- try {
- if (content.getLocRefContent() != null) {
- log.trace("Resolved resource '" + reference + "' to supplement with LocRefContent.");
- return createLSInput(content.getLocRefContent());
- } else if (content.getBase64Content() != null) {
- log.trace("Resolved resource '" + reference + "' to supplement with Base64Content.");
- return createLSInput(content.getBase64Content());
- } else if (content.getXMLContent() != null) {
- log.trace("Resolved resource '" + reference + "' to supplement with XMLContent.");
- return createLSInput((XMLContentType) content.getXMLContent());
- } else {
- return null;
- }
- } catch (IOException e) {
- log.info("Failed to resolve resource '" + systemId + "' to supplement.", e);
- error = e;
- return null;
- } catch (XMLStreamException e) {
- log.info("Failed to resolve resource '" + systemId + "' to supplement.", e);
- error = e;
- return null;
- }
-
- }
-
- }
-
- }
-
- log.info("Failed to resolve resource '" + systemId + "' to supplement. No such supplement.");
-
- }
-
- return null;
-
- }
-
-
- }
-
-}
+package at.gv.egiz.bku.slcommands.impl.xsect;
+
+import at.gv.egiz.stal.HashDataInput;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dom.DOMStructure;
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.crypto.dsig.Reference;
+import javax.xml.crypto.dsig.SignatureMethod;
+import javax.xml.crypto.dsig.SignedInfo;
+import javax.xml.crypto.dsig.XMLObject;
+import javax.xml.crypto.dsig.XMLSignature;
+import javax.xml.crypto.dsig.XMLSignatureException;
+import javax.xml.crypto.dsig.XMLSignatureFactory;
+import javax.xml.crypto.dsig.dom.DOMSignContext;
+import javax.xml.crypto.dsig.keyinfo.KeyInfo;
+import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
+import javax.xml.crypto.dsig.keyinfo.X509Data;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.etsi.uri._01903.v1_1.DataObjectFormatType;
+import org.etsi.uri._01903.v1_1.QualifyingPropertiesType;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSException;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSParser;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.w3c.dom.ls.LSSerializer;
+
+import at.buergerkarte.namespaces.securitylayer._1.Base64XMLLocRefReqRefContentType;
+import at.buergerkarte.namespaces.securitylayer._1.Base64XMLOptRefContentType;
+import at.buergerkarte.namespaces.securitylayer._1.DataObjectAssociationType;
+import at.buergerkarte.namespaces.securitylayer._1.DataObjectInfoType;
+import at.buergerkarte.namespaces.securitylayer._1.SignatureInfoCreationType;
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.utils.HexDump;
+import at.gv.egiz.bku.utils.urldereferencer.StreamData;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
+import at.gv.egiz.dom.DOMUtils;
+import at.gv.egiz.slbinding.impl.XMLContentType;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.xades.QualifyingPropertiesException;
+import at.gv.egiz.xades.QualifyingPropertiesFactory;
+
+/**
+ * This class represents an XML-Signature as to be created by the
+ * security layer command CreateXMLSignatureRequest.
+ *
+ * @author mcentner
+ */
+public class Signature {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(Signature.class);
+
+ /**
+ * The DOM implementation used.
+ */
+ private DOMImplementationLS domImplLS;
+
+ /**
+ * The SignatureContext for the XMLSignature.
+ */
+ private SignatureContext ctx;
+
+ /**
+ * The list of {@link DataObject}s for this signature.
+ */
+ private List dataObjects = new ArrayList();
+
+ /**
+ * A mapping from the Id-attribute values of this signature's
+ * ds:References to the corresponding {@link DataObject}s.
+ */
+// private Map dataObjectReferencIds = new HashMap();
+
+ /**
+ * The SignatureEnvironment for this signature.
+ */
+ private SignatureLocation signatureLocation;
+
+ /**
+ * The XML signature.
+ */
+ private XMLSignature xmlSignature;
+
+ /**
+ * A list of attributes of type xsd:ID to be registered in the {@link DOMSignContext}.
+ */
+ private List idAttributes = new ArrayList();
+
+ /**
+ * The signer's X509 certificate.
+ */
+ private X509Certificate signerCertificate;
+
+ /**
+ * The signing time.
+ */
+ private Date signingTime;
+
+ /**
+ * Creates a new SLXMLSignature instance.
+ */
+ public Signature(URLDereferencerContext dereferencerContext,
+ IdValueFactory idValueFactory,
+ AlgorithmMethodFactory algorithmMethodFactory) {
+
+ domImplLS = DOMUtils.getDOMImplementationLS();
+
+ ctx = new SignatureContext();
+
+ ctx.setSignatureFactory(XMLSignatureFactory.getInstance());
+
+ ctx.setDereferencerContext(dereferencerContext);
+ ctx.setIdValueFactory(idValueFactory);
+ ctx.setAlgorithmMethodFactory(algorithmMethodFactory);
+
+ }
+
+ /**
+ * @return the Document containing this Signature
+ */
+ public Document getDocument() {
+ return ctx.getDocument();
+ }
+
+ /**
+ * @return the parent Node for this Signature
+ */
+ public Node getParent() {
+ return (signatureLocation != null) ? signatureLocation.getParent() : null;
+ }
+
+ /**
+ * @return the next sibling Node for this Signature
+ */
+ public Node getNextSibling() {
+ return (signatureLocation != null) ? signatureLocation.getNextSibling() : null;
+ }
+
+ /**
+ * @return the XMLSignature
+ */
+ public XMLSignature getXMLSignature() {
+ return xmlSignature;
+ }
+
+ /**
+ * @return the list of {@link Reference}s of this Signature
+ */
+ @SuppressWarnings("unchecked")
+ public List getReferences() {
+ return (xmlSignature != null) ? xmlSignature.getSignedInfo().getReferences() : null;
+ }
+
+ /**
+ * @return the list of {@link XMLObject}s of this Signature
+ */
+ @SuppressWarnings("unchecked")
+ public List getXMLObjects() {
+ return (xmlSignature != null) ? xmlSignature.getObjects() : null;
+ }
+
+ /**
+ * Prepares the signature document with the information given by the
+ * signatureInfo provided.
+ *
+ * @param signatureInfo
+ * the SignatureInfo
+ *
+ * @throws SLCommandException
+ * if processing fails for any reason
+ * @throws IllegalStateException
+ * if the parent node has already been set
+ * @throws NullPointerException
+ * if signatureInfo is null
+ */
+ public void setSignatureInfo(SignatureInfoCreationType signatureInfo) throws SLCommandException {
+
+ if (signatureLocation != null) {
+ throw new IllegalStateException("SignatureEnvironment already set.");
+ }
+
+ Base64XMLOptRefContentType signatureEnvironment = signatureInfo.getSignatureEnvironment();
+
+ if (signatureEnvironment == null) {
+
+ // no SignatureEnvironment, so we use an empty document and the document as parent
+ ensureSignatureLocation();
+
+ } else {
+
+ // parse SignatureEnvrionment and use as document
+ Document document = parseSignatureEnvironment(signatureEnvironment, signatureInfo.getSupplement());
+ ctx.setDocument(document);
+
+ signatureLocation = new SignatureLocation(ctx);
+ signatureLocation.setSignatureInfo(signatureInfo);
+
+ }
+
+ }
+
+ /**
+ * Ensures a SignatureLocation for this Signature.
+ */
+ private void ensureSignatureLocation() {
+
+ if (signatureLocation == null) {
+ Document document = DOMUtils.createDocument();
+ ctx.setDocument(document);
+
+ signatureLocation = new SignatureLocation(ctx);
+ signatureLocation.setParent(document);
+ }
+
+ }
+
+ /**
+ * Adds a DataObject with the information given by the
+ * dataObjectInfo provided to this Signature.
+ *
+ * @param dataObjectInfo
+ * the DataObjectInfo element
+ *
+ * @throws SLCommandException
+ * if adding the DataObject fails
+ * @throws SLRequestException
+ * if the information provided by the given
+ * dataObjectInfo does not conform to the security
+ * layer specification
+ * @throws NullPointerException
+ * if dataObjectInfo is null
+ */
+ public void addDataObject(DataObjectInfoType dataObjectInfo) throws SLCommandException, SLRequestException {
+
+ ensureSignatureLocation();
+
+ DataObject dataObject = new DataObject(ctx);
+ dataObject.setDataObjectInfo(dataObjectInfo);
+
+ dataObjects.add(dataObject);
+
+// dataObjectReferencIds.put(dataObject.getReference().getId(), dataObject);
+
+ }
+
+ /**
+ * Sets the SigningTime qualifying property of this Signature.
+ *
+ * @param signingTime the signing time to set
+ */
+ public void setSigningTime(Date signingTime) {
+ this.signingTime = signingTime;
+ }
+
+ /**
+ * Sets the SignerCertificate qualifying property of this Signature.
+ *
+ * @param certificate the signer's certificate
+ */
+ public void setSignerCeritifcate(X509Certificate certificate) {
+ this.signerCertificate = certificate;
+ }
+
+ /**
+ * Builds the XMLSignature data structure of this Signature as configured by
+ * the various setter methods.
+ *
+ * @throws SLCommandException if building this signature fails
+ */
+ public void buildXMLSignature() throws SLCommandException {
+
+ List objects = new ArrayList();
+ List references = new ArrayList();
+
+ // add all data objects
+ for (DataObject dataObject : dataObjects) {
+ if (dataObject.getXmlObject() != null) {
+ objects.add(dataObject.getXmlObject());
+ }
+ if (dataObject.getReference() != null) {
+ references.add(dataObject.getReference());
+ }
+ }
+
+ addXAdESObjectAndReference(objects, references);
+
+ XMLSignatureFactory signatureFactory = ctx.getSignatureFactory();
+ AlgorithmMethodFactory algorithmMethodFactory = ctx.getAlgorithmMethodFactory();
+
+ CanonicalizationMethod cm;
+ SignatureMethod sm;
+ try {
+ cm = algorithmMethodFactory.createCanonicalizationMethod(ctx);
+ sm = algorithmMethodFactory.createSignatureMethod(ctx);
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Failed to get Canonicalization or Signature algorithm.", e);
+ throw new SLCommandException(4006);
+ } catch (InvalidAlgorithmParameterException e) {
+ log.error("Failed to get Canonicalization or Signature algorithm.", e);
+ throw new SLCommandException(4006);
+ }
+
+ String siId = ctx.getIdValueFactory().createIdValue("SignedInfo");
+
+ SignedInfo si = signatureFactory.newSignedInfo(cm, sm, references, siId);
+
+ KeyInfo ki = null;
+ if (signerCertificate != null) {
+ KeyInfoFactory kif = KeyInfoFactory.getInstance();
+ X509Data x509Data = kif.newX509Data(Collections.singletonList(signerCertificate));
+ ki = kif.newKeyInfo(Collections.singletonList(x509Data));
+ }
+
+ String signatureId = ctx.getIdValueFactory().createIdValue("Signature");
+ String signatureValueId = ctx.getIdValueFactory().createIdValue("SignatureValue");
+
+ xmlSignature = signatureFactory.newXMLSignature(si, ki, objects, signatureId, signatureValueId);
+
+ }
+
+ /**
+ * Sign this Signature using the given signContext.
+ *
+ * Call's {@link #buildXMLSignature()} if it has not been called yet.
+ *
+ *
+ * @param signContext
+ * the signing context
+ *
+ * @throws MarshalException
+ * if marshalling the XMLSignature fails
+ * @throws XMLSignatureException
+ * if signing the XMLSignature fails
+ * @throws SLCommandException
+ * if building the XMLSignature fails
+ * @throws NullPointerException
+ * if signContext is null
+ */
+ public void sign(DOMSignContext signContext) throws MarshalException, XMLSignatureException, SLCommandException {
+
+ if (xmlSignature == null) {
+ buildXMLSignature();
+ }
+
+ for (IdAttribute idAttribute : idAttributes) {
+ signContext.setIdAttributeNS(idAttribute.element, idAttribute.namespaceURI, idAttribute.localName);
+ }
+
+ // DO NOT USE:
+ // signContext.setProperty("iaik.xml.crypto.dsig.sign-over", Boolean.TRUE);
+
+ signContext.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
+
+ signContext.putNamespacePrefix(XMLSignature.XMLNS, "dsig");
+
+ signContext.setURIDereferencer(new URIDereferncerAdapter(ctx.getDereferencerContext()));
+
+ try {
+ xmlSignature.sign(signContext);
+ } catch (XMLSignatureException e) {
+ Throwable cause = e.getCause();
+ while (cause != null) {
+ if (cause instanceof STALSignatureException) {
+ int errorCode = ((STALSignatureException) cause).getErrorCode();
+ SLCommandException commandException = new SLCommandException(errorCode);
+ log.info("Failed to sign signature.", commandException);
+ throw commandException;
+ } else {
+ cause = cause.getCause();
+ }
+ }
+ throw e;
+ }
+
+ // debug
+ if (log.isTraceEnabled()) {
+ for (DataObject dataObject : dataObjects) {
+ Reference reference = dataObject.getReference();
+ InputStream digestInputStream = reference.getDigestInputStream();
+ if (digestInputStream != null) {
+ String mimeType = dataObject.getMimeType();
+ StringBuilder sb = new StringBuilder();
+ sb.append("DigestInput for Reference with id='");
+ sb.append(reference.getId());
+ sb.append("' (MIME-Type=");
+ sb.append(dataObject.getMimeType());
+ sb.append("):\n");
+ try {
+ if (mimeType != null && (
+ mimeType.startsWith("text") ||
+ "application/xhtml+xml".equals(mimeType))) {
+ byte[] b = new byte[512];
+ for (int l; (l = digestInputStream.read(b)) != -1;) {
+ sb.append(new String(b, 0, l));
+ }
+ } else {
+ sb.append(HexDump.hexDump(digestInputStream));
+ }
+ } catch (IOException e) {
+ log.error(e);
+ }
+ log.trace(sb.toString());
+ } else {
+ log.trace("Reference caching is not enabled.");
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Sign this Signature using the given stal implementation and
+ * keyboxIdentifier.
+ *
+ * This method configures an appropriate {@link DOMSignContext} and calls
+ * {@link #sign(DOMSignContext)}. If {@link #buildXMLSignature()} has not been
+ * called yet, it is called by this method.
+ *
+ *
+ * @param stal
+ * the STAL implementation to use
+ * @param keyboxIdentifier
+ * the KeyboxIdentifier to use
+ *
+ * @throws MarshalException
+ * if marshalling this Signature fails
+ * @throws XMLSignatureException
+ * if signing this Signature fails
+ * @throws SLCommandException
+ * if building this Signature fails
+ * @throws NullPointerException
+ * if stal or keyboxIdentifier is
+ * null
+ */
+ public void sign(STAL stal, String keyboxIdentifier) throws MarshalException, XMLSignatureException, SLCommandException {
+
+ if (stal == null) {
+ throw new NullPointerException("Argument 'stal' must not be null.");
+ }
+
+ if (keyboxIdentifier == null) {
+ throw new NullPointerException("Argument 'keyboxIdentifier' must not be null.");
+ }
+
+ if (xmlSignature == null) {
+ buildXMLSignature();
+ }
+
+ SignatureMethod signatureMethod = xmlSignature.getSignedInfo().getSignatureMethod();
+ String algorithm = signatureMethod.getAlgorithm();
+
+ //don't get hashDataInputs (digestInputStreams) now, only once Signature.sign() was called (cf STALSignature.engineSign)
+ PrivateKey privateKey = new STALPrivateKey(stal, algorithm, keyboxIdentifier, dataObjects); // hashDataInputs);
+
+ DOMSignContext signContext;
+ if (getNextSibling() == null) {
+ signContext = new DOMSignContext(privateKey, getParent());
+ } else {
+ signContext = new DOMSignContext(privateKey, getParent(), getNextSibling());
+ }
+
+ sign(signContext);
+ }
+
+// @Override
+// public HashDataInput getHashDataInput(final String referenceId) {
+// final DataObject dataObject = dataObjectReferencIds.get(referenceId);
+// if (dataObject != null) {
+// return new HashDataInput() {
+//
+// InputStream hashDataInput = dataObject.getReference().getDigestInputStream();
+//
+// @Override
+// public String getReferenceId() {
+// return referenceId;
+// }
+//
+// @Override
+// public String getMimeType() {
+// return dataObject.getMimeType();
+// }
+//
+// @Override
+// public InputStream getHashDataInput() {
+// return hashDataInput;
+// }
+// };
+// }
+// return null;
+// }
+
+ /**
+ * Adds the XAdES QualifyingProperties as an
+ * ds:Object and a corresponding ds:Reference to
+ * it's SignedProperties element to this Signature.
+ *
+ * @param objects
+ * the list of ds:Objects to add the created
+ * ds:Object to
+ * @param references
+ * the list of ds:References to add the created
+ * ds:Reference to
+ *
+ * @throws SLCommandException
+ * if creating and adding the XAdES
+ * QualifyingProperties fails
+ * @throws NullPointerException
+ * if objects or references is
+ * null
+ */
+ private void addXAdESObjectAndReference(List objects, List references) throws SLCommandException {
+
+ QualifyingPropertiesFactory factory = QualifyingPropertiesFactory.getInstance();
+
+ String idValue = ctx.getIdValueFactory().createIdValue("SignedProperties");
+
+ Date date = (signingTime != null) ? signingTime : new Date();
+
+ List signingCertificates;
+ if (signerCertificate != null) {
+ signingCertificates = Collections.singletonList(signerCertificate);
+ } else {
+ signingCertificates = Collections.emptyList();
+ }
+
+ // TODO: report MOA-SP bug
+ //
+ // The security layer specification mandates the use of version 1.2.2. of the
+ // XAdES QualifyingProperties. However MOA-SP supports only version 1.1.1. Therefore,
+ // the version 1.1.1 is used in order to be compatible with current MOA-SP versions.
+
+ List dataObjectFormats = new ArrayList();
+ for (DataObject dataObject : dataObjects) {
+ if (dataObject.getMimeType() != null && dataObject.getReference() != null) {
+ Reference reference = dataObject.getReference();
+ if (reference.getId() != null) {
+ String objectReference = "#" + reference.getId();
+ dataObjectFormats.add(factory.createDataObjectFormatType(
+ objectReference, dataObject.getMimeType(), dataObject
+ .getDescription()));
+ }
+ }
+ }
+
+ JAXBElement qualifyingProperties;
+ try {
+ qualifyingProperties = factory.createQualifyingProperties111(date, signingCertificates, idValue, dataObjectFormats);
+ } catch (QualifyingPropertiesException e) {
+ log.error("Failed to create QualifyingProperties.", e);
+ throw new SLCommandException(4000);
+ }
+
+ DocumentFragment fragment = ctx.getDocument().createDocumentFragment();
+
+ try {
+ factory.marshallQualifyingProperties(qualifyingProperties, fragment);
+ } catch (JAXBException e) {
+ log.error("Failed to marshal QualifyingProperties.", e);
+ throw new SLCommandException(4000);
+ }
+
+ List content = Collections.singletonList(new DOMStructure(fragment.getFirstChild()));
+
+ String objectIdValue = ctx.getIdValueFactory().createIdValue("Object");
+
+ XMLObject object = ctx.getSignatureFactory().newXMLObject(content, objectIdValue, null, null);
+
+ objects.add(object);
+
+ // TODO: Report MOA-SP Bug
+ //
+ // Direct referencing of the SignedPorperties Id-attribute is not supported by MOA-SP
+ // because the QualifyingProperties are parsed without the XAdES schema. Therefore,
+ // the shorthand XPointer could not be resolved.
+ //
+ // The following workaround uses an XPointer to select the SignedProperties in order
+ // to allow the signature to be verified with MOA-SP.
+
+ String referenceURI = "#xmlns(xades=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('"
+ + objectIdValue
+ + "')/child::xades:QualifyingProperties/child::xades:SignedProperties)";
+ DigestMethod dm;
+ try {
+ dm = ctx.getAlgorithmMethodFactory().createDigestMethod(ctx);
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Failed to get DigestMethod algorithm.", e);
+ throw new SLCommandException(4006);
+ } catch (InvalidAlgorithmParameterException e) {
+ log.error("Failed to get DigestMethod algorithm.", e);
+ throw new SLCommandException(4006);
+ }
+
+ String referenceIdValue = ctx.getIdValueFactory().createIdValue("Reference");
+ String referenceType = QualifyingPropertiesFactory.SIGNED_PROPERTIES_REFERENCE_TYPE_V1_1_1;
+
+ Reference reference = ctx.getSignatureFactory().newReference(referenceURI, dm, null, referenceType, referenceIdValue);
+
+ references.add(reference);
+
+ Node child = fragment.getFirstChild();
+ if (child instanceof Element) {
+ NodeList nodes = ((Element) child).getElementsByTagNameNS(QualifyingPropertiesFactory.NS_URI_V1_1_1, "SignedProperties");
+ if (nodes.getLength() > 0) {
+ IdAttribute idAttribute = new IdAttribute();
+ idAttribute.element = (Element) nodes.item(0);
+ idAttribute.namespaceURI = null;
+ idAttribute.localName = "Id";
+ idAttributes.add(idAttribute);
+ }
+ }
+
+ }
+
+ /**
+ * Parse the SignatureEnvironment.
+ *
+ * @param signatureEnvironment
+ * the SignatureEnvironment element
+ * @param supplements
+ * an optional list of Supplements (may be
+ * null)
+ *
+ * @return the parsed SignatureEnvironment document
+ *
+ * @throws SLCommandException
+ * if parsing the SignatureEnvironment fails
+ * @throws NullPointerException
+ * if signatureEnvironment is null
+ */
+ private Document parseSignatureEnvironment(
+ Base64XMLOptRefContentType signatureEnvironment,
+ List supplements) throws SLCommandException {
+
+ if (signatureEnvironment == null) {
+ throw new NullPointerException("Argument 'signatureEnvironment' must not be null.");
+ }
+
+ LSInput input;
+ try {
+ if (signatureEnvironment.getReference() != null) {
+ log.debug("SignatureEnvironment contains Reference " + signatureEnvironment.getReference() + ".");
+ input = createLSInput(signatureEnvironment.getReference());
+ } else if (signatureEnvironment.getBase64Content() != null) {
+ log.debug("SignatureEnvironment contains Base64Content.");
+ input = createLSInput(signatureEnvironment.getBase64Content());
+ } else if (signatureEnvironment.getXMLContent() != null) {
+ log.debug("SignatureEnvironment contains XMLContent.");
+ input = createLSInput((XMLContentType) signatureEnvironment.getXMLContent());
+ } else {
+ // the schema does not allow us to reach this point
+ throw new SLCommandException(4000);
+ }
+ } catch (IOException e) {
+ log.info("XML document in which the signature is to be integrated cannot be resolved.", e);
+ throw new SLCommandException(4100);
+ } catch (XMLStreamException e) {
+ log.info("XML document in which the signature is to be integrated cannot be resolved.", e);
+ throw new SLCommandException(4100);
+ }
+
+ LSParser parser = domImplLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
+ DOMConfiguration domConfig = parser.getDomConfig();
+ SimpleDOMErrorHandler errorHandler = new SimpleDOMErrorHandler();
+ domConfig.setParameter("error-handler", errorHandler);
+ LSResourceResolverAdapter resourceResolver = new LSResourceResolverAdapter(supplements);
+ domConfig.setParameter("resource-resolver", resourceResolver);
+ domConfig.setParameter("validate", Boolean.TRUE);
+
+ Document doc;
+ try {
+ doc = parser.parse(input);
+ } catch (DOMException e) {
+ log.info("XML document in which the signature is to be integrated cannot be parsed.", e);
+ throw new SLCommandException(4101);
+ } catch (LSException e) {
+ log.info("XML document in which the signature is to be integrated cannot be parsed.", e);
+ throw new SLCommandException(4101);
+ }
+
+ if (resourceResolver.getError() != null) {
+ log.info("Failed to resolve resource while parsing SignatureEnvironment document.", resourceResolver.getError());
+ // we don't stop here, as we only _try_ to parse validating
+ }
+
+ if (errorHandler.hasFatalErrors()) {
+ // log fatal errors
+ if (log.isInfoEnabled()) {
+ List errorMessages = errorHandler.getErrorMessages();
+ StringBuffer sb = new StringBuffer();
+ for (String errorMessage : errorMessages) {
+ sb.append(" ");
+ sb.append(errorMessage);
+ }
+ log.info("XML document in which the signature is to be integrated cannot be parsed." + sb.toString());
+ }
+ throw new SLCommandException(4101);
+ }
+
+ // log parsed document
+ if (log.isTraceEnabled()) {
+
+ StringWriter writer = new StringWriter();
+
+ writer.write("SignatureEnvironment:\n");
+
+ LSOutput output = domImplLS.createLSOutput();
+ output.setCharacterStream(writer);
+ output.setEncoding("UTF-8");
+ LSSerializer serializer = domImplLS.createLSSerializer();
+ serializer.write(doc, output);
+
+ log.trace(writer.toString());
+ }
+
+ return doc;
+
+ }
+
+ /**
+ * Creates an LSInput from the given reference URI.
+ *
+ * @param reference
+ * the reference URL
+ *
+ * @return an LSInput from the given reference URI
+ *
+ * @throws IOException
+ * if dereferencing the given reference fails
+ */
+ private LSInput createLSInput(String reference) throws IOException {
+
+ URLDereferencer urlDereferencer = URLDereferencer.getInstance();
+ StreamData streamData = urlDereferencer.dereference(reference, ctx.getDereferencerContext());
+
+ String contentType = streamData.getContentType();
+ String charset = HttpUtil.getCharset(contentType, true);
+ InputStreamReader streamReader;
+ try {
+ streamReader = new InputStreamReader(streamData.getStream(), charset);
+ } catch (UnsupportedEncodingException e) {
+ log.info("Charset " + charset + " not supported. Using default.");
+ streamReader = new InputStreamReader(streamData.getStream());
+ }
+
+ LSInput input = domImplLS.createLSInput();
+ input = domImplLS.createLSInput();
+ input.setCharacterStream(streamReader);
+
+ return input;
+
+ }
+
+ /**
+ * Creates an LSInput from the given content bytes.
+ *
+ * @param content
+ * the content bytes
+ *
+ * @return an LSInput from the givne content bytes
+ */
+ private LSInput createLSInput(byte[] content) {
+
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
+ LSInput input = domImplLS.createLSInput();
+ input.setByteStream(inputStream);
+
+ return input;
+
+ }
+
+ /**
+ * Creates an LSInput from the given XML content.
+ *
+ * @param content
+ * the XML content
+ * @return an LSInput from the given XML content
+ *
+ * @throws XMLStreamException
+ * if reading the XMLStream from the given XML content fails
+ */
+ private LSInput createLSInput(XMLContentType content) throws XMLStreamException {
+
+ ByteArrayOutputStream redirectedStream = content.getRedirectedStream();
+ if (redirectedStream != null) {
+ LSInput input = domImplLS.createLSInput();
+ input.setByteStream(new ByteArrayInputStream(redirectedStream.toByteArray()));
+ return input;
+ } else {
+ return null;
+ }
+
+ }
+
+ /**
+ * Represents an xsd:Id-attribute value.
+ *
+ * @author mcentner
+ */
+ private class IdAttribute {
+
+ private Element element;
+
+ private String namespaceURI;
+
+ private String localName;
+
+ }
+
+ /**
+ * An implementation of the LSResourceResolver that uses a list of supplements
+ * to resolve resources.
+ *
+ * @author mcentner
+ */
+ private class LSResourceResolverAdapter implements LSResourceResolver {
+
+ List supplements;
+
+ private LSResourceResolverAdapter(
+ List supplements) {
+ this.supplements = supplements;
+ }
+
+ private Exception error;
+
+ /**
+ * @return the error
+ */
+ public Exception getError() {
+ return error;
+ }
+
+ @Override
+ public LSInput resolveResource(String type, String namespaceURI,
+ String publicId, String systemId, String baseURI) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("Resolve resource :" +
+ "\n type=" + type +
+ "\n namespaceURI=" + namespaceURI +
+ "\n publicId=" + publicId +
+ "\n systemId=" + systemId +
+ "\n baseURI=" + baseURI);
+ }
+
+ if (systemId != null) {
+
+ log.debug("Resolve resource '" + systemId + "'.");
+
+ for (DataObjectAssociationType supplement : supplements) {
+
+ Base64XMLLocRefReqRefContentType content = supplement.getContent();
+ if (content != null) {
+
+ String reference = content.getReference();
+ if (systemId.equals(reference)) {
+
+ try {
+ if (content.getLocRefContent() != null) {
+ log.trace("Resolved resource '" + reference + "' to supplement with LocRefContent.");
+ return createLSInput(content.getLocRefContent());
+ } else if (content.getBase64Content() != null) {
+ log.trace("Resolved resource '" + reference + "' to supplement with Base64Content.");
+ return createLSInput(content.getBase64Content());
+ } else if (content.getXMLContent() != null) {
+ log.trace("Resolved resource '" + reference + "' to supplement with XMLContent.");
+ return createLSInput((XMLContentType) content.getXMLContent());
+ } else {
+ return null;
+ }
+ } catch (IOException e) {
+ log.info("Failed to resolve resource '" + systemId + "' to supplement.", e);
+ error = e;
+ return null;
+ } catch (XMLStreamException e) {
+ log.info("Failed to resolve resource '" + systemId + "' to supplement.", e);
+ error = e;
+ return null;
+ }
+
+ }
+
+ }
+
+ }
+
+ log.info("Failed to resolve resource '" + systemId + "' to supplement. No such supplement.");
+
+ }
+
+ return null;
+
+ }
+
+
+ }
+
+}
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/accesscontrol/config/AccessControl.xsd b/bkucommon/src/main/resources/at/gv/egiz/bku/accesscontrol/config/AccessControl.xsd
new file mode 100644
index 00000000..9031ea78
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/accesscontrol/config/AccessControl.xsd
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--
cgit v1.2.3
From a3361b40aa8f92849c50db27e349e17b87bebb1e Mon Sep 17 00:00:00 2001
From: wbauer
Date: Tue, 9 Sep 2008 12:40:52 +0000
Subject: improved security handling and added shutdown handler
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@27 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../online/applet/InternalSSLSocketFactory.java | 4 +-
.../at/gv/egiz/bku/online/conf/Configurator.java | 8 +--
.../gv/egiz/bku/online/webapp/ResultServlet.java | 3 +-
.../gv/egiz/bku/online/webapp/ShutdownHandler.java | 31 ++++++++
.../egiz/bku/online/conf/accessControlConfig.xml | 3 +-
.../src/main/webapp/WEB-INF/applicationContext.xml | 6 +-
.../accesscontroller/AuthenticationClassifier.java | 82 +++++++++++++++-------
.../egiz/bku/binding/BindingProcessorManager.java | 4 +-
.../bku/binding/BindingProcessorManagerImpl.java | 11 ++-
.../AuthenticationClassifierTest.java | 28 ++++++++
.../egiz/bku/accesscontroller/www.a-trust.at.crt | 28 ++++++++
11 files changed, 169 insertions(+), 39 deletions(-)
create mode 100644 BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java
create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt
(limited to 'bkucommon/src/main')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
index 79c369a2..fa3587e4 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
@@ -40,13 +40,13 @@ import org.apache.commons.logging.LogFactory;
public class InternalSSLSocketFactory extends SSLSocketFactory {
+ private final static String GOV_DOMAIN = ".gv.at";
+
private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory();
private final static Log log = LogFactory
.getLog(InternalSSLSocketFactory.class);
- private final static String GOV_DOMAIN = ".gv.at";
-
private SSLSocket sslSocket;
private SSLSocketFactory proxy;
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
index a0a268e4..de577139 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
@@ -52,9 +52,9 @@ public class Configurator {
protected void configureProviders() {
log.debug("Registering security providers");
- Security.insertProviderAt(new IAIK(), 1);
- Security.insertProviderAt(new ECCProvider(false), 2);
- Security.addProvider(new STALProvider());
+ Security.insertProviderAt(new IAIK(), 1);
+ Security.insertProviderAt(new ECCProvider(false), 2);
+ Security.addProvider(new STALProvider());
XSecProvider.addAsProvider(false);
StringBuilder sb = new StringBuilder();
sb.append("Registered providers: ");
@@ -65,7 +65,7 @@ public class Configurator {
log.debug(sb.toString());
}
- public void configure() {
+ public void configure() {
configureProviders();
configUrlConnections();
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index 6c1a4c3a..bc3edf18 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -115,6 +115,7 @@ public class ResultServlet extends SpringBKUServlet {
resp.setContentType(bp.getResultContentType());
resp.setCharacterEncoding(encoding);
bp.writeResultTo(resp.getOutputStream(), encoding);
- session.invalidate();
+ session.invalidate();
+ getBindingProcessorManager().removeBindingProcessor(bp.getId());
}
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java
new file mode 100644
index 00000000..86da6c06
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java
@@ -0,0 +1,31 @@
+package at.gv.egiz.bku.online.webapp;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextClosedEvent;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+
+public class ShutdownHandler implements ApplicationListener {
+
+ private static Log log = LogFactory.getLog(ShutdownHandler.class);
+
+ private BindingProcessorManager bindingProcessorManager;
+
+ public void setBindingProcessorManager(
+ BindingProcessorManager bindingProcessorManager) {
+ this.bindingProcessorManager = bindingProcessorManager;
+ }
+
+ @Override
+ public void onApplicationEvent(ApplicationEvent event) {
+ if (event instanceof ContextClosedEvent) {
+ log.info("Shutting down BKU");
+ bindingProcessorManager.shutdownNow();
+ }
+
+ }
+
+}
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
index 69b45d1b..f8d1411c 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
@@ -54,8 +54,7 @@
certified
-
-
+
IdentityLink
derived
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index 4bb5e8e2..f87d09f5 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -49,5 +49,9 @@
scope="singleton" init-method="configure">
-
+
+
+
+
+
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
index ace8a75a..ed4b9bda 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
@@ -1,30 +1,31 @@
/*
-* 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.
-*/
+ * 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.bku.accesscontroller;
import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.ANONYMOUS;
import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.CERTIFIED;
-import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.PSEUDO_ANONYMOUS;
import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.CERTIFIED_GOV_AGENCY;
+import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.PSEUDO_ANONYMOUS;
-import java.net.InetAddress;
import java.net.URL;
-import java.net.UnknownHostException;
+import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
+import java.util.Collection;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -37,6 +38,39 @@ public class AuthenticationClassifier {
private AuthenticationClassifier() {
}
+ public static boolean isGovAgency(X509Certificate cert) {
+ String[] rdns = (cert.getSubjectX500Principal().getName()).split(",");
+ for (String rdn : rdns) {
+ if (rdn.startsWith("CN=")) {
+ String dns = rdn.split("=")[1];
+ log.trace("Analyzing cn dn: " + dns);
+ if (dns.endsWith(GOV_DOMAIN)) {
+ return true;
+ }
+ }
+ }
+ try {
+ Collection> sanList = cert.getSubjectAlternativeNames();
+ if (sanList != null) {
+ for (List> san : sanList) {
+ log.trace("Analyzing subj. alt name: " + san);
+ if ((Integer) san.get(0) == 2) {
+ String dns = (String) san.get(1);
+ if (dns.endsWith(GOV_DOMAIN)) {
+ return true;
+ }
+ }
+ }
+ }
+ } catch (CertificateParsingException e) {
+ log.error(e);
+ }
+ if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
+ return true;
+ }
+ return false;
+ }
+
/**
* Client Certificates are currently not supported
*
@@ -45,13 +79,8 @@ public class AuthenticationClassifier {
URL url, X509Certificate cert) {
if (isDataUrl) {
if (url.getProtocol().equalsIgnoreCase("https")) {
- try {
- if (InetAddress.getByName(url.getHost()).getCanonicalHostName()
- .endsWith(GOV_DOMAIN)) {
- return CERTIFIED_GOV_AGENCY;
- }
- } catch (UnknownHostException e) {
- log.error("Cannot determine host name", e);
+ if (isGovAgency(cert)) {
+ return CERTIFIED_GOV_AGENCY;
}
if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
return CERTIFIED_GOV_AGENCY;
@@ -68,7 +97,8 @@ public class AuthenticationClassifier {
/**
*
* @param isDataUrl
- * @param url if the url's protocol is https a cert parameter must be provided.
+ * @param url
+ * if the url's protocol is https a cert parameter must be provided.
* @param cert
* @return
*/
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
index ed37f08f..aaf81e51 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
@@ -99,5 +99,7 @@ public interface BindingProcessorManager {
*/
public Set getManagedIds();
- public void shutdown();
+ public void shutdown();
+
+ public void shutdownNow();
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 6f5ca2d2..0082de26 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -149,6 +149,11 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
public void shutdown() {
log.info("Shutting down the BindingProcessorManager");
executorService.shutdown();
+ }
+
+ public void shutdownNow() {
+ log.info("Shutting down the BindingProcessorManager NOW!");
+ executorService.shutdownNow();
}
/**
@@ -223,7 +228,8 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
throw new SLRuntimeException(
"Clashing ids, cannot process bindingprocessor with id:"
+ aBindingProcessor.getId());
- }
+ }
+ log.debug("processing bindingprocessor: "+aBindingProcessor.getId());
Future> f = executorService.submit(aBindingProcessor);
bindingProcessorMap.put(aBindingProcessor.getId(), new MapEntityWrapper(f,
aBindingProcessor));
@@ -235,7 +241,8 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
}
@Override
- public void removeBindingProcessor(Id sessionId) {
+ public void removeBindingProcessor(Id sessionId) {
+ log.debug("Removing binding processor: "+sessionId);
MapEntityWrapper wrapper = bindingProcessorMap
.get(sessionId);
if (wrapper == null) {
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java
new file mode 100644
index 00000000..c339704e
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java
@@ -0,0 +1,28 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import static org.junit.Assert.assertTrue;
+
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class AuthenticationClassifierTest {
+
+ private X509Certificate atrust;
+
+ @Before
+ public void setUp() throws Exception {
+ atrust = (X509Certificate) CertificateFactory.getInstance("X509")
+ .generateCertificate(
+ getClass().getClassLoader().getResourceAsStream(
+ "at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt"));
+ }
+
+ @Test
+ public void testATrust() {
+ assertTrue(AuthenticationClassifier.isGovAgency(atrust));
+ }
+
+}
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt
new file mode 100644
index 00000000..11cde026
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt
@@ -0,0 +1,28 @@
+-----BEGIN CERTIFICATE-----
+MIIEyjCCA7KgAwIBAgIDA4LFMA0GCSqGSIb3DQEBBQUAMIGHMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRYwFAYDVQQLDA1hLXNpZ24tU1NM
+LTAzMRYwFAYDVQQDDA1hLXNpZ24tU1NMLTAzMB4XDTA3MTIxMTExMTQ0NFoXDTEy
+MTIxMTExMTQ0NFowYTELMAkGA1UEBhMCQVQxEDAOBgNVBAoMB0EtVHJ1c3QxEDAO
+BgNVBAsMB0EtVHJ1c3QxFzAVBgNVBAMMDnd3dy5hLXRydXN0LmF0MRUwEwYDVQQF
+Eww2NDk2ODY0MDkzMzkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK2oRtJ4
+R9ipr/NUH5F4p86cjWtzT1g+ytpjg1lwh4HNY+lTjdUcx/VKBrtf0N8qnMK1UHhA
+LLvvZeKTFi3L15i5or1WjZRi4RfH/4vcL0o1w/91liwMOKH3D30omnVceuxmQp2j
+V9QrGPbz0/IsP51cnBWCBTWGqgfBebB8v1FLAgMBAAGjggHmMIIB4jATBgNVHSME
+DDAKgAhAPqHTYrQD3TByBggrBgEFBQcBAQRmMGQwJwYIKwYBBQUHMAGGG2h0dHA6
+Ly9vY3NwLmEtdHJ1c3QuYXQvb2NzcDA5BggrBgEFBQcwAoYtaHR0cDovL3d3dy5h
+LXRydXN0LmF0L2NlcnRzL2Etc2lnbi1zc2wtMDMuY3J0MEsGA1UdIAREMEIwQAYG
+KigAEQEUMDYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cuYS10cnVzdC5hdC9kb2Nz
+L2NwL2Etc2lnbi1zc2wwgY8GA1UdHwSBhzCBhDCBgaB/oH2Ge2xkYXA6Ly9sZGFw
+LmEtdHJ1c3QuYXQvb3U9YS1zaWduLVNTTC0wMyxvPUEtVHJ1c3QsYz1BVD9jZXJ0
+aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2VydGlm
+aWNhdGlvbkF1dGhvcml0eTARBgNVHQ4ECgQIRu1a/pOZZpMwDgYDVR0PAQH/BAQD
+AgWgMEoGA1UdEQRDMEGBEW9mZmljZUBhLXRydXN0LmF0gg53d3cuYS10cnVzdC5h
+dIIcemRhLnNvemlhbHZlcnNpY2hlcnVuZy5ndi5hdDAJBgNVHRMEAjAAMA0GCSqG
+SIb3DQEBBQUAA4IBAQCQGheDpci0lnSEoKw/N3tbJqn/KG49/OWZcsw6XZiAEHsx
+Rx9TlNJhL2d/SqFXBmmqfR496gdzTb4823WJsmXtyBY2t5ZnmD9tY5oJi5bHKchO
+50QCd1x24HzH1mxPReCJzRxzLEM/znojEMdYqQ5Y+BZuj7n9BY+l2nY0Qnhn09FE
+dxXAfNcuZnZavLJgk7vTBg8OFkAh6DJ21ACxf/y+rN53gKFK4Jh+PodRu0J2tK8B
+wAZg7HlnT8U7tcEsf1JnsBhlzAWCHgZc6whgBbDHFs6WSFWuobKN+maU91g/Tvgk
+Obos/EhVNti54Zhu1PO9RSKpKkwzTJT4kmGtaOJN
+-----END CERTIFICATE-----
--
cgit v1.2.3
From 66cfb865fbfa7af514e803003f928d77f1156e46 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Thu, 11 Sep 2008 12:16:35 +0000
Subject: Added to be signed data validation.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@32 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUViewer/.classpath | 10 +
BKUViewer/.project | 23 +
BKUViewer/.settings/org.eclipse.jdt.core.prefs | 5 +
BKUViewer/.settings/org.maven.ide.eclipse.prefs | 8 +
BKUViewer/pom.xml | 44 ++
.../at/gv/egiz/bku/slxhtml/SLXHTMLValidator.java | 251 ++++++++
.../egiz/bku/slxhtml/css/CSSValidatorSLXHTML.java | 95 +++
.../bku/slxhtml/css/CssBackgroundColorSLXHTML.java | 57 ++
.../egiz/bku/slxhtml/css/CssBackgroundSLXHTML.java | 93 +++
.../slxhtml/css/CssBorderBottomColorSLXHTML.java | 57 ++
.../bku/slxhtml/css/CssBorderColorSLXHTML.java | 81 +++
.../bku/slxhtml/css/CssBorderLeftColorSLXHTML.java | 57 ++
.../slxhtml/css/CssBorderRightColorSLXHTML.java | 57 ++
.../gv/egiz/bku/slxhtml/css/CssBorderSLXHTML.java | 85 +++
.../bku/slxhtml/css/CssBorderTopColorSLXHTML.java | 57 ++
.../gv/egiz/bku/slxhtml/css/CssColorSLXHTML.java | 99 ++++
.../at/gv/egiz/bku/slxhtml/css/CssFontSLXHTML.java | 59 ++
.../bku/slxhtml/css/CssLetterSpacingSLXHTML.java | 54 ++
.../bku/slxhtml/css/CssMarginBottomSLXHTML.java | 60 ++
.../egiz/bku/slxhtml/css/CssMarginLeftSLXHTML.java | 61 ++
.../bku/slxhtml/css/CssMarginRightSLXHTML.java | 60 ++
.../gv/egiz/bku/slxhtml/css/CssMarginSLXHTML.java | 101 ++++
.../egiz/bku/slxhtml/css/CssMarginTopSLXHTML.java | 61 ++
.../bku/slxhtml/css/CssPaddingBottomSLXHTML.java | 60 ++
.../bku/slxhtml/css/CssPaddingLeftSLXHTML.java | 60 ++
.../bku/slxhtml/css/CssPaddingRightSLXHTML.java | 60 ++
.../gv/egiz/bku/slxhtml/css/CssPaddingSLXHTML.java | 102 ++++
.../egiz/bku/slxhtml/css/CssPaddingTopSLXHTML.java | 61 ++
.../bku/slxhtml/css/CssTextDecorationSLXHTML.java | 51 ++
.../bku/slxhtml/css/CssWordSpacingSLXHTML.java | 54 ++
.../slxhtml/css/SLXHTMLInvalidParamException.java | 71 +++
.../at/gv/egiz/bku/slxhtml/css/SLXHTMLStyle.java | 22 +
.../egiz/bku/slxhtml/css/TableLayoutSLXHTML.java | 45 ++
.../java/at/gv/egiz/bku/text/TextValidator.java | 32 +
.../services/at.gv.egiz.bku.viewer.Validator | 2 +
.../at/gv/egiz/bku/slxhtml/slxhtml-model-1.xsd | 469 +++++++++++++++
.../at/gv/egiz/bku/slxhtml/slxhtml-modules-1.xsd | 248 ++++++++
.../resources/at/gv/egiz/bku/slxhtml/slxhtml.xsd | 70 +++
.../at/gv/egiz/bku/slxhtml/xhtml-attribs-1.xsd | 72 +++
.../at/gv/egiz/bku/slxhtml/xhtml-blkphras-1.xsd | 161 ++++++
.../at/gv/egiz/bku/slxhtml/xhtml-blkpres-1.xsd | 37 ++
.../at/gv/egiz/bku/slxhtml/xhtml-blkstruct-1.xsd | 49 ++
.../at/gv/egiz/bku/slxhtml/xhtml-datatypes-1.xsd | 175 ++++++
.../at/gv/egiz/bku/slxhtml/xhtml-framework-1.xsd | 66 +++
.../at/gv/egiz/bku/slxhtml/xhtml-image-1.xsd | 45 ++
.../at/gv/egiz/bku/slxhtml/xhtml-inlphras-1.xsd | 163 ++++++
.../at/gv/egiz/bku/slxhtml/xhtml-inlpres-1.xsd | 39 ++
.../at/gv/egiz/bku/slxhtml/xhtml-inlstruct-1.xsd | 50 ++
.../at/gv/egiz/bku/slxhtml/xhtml-list-1.xsd | 99 ++++
.../at/gv/egiz/bku/slxhtml/xhtml-pres-1.xsd | 51 ++
.../at/gv/egiz/bku/slxhtml/xhtml-struct-1.xsd | 116 ++++
.../at/gv/egiz/bku/slxhtml/xhtml-style-1.xsd | 53 ++
.../at/gv/egiz/bku/slxhtml/xhtml-table-1.xsd | 272 +++++++++
.../at/gv/egiz/bku/slxhtml/xhtml-text-1.xsd | 67 +++
.../main/resources/at/gv/egiz/bku/slxhtml/xml.xsd | 145 +++++
.../org/w3c/css/properties/Config.properties | 32 +
.../css/properties/ProfilesProperties.properties | 30 +
.../css/properties/SLXHTMLProperties.properties | 641 +++++++++++++++++++++
.../java/at/gv/egiz/bku/slxhtml/ValidatorTest.java | 66 +++
.../gv/egiz/bku/slxhtml/css/CssValidatorTest.java | 75 +++
.../resources/at/gv/egiz/bku/slxhtml/test.xhtml | 10 +
.../src/test/resources/commons-logging.properties | 1 +
BKUViewer/src/test/resources/log4j.properties | 19 +
bkucommon/pom.xml | 9 +-
.../binding/multipart/InputStreamPartSource.java | 5 -
.../egiz/bku/binding/multipart/SLResultPart.java | 5 -
.../impl/CreateXMLSignatureCommandImpl.java | 13 +-
.../egiz/bku/slcommands/impl/xsect/DataObject.java | 119 +++-
.../bku/slcommands/impl/xsect/STALSignature.java | 11 +-
.../egiz/bku/slcommands/impl/xsect/Signature.java | 10 +-
.../egiz/bku/slexceptions/SLViewerException.java | 7 +-
.../at/gv/egiz/bku/viewer/ValidationException.java | 38 ++
.../main/java/at/gv/egiz/bku/viewer/Validator.java | 25 +
.../at/gv/egiz/bku/viewer/ValidatorFactory.java | 165 ++++++
.../bku/slcommands/impl/xsect/SignatureTest.java | 21 +-
pom.xml | 33 +-
76 files changed, 5885 insertions(+), 52 deletions(-)
create mode 100644 BKUViewer/.classpath
create mode 100644 BKUViewer/.project
create mode 100644 BKUViewer/.settings/org.eclipse.jdt.core.prefs
create mode 100644 BKUViewer/.settings/org.maven.ide.eclipse.prefs
create mode 100644 BKUViewer/pom.xml
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/SLXHTMLValidator.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CSSValidatorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundColorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderBottomColorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderColorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderLeftColorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderRightColorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderTopColorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssColorSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssFontSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssLetterSpacingSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginBottomSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginLeftSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginRightSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginTopSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingBottomSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingLeftSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingRightSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingTopSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssTextDecorationSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssWordSpacingSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLInvalidParamException.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLStyle.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/TableLayoutSLXHTML.java
create mode 100644 BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java
create mode 100644 BKUViewer/src/main/resources/META-INF/services/at.gv.egiz.bku.viewer.Validator
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-model-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-modules-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-attribs-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkphras-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkpres-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkstruct-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-datatypes-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-framework-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-image-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlphras-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlpres-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlstruct-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-list-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-pres-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-struct-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-style-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-table-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-text-1.xsd
create mode 100644 BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xml.xsd
create mode 100644 BKUViewer/src/main/resources/org/w3c/css/properties/Config.properties
create mode 100644 BKUViewer/src/main/resources/org/w3c/css/properties/ProfilesProperties.properties
create mode 100644 BKUViewer/src/main/resources/org/w3c/css/properties/SLXHTMLProperties.properties
create mode 100644 BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
create mode 100644 BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/css/CssValidatorTest.java
create mode 100644 BKUViewer/src/test/resources/at/gv/egiz/bku/slxhtml/test.xhtml
create mode 100644 BKUViewer/src/test/resources/commons-logging.properties
create mode 100644 BKUViewer/src/test/resources/log4j.properties
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidationException.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/viewer/Validator.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java
(limited to 'bkucommon/src/main')
diff --git a/BKUViewer/.classpath b/BKUViewer/.classpath
new file mode 100644
index 00000000..1041acfa
--- /dev/null
+++ b/BKUViewer/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/.project b/BKUViewer/.project
new file mode 100644
index 00000000..c18f3f10
--- /dev/null
+++ b/BKUViewer/.project
@@ -0,0 +1,23 @@
+
+
+ BKUViewer
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.maven.ide.eclipse.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.maven.ide.eclipse.maven2Nature
+
+
diff --git a/BKUViewer/.settings/org.eclipse.jdt.core.prefs b/BKUViewer/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..59690d7b
--- /dev/null
+++ b/BKUViewer/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+#Tue Sep 09 16:54:39 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/BKUViewer/.settings/org.maven.ide.eclipse.prefs b/BKUViewer/.settings/org.maven.ide.eclipse.prefs
new file mode 100644
index 00000000..feb34e97
--- /dev/null
+++ b/BKUViewer/.settings/org.maven.ide.eclipse.prefs
@@ -0,0 +1,8 @@
+#Tue Sep 09 16:54:38 CEST 2008
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+version=1
diff --git a/BKUViewer/pom.xml b/BKUViewer/pom.xml
new file mode 100644
index 00000000..d7dbe0aa
--- /dev/null
+++ b/BKUViewer/pom.xml
@@ -0,0 +1,44 @@
+
+
+ bku
+ at.gv.egiz
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ at.gv.egiz
+ BKUViewer
+ BKU viewer components
+ 1.0-SNAPSHOT
+
+
+
+ at.gv.egiz
+ bkucommon
+ 1.0-SNAPSHOT
+
+
+ commons-logging
+ commons-logging
+
+
+ xerces
+ xercesImpl
+
+
+ org.w3c
+ css-validator
+ 2.1-mocca
+
+
+ org.w3c
+ jigsaw
+
+
+ tagsoup
+ tagsoup
+
+
+
+
+
\ No newline at end of file
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/SLXHTMLValidator.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/SLXHTMLValidator.java
new file mode 100644
index 00000000..7ce5fdbe
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/SLXHTMLValidator.java
@@ -0,0 +1,251 @@
+/*
+* 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.bku.slxhtml;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.util.Locale;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.ValidatorHandler;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import at.gv.egiz.bku.slxhtml.css.CSSValidatorSLXHTML;
+import at.gv.egiz.bku.viewer.ValidationException;
+
+public class SLXHTMLValidator implements at.gv.egiz.bku.viewer.Validator {
+
+ /**
+ * The schema file for the SLXHTML schema.
+ */
+ private static final String SLXHTML_SCHEMA_FILE = "at/gv/egiz/bku/slxhtml/slxhtml.xsd";
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(SLXHTMLValidator.class);
+
+ private static Schema slSchema;
+
+ /**
+ * Initialize the security layer schema.
+ */
+ private synchronized static void ensureSchema() {
+ if (slSchema == null) {
+ try {
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ ClassLoader cl = SLXHTMLValidator.class.getClassLoader();
+ URL schemaURL = cl.getResource(SLXHTML_SCHEMA_FILE);
+ log.debug("Trying to create SLXHTML schema from URL '" + schemaURL + "'.");
+ long t0 = System.currentTimeMillis();
+ slSchema = schemaFactory.newSchema(schemaURL);
+ long t1 = System.currentTimeMillis();
+ log.debug("SLXHTML schema successfully created in " + (t1 - t0) + "ms.");
+ } catch (SAXException e) {
+ log.error("Failed to load security layer XHTML schema.", e);
+ throw new RuntimeException("Failed to load security layer XHTML schema.", e);
+ }
+
+ }
+ }
+
+ public SLXHTMLValidator() {
+ ensureSchema();
+ }
+
+ public void validate(InputStream is, String charset)
+ throws ValidationException {
+ if (charset == null) {
+ validate(is, (Charset) null);
+ } else {
+ try {
+ validate(is, Charset.forName(charset));
+ } catch (IllegalCharsetNameException e) {
+ throw new ValidationException(e);
+ } catch (UnsupportedCharsetException e) {
+ throw new ValidationException(e);
+ }
+ }
+ }
+
+ public void validate(InputStream is, Charset charset) throws ValidationException {
+
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ spf.setSchema(slSchema);
+ spf.setValidating(true);
+ spf.setXIncludeAware(false);
+
+ SAXParser parser;
+ try {
+ parser = spf.newSAXParser();
+ } catch (ParserConfigurationException e) {
+ log.error("Failed to create SLXHTML parser.", e);
+ throw new RuntimeException("Failed to create SLXHTML parser.", e);
+ } catch (SAXException e) {
+ log.error("Failed to create SLXHTML parser.", e);
+ throw new RuntimeException("Failed to create SLXHTML parser.", e);
+ }
+
+ InputSource source;
+ if (charset != null) {
+ source = new InputSource(new InputStreamReader(is, charset));
+ } else {
+ source = new InputSource(is);
+ }
+
+
+ ValidatorHandler validatorHandler = slSchema.newValidatorHandler();
+
+ DefaultHandler defaultHandler = new ValidationHandler(validatorHandler);
+ try {
+ parser.parse(source, defaultHandler);
+ } catch (SAXException e) {
+ if (e.getException() instanceof ValidationException) {
+ throw (ValidationException) e.getException();
+ } else {
+ throw new ValidationException(e);
+ }
+ } catch (IOException e) {
+ throw new ValidationException(e);
+ }
+
+ }
+
+ private void validateCss(InputStream is) throws ValidationException {
+ CSSValidatorSLXHTML cssValidator = new CSSValidatorSLXHTML();
+ // TODO: use the right locale
+ cssValidator.validate(is, Locale.getDefault(), "SLXHTML", 0);
+ }
+
+ private class ValidationHandler extends DefaultHandler implements ContentHandler {
+
+ private ValidatorHandler validatorHandler;
+
+ private boolean insideStyle = false;
+
+ private StringBuffer style = new StringBuffer();
+
+ private ValidationHandler(ValidatorHandler contentHandler) {
+ this.validatorHandler = contentHandler;
+ }
+
+ @Override
+ public void endDocument() throws SAXException {
+ validatorHandler.endDocument();
+ }
+
+ @Override
+ public void endPrefixMapping(String prefix) throws SAXException {
+ validatorHandler.endPrefixMapping(prefix);
+ }
+
+ @Override
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException {
+ validatorHandler.ignorableWhitespace(ch, start, length);
+ }
+
+ @Override
+ public void processingInstruction(String target, String data)
+ throws SAXException {
+ validatorHandler.processingInstruction(target, data);
+ }
+
+ @Override
+ public void setDocumentLocator(Locator locator) {
+ validatorHandler.setDocumentLocator(locator);
+ }
+
+ @Override
+ public void skippedEntity(String name) throws SAXException {
+ validatorHandler.skippedEntity(name);
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ validatorHandler.startDocument();
+ }
+
+ @Override
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException {
+ validatorHandler.startPrefixMapping(prefix, uri);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String name,
+ Attributes attributes) throws SAXException {
+ validatorHandler.startElement(uri, localName, name, attributes);
+
+ System.out.println(uri + ":" + localName);
+
+ if ("http://www.w3.org/1999/xhtml".equals(uri) &&
+ "style".equals(localName)) {
+ insideStyle = true;
+ }
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
+ validatorHandler.characters(ch, start, length);
+
+ if (insideStyle) {
+ style.append(ch, start, length);
+ }
+
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String name)
+ throws SAXException {
+ validatorHandler.endElement(uri, localName, name);
+
+ if (insideStyle) {
+ insideStyle = false;
+ try {
+ validateCss(new ByteArrayInputStream(style.toString().getBytes(Charset.forName("UTF-8"))));
+ } catch (ValidationException e) {
+ throw new SAXException(e);
+ }
+ }
+ }
+
+ }
+
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CSSValidatorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CSSValidatorSLXHTML.java
new file mode 100644
index 00000000..7abe4741
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CSSValidatorSLXHTML.java
@@ -0,0 +1,95 @@
+/*
+* 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.bku.slxhtml.css;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Locale;
+
+import org.w3c.css.css.CssParser;
+import org.w3c.css.css.StyleSheet;
+import org.w3c.css.css.StyleSheetParser;
+import org.w3c.css.parser.CssError;
+import org.w3c.css.parser.Errors;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.Util;
+import org.w3c.css.util.Warning;
+import org.w3c.css.util.Warnings;
+
+import at.gv.egiz.bku.viewer.ValidationException;
+
+public class CSSValidatorSLXHTML {
+
+ public void validate(InputStream input, Locale locale, String title, int lineno) throws ValidationException {
+
+ // disable imports
+ Util.importSecurity = true;
+
+ CssParser cssParser = new StyleSheetParser();
+
+ ApplContext ac = new ApplContext(locale.getLanguage());
+ ac.setCssVersion("slxhtml");
+ ac.setMedium("all");
+
+ URL url;
+ try {
+ url = new URL("http://test.xyz");
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+
+ cssParser.parseStyleElement(ac, input, title, "all", url, lineno);
+
+ StyleSheet styleSheet = cssParser.getStyleSheet();
+
+ // find conflicts
+ styleSheet.findConflicts(ac);
+
+ boolean valid = true;
+ StringBuilder sb = new StringBuilder().append("CSS:");
+
+ // look for errors
+ Errors errors = styleSheet.getErrors();
+ if (errors.getErrorCount() != 0) {
+ valid = false;
+ CssError[] cssErrors = errors.getErrors();
+ for (CssError cssError : cssErrors) {
+ Exception exception = cssError.getException();
+ sb.append(" ");
+ sb.append(exception.getMessage());
+ }
+ }
+
+ // look for warnings
+ Warnings warnings = styleSheet.getWarnings();
+ if (warnings.getWarningCount() != 0) {
+ valid = false;
+ Warning[] cssWarnings = warnings.getWarnings();
+ for (Warning warning : cssWarnings) {
+ sb.append(" ");
+ sb.append(warning.getWarningMessage());
+ }
+ }
+
+ if (!valid) {
+ throw new ValidationException(sb.toString());
+ }
+
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundColorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundColorSLXHTML.java
new file mode 100644
index 00000000..53191d17
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundColorSLXHTML.java
@@ -0,0 +1,57 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBackgroundColorCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssBackgroundColorSLXHTML extends CssBackgroundColorCSS2 {
+
+ public CssBackgroundColorSLXHTML() {
+ }
+
+ public CssBackgroundColorSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssValue color = getColor();
+ if (!isSoftlyInherited() && color != null) {
+ if (CssColorSLXHTML.isDisallowedColor(color)) {
+ throw new SLXHTMLInvalidParamException("color", color, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssBackgroundColorSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ super(ac, expression);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundSLXHTML.java
new file mode 100644
index 00000000..724c8c6a
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBackgroundSLXHTML.java
@@ -0,0 +1,93 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBackgroundCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+/**
+ * @author mcentner
+ *
+ */
+public class CssBackgroundSLXHTML extends CssBackgroundCSS2 {
+
+ public CssBackgroundSLXHTML() {
+ }
+
+ public CssBackgroundSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssValue color = getColor();
+ if (!isSoftlyInherited() && color != null) {
+ if (CssColorSLXHTML.isDisallowedColor(color)) {
+ throw new SLXHTMLInvalidParamException("color", color, getPropertyName(), ac);
+ }
+ }
+
+ // The properties for selecting and controlling an image as background
+ // (background-image, background-repeat, background-position,
+ // background-attachment; cf. [CSS 2], section 14.2.1) must not be contained
+ // in an instance document to prevent content from overlapping. Otherwise
+ // the instance document must be rejected by the Citizen Card Environment.
+ //
+ // The property for the shorthand version of the background properties
+ // (background) should be supported by a Citizen Card Environment. The
+ // recommended values result from the explanations for the background-color
+ // property above (cf. [CSS 2], section 14.2.1). If the property contains
+ // values for selecting and controlling an image as background, the instance
+ // document must be rejected by the Citizen Card Environment.
+
+ if (getImage() != null) {
+ throw new SLXHTMLInvalidParamException("background", "background-image", ac);
+ }
+
+ if (getRepeat() != null) {
+ throw new SLXHTMLInvalidParamException("background", "background-repeat", ac);
+ }
+
+ if (getPosition() != null) {
+ throw new SLXHTMLInvalidParamException("background", "background-position", ac);
+ }
+
+ if (getAttachment() != null) {
+ throw new SLXHTMLInvalidParamException("background", "background-attachment", ac);
+ }
+
+ }
+
+ public CssBackgroundSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderBottomColorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderBottomColorSLXHTML.java
new file mode 100644
index 00000000..4f5798b0
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderBottomColorSLXHTML.java
@@ -0,0 +1,57 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBorderBottomColorCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssBorderBottomColorSLXHTML extends CssBorderBottomColorCSS2 {
+
+ public CssBorderBottomColorSLXHTML() {
+ }
+
+ public CssBorderBottomColorSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssValue color = getColor();
+ if (!isSoftlyInherited() && color != null) {
+ if (CssColorSLXHTML.isDisallowedColor(color)) {
+ throw new SLXHTMLInvalidParamException("color", color, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssBorderBottomColorSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderColorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderColorSLXHTML.java
new file mode 100644
index 00000000..3f5a7319
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderColorSLXHTML.java
@@ -0,0 +1,81 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBorderBottomColorCSS2;
+import org.w3c.css.properties.css1.CssBorderColorCSS2;
+import org.w3c.css.properties.css1.CssBorderLeftColorCSS2;
+import org.w3c.css.properties.css1.CssBorderRightColorCSS2;
+import org.w3c.css.properties.css1.CssBorderTopColorCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssBorderColorSLXHTML extends CssBorderColorCSS2 {
+
+ public CssBorderColorSLXHTML() {
+ }
+
+ public CssBorderColorSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssBorderTopColorCSS2 top = getTop();
+ if (!isSoftlyInherited() && top != null) {
+ if (CssColorSLXHTML.isDisallowedColor(top.getColor())) {
+ throw new SLXHTMLInvalidParamException("color", top.getColor(), getPropertyName(), ac);
+ }
+ }
+
+ CssBorderLeftColorCSS2 left = getLeft();
+ if (!isSoftlyInherited() && left != null) {
+ if (CssColorSLXHTML.isDisallowedColor(left.getColor())) {
+ throw new SLXHTMLInvalidParamException("color", left.getColor(), getPropertyName(), ac);
+ }
+ }
+
+ CssBorderRightColorCSS2 right = getRight();
+ if (!isSoftlyInherited() && right != null) {
+ if (CssColorSLXHTML.isDisallowedColor(right.getColor())) {
+ throw new SLXHTMLInvalidParamException("color", right.getColor(), getPropertyName(), ac);
+ }
+ }
+
+ CssBorderBottomColorCSS2 bottom = getBottom();
+ if (!isSoftlyInherited() && bottom != null) {
+ if (CssColorSLXHTML.isDisallowedColor(bottom.getColor())) {
+ throw new SLXHTMLInvalidParamException("color", bottom.getColor(), getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssBorderColorSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderLeftColorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderLeftColorSLXHTML.java
new file mode 100644
index 00000000..e2378e99
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderLeftColorSLXHTML.java
@@ -0,0 +1,57 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBorderLeftColorCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssBorderLeftColorSLXHTML extends CssBorderLeftColorCSS2 {
+
+ public CssBorderLeftColorSLXHTML() {
+ }
+
+ public CssBorderLeftColorSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssValue color = getColor();
+ if (!isSoftlyInherited() && color != null) {
+ if (CssColorSLXHTML.isDisallowedColor(color)) {
+ throw new SLXHTMLInvalidParamException("color", color, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssBorderLeftColorSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderRightColorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderRightColorSLXHTML.java
new file mode 100644
index 00000000..99d6bae5
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderRightColorSLXHTML.java
@@ -0,0 +1,57 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBorderRightColorCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssBorderRightColorSLXHTML extends CssBorderRightColorCSS2 {
+
+ public CssBorderRightColorSLXHTML() {
+ }
+
+ public CssBorderRightColorSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssValue color = getColor();
+ if (!isSoftlyInherited() && color != null) {
+ if (CssColorSLXHTML.isDisallowedColor(color)) {
+ throw new SLXHTMLInvalidParamException("color", color, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssBorderRightColorSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderSLXHTML.java
new file mode 100644
index 00000000..ac32670e
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderSLXHTML.java
@@ -0,0 +1,85 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBorderCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssBorderSLXHTML extends CssBorderCSS2 {
+
+ public CssBorderSLXHTML() {
+ }
+
+ public CssBorderSLXHTML(ApplContext ac, CssExpression value, boolean check)
+ throws InvalidParamException {
+ super(ac, value, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ if (getTop() != null) {
+ CssValue top = getTop().getColor();
+ if (!isSoftlyInherited() && top != null) {
+ if (CssColorSLXHTML.isDisallowedColor(top)) {
+ throw new SLXHTMLInvalidParamException("color", top, getPropertyName(), ac);
+ }
+ }
+ }
+
+ if (getLeft() != null) {
+ CssValue left = getLeft().getColor();
+ if (!isSoftlyInherited() && left != null) {
+ if (CssColorSLXHTML.isDisallowedColor(left)) {
+ throw new SLXHTMLInvalidParamException("color", left, getPropertyName(), ac);
+ }
+ }
+ }
+
+ if (getRight() != null) {
+ CssValue right = getRight().getColor();
+ if (!isSoftlyInherited() && right != null) {
+ if (CssColorSLXHTML.isDisallowedColor(right)) {
+ throw new SLXHTMLInvalidParamException("color", right, getPropertyName(), ac);
+ }
+ }
+ }
+
+ if (getBottom() != null) {
+ CssValue bottom = getBottom().getColor();
+ if (!isSoftlyInherited() && bottom != null) {
+ if (CssColorSLXHTML.isDisallowedColor(bottom)) {
+ throw new SLXHTMLInvalidParamException("color", bottom, getPropertyName(), ac);
+ }
+ }
+ }
+ }
+
+ public CssBorderSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderTopColorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderTopColorSLXHTML.java
new file mode 100644
index 00000000..42926479
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssBorderTopColorSLXHTML.java
@@ -0,0 +1,57 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssBorderTopColorCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssBorderTopColorSLXHTML extends CssBorderTopColorCSS2 {
+
+ public CssBorderTopColorSLXHTML() {
+ }
+
+ public CssBorderTopColorSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssValue color = getColor();
+ if (!isSoftlyInherited() && color != null) {
+ if (CssColorSLXHTML.isDisallowedColor(color)) {
+ throw new SLXHTMLInvalidParamException("color", color, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssBorderTopColorSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssColorSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssColorSLXHTML.java
new file mode 100644
index 00000000..a640eb3a
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssColorSLXHTML.java
@@ -0,0 +1,99 @@
+/*
+* 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.bku.slxhtml.css;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssColorSLXHTML extends org.w3c.css.properties.css1.CssColorCSS2 {
+
+ private static Set SLXHTML_DISSALLOWED_COLORS = new HashSet();
+
+ static {
+
+ SLXHTML_DISSALLOWED_COLORS.add("activeborder");
+ SLXHTML_DISSALLOWED_COLORS.add("activecaption");
+ SLXHTML_DISSALLOWED_COLORS.add("appworkspace");
+ SLXHTML_DISSALLOWED_COLORS.add("background");
+ SLXHTML_DISSALLOWED_COLORS.add("buttonface");
+ SLXHTML_DISSALLOWED_COLORS.add("buttonhighlight");
+ SLXHTML_DISSALLOWED_COLORS.add("buttonshadow");
+ SLXHTML_DISSALLOWED_COLORS.add("buttontext");
+ SLXHTML_DISSALLOWED_COLORS.add("captiontext");
+ SLXHTML_DISSALLOWED_COLORS.add("graytext");
+ SLXHTML_DISSALLOWED_COLORS.add("highlight");
+ SLXHTML_DISSALLOWED_COLORS.add("highlighttext");
+ SLXHTML_DISSALLOWED_COLORS.add("inactiveborder");
+ SLXHTML_DISSALLOWED_COLORS.add("inactivecaption");
+ SLXHTML_DISSALLOWED_COLORS.add("inactivecaptiontext");
+ SLXHTML_DISSALLOWED_COLORS.add("infobackground");
+ SLXHTML_DISSALLOWED_COLORS.add("infotext");
+ SLXHTML_DISSALLOWED_COLORS.add("menu");
+ SLXHTML_DISSALLOWED_COLORS.add("menutext");
+ SLXHTML_DISSALLOWED_COLORS.add("scrollbar");
+ SLXHTML_DISSALLOWED_COLORS.add("threeddarkshadow");
+ SLXHTML_DISSALLOWED_COLORS.add("threedface");
+ SLXHTML_DISSALLOWED_COLORS.add("threedhighlight");
+ SLXHTML_DISSALLOWED_COLORS.add("threedlightshadow");
+ SLXHTML_DISSALLOWED_COLORS.add("threedshadow");
+ SLXHTML_DISSALLOWED_COLORS.add("window");
+ SLXHTML_DISSALLOWED_COLORS.add("windowframe");
+ SLXHTML_DISSALLOWED_COLORS.add("windowtext");
+
+ }
+
+ public static boolean isDisallowedColor(CssValue cssValue) {
+ return SLXHTML_DISSALLOWED_COLORS.contains(cssValue.toString().toLowerCase());
+ }
+
+ public CssColorSLXHTML() {
+ }
+
+ public CssColorSLXHTML(ApplContext ac, CssExpression expression, boolean check)
+ throws InvalidParamException {
+
+ super(ac, expression, check);
+
+ // A Citizen Card Environment must support all the options for specifying a
+ // colour listed in [CSS 2], section 4.3.6 for a CSS property, if such an
+ // option is available for this property according to [CSS 2].
+
+ // The exceptions are the system colours (cf. [CSS 2], section 18.2); these
+ // must not be used in an instance document so as to prevent dependencies on
+ // the system environment. Otherwise the instance document must be rejected
+ // by the Citizen Card Environment.
+
+ CssValue color = getColor();
+ if (!isSoftlyInherited() && color != null) {
+ if (CssColorSLXHTML.isDisallowedColor(color)) {
+ throw new SLXHTMLInvalidParamException("color", color, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssColorSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssFontSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssFontSLXHTML.java
new file mode 100644
index 00000000..8e5298ec
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssFontSLXHTML.java
@@ -0,0 +1,59 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssFontCSS2;
+import org.w3c.css.properties.css1.CssFontConstantCSS2;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssIdent;
+import org.w3c.css.values.CssValue;
+
+public class CssFontSLXHTML extends CssFontCSS2 {
+
+ public CssFontSLXHTML() {
+ }
+
+ public CssFontSLXHTML(ApplContext ac, CssExpression expression, boolean check)
+ throws InvalidParamException {
+ super(ac, checkExpression(expression, ac), check);
+ }
+
+ public CssFontSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+ protected static CssExpression checkExpression(CssExpression expression,
+ ApplContext ac) throws InvalidParamException {
+
+ CssValue value = expression.getValue();
+
+ if (value instanceof CssIdent) {
+ for (String font : CssFontConstantCSS2.FONT) {
+ if (font.equalsIgnoreCase(value.toString())) {
+ throw new SLXHTMLInvalidParamException("font", value.toString(), ac);
+ }
+ }
+ }
+
+ return expression;
+
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssLetterSpacingSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssLetterSpacingSLXHTML.java
new file mode 100644
index 00000000..326a731f
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssLetterSpacingSLXHTML.java
@@ -0,0 +1,54 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssLetterSpacing;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssLength;
+import org.w3c.css.values.CssNumber;
+
+public class CssLetterSpacingSLXHTML extends CssLetterSpacing {
+
+ public CssLetterSpacingSLXHTML() {
+ }
+
+ public CssLetterSpacingSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ Object value = get();
+ if (value instanceof CssLength) {
+ Object length = ((CssLength) value).get();
+ if (length instanceof Float && ((Float) length).floatValue() < 0) {
+ throw new SLXHTMLInvalidParamException("spacing", length, getPropertyName(), ac);
+ }
+ } else if (value instanceof CssNumber) {
+ if (((CssNumber) value).getValue() < 0) {
+ throw new SLXHTMLInvalidParamException("spacing", value, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssLetterSpacingSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginBottomSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginBottomSLXHTML.java
new file mode 100644
index 00000000..cac97d06
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginBottomSLXHTML.java
@@ -0,0 +1,60 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssMarginBottom;
+import org.w3c.css.properties.css1.CssMarginSide;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssMarginBottomSLXHTML extends CssMarginBottom {
+
+ public CssMarginBottomSLXHTML() {
+ }
+
+ public CssMarginBottomSLXHTML(CssMarginSide another) {
+ super(another);
+ }
+
+ public CssMarginBottomSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+ public CssMarginBottomSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // The margin-top, margin-bottom, margin-left and margin-right properties
+ // must be supported by a Citizen Card Environment. Values specified as
+ // percentages (cf. section 3.5.1.2) should be supported.
+
+ // The margin property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssMarginSLXHTML.isDisallowedMargin(getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginLeftSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginLeftSLXHTML.java
new file mode 100644
index 00000000..c456af43
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginLeftSLXHTML.java
@@ -0,0 +1,61 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssMarginLeft;
+import org.w3c.css.properties.css1.CssMarginSide;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssMarginLeftSLXHTML extends CssMarginLeft {
+
+ public CssMarginLeftSLXHTML() {
+ }
+
+ public CssMarginLeftSLXHTML(CssMarginSide another) {
+ super(another);
+ }
+
+ public CssMarginLeftSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+ public CssMarginLeftSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // TODO Auto-generated constructor stub
+ // The margin-top, margin-bottom, margin-left and margin-right properties
+ // must be supported by a Citizen Card Environment. Values specified as
+ // percentages (cf. section 3.5.1.2) should be supported.
+
+ // The margin property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssMarginSLXHTML.isDisallowedMargin(getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginRightSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginRightSLXHTML.java
new file mode 100644
index 00000000..7f16830d
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginRightSLXHTML.java
@@ -0,0 +1,60 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssMarginRight;
+import org.w3c.css.properties.css1.CssMarginSide;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssMarginRightSLXHTML extends CssMarginRight {
+
+ public CssMarginRightSLXHTML() {
+ }
+
+ public CssMarginRightSLXHTML(CssMarginSide another) {
+ super(another);
+ }
+
+ public CssMarginRightSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+ public CssMarginRightSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // The margin-top, margin-bottom, margin-left and margin-right properties
+ // must be supported by a Citizen Card Environment. Values specified as
+ // percentages (cf. section 3.5.1.2) should be supported.
+
+ // The margin property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssMarginSLXHTML.isDisallowedMargin(getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginSLXHTML.java
new file mode 100644
index 00000000..f478b96a
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginSLXHTML.java
@@ -0,0 +1,101 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssMargin;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssLength;
+import org.w3c.css.values.CssNumber;
+import org.w3c.css.values.CssPercentage;
+import org.w3c.css.values.CssValue;
+
+public class CssMarginSLXHTML extends CssMargin {
+
+ public CssMarginSLXHTML() {
+ }
+
+ public CssMarginSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ if (getTop() != null) {
+ if (isDisallowedMargin(getTop().getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getTop().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ if (getRight() != null) {
+ if (isDisallowedMargin(getRight().getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getRight().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ if (getLeft() != null) {
+ if (isDisallowedMargin(getLeft().getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getLeft().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ if (getBottom() != null) {
+ if (isDisallowedMargin(getBottom().getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getBottom().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssMarginSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+ public static boolean isDisallowedMargin(CssValue margin) {
+
+ // The margin-top, margin-bottom, margin-left and margin-right properties
+ // must be supported by a Citizen Card Environment. Values specified as
+ // percentages (cf. section 3.5.1.2) should be supported.
+
+ // The margin property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (margin instanceof CssLength) {
+ Object value = ((CssLength) margin).get();
+ if (value instanceof Float) {
+ return ((Float) value).floatValue() < 0;
+ }
+ } else if (margin instanceof CssPercentage) {
+ Object value = ((CssPercentage) margin).get();
+ if (value instanceof Float) {
+ return ((Float) value).floatValue() < 0;
+ }
+ } else if (margin instanceof CssNumber) {
+ return ((CssNumber) margin).getValue() < 0;
+ }
+
+ return false;
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginTopSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginTopSLXHTML.java
new file mode 100644
index 00000000..06b30c4f
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssMarginTopSLXHTML.java
@@ -0,0 +1,61 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssMarginSide;
+import org.w3c.css.properties.css1.CssMarginTop;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssMarginTopSLXHTML extends CssMarginTop {
+
+ public CssMarginTopSLXHTML() {
+ }
+
+ public CssMarginTopSLXHTML(CssMarginSide another) {
+ super(another);
+ }
+
+ public CssMarginTopSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+
+ }
+
+ public CssMarginTopSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // The margin-top, margin-bottom, margin-left and margin-right properties
+ // must be supported by a Citizen Card Environment. Values specified as
+ // percentages (cf. section 3.5.1.2) should be supported.
+
+ // The margin property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssMarginSLXHTML.isDisallowedMargin(getValue())) {
+ throw new SLXHTMLInvalidParamException("margin", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingBottomSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingBottomSLXHTML.java
new file mode 100644
index 00000000..4bcb0065
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingBottomSLXHTML.java
@@ -0,0 +1,60 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssPaddingBottom;
+import org.w3c.css.properties.css1.CssPaddingSide;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssPaddingBottomSLXHTML extends CssPaddingBottom {
+
+ public CssPaddingBottomSLXHTML() {
+ }
+
+ public CssPaddingBottomSLXHTML(CssPaddingSide another) {
+ super(another);
+ }
+
+ public CssPaddingBottomSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // The padding-top, padding-bottom, padding-left and padding-right
+ // properties must be supported by a Citizen Card Environment. Values
+ // specified as percentages (cf. section 3.5.1.2) should be supported.
+
+ // The padding property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssPaddingSLXHTML.isDisallowedValue(getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+ public CssPaddingBottomSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingLeftSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingLeftSLXHTML.java
new file mode 100644
index 00000000..350a5c15
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingLeftSLXHTML.java
@@ -0,0 +1,60 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssPaddingLeft;
+import org.w3c.css.properties.css1.CssPaddingSide;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssPaddingLeftSLXHTML extends CssPaddingLeft {
+
+ public CssPaddingLeftSLXHTML() {
+ }
+
+ public CssPaddingLeftSLXHTML(CssPaddingSide another) {
+ super(another);
+ }
+
+ public CssPaddingLeftSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // The padding-top, padding-bottom, padding-left and padding-right
+ // properties must be supported by a Citizen Card Environment. Values
+ // specified as percentages (cf. section 3.5.1.2) should be supported.
+
+ // The padding property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssPaddingSLXHTML.isDisallowedValue(getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+ public CssPaddingLeftSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingRightSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingRightSLXHTML.java
new file mode 100644
index 00000000..d2d62748
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingRightSLXHTML.java
@@ -0,0 +1,60 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssPaddingRight;
+import org.w3c.css.properties.css1.CssPaddingSide;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssPaddingRightSLXHTML extends CssPaddingRight {
+
+ public CssPaddingRightSLXHTML() {
+ }
+
+ public CssPaddingRightSLXHTML(CssPaddingSide another) {
+ super(another);
+ }
+
+ public CssPaddingRightSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // The padding-top, padding-bottom, padding-left and padding-right
+ // properties must be supported by a Citizen Card Environment. Values
+ // specified as percentages (cf. section 3.5.1.2) should be supported.
+
+ // The padding property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssPaddingSLXHTML.isDisallowedValue(getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+ public CssPaddingRightSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingSLXHTML.java
new file mode 100644
index 00000000..57d7cf77
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingSLXHTML.java
@@ -0,0 +1,102 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssPadding;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssLength;
+import org.w3c.css.values.CssNumber;
+import org.w3c.css.values.CssPercentage;
+import org.w3c.css.values.CssValue;
+
+public class CssPaddingSLXHTML extends CssPadding {
+
+ public CssPaddingSLXHTML() {
+ }
+
+ public CssPaddingSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ if (getTop() != null) {
+ if (isDisallowedValue(getTop().getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getTop().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ if (getRight() != null) {
+ if (isDisallowedValue(getRight().getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getRight().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ if (getLeft() != null) {
+ if (isDisallowedValue(getLeft().getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getLeft().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ if (getBottom() != null) {
+ if (isDisallowedValue(getBottom().getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getBottom().getValue(),
+ getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssPaddingSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+ public static boolean isDisallowedValue(CssValue padding) {
+
+ // The padding-top, padding-bottom, padding-left and padding-right
+ // properties must be supported by a Citizen Card Environment. Values
+ // specified as percentages (cf. section 3.5.1.2) should be supported.
+
+ // The padding property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (padding instanceof CssLength) {
+ Object value = ((CssLength) padding).get();
+ if (value instanceof Float) {
+ return ((Float) value).floatValue() < 0;
+ }
+ } else if (padding instanceof CssPercentage) {
+ Object value = ((CssPercentage) padding).get();
+ if (value instanceof Float) {
+ return ((Float) value).floatValue() < 0;
+ }
+ } else if (padding instanceof CssNumber) {
+ return ((CssNumber) padding).getValue() < 0;
+ }
+
+ return false;
+
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingTopSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingTopSLXHTML.java
new file mode 100644
index 00000000..bc113bfe
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssPaddingTopSLXHTML.java
@@ -0,0 +1,61 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssPaddingSide;
+import org.w3c.css.properties.css1.CssPaddingTop;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+
+public class CssPaddingTopSLXHTML extends CssPaddingTop {
+
+ public CssPaddingTopSLXHTML() {
+ }
+
+ public CssPaddingTopSLXHTML(CssPaddingSide another) {
+ super(another);
+ }
+
+ public CssPaddingTopSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ // The padding-top, padding-bottom, padding-left and padding-right
+ // properties must be supported by a Citizen Card Environment. Values
+ // specified as percentages (cf. section 3.5.1.2) should be supported.
+
+ // The padding property may be supported by a Citizen Card Environment.
+
+ // An instance document must not contain a negative value in the properties
+ // mentioned above. Otherwise it must be rejected by the Citizen Card
+ // Environment.
+
+ if (CssPaddingSLXHTML.isDisallowedValue(getValue())) {
+ throw new SLXHTMLInvalidParamException("padding", getValue(),
+ getPropertyName(), ac);
+ }
+
+ }
+
+ public CssPaddingTopSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ super(ac, expression);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssTextDecorationSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssTextDecorationSLXHTML.java
new file mode 100644
index 00000000..16b9780a
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssTextDecorationSLXHTML.java
@@ -0,0 +1,51 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssTextDecoration;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssValue;
+
+public class CssTextDecorationSLXHTML extends CssTextDecoration {
+
+ public CssTextDecorationSLXHTML() {
+ }
+
+ public CssTextDecorationSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ if (get() instanceof CssValue) {
+ if ("blink".equalsIgnoreCase(((CssValue) get()).toString())) {
+ throw new SLXHTMLInvalidParamException("text-decoration", "blink", ac);
+ }
+ } else if (get() instanceof String) {
+ if ("blink".equalsIgnoreCase((String) get())) {
+ throw new SLXHTMLInvalidParamException("text-decoration", "blink", ac);
+ }
+ }
+
+ }
+
+ public CssTextDecorationSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssWordSpacingSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssWordSpacingSLXHTML.java
new file mode 100644
index 00000000..a497f4e3
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/CssWordSpacingSLXHTML.java
@@ -0,0 +1,54 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css1.CssWordSpacing;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssLength;
+import org.w3c.css.values.CssNumber;
+
+public class CssWordSpacingSLXHTML extends CssWordSpacing {
+
+ public CssWordSpacingSLXHTML() {
+ }
+
+ public CssWordSpacingSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ Object value = get();
+ if (value instanceof CssLength) {
+ Object length = ((CssLength) value).get();
+ if (length instanceof Float && ((Float) length).floatValue() < 0) {
+ throw new SLXHTMLInvalidParamException("spacing", length, getPropertyName(), ac);
+ }
+ } else if (value instanceof CssNumber) {
+ if (((CssNumber) value).getValue() < 0) {
+ throw new SLXHTMLInvalidParamException("spacing", value, getPropertyName(), ac);
+ }
+ }
+
+ }
+
+ public CssWordSpacingSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLInvalidParamException.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLInvalidParamException.java
new file mode 100644
index 00000000..edac03f4
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLInvalidParamException.java
@@ -0,0 +1,71 @@
+/*
+* 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.bku.slxhtml.css;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.w3c.css.util.ApplContext;
+
+public class SLXHTMLInvalidParamException extends
+ org.w3c.css.util.InvalidParamException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String message;
+
+ public SLXHTMLInvalidParamException() {
+ }
+
+ public SLXHTMLInvalidParamException(String error, ApplContext ac) {
+ setMessage(error, null, ac);
+ }
+
+ public SLXHTMLInvalidParamException(String error, Object message, ApplContext ac) {
+ setMessage(error, new Object[] {message}, ac);
+ }
+
+ public SLXHTMLInvalidParamException(String error, Object message1, Object message2,
+ ApplContext ac) {
+ setMessage(error, new Object[] {message1, message2}, ac);
+ }
+
+ @Override
+ public String getMessage() {
+ return getLocalizedMessage();
+ }
+
+ @Override
+ public String getLocalizedMessage() {
+ return message;
+ }
+
+ protected void setMessage(String error, Object[] arguments, ApplContext ac) {
+ Locale locale = new Locale(ac.getContentLanguage());
+ ResourceBundle bundle = ResourceBundle.getBundle("at/gv/egiz/bku/slxhtml/css/Messages", locale);
+ String pattern;
+ try {
+ pattern = bundle.getString(error);
+ } catch (MissingResourceException e) {
+ pattern = "Can't find error message for : " + error;
+ }
+ message = MessageFormat.format(pattern, arguments);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLStyle.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLStyle.java
new file mode 100644
index 00000000..99448ec4
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/SLXHTMLStyle.java
@@ -0,0 +1,22 @@
+//
+// $Id: Css2Style.java,v 1.2 2005-09-08 12:24:01 ylafon Exp $
+// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
+//
+// (c) COPYRIGHT MIT and INRIA, 1997.
+// Please first read the full copyright statement in file COPYRIGHT.html
+package at.gv.egiz.bku.slxhtml.css;
+
+import org.w3c.css.properties.aural.ACssStyle;
+import org.w3c.css.parser.CssPrinterStyle;
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public class SLXHTMLStyle extends ACssStyle {
+
+ public void print(CssPrinterStyle printer) {
+ super.print(printer);
+ }
+
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/TableLayoutSLXHTML.java b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/TableLayoutSLXHTML.java
new file mode 100644
index 00000000..50f30cce
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/slxhtml/css/TableLayoutSLXHTML.java
@@ -0,0 +1,45 @@
+/*
+* 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.bku.slxhtml.css;
+
+import org.w3c.css.properties.css2.table.TableLayout;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssIdent;
+
+public class TableLayoutSLXHTML extends TableLayout {
+
+ public TableLayoutSLXHTML() {
+ }
+
+ public TableLayoutSLXHTML(ApplContext ac, CssExpression expression,
+ boolean check) throws InvalidParamException {
+ super(ac, expression, check);
+
+ if (new CssIdent("fixed").equals(get())) {
+ throw new SLXHTMLInvalidParamException("table-layout", "fixed", getPropertyName(), ac);
+ }
+
+ }
+
+ public TableLayoutSLXHTML(ApplContext ac, CssExpression expression)
+ throws InvalidParamException {
+ this(ac, expression, false);
+ }
+
+}
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java b/BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java
new file mode 100644
index 00000000..5108140d
--- /dev/null
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java
@@ -0,0 +1,32 @@
+/*
+* 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.bku.text;
+
+import java.io.InputStream;
+
+import at.gv.egiz.bku.viewer.ValidationException;
+import at.gv.egiz.bku.viewer.Validator;
+
+public class TextValidator implements Validator {
+
+ @Override
+ public void validate(InputStream is, String charset)
+ throws ValidationException {
+ // TODO: implement character validation
+ }
+
+}
diff --git a/BKUViewer/src/main/resources/META-INF/services/at.gv.egiz.bku.viewer.Validator b/BKUViewer/src/main/resources/META-INF/services/at.gv.egiz.bku.viewer.Validator
new file mode 100644
index 00000000..0004949b
--- /dev/null
+++ b/BKUViewer/src/main/resources/META-INF/services/at.gv.egiz.bku.viewer.Validator
@@ -0,0 +1,2 @@
+application/xhtml+xml at.gv.egiz.bku.slxhtml.SLXHTMLValidator
+text/plain at.gv.egiz.bku.text.TextValidator
\ No newline at end of file
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-model-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-model-1.xsd
new file mode 100644
index 00000000..89e91faa
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-model-1.xsd
@@ -0,0 +1,469 @@
+
+
+
+
+
+ This is the XML Schema module of common content models for SLXHTML.
+ SLXHTML is a profile of XHTML (see W3C copyright notice below).
+
+ @author: Gregor Karlinger gregor.karlinger@cio.gv.at
+ $Id: slxhtml-model-1.xsd,v 1.4 2004/05/12 11:35:31 karlinger Exp $
+
+
+
+
+
+ XHTML Document Model
+ This module describes the groupings of elements/attributes
+ that make up common content models for XHTML elements.
+ XHTML has following basic content models:
+ xhtml.Inline.mix; character-level elements
+ xhtml.Block.mix; block-like elements, e.g., paragraphs and lists
+ xhtml.Flow.mix; any block or inline elements
+ xhtml.HeadOpts.mix; Head Elements
+ xhtml.InlinePre.mix; Special class for pre content model
+ xhtml.InlineNoAnchor.mix; Content model for Anchor
+
+ Any groups declared in this module may be used to create
+ element content models, but the above are considered 'global'
+ (insofar as that term applies here). XHTML has the
+ following Attribute Groups
+ xhtml.Core.extra.attrib
+ xhtml.I18n.extra.attrib
+ xhtml.Common.extra
+
+ The above attribute Groups are considered Global
+
+
+
+
+
+
+ SLXHTML 1.2: attributeGroup "dir.attrib" removed.
+
+
+
+
+
+
+
+ SLXHTML 1.2: attributeGroup "style.attrib" removed.
+
+
+
+
+
+
+
+
+
+ Extended Global Core Attributes
+
+
+
+
+ Extended Global I18n attributes
+
+
+
+
+ Extended Global Common Attributes
+
+
+
+
+
+
+ SLXHTML 1.2: elements "script", "meta", "link", "object" removed.
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: Only a single instance of element "style" is
+ allowed apart from the obligatory "title" element.
+
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: elements "ins", "del" removed.
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: elements "script", "noscript" removed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: elements "dfn", "samp", "kbd", "var", "q" , "abbr" and
+ "acronym" removed.
+
+
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: elements "tt", "i", "b", "big", "small", "sub", "sup" removed.
+
+
+
+
+
+
+
+ SLXHTML 1.2: element "bdo" removed.
+
+
+
+
+
+
+
+ SLXHTML 1.2: element "a" removed.
+
+
+
+
+
+
+
+ SLXHTML 1.2: elements "map", "object" removed.
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: elements "input", "select", "textara", "lable", "button" removed.
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: element "ruby" removed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: elements "tt", "i", "b", "script", "map" removed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: element "form" removed.
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: element "fieldset" removed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SLXHTML 1.2: element "address" removed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-modules-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-modules-1.xsd
new file mode 100644
index 00000000..016833be
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml-modules-1.xsd
@@ -0,0 +1,248 @@
+
+
+
+
+
+
+ This XML Schema declares changes to the content models
+ of modules included in SLXHTML 1.2
+
+
+
+
+
+
+ Module Content Model Redefinitions
+
+ This schema describes the changes (Redefinitions) to the
+ content model of individual modules as they are instantiated as part of
+ SLXHTML 1.2 Document
+
+
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2: Removed xml:lang attrib.
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2: Removed title attrib.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2: Removed cite attrib.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2: Change value of the version attrib.
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2: Removed profile attrib.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2: Removed attributes "longdesc", "height", "width".
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute group "title"
+ Removed attribute "xml:space"
+ Fixed value of attribute "type"
+ Fixed value of attribute "media"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "scope.attrib", "CellHAlign.attrib", "CellVAlign.attrib"
+ Removed attributes "abbr", "axis", "headers"
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "scope.attrib", "CellHAlign.attrib", "CellVAlign.attrib"
+ Removed attributes "abbr", "axis", "headers"
+
+
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "CellHAlign.attrib", "CellVAlign.attrib"
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "CellHAlign.attrib", "CellVAlign.attrib"
+ Removed attributes "span", "width"
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "CellHAlign.attrib", "CellVAlign.attrib"
+ Removed attributes "span", "width"
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "CellHAlign.attrib", "CellVAlign.attrib"
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "CellHAlign.attrib", "CellVAlign.attrib"
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "CellHAlign.attrib", "CellVAlign.attrib"
+
+
+
+
+
+
+
+
+ Redefinition by SLXHTML 1.2:
+ Removed attribute groups "frame.attrib", "rules.attrib"
+ Removed attributes "summary", "width", "border", "cellspacing", "cellpadding"
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml.xsd
new file mode 100644
index 00000000..555edb52
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/slxhtml.xsd
@@ -0,0 +1,70 @@
+
+
+
+
+ This is the XML Schema driver for SLXHTML 1.2.
+ SLXHTML is a profile of XHTML (see W3C copyright notice below).
+
+ @author: Gregor Karlinger gregor.karlinger@cio.gv.at
+ $Id: slxhtml.xsd,v 1.3 2004/05/12 11:35:31 karlinger Exp $
+
+
+
+
+ This is the Schema Driver file for SLXHTML 1.2
+ Document Type
+
+ This schema includes
+ + modules for SLXHTML 1.2 Document Type.
+
+ + schema that defines all the named model for
+ the SLXHTML 1.2 Document Type
+
+ + schema that redefines the content model of
+ individual elements defined in the Module
+ implementations.
+
+ SLXHTML 1.2 Document Type includes the following Modules
+
+ XHTML Core modules
+ + text
+ + lists
+ + structure
+
+ Other XHTML modules
+ + Style
+ + Image
+ + Tables
+
+
+
+
+
+
+
+ This import brings in the XML namespace attributes
+ The XML attributes are used by various modules
+
+
+
+
+
+
+
+ This schema redefines the content model defined by
+ the individual modules for SLXHTML 1.2 Document Type
+
+
+
+
+
+
+
+ Document Model module for the SLXHTML 1.2 Document Type.
+ This schema file defines all named models used by XHTML
+ Modularization Framework for SLXHTML 1.2 Document Type
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-attribs-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-attribs-1.xsd
new file mode 100644
index 00000000..df5ce483
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-attribs-1.xsd
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+ This is the XML Schema common attributes module for XHTML
+ $Id: xhtml-attribs-1.xsd,v 1.6 2005/09/26 23:37:47 ahby Exp $
+
+
+
+
+
+
+
+ This import brings in the XML namespace attributes
+ The module itself does not provide the schemaLocation
+ and expects the driver schema to provide the
+ actual SchemaLocation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkphras-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkphras-1.xsd
new file mode 100644
index 00000000..da15e4c1
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkphras-1.xsd
@@ -0,0 +1,161 @@
+
+
+
+
+
+
+
+
+ This is the XML Schema Block Phrasal support module for XHTML
+ $Id: xhtml-blkphras-1.xsd,v 1.6 2006/09/11 10:27:50 ahby Exp $
+
+
+
+
+
+ Block Phrasal
+ This module declares the elements and their attributes used to
+ support block-level phrasal markup.
+ This is the XML Schema block phrasal elements module for XHTML
+
+ * address, blockquote, pre, h1, h2, h3, h4, h5, h6
+
+
+
+
+
+
+ This import brings in the XML namespace attributes
+ The module itself does not provide the schemaLocation
+ and expects the driver schema to provide the
+ actual SchemaLocation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkpres-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkpres-1.xsd
new file mode 100644
index 00000000..cf42303a
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkpres-1.xsd
@@ -0,0 +1,37 @@
+
+
+
+
+
+ This is the XML SchemaBlock presentation element module for XHTML
+ $Id: xhtml-blkpres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+ Block Presentational Elements
+
+ * hr
+
+ This module declares the elements and their attributes used to
+ support block-level presentational markup.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkstruct-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkstruct-1.xsd
new file mode 100644
index 00000000..1e658580
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-blkstruct-1.xsd
@@ -0,0 +1,49 @@
+
+
+
+
+
+ Block Structural
+
+ * div, p
+
+ This module declares the elements and their attributes used to
+ support block-level structural markup.
+
+ This is the XML Schema Block Structural module for XHTML
+ $Id: xhtml-blkstruct-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-datatypes-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-datatypes-1.xsd
new file mode 100644
index 00000000..5943cf35
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-datatypes-1.xsd
@@ -0,0 +1,175 @@
+
+
+
+
+ XHTML Datatypes
+ This is the XML Schema datatypes module for XHTML
+
+ Defines containers for the XHTML datatypes, many of
+ these imported from other specifications and standards.
+
+ $Id: xhtml-datatypes-1.xsd,v 1.9 2008/06/04 20:58:09 ahby Exp $
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-framework-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-framework-1.xsd
new file mode 100644
index 00000000..05b906d4
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-framework-1.xsd
@@ -0,0 +1,66 @@
+
+
+
+
+ This is the XML Schema Modular Framework support module for XHTML
+ $Id: xhtml-framework-1.xsd,v 1.5 2005/09/26 23:37:47 ahby Exp $
+
+
+
+
+
+ XHTML Modular Framework
+ This required module instantiates the necessary modules
+ needed to support the XHTML modularization framework.
+
+ The Schema modules instantiated are:
+ + notations
+ + datatypes
+ + common attributes
+ + character entities
+
+
+
+
+
+
+
+ This module defines XHTML Attribute DataTypes
+
+
+
+
+
+
+
+ This module defines Common attributes for XHTML
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-image-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-image-1.xsd
new file mode 100644
index 00000000..cd16bc9b
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-image-1.xsd
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ Images
+ This is the XML Schema Images module for XHTML
+
+ * img
+
+ This module provides markup to support basic image embedding.
+
+ To avoid problems with text-only UAs as well as to make
+ image content understandable and navigable to users of
+ non-visual UAs, you need to provide a description with
+ the 'alt' attribute, and avoid server-side image maps.
+
+
+ $Id: xhtml-image-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlphras-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlphras-1.xsd
new file mode 100644
index 00000000..919c59de
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlphras-1.xsd
@@ -0,0 +1,163 @@
+
+
+
+
+
+
+ This is the XML Schema Inline Phrasal support module for XHTML
+ $Id: xhtml-inlphras-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+ Inline Phrasal.
+ This module declares the elements and their attributes used to
+ support inline-level phrasal markup.
+ This is the XML Schema Inline Phrasal module for XHTML
+
+ * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var
+
+ $Id: xhtml-inlphras-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlpres-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlpres-1.xsd
new file mode 100644
index 00000000..a053447c
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlpres-1.xsd
@@ -0,0 +1,39 @@
+
+
+
+
+
+ This is the XML Schema Inline Presentation element module for XHTML
+ $Id: xhtml-inlpres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+ Inline Presentational Elements
+
+ * b, big, i, small, sub, sup, tt
+
+ This module declares the elements and their attributes used to
+ support inline-level presentational markup.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlstruct-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlstruct-1.xsd
new file mode 100644
index 00000000..635eb5f1
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-inlstruct-1.xsd
@@ -0,0 +1,50 @@
+
+
+
+
+
+ This is the XML Schema Inline Structural support module for XHTML
+ $Id: xhtml-inlstruct-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+ Inline Structural.
+ This module declares the elements and their attributes
+ used to support inline-level structural markup.
+ This is the XML Schema Inline Structural element module for XHTML
+
+ * br, span
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-list-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-list-1.xsd
new file mode 100644
index 00000000..cc22ba88
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-list-1.xsd
@@ -0,0 +1,99 @@
+
+
+
+
+
+ List Module
+ This is the XML Schema Lists module for XHTML
+ List Module Elements
+
+ * dl, dt, dd, ol, ul, li
+
+ This module declares the list-oriented element types
+ and their attributes.
+ $Id: xhtml-list-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-pres-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-pres-1.xsd
new file mode 100644
index 00000000..bc36fc48
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-pres-1.xsd
@@ -0,0 +1,51 @@
+
+
+
+
+
+ This is the XML Schema Presentation module for XHTML
+ This is a REQUIRED module.
+ $Id: xhtml-pres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+ Presentational Elements
+
+ This module defines elements and their attributes for
+ simple presentation-related markup.
+
+ Elements defined here:
+
+ * hr
+ * b, big, i, small, sub, sup, tt
+
+
+
+
+
+
+ Block Presentational module
+ Elements defined here:
+
+ * hr
+
+
+
+
+
+
+ Inline Presentational module
+ Elements defined here:
+
+ * b, big, i, small, sub, sup, tt
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-struct-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-struct-1.xsd
new file mode 100644
index 00000000..60cbcbf5
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-struct-1.xsd
@@ -0,0 +1,116 @@
+
+
+
+
+
+ This is the XML Schema Document Structure module for XHTML
+ Document Structure
+
+ * title, head, body, html
+
+ The Structure Module defines the major structural elements and
+ their attributes.
+
+ $Id: xhtml-struct-1.xsd,v 1.8 2006/09/11 10:27:50 ahby Exp $
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-style-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-style-1.xsd
new file mode 100644
index 00000000..1b3e7d3b
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-style-1.xsd
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+ This is the XML Schema Stylesheets module for XHTML
+ $Id: xhtml-style-1.xsd,v 1.5 2006/09/11 10:14:57 ahby Exp $
+
+
+
+
+
+ Stylesheets
+
+ * style
+
+ This module declares the style element type and its attributes,
+ used to embed stylesheet information in the document head element.
+
+
+
+
+
+
+ This import brings in the XML namespace attributes
+ The module itself does not provide the schemaLocation
+ and expects the driver schema to provide the
+ actual SchemaLocation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-table-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-table-1.xsd
new file mode 100644
index 00000000..ec76db3c
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-table-1.xsd
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+ This is the XML Schema Tables module for XHTML
+ $Id: xhtml-table-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+ Tables
+
+ * table, caption, thead, tfoot, tbody, colgroup, col, tr, th, td
+
+ This module declares element types and attributes used to provide
+ table markup similar to HTML 4.0, including features that enable
+ better accessibility for non-visual user agents.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-text-1.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-text-1.xsd
new file mode 100644
index 00000000..432bdad7
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xhtml-text-1.xsd
@@ -0,0 +1,67 @@
+
+
+
+
+
+ Textual Content
+ This is the XML Schema Text module for XHTML
+
+ The Text module includes declarations for all core
+ text container elements and their attributes.
+
+ + block phrasal
+ + block structural
+ + inline phrasal
+ + inline structural
+
+ $Id: xhtml-text-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $
+
+
+
+
+
+
+
+ Block Phrasal module
+ Elements defined here:
+
+ * address, blockquote, pre, h1, h2, h3, h4, h5, h6
+
+
+
+
+
+
+ Block Structural module
+ Elements defined here:
+
+ * div, p
+
+
+
+
+
+
+ Inline Phrasal module
+ Elements defined here:
+
+ * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var
+
+
+
+
+
+
+ Inline Structural module
+ Elements defined here:
+
+ * br,span
+
+
+
+
diff --git a/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xml.xsd b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xml.xsd
new file mode 100644
index 00000000..eeb9db56
--- /dev/null
+++ b/BKUViewer/src/main/resources/at/gv/egiz/bku/slxhtml/xml.xsd
@@ -0,0 +1,145 @@
+
+
+
+
+
+ See http://www.w3.org/XML/1998/namespace.html and
+ http://www.w3.org/TR/REC-xml for information about this namespace.
+
+ This schema document describes the XML namespace, in a form
+ suitable for import by other schema documents.
+
+ Note that local names in this namespace are intended to be defined
+ only by the World Wide Web Consortium or its subgroups. The
+ following names are currently defined in this namespace and should
+ not be used with conflicting semantics by any Working Group,
+ specification, or document instance:
+
+ base (as an attribute name): denotes an attribute whose value
+ provides a URI to be used as the base for interpreting any
+ relative URIs in the scope of the element on which it
+ appears; its value is inherited. This name is reserved
+ by virtue of its definition in the XML Base specification.
+
+ id (as an attribute name): denotes an attribute whose value
+ should be interpreted as if declared to be of type ID.
+ This name is reserved by virtue of its definition in the
+ xml:id specification.
+
+ lang (as an attribute name): denotes an attribute whose value
+ is a language code for the natural language of the content of
+ any element; its value is inherited. This name is reserved
+ by virtue of its definition in the XML specification.
+
+ space (as an attribute name): denotes an attribute whose
+ value is a keyword indicating what whitespace processing
+ discipline is intended for the content of the element; its
+ value is inherited. This name is reserved by virtue of its
+ definition in the XML specification.
+
+ Father (in any context at all): denotes Jon Bosak, the chair of
+ the original XML Working Group. This name is reserved by
+ the following decision of the W3C XML Plenary and
+ XML Coordination groups:
+
+ In appreciation for his vision, leadership and dedication
+ the W3C XML Plenary on this 10th day of February, 2000
+ reserves for Jon Bosak in perpetuity the XML name
+ xml:Father
+
+
+
+
+ This schema defines attributes and an attribute group
+ suitable for use by
+ schemas wishing to allow xml:base, xml:lang, xml:space or xml:id
+ attributes on elements they define.
+
+ To enable this, such a schema must import this schema
+ for the XML namespace, e.g. as follows:
+ <schema . . .>
+ . . .
+ <import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+
+ Subsequently, qualified reference to any of the attributes
+ or the group defined below will have the desired effect, e.g.
+
+ <type . . .>
+ . . .
+ <attributeGroup ref="xml:specialAttrs"/>
+
+ will define a type which will schema-validate an instance
+ element with any of those attributes
+
+
+
+ In keeping with the XML Schema WG's standard versioning
+ policy, this schema document will persist at
+ http://www.w3.org/2007/08/xml.xsd.
+ At the date of issue it can also be found at
+ http://www.w3.org/2001/xml.xsd.
+ The schema document at that URI may however change in the future,
+ in order to remain compatible with the latest version of XML Schema
+ itself, or with the XML namespace itself. In other words, if the XML
+ Schema or XML namespaces change, the version of this document at
+ http://www.w3.org/2001/xml.xsd will change
+ accordingly; the version at
+ http://www.w3.org/2007/08/xml.xsd will not change.
+
+
+
+
+
+ Attempting to install the relevant ISO 2- and 3-letter
+ codes as the enumerated possible values is probably never
+ going to be a realistic possibility. See
+ RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry
+ at http://www.iana.org/assignments/lang-tag-apps.htm for
+ further information.
+
+ The union allows for the 'un-declaration' of xml:lang with
+ the empty string.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ See http://www.w3.org/TR/xmlbase/ for
+ information about this attribute.
+
+
+
+
+
+ See http://www.w3.org/TR/xml-id/ for
+ information about this attribute.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUViewer/src/main/resources/org/w3c/css/properties/Config.properties b/BKUViewer/src/main/resources/org/w3c/css/properties/Config.properties
new file mode 100644
index 00000000..0ece8cda
--- /dev/null
+++ b/BKUViewer/src/main/resources/org/w3c/css/properties/Config.properties
@@ -0,0 +1,32 @@
+# configuration file for org.w3c.css.parser.CssFouffa
+# Properties should be in the style directory
+
+# Is the parser should run in CSS2 ?
+extended-parser: true
+
+# the CssStyle to use
+#style for CSS1
+css1: org.w3c.css.properties.css1.Css1Style
+#style for CSS2 (and mobile profile and TV profile)
+css2: org.w3c.css.properties.css2.font.Css2Style
+#style for CSS2.1
+css21: org.w3c.css.properties.css21.Css21Style
+#style for CSS3
+css3: org.w3c.css.properties.css3.Css3Style
+#SVG styles
+svg : org.w3c.css.properties.svg.SVGStyle
+svgbasic : org.w3c.css.properties.svg.SVGBasicStyle
+svgtiny : org.w3c.css.properties.svg.SVGTinyStyle
+#ATSC style
+atsc-tv: org.w3c.css.properties.atsc.ATSCStyle
+#SLXHMTL
+slxhtml: at.gv.egiz.bku.slxhtml.css.SLXHTMLStyle
+
+#media
+media: Media.properties
+
+# file containing the properties files for each profile
+profilesProperties: ProfilesProperties.properties
+
+#default profile
+defaultProfile: css21
diff --git a/BKUViewer/src/main/resources/org/w3c/css/properties/ProfilesProperties.properties b/BKUViewer/src/main/resources/org/w3c/css/properties/ProfilesProperties.properties
new file mode 100644
index 00000000..8c2aded8
--- /dev/null
+++ b/BKUViewer/src/main/resources/org/w3c/css/properties/ProfilesProperties.properties
@@ -0,0 +1,30 @@
+# The list of properties to use
+
+# properties for CSS1
+css1 : CSS1Properties.properties
+
+# properties for CSS2
+css2 : CSS2Properties.properties
+
+# properties for CSS2.1
+css21 : CSS21Properties.properties
+
+# properties for CSS3
+css3 : CSS3Properties.properties
+
+# properties for mobile profile
+mobile : MobileProperties.properties
+
+# properties for ATSC TV profile
+atsc-tv : ATSCProperties.properties
+
+# properties for TV profile
+tv : TVProperties.properties
+
+# properties for SVG profiles
+svg : SVGProperties.properties
+svgbasic : SVGBasicProperties.properties
+svgtiny : SVGTinyProperties.properties
+
+# properties for SLXHTML profile
+slxhtml : SLXHTMLProperties.properties
diff --git a/BKUViewer/src/main/resources/org/w3c/css/properties/SLXHTMLProperties.properties b/BKUViewer/src/main/resources/org/w3c/css/properties/SLXHTMLProperties.properties
new file mode 100644
index 00000000..dec68c11
--- /dev/null
+++ b/BKUViewer/src/main/resources/org/w3c/css/properties/SLXHTMLProperties.properties
@@ -0,0 +1,641 @@
+# All properties for all media
+
+# CSS2 Properties
+
+# Margin spacing
+#
+# The margin-top, margin-bottom, margin-left and margin-right properties
+# must be supported by a Citizen Card Environment. Values specified as percentages
+# (cf. section 3.5.1.2) should be supported.
+#
+# The margin property may be supported by a Citizen Card Environment.
+#
+# An instance document must not contain a negative value in the properties mentioned
+# above. Otherwise it must be rejected by the Citizen Card Environment.
+
+margin-top: at.gv.egiz.bku.slxhtml.css.CssMarginTopSLXHTML
+margin-bottom: at.gv.egiz.bku.slxhtml.css.CssMarginBottomSLXHTML
+margin-left: at.gv.egiz.bku.slxhtml.css.CssMarginLeftSLXHTML
+margin-right: at.gv.egiz.bku.slxhtml.css.CssMarginRightSLXHTML
+margin: at.gv.egiz.bku.slxhtml.css.CssMarginSLXHTML
+
+# Padding spacing
+#
+# The padding-top, padding-bottom, padding-left and padding-right properties must be
+# supported by a Citizen Card Environment. Values specified as percentages (cf. section
+# 3.5.1.2) should be supported.
+#
+# The padding property may be supported by a Citizen Card Environment.
+#
+# An instance document must not contain a negative value in the properties
+# mentioned above. Otherwise it must be rejected by the Citizen Card Environment.
+
+padding-top: at.gv.egiz.bku.slxhtml.css.CssPaddingTopSLXHTML
+padding-bottom: at.gv.egiz.bku.slxhtml.css.CssPaddingBottomSLXHTML
+padding-left: at.gv.egiz.bku.slxhtml.css.CssPaddingLeftSLXHTML
+padding-right: at.gv.egiz.bku.slxhtml.css.CssPaddingRightSLXHTML
+padding: at.gv.egiz.bku.slxhtml.css.CssPaddingSLXHTML
+
+#
+# Borders
+#
+
+# Border width
+#
+# The border-top-width, border-bottom-width, border-left-width, border-right-width
+# and border-width properties should be supported by a Citizen Card Environment. If
+# the properties are supported, the predefined values thin, medium and thick should
+# also be supported (cf. [CSS 2], section 8.5.1).
+
+border-top-width: org.w3c.css.properties.css1.CssBorderTopWidthCSS2
+border-right-width: org.w3c.css.properties.css1.CssBorderRightWidthCSS2
+border-left-width: org.w3c.css.properties.css1.CssBorderLeftWidthCSS2
+border-bottom-width: org.w3c.css.properties.css1.CssBorderBottomWidthCSS2
+
+# Border colour
+#
+# The border-top-color, border-bottom-color, border-left-color, border-right-color
+# and border-color properties should be supported by a Citizen Card Environment. The
+# predefined value transparent for the border-color property may be supported (cf.
+# [CSS 2], section 8.5.2).
+
+border-top-color: at.gv.egiz.bku.slxhtml.css.CssBorderTopColorSLXHTML
+border-right-color: at.gv.egiz.bku.slxhtml.css.CssBorderRightColorSLXHTML
+border-left-color: at.gv.egiz.bku.slxhtml.css.CssBorderLeftColorSLXHTML
+border-bottom-color: at.gv.egiz.bku.slxhtml.css.CssBorderBottomColorSLXHTML
+
+# Border style
+#
+# The border-top-style, border-bottom-style, border-left-style, border-right-style and
+# border-style properties should be supported by a Citizen Card Environment. If the properties
+# are supported, the predefined values none, dashed, dotted, solid and double should also
+# be supported; all other values may be supported (cf. [CSS 2], section 8.5.3).
+
+border-top-style: org.w3c.css.properties.css1.CssBorderTopStyleCSS2
+border-right-style: org.w3c.css.properties.css1.CssBorderRightStyleCSS2
+border-left-style: org.w3c.css.properties.css1.CssBorderLeftStyleCSS2
+border-bottom-style: org.w3c.css.properties.css1.CssBorderBottomStyleCSS2
+
+# Shorthand
+#
+# The properties for the shorthand version of the border properties (border-top,
+# border-bottom, border-left, border-right and border (cf. [CSS 2], section 8.5.4)
+# should be supported by a Citizen Card Environment. The recommended values result
+# from the three previous sections.
+
+border-width: org.w3c.css.properties.css1.CssBorderWidthCSS2
+border-color: at.gv.egiz.bku.slxhtml.css.CssBorderColorSLXHTML
+border-style: org.w3c.css.properties.css1.CssBorderStyleCSS2
+border-top: org.w3c.css.properties.css1.CssBorderTopCSS2
+border-right: org.w3c.css.properties.css1.CssBorderRightCSS2
+border-left: org.w3c.css.properties.css1.CssBorderLeftCSS2
+border-bottom: org.w3c.css.properties.css1.CssBorderBottomCSS2
+border: at.gv.egiz.bku.slxhtml.css.CssBorderSLXHTML
+
+#
+# Positioning of boxes
+#
+
+# Box type
+#
+# The property for controlling the box type (display) may be supported by a Citizen
+# Card Environment (cf. [CSS 2], section 9.2).
+
+display: org.w3c.css.properties.css1.CssDisplayCSS2
+
+# Positioning scheme
+#
+# The property for defining the positioning scheme for a box (position, cf. [CSS 2],
+# section 9.3) must not be contained in an instance document to prevent content
+# from overlapping. Otherwise the instance document must be rejected by the Citizen
+# Card Environment.
+
+#! position: org.w3c.css.properties.css1.CssPosition
+
+# Box spacing
+#
+# The property for defining the positioning scheme for a box (top, bottom, left, right;
+# cf. [CSS 2], section 9.3) must not be contained in an instance document to prevent
+# content from overlapping. Otherwise the instance document must be rejected by the
+# Citizen Card Environment.
+
+#! top: org.w3c.css.properties.css1.CssTop
+#! right: org.w3c.css.properties.css1.CssRight
+#! left: org.w3c.css.properties.css1.CssLeft
+#! bottom: org.w3c.css.properties.css1.CssBottom
+
+# Flow around boxes
+#
+# The properties for defining the flow around boxes (float, clear) may be supported by
+# a Citizen Card Environment (cf. [CSS 2], section 9.5).
+
+float: org.w3c.css.properties.css1.CssFloat
+clear: org.w3c.css.properties.css1.CssClear
+
+# Positioning of boxes on the z-axis
+#
+# The property for defining the positioning of boxes on the z-axis (z-index, cf. [CSS 2],
+# section 9.9) must not be contained in an instance document to prevent content from
+# overlapping. Otherwise the instance document must be rejected by the Citizen Card Environment.
+
+#! z-index: org.w3c.css.properties.css1.CssZIndex
+
+# Text direction
+#
+# The properties for controlling the text direction (direction, unicode-bidi) may be
+# supported by a Citizen Card Environment (cf. [CSS 2], section 9.10).
+
+direction: org.w3c.css.properties.css1.CssDirection
+unicode-bidi: org.w3c.css.properties.css1.CssUnicodeBidi
+
+#
+# Displaying boxes
+#
+
+# Width and height
+#
+# The properties for specifying the width and height of a box (width, height, cf. [CSS 2],
+# sections 10.2 and 10.5) must not be supported by a Citizen Card Environment to prevent
+# content from overlapping. Otherwise the instance document must be rejected by the
+# Citizen Card Environment.
+#
+# The properties for specifying the minimum width and height of a box (min-width, min-height)
+# may be supported by a Citizen Card Environment (cf. [CSS 2], sections 10.4 and 10.7).
+#
+# The properties for specifying the maximum width and height of a box (max-width, max-height,
+# cf. [CSS 2], sections 10.4 and 10.7) must not be supported by a Citizen Card Environment
+# to prevent content from overlapping. Otherwise the instance document must be rejected by
+# the Citizen Card Environment.
+
+#! width: org.w3c.css.properties.css1.CssWidth
+min-width: org.w3c.css.properties.css1.CssMinWidth
+#! max-width: org.w3c.css.properties.css1.CssMaxWidth
+min-height: org.w3c.css.properties.css1.CssMinHeight
+#! max-height: org.w3c.css.properties.css1.CssMaxHeight
+#! height: org.w3c.css.properties.css1.CssHeight
+
+# Line height
+#
+# The properties for specifying the line height (line-height, vertical-align) should be
+# supported by a Citizen Card (cf. [CSS 2], section 10.8). The only exception is the
+# vertical-align property: In this case a Citizen Card Environment must be able to interpret
+# the values sub and super.
+
+line-height: org.w3c.css.properties.css1.CssLineHeightCSS2
+vertical-align: org.w3c.css.properties.css1.CssVerticalAlign
+
+#
+# Visible area in boxes
+#
+
+# The property for specifying the visibility of a box (visibility) may be supported by a
+# Citizen Card Environment (cf. [CSS 2], section 11).
+#
+# The properties for controlling the visible area of a box (overflow, clip; cf. [CSS 2],
+# section 11) must not be contained in an instance document to prevent hidden content. Otherwise
+# the instance document must be rejected by the Citizen Card Environment.
+
+#! overflow: org.w3c.css.properties.css1.CssOverflow
+#! clip: org.w3c.css.properties.css1.CssClip
+visibility: org.w3c.css.properties.css1.CssVisibility
+
+#
+# Generated content, numbering, lists
+#
+
+# Generated content
+#
+# The property for generating content (content) may be supported by a Citizen Card Environment
+# (cf. [CSS 2], section 12.2).
+
+content: org.w3c.css.properties.css1.CssContentCSS2
+
+# Displaying quotation marks
+#
+# The property for displaying quotation marks (quotes) may be supported by a Citizen Card
+# Environment (cf. [CSS 2], section 12.3).
+
+quotes: org.w3c.css.properties.css1.CssQuotes
+
+# Numbering
+#
+# The properties for automatic numbering (counter-reset, counter-increment) may be supported
+# by a Citizen Card Environment (cf. [CSS 2], section 12.5).
+
+counter-reset: org.w3c.css.properties.css1.CssCounterReset
+counter-increment: org.w3c.css.properties.css1.CssCounterIncrement
+
+#
+# Markers and lists
+#
+
+# Marker spacing
+#
+# The property for defining the space between a marker and the associated box
+# (marker-offset) may be supported by a Citizen Card Environment (cf. [CSS 2],
+# section 12.6.1).
+
+marker-offset: org.w3c.css.properties.css1.CssMarkerOffset
+
+# List symbols
+#
+# For the property for selecting the list symbol (list-style-type) a Citizen
+# Card Environment must support the values none, disc, circle, square, decimal,
+# decimal-leading-zero, lower-roman, upper-roman, lower-alpha, lower-latin,
+# upper-alpha and upper-latin. The other values may be supported (cf. [CSS 2],
+# section 12.6.2).
+
+list-style-type: org.w3c.css.properties.css1.CssListStyleTypeCSS2
+
+# Position of the list symbol
+#
+# The property for positioning the list symbol in relation to the associated box
+# (list-style-position) should be supported by a Citizen Card Environment (cf. [CSS 2],
+# section 12.6.2).
+
+list-style-position: org.w3c.css.properties.css1.CssListStylePositionCSS2
+
+# Image as a list symbol
+#
+# The property for selecting an image as a list symbol (list-style-image) may be supported
+# by a Citizen Card Environment (cf. [CSS 2], section 12.6.2). If the Citizen Card Environment
+# supports this property, then it must proceed in respect of the integration of the image
+# in the signature as described in section 2.1.7.
+
+# optional, not supported:
+#! list-style-image: org.w3c.css.properties.css1.CssListStyleImageCSS2
+
+# Shorthand
+#
+# The property for the shorthand version of the list properties (list-style) should be supported
+# by a Citizen Card Environment. The recommended values result from the explanations for the
+# list-style-type, list-style-position and list-style-image properties above (cf. [CSS 2],
+# section 12.6.2).
+
+list-style: org.w3c.css.properties.css1.CssListStyleCSS2
+
+# Page-based media
+#
+# The properties for page-based media may be supported by a Citizen Card Environment (size, marks,
+# page-break-before, page-break-inside, page-break-after, page, orphans and widows (cf. [CSS 2],
+# section 13).
+
+page-break-before: org.w3c.css.properties.paged.PageBreakBefore
+page-break-after: org.w3c.css.properties.paged.PageBreakAfter
+page-break-inside: org.w3c.css.properties.paged.PageBreakInside
+page: org.w3c.css.properties.paged.Page
+orphans: org.w3c.css.properties.paged.Orphans
+widows: org.w3c.css.properties.paged.Widows
+
+@page.size: org.w3c.css.properties.paged.Size
+@page.marks: org.w3c.css.properties.paged.Marks
+@page.page-break-before: org.w3c.css.properties.paged.PageBreakBefore
+@page.page-break-after: org.w3c.css.properties.paged.PageBreakAfter
+@page.page-break-inside: org.w3c.css.properties.paged.PageBreakInside
+@page.page: org.w3c.css.properties.paged.Page
+@page.orphans: org.w3c.css.properties.paged.Orphans
+@page.widows: org.w3c.css.properties.paged.Widows
+
+
+#
+# Colours and background
+#
+
+# A Citizen Card Environment must support all the options for specifying a colour listed in [CSS 2],
+# section 4.3.6 for a CSS property, if such an option is available for this property according to [CSS 2].
+#
+# The exceptions are the system colours (cf. [CSS 2], section 18.2); these must not be used in an
+# instance document so as to prevent dependencies on the system environment. Otherwise the instance
+# document must be rejected by the Citizen Card Environment.
+
+# Colour
+
+# The property for defining the foreground colour of the content of an element (color) must be
+# supported by a Citizen Card Environment (cf. [CSS 2], section 14.1).
+
+color: at.gv.egiz.bku.slxhtml.css.CssColorSLXHTML
+
+# Background
+#
+# The property for defining the background colour of the content of an element (background-color)
+# must be supported by a Citizen Card Environment (cf. [CSS 2], section 14.2.1).
+#
+# The properties for selecting and controlling an image as background (background-image, background-repeat,
+# background-position, background-attachment; cf. [CSS 2], section 14.2.1) must not be contained in an
+# instance document to prevent content from overlapping. Otherwise the instance document must be
+# rejected by the Citizen Card Environment.
+
+# The property for the shorthand version of the background properties (background) should be supported
+# by a Citizen Card Environment. The recommended values result from the explanations for the background-color
+# property above (cf. [CSS 2], section 14.2.1). If the property contains values for selecting and controlling
+# an image as background, the instance document must be rejected by the Citizen Card Environment.
+
+background-color: at.gv.egiz.bku.slxhtml.css.CssBackgroundColorSLXHTML
+#! background-image: org.w3c.css.properties.css1.CssBackgroundImageCSS2
+#! background-repeat: org.w3c.css.properties.css1.CssBackgroundRepeatCSS2
+#! background-attachment: org.w3c.css.properties.css1.CssBackgroundAttachmentCSS2
+#! background-position: org.w3c.css.properties.css1.CssBackgroundPositionCSS2
+background: at.gv.egiz.bku.slxhtml.css.CssBackgroundSLXHTML
+
+#
+# Fonts
+#
+#
+# For the property for selecting a font family (font-family), a Citizen Card Environment must
+# support the predefined values serif, sans-serif and monospaced for the general font families.
+# All other values may be supported by a Citizen Card Environment (cf. [CSS 2], section 15.2.2).
+#
+# If a preferred font family is specified in the instance document that cannot be displayed by the
+# Citizen Card Environment, then the Citizen Card Environment may still display the instance
+# document if another displayable font family has been specified as an alternative. For example,
+# if the specification in the instance document is font-family: "Times New Roman", serif, then the
+# Citizen Card Environment may display the instance document in the secure viewer even if it does
+# not know the Times New Roman font family (as it must always support serif).
+
+font-family: org.w3c.css.properties.css1.CssFontFamilyCSS2
+
+# Font style
+#
+# The properties for defining the font style (font-style) and font weight (font-weight)
+# must be supported by a Citizen Card Environment. The values normal and italic must be supported,
+# while the value oblique should be supported.
+#
+# The property for defining the font variant (font-variant) should be supported by a Citizen Card
+# Environment, while the property for defining the font stretch (font-stretch) may be supported
+# by a Citizen Card Environment (cf. [CSS 2], section 15.2.3).
+
+font-style: org.w3c.css.properties.css1.CssFontStyleCSS2
+font-weight: org.w3c.css.properties.css1.CssFontWeightCSS2
+font-variant: org.w3c.css.properties.css1.CssFontVariantCSS2
+font-stretch: org.w3c.css.properties.css1.CssFontStretchCSS2
+
+# Font size
+#
+# The property for specifying the font size (font-size) must be supported by a Citizen
+# Card Environment. The property for specifying the stretch ratio (font-size-adjust) may
+# be supported by a Citizen Card Environment (cf. [CSS 2], section 15.2.4).
+
+font-size: org.w3c.css.properties.css1.CssFontSizeCSS2
+font-size-adjust: org.w3c.css.properties.css1.CssFontSizeAdjustCSS2
+
+# Shorthand
+#
+# The property for the shorthand version of the font properties (font) should be supported by
+# a Citizen Card Environment (cf. [CSS 2], section 15.2.5). The recommended values result from
+# the explanations above for the font-style, font-variant, font-weight, font-size and font-family
+# properties and the explanations for the line-height property in section 3.5.4.2.
+#
+# The additional, predefined values relating to the system fonts used (caption, icon, etc.) must
+# not be contained in an instance document so as to prevent dependencies on the system environment.
+# Otherwise the instance document must be rejected by the Citizen Card Environment.
+
+font: at.gv.egiz.bku.slxhtml.css.CssFontSLXHTML
+
+#
+# Displaying text
+#
+
+# Non-displayable characters
+#
+# If the text of an instance document contains a character that cannot be displayed by the
+# Citizen Card Environment, then the instance document must be rejected by the Citizen Card
+# Environment. The character must not be represented by a placeholder.
+
+# FIXME: How to implement?!
+
+# Indent
+#
+# The property for indenting the first line of a text block (text-indent) should be supported
+# by a Citizen Card Environment (cf. [CSS 2], section 16.1).
+
+text-indent: org.w3c.css.properties.css1.CssTextIndent
+
+# Alignment
+#
+# For the property for aligning the content of a text block (text-align) a Citizen Card Environment
+# must support the values left, right and center. The value justified should be supported,
+# while the specification of a string value may be supported (cf. [CSS 2], section 16.2).
+
+text-align: org.w3c.css.properties.css1.CssTextAlign
+
+# Text decoration
+#
+# For the property for decorating a text (text-decoration; cf. [CSS 2], section 16.3.1) a
+# Citizen Card Environment must support the values none, underline and line-through.
+#
+# The value blink must not be contained in an instance document. Otherwise the instance
+# document must be rejected by the Citizen Card Environment.
+#
+# The other values may be supported by a Citizen Card Environment.
+
+text-decoration: at.gv.egiz.bku.slxhtml.css.CssTextDecorationSLXHTML
+
+# Shadows
+#
+# The property for specifying a text shadow (text-shadow) may be supported by a Citizen Card
+# Environment (cf. [CSS 2], section 16.3.2).
+
+text-shadow: org.w3c.css.properties.css1.CssTextShadow
+
+# Word and letter spacing
+#
+# The word-spacing and letter-spacing should be supported by a Citizen Card Environment
+# (cf. [CSS 2], section 16.4).
+#
+# An instance document must not contain negative values in order to prevent content from
+# overlapping. Otherwise the instance document must be rejected by the Citizen Card Environment.
+
+word-spacing: at.gv.egiz.bku.slxhtml.css.CssWordSpacingSLXHTML
+letter-spacing: at.gv.egiz.bku.slxhtml.css.CssLetterSpacingSLXHTML
+
+# Capitalisation
+#
+# The property for specifying the capitalisation of the text of an element (text-transform)
+# may be supported by a Citizen Card Environment (cf. [CSS 2], section 16.5).
+
+text-transform: org.w3c.css.properties.css1.CssTextTransform
+
+# White space
+#
+# The property for the handling of white space within the text of an element (white-space) should
+# be supported by a Citizen Card Environment (cf. [CSS 2], section 16.6).
+
+white-space: org.w3c.css.properties.css1.CssWhiteSpace
+
+#
+# Tables
+#
+
+# Position of caption
+#
+# A Citizen Card Environment should support the top and bottom properties for the property for
+# specifying the position when labelling a table (caption-side); the properties left and right
+# may be supported (cf. [CSS 2], section 17.4.1).
+
+caption-side: org.w3c.css.properties.css2.table.CaptionSide
+
+# Layout algorithm
+#
+# The property for defining the layout algorithm for a table (table-layout) may be supported by
+# a Citizen Card Environment (cf. [CSS 2], section 17.5.2).
+#
+# However, the fixed value must not be supported because the layout algorithm selected with it can
+# cause content to overlap.
+#
+# In general, the viewer component of the Citizen Card Environment must use a layout algorithm for a
+# table that does not generate an overflow, in other words with which the content of every table
+# element can be rendered so that it does not extend beyond the confines of the table element.
+# There is an example of such an algorithm in [CSS 2], section 17.5.2, subsection Automatic table layout.
+
+table-layout: at.gv.egiz.bku.slxhtml.css.TableLayoutSLXHTML
+row-span: org.w3c.css.properties.css2.table.RowSpan
+column-span: org.w3c.css.properties.css2.table.ColumnSpan
+
+# Borders
+#
+# The properties for displaying borders in tables (border-collapse, border-spacing, empty-cells) may
+# be supported by a Citizen Card Environment (cf. [CSS 2], section 17.6).
+
+border-collapse: org.w3c.css.properties.css2.table.BorderCollapse
+border-spacing: org.w3c.css.properties.css2.table.BorderSpacing
+empty-cells: org.w3c.css.properties.css2.table.EmptyCells
+
+# Voice output
+#
+# The property for controlling the voice output of the column headers in a table (speak-header) may
+# be supported by a Citizen Card Environment (cf. [CSS 2], section 17.7.1).
+
+speak-header: org.w3c.css.properties.css2.table.SpeakHeader
+
+#
+# User interface
+#
+
+# Cursor format
+#
+# The property for controlling the cursor format (cursor; cf. [CSS 2], section 18.1) must not be
+# contained in an instance document. Otherwise the instance document must be rejected by the Citizen
+# Card Environment.
+
+#! cursor: org.w3c.css.properties.css2.user.CursorCSS2
+
+# Contours
+#
+# The properties for defining element contours (outline-width, outline-style, outline-color and
+# outline; cf. [CSS 2], section 18.4) must not be contained in an instance document. Otherwise the
+# instance document must be rejected by the Citizen Card Environment.
+
+#! outline: org.w3c.css.properties.css2.user.Outline
+#! outline-width: org.w3c.css.properties.css2.user.OutlineWidth
+#! outline-style: org.w3c.css.properties.css2.user.OutlineStyle
+#! outline-color: org.w3c.css.properties.css2.user.OutlineColor
+
+#
+# Aural Properties
+#
+# The properties for the voice output of a document (cf. [CSS 2], section 19) may be supported
+# by a Citizen Card Environment.
+
+volume: org.w3c.css.properties.aural.ACssVolume
+pause-before: org.w3c.css.properties.aural.ACssPauseBefore
+pause-after: org.w3c.css.properties.aural.ACssPauseAfter
+pause: org.w3c.css.properties.aural.ACssPause
+cue-before: org.w3c.css.properties.aural.ACssCueBefore
+cue-after: org.w3c.css.properties.aural.ACssCueAfter
+cue: org.w3c.css.properties.aural.ACssCue
+play-during: org.w3c.css.properties.aural.ACssPlayDuring
+voice-family: org.w3c.css.properties.aural.ACssVoiceFamily
+elevation: org.w3c.css.properties.aural.ACssElevation
+speech-rate: org.w3c.css.properties.aural.ACssSpeechRate
+pitch: org.w3c.css.properties.aural.ACssPitch
+pitch-range: org.w3c.css.properties.aural.ACssPitchRange
+stress: org.w3c.css.properties.aural.ACssStress
+richness: org.w3c.css.properties.aural.ACssRichness
+speak-punctuation: org.w3c.css.properties.aural.ACssSpeakPunctuation
+speak-date: org.w3c.css.properties.aural.ACssSpeakDate
+speak-numeral: org.w3c.css.properties.aural.ACssSpeakNumeral
+speak-time: org.w3c.css.properties.aural.ACssSpeakTime
+speak: org.w3c.css.properties.aural.ACssSpeak
+azimuth: org.w3c.css.properties.aural.ACssAzimuth
+
+#
+# @page
+#
+# The @page rule for defining the page properties for page-based output media may be
+# supported by a Citizen Card Environment (cf. [CSS 2], section 13, and section 3.5.7
+# of this document).
+#
+
+@page.margin-top: org.w3c.css.properties.css1.CssMarginTop
+@page.margin-bottom: org.w3c.css.properties.css1.CssMarginBottom
+@page.margin-left: org.w3c.css.properties.css1.CssMarginLeft
+@page.margin-right: org.w3c.css.properties.css1.CssMarginRight
+@page.margin: org.w3c.css.properties.css1.CssMargin
+@page.padding-top: org.w3c.css.properties.css1.CssPaddingTop
+@page.padding-bottom: org.w3c.css.properties.css1.CssPaddingBottom
+@page.padding-left: org.w3c.css.properties.css1.CssPaddingLeft
+@page.padding-right: org.w3c.css.properties.css1.CssPaddingRight
+@page.padding: org.w3c.css.properties.css1.CssPadding
+@page.border-top-width: org.w3c.css.properties.css1.CssBorderTopWidthCSS2
+@page.border-right-width: org.w3c.css.properties.css1.CssBorderRightWidthCSS2
+@page.border-left-width: org.w3c.css.properties.css1.CssBorderLeftWidthCSS2
+@page.border-bottom-width: org.w3c.css.properties.css1.CssBorderBottomWidthCSS2
+@page.border-top-color: org.w3c.css.properties.css1.CssBorderTopColorCSS2
+@page.border-right-color: org.w3c.css.properties.css1.CssBorderRightColorCSS2
+@page.border-left-color: org.w3c.css.properties.css1.CssBorderLeftColorCSS2
+@page.border-bottom-color: org.w3c.css.properties.css1.CssBorderBottomColorCSS2
+@page.border-top-style: org.w3c.css.properties.css1.CssBorderTopStyleCSS2
+@page.border-right-style: org.w3c.css.properties.css1.CssBorderRightStyleCSS2
+@page.border-left-style: org.w3c.css.properties.css1.CssBorderLeftStyleCSS2
+@page.border-bottom-style: org.w3c.css.properties.css1.CssBorderBottomStyleCSS2
+@page.border-width: org.w3c.css.properties.css1.CssBorderWidthCSS2
+@page.border-color: org.w3c.css.properties.css1.CssBorderColorCSS2
+@page.border-style: org.w3c.css.properties.css1.CssBorderStyleCSS2
+@page.border-top: org.w3c.css.properties.css1.CssBorderTopCSS2
+@page.border-right: org.w3c.css.properties.css1.CssBorderRightCSS2
+@page.border-left: org.w3c.css.properties.css1.CssBorderLeftCSS2
+@page.border-bottom: org.w3c.css.properties.css1.CssBorderBottomCSS2
+@page.border: org.w3c.css.properties.css1.CssBorderCSS2
+@page.display: org.w3c.css.properties.css1.CssDisplayCSS2
+@page.position: org.w3c.css.properties.css1.CssPosition
+@page.z-index: org.w3c.css.properties.css1.CssZIndex
+@page.direction: org.w3c.css.properties.css1.CssDirection
+@page.unicode-bidi: org.w3c.css.properties.css1.CssUnicodeBidi
+@page.top: org.w3c.css.properties.css1.CssTop
+@page.right: org.w3c.css.properties.css1.CssRight
+@page.left: org.w3c.css.properties.css1.CssLeft
+@page.bottom: org.w3c.css.properties.css1.CssBottom
+@page.float: org.w3c.css.properties.css1.CssFloat
+@page.clear: org.w3c.css.properties.css1.CssClear
+
+#
+# @font-face
+#
+# The @font-face rule for describing or referencing additional font families (cf. [CSS 2],
+# section 15.3) must not be used in an instance document. The viewer component of the Citizen
+# Card Environment must reject an instance document containing a @font-face rule.
+
+#! @font-face.font-style: org.w3c.css.properties.css2.font.FontStyle
+#! @font-face.font-variant: org.w3c.css.properties.css2.font.FontVariant
+#! @font-face.font-weight: org.w3c.css.properties.css2.font.FontWeight
+#! @font-face.font-size: org.w3c.css.properties.css2.font.FontSize
+#! @font-face.font-family: org.w3c.css.properties.css2.font.FontFamily
+#! @font-face.font-stretch: org.w3c.css.properties.css2.font.FontStretch
+#! @font-face.unicode-range: org.w3c.css.properties.css2.font.UnicodeRange
+#! @font-face.units-per-em: org.w3c.css.properties.css2.font.UnitsPerEm
+#! @font-face.src: org.w3c.css.properties.css2.font.Src
+#! @font-face.panose-1: org.w3c.css.properties.css2.font.Panose1
+#! @font-face.stemv: org.w3c.css.properties.css2.font.Stemv
+#! @font-face.stemh: org.w3c.css.properties.css2.font.Stemh
+#! @font-face.slope: org.w3c.css.properties.css2.font.Slope
+#! @font-face.cap-height: org.w3c.css.properties.css2.font.CapHeight
+#! @font-face.x-hegiht: org.w3c.css.properties.css2.font.XHeight
+#! @font-face.widths: org.w3c.css.properties.css2.font.Widths
+#! @font-face.ascent: org.w3c.css.properties.css2.font.Ascent
+#! @font-face.descent: org.w3c.css.properties.css2.font.Descent
+#! @font-face.bbox: org.w3c.css.properties.css2.font.Bbox
+#! @font-face.baseline: org.w3c.css.properties.css2.font.Baseline
+#! @font-face.centerline: org.w3c.css.properties.css2.font.Centerline
+#! @font-face.definition-src: org.w3c.css.properties.css2.font.DefinitionSrc
+#! @font-face.mathline: org.w3c.css.properties.css2.font.Mathline
+#! @font-face.topline: org.w3c.css.properties.css2.font.Topline
diff --git a/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
new file mode 100644
index 00000000..38c64262
--- /dev/null
+++ b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
@@ -0,0 +1,66 @@
+/*
+* 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.bku.slxhtml;
+
+import static org.junit.Assert.*;
+
+import java.io.InputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+
+import at.gv.egiz.bku.viewer.ValidationException;
+import at.gv.egiz.bku.viewer.Validator;
+import at.gv.egiz.bku.viewer.ValidatorFactory;
+
+
+public class ValidatorTest {
+
+ private static Log log = LogFactory.getLog(ValidatorTest.class);
+
+ @Test
+ public void testGetInstance() {
+
+ Validator validator = ValidatorFactory.newValidator("application/xhtml+xml");
+
+ assertNotNull(validator);
+
+ }
+
+ @Test
+ public void testValidate() throws ValidationException {
+
+ String slxhtmlFile = "at/gv/egiz/bku/slxhtml/test.xhtml";
+
+ Validator validator = ValidatorFactory.newValidator("application/xhtml+xml");
+
+ ClassLoader cl = ValidatorTest.class.getClassLoader();
+ InputStream slxhtml = cl.getResourceAsStream(slxhtmlFile);
+ long t0 = System.currentTimeMillis();
+ try {
+ validator.validate(slxhtml, null);
+ } catch (ValidationException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ long t1 = System.currentTimeMillis();
+ log.info("Validated SLXHTML file '" + slxhtmlFile + "' in " + (t1 - t0) + "ms.");
+
+ }
+
+}
diff --git a/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/css/CssValidatorTest.java b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/css/CssValidatorTest.java
new file mode 100644
index 00000000..2b4740f9
--- /dev/null
+++ b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/css/CssValidatorTest.java
@@ -0,0 +1,75 @@
+/*
+* 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.bku.slxhtml.css;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Test;
+
+import at.gv.egiz.bku.viewer.ValidationException;
+
+public class CssValidatorTest {
+
+ @Test
+ public void testProperties() throws IOException {
+
+ ClassLoader cs = CssValidatorTest.class.getClassLoader();
+ InputStream is = cs.getResourceAsStream("org/w3c/css/properties/SLXHTMLProperties.properties");
+
+ assertNotNull(is);
+
+ Properties cssProperties = new Properties();
+ cssProperties.load(is);
+
+ Set names = cssProperties.stringPropertyNames();
+ for (String name : names) {
+ String className = cssProperties.getProperty(name);
+ try {
+ Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ fail("Implementation class '" + className + "' for property '" + name + "' not found.");
+ }
+
+ }
+
+ }
+
+ @Test(expected=ValidationException.class)
+ public void testValidator() throws UnsupportedEncodingException, ValidationException {
+
+ String css = "@charset \"ABCDEFG\";\n" +
+ " @import url(http://test.abc/test); * { color: black }";
+ ByteArrayInputStream input = new ByteArrayInputStream(css.getBytes("UTF-8"));
+
+ CSSValidatorSLXHTML validator = new CSSValidatorSLXHTML();
+
+ Locale locale = new Locale("de");
+
+ validator.validate(input, locale, "Test", 10);
+
+ }
+
+
+}
diff --git a/BKUViewer/src/test/resources/at/gv/egiz/bku/slxhtml/test.xhtml b/BKUViewer/src/test/resources/at/gv/egiz/bku/slxhtml/test.xhtml
new file mode 100644
index 00000000..cbd29551
--- /dev/null
+++ b/BKUViewer/src/test/resources/at/gv/egiz/bku/slxhtml/test.xhtml
@@ -0,0 +1,10 @@
+
+
+
+ Ein einfaches SLXHTML-Dokument
+ @font-face { color: red }; p { color: red; }
+
+
+ Ich bin ein einfacher Text in rot.
+
+
diff --git a/BKUViewer/src/test/resources/commons-logging.properties b/BKUViewer/src/test/resources/commons-logging.properties
new file mode 100644
index 00000000..29292562
--- /dev/null
+++ b/BKUViewer/src/test/resources/commons-logging.properties
@@ -0,0 +1 @@
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
diff --git a/BKUViewer/src/test/resources/log4j.properties b/BKUViewer/src/test/resources/log4j.properties
new file mode 100644
index 00000000..053eac17
--- /dev/null
+++ b/BKUViewer/src/test/resources/log4j.properties
@@ -0,0 +1,19 @@
+# loglever DEBUG, appender STDOUT
+log4j.rootLogger=TRACE, STDOUT
+#log4j.logger.at.gv.egiz.slbinding.RedirectEventFilter=DEBUG, STDOUT
+
+# STDOUT appender
+log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
+log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
+#log4j.appender.STDOUT.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n
+#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+log4j.appender.STDOUT.layout.ConversionPattern=%-5p |%d | %t | %c %x- %m%n
+
+### FILE appender
+#log4j.appender.file=org.apache.log4j.RollingFileAppender
+#log4j.appender.file.maxFileSize=100KB
+#log4j.appender.file.maxBackupIndex=9
+#log4j.appender.file.File=egovbus_ca.log
+#log4j.appender.file.threshold=info
+#log4j.appender.file.layout=org.apache.log4j.PatternLayout
+#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
\ No newline at end of file
diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml
index 2ccf0766..2db0cc84 100644
--- a/bkucommon/pom.xml
+++ b/bkucommon/pom.xml
@@ -1,7 +1,5 @@
-
+bkuat.gv.egiz
@@ -42,10 +40,13 @@
commons-httpclientcompile
+
+ xerces
+ xercesImpl
+ xalanxalan
- 2.7.0iaik
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java
index 253f8ff5..1a22f787 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/InputStreamPartSource.java
@@ -14,11 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
package at.gv.egiz.bku.binding.multipart;
import java.io.IOException;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
index 566b77b3..5585f02e 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
@@ -14,11 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
package at.gv.egiz.bku.binding.multipart;
import at.gv.egiz.bku.slcommands.SLResult;
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 136fa6f3..628326cf 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
@@ -44,7 +44,9 @@ import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactory;
import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactoryImpl;
import at.gv.egiz.bku.slcommands.impl.xsect.Signature;
import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.slexceptions.SLViewerException;
import at.gv.egiz.dom.DOMUtils;
import at.gv.egiz.stal.InfoboxReadRequest;
import at.gv.egiz.stal.InfoboxReadResponse;
@@ -166,9 +168,10 @@ public class CreateXMLSignatureCommandImpl extends SLCommandImpltrue if validation should be enabled, or
+ * false otherwise.
+ */
+ public static void enableHashDataInputValidation(boolean validate) {
+ DataObject.validate = validate;
+ }
+
+ /**
+ * @return true if hash data input validation is enabled,
+ * or false otherwise.
+ */
+ public static boolean isHashDataInputValidationEnabled() {
+ return validate;
+ }
+
+ /**
+ * Valid MIME types.
+ */
+ private static String[] validMimeTypes = DEFAULT_PREFFERED_MIME_TYPES;
+
+ /**
+ * Sets the list of valid hash data input media types.
+ *
The array is also used for transformation path selection.
+ * The transformation path with a final type, that appears in the
+ * given array in the earliest position is used selected.
+ *
+ * @param mediaTypes an array of MIME media types.
+ */
+ public static void setValidHashDataInputMediaTypes(String[] mediaTypes) {
+ validMimeTypes = mediaTypes;
+ }
+
/**
* The DOM implementation used.
*/
@@ -184,7 +230,70 @@ public class DataObject {
public String getDescription() {
return description;
}
-
+
+ public void validateHashDataInput() throws SLViewerException {
+
+ if (validate) {
+
+ if (reference == null) {
+ log.error("Medthod validateHashDataInput() called before reference has been created.");
+ throw new SLViewerException(5000);
+ }
+
+ InputStream digestInputStream = reference.getDigestInputStream();
+ if (digestInputStream == null) {
+ log.error("Method validateHashDataInput() called before reference has been generated " +
+ "or reference caching is not enabled.");
+ throw new SLViewerException(5000);
+ }
+
+ if (mimeType == null) {
+ log.info("FinalDataMetaInfo does not specify MIME type of to be signed data.");
+ // TODO: add detailed message
+ throw new SLViewerException(5000);
+ }
+
+ // get MIME media type
+ String mediaType = mimeType.split(";")[0].trim();
+ // and optional charset
+ String charset = HttpUtil.getCharset(mimeType, false);
+
+ if (Arrays.asList(validMimeTypes).contains(mediaType)) {
+
+ Validator validator;
+ try {
+ validator = ValidatorFactory.newValidator(mediaType);
+ } catch (IllegalArgumentException e) {
+ log.error("No validator found for mime type '" + mediaType + "'.");
+ throw new SLViewerException(5000);
+ }
+
+ try {
+ validator.validate(digestInputStream, charset);
+ } catch (ValidationException e) {
+ if ("text/plain".equals(mediaType)) {
+ log.info("Data to be displayed contains unsupported characters.", e);
+ // TODO: add detailed message
+ throw new SLViewerException(5003);
+ } else if ("application/xhtml+xml".equals(mediaType)) {
+ // TODO: add detailed message
+ log.info("Standard display format: HTML does not conform to specification.", e);
+ throw new SLViewerException(5004);
+ } else {
+ // TODO: add detailed message
+ log.info("Data to be displayed is invalid.", e);
+ throw new SLViewerException(5000);
+ }
+ }
+
+ } else {
+ log.info("MIME media type '" + mediaType + "' is not a valid digest input.");
+ throw new SLViewerException(5001);
+ }
+ }
+
+ }
+
/**
* Configures this DataObject with the information provided within the given
* sl:DataObjectInfo.
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
index eba1d96d..2d89c8ae 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
@@ -17,6 +17,8 @@
package at.gv.egiz.bku.slcommands.impl.xsect;
import at.gv.egiz.bku.slcommands.impl.HashDataInputImpl;
+import at.gv.egiz.bku.slexceptions.SLViewerException;
+
import java.io.ByteArrayOutputStream;
import java.security.InvalidKeyException;
import java.security.InvalidParameterException;
@@ -123,9 +125,14 @@ public class STALSignature extends SignatureSpi {
// log.debug("got " + dataObjects.size() + " DataObjects, passing HashDataInputs to STAL SignRequest");
List hashDataInputs = new ArrayList();
- for (DataObject dataObject : dataObjects) {
- hashDataInputs.add(new HashDataInputImpl(dataObject));
+ for (DataObject dataObject : dataObjects) {
+ try {
+ dataObject.validateHashDataInput();
+ } catch (SLViewerException e) {
+ throw new STALSignatureException(e);
}
+ hashDataInputs.add(new HashDataInputImpl(dataObject));
+ }
SignRequest signRequest = new SignRequest();
signRequest.setKeyIdentifier(keyboxIdentifier);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
index 191f8371..2330ed3f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
@@ -81,6 +81,7 @@ import at.buergerkarte.namespaces.securitylayer._1.SignatureInfoCreationType;
import at.gv.egiz.bku.binding.HttpUtil;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.slexceptions.SLViewerException;
import at.gv.egiz.bku.utils.HexDump;
import at.gv.egiz.bku.utils.urldereferencer.StreamData;
import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
@@ -387,10 +388,11 @@ public class Signature {
* if signing the XMLSignature fails
* @throws SLCommandException
* if building the XMLSignature fails
+ * @throws SLViewerException
* @throws NullPointerException
* if signContext is null
*/
- public void sign(DOMSignContext signContext) throws MarshalException, XMLSignatureException, SLCommandException {
+ public void sign(DOMSignContext signContext) throws MarshalException, XMLSignatureException, SLCommandException, SLViewerException {
if (xmlSignature == null) {
buildXMLSignature();
@@ -415,6 +417,9 @@ public class Signature {
Throwable cause = e.getCause();
while (cause != null) {
if (cause instanceof STALSignatureException) {
+ if (((STALSignatureException) cause).getCause() instanceof SLViewerException) {
+ throw (SLViewerException) ((STALSignatureException) cause).getCause();
+ }
int errorCode = ((STALSignatureException) cause).getErrorCode();
SLCommandException commandException = new SLCommandException(errorCode);
log.info("Failed to sign signature.", commandException);
@@ -482,11 +487,12 @@ public class Signature {
* if signing this Signature fails
* @throws SLCommandException
* if building this Signature fails
+ * @throws SLViewerException
* @throws NullPointerException
* if stal or keyboxIdentifier is
* null
*/
- public void sign(STAL stal, String keyboxIdentifier) throws MarshalException, XMLSignatureException, SLCommandException {
+ public void sign(STAL stal, String keyboxIdentifier) throws MarshalException, XMLSignatureException, SLCommandException, SLViewerException {
if (stal == null) {
throw new NullPointerException("Argument 'stal' must not be null.");
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java
index 1d128a00..853328d5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLViewerException.java
@@ -17,9 +17,12 @@
package at.gv.egiz.bku.slexceptions;
public class SLViewerException extends SLException {
-
+
+ public SLViewerException(int errorCode) {
+ super(errorCode);
+ }
+
public SLViewerException(int errorCode, String msg, Object[] args) {
super(errorCode, msg, args);
- // TODO Auto-generated constructor stub
}
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidationException.java b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidationException.java
new file mode 100644
index 00000000..fb332a09
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidationException.java
@@ -0,0 +1,38 @@
+/*
+* 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.bku.viewer;
+
+public class ValidationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public ValidationException() {
+ }
+
+ public ValidationException(String message) {
+ super(message);
+ }
+
+ public ValidationException(Throwable cause) {
+ super(cause);
+ }
+
+ public ValidationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/Validator.java b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/Validator.java
new file mode 100644
index 00000000..08b21080
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/Validator.java
@@ -0,0 +1,25 @@
+/*
+* 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.bku.viewer;
+
+import java.io.InputStream;
+
+public interface Validator {
+
+ public void validate(InputStream is, String charset) throws ValidationException;
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java
new file mode 100644
index 00000000..e16a261e
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java
@@ -0,0 +1,165 @@
+/*
+* 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.bku.viewer;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ValidatorFactory {
+
+ /**
+ * Logging facility.
+ */
+ protected static Log log = LogFactory.getLog(ValidatorFactory.class);
+
+ private static final Class VALIDATOR_CLASS = Validator.class;
+
+ private static final String SERVICE_ID = "META-INF/services/" + VALIDATOR_CLASS.getName();
+
+ /**
+ * Creates a new Validator for the given mimeType.
+ *
+ * @param mimeType
+ *
+ * @return
+ *
+ * @throws IllegalArgumentException
+ * if no Validator for the mimeType could be found
+ */
+ public static Validator newValidator(String mimeType) throws IllegalArgumentException {
+
+ ClassLoader classLoader = ValidatorFactory.class.getClassLoader();
+ ValidatorFactory factory = new ValidatorFactory(classLoader);
+
+ Validator validator = factory.createValidator(mimeType);
+
+ if (validator == null) {
+ throw new IllegalArgumentException("Validator for '" + mimeType
+ + "' could not be found.");
+ }
+
+ return validator;
+
+ }
+
+ private ClassLoader classLoader;
+
+ /**
+ * Private constructor.
+ *
+ * @param classLoader must not be null
+ */
+ private ValidatorFactory(ClassLoader classLoader) {
+
+ if (classLoader == null) {
+ throw new NullPointerException("Argument 'classLoader' must no be null.");
+ }
+
+ this.classLoader = classLoader;
+
+ }
+
+ private Validator createValidator(String mimeType) {
+
+ Iterator serviceIterator = createServiceIterator();
+ while (serviceIterator.hasNext()) {
+ URL url = serviceIterator.next();
+
+ Properties properties = new Properties();
+ try {
+ properties.load(url.openStream());
+ } catch (IOException e) {
+ log.error("Failed to load service properties " + url.toExternalForm());
+ continue;
+ }
+ String className = properties.getProperty(mimeType);
+ if (className != null) {
+ try {
+ return createValidatorInstance(className);
+ } catch (Exception e) {
+ continue;
+ }
+ }
+
+ }
+
+ return null;
+
+ }
+
+ private Validator createValidatorInstance(String className)
+ throws ClassNotFoundException, InstantiationException,
+ IllegalAccessException {
+
+ try {
+ Class> implClass = classLoader.loadClass(className);
+ return (Validator) implClass.newInstance();
+ } catch (ClassNotFoundException e) {
+ log.error("Validator class '" + className + "' not found.", e);
+ throw e;
+ } catch (InstantiationException e) {
+ log.error("Faild to initialize validator class '" + className + "'.", e);
+ throw e;
+ } catch (IllegalAccessException e) {
+ log.error("Faild to initialize validator class '" + className + "'.", e);
+ throw e;
+ } catch (ClassCastException e) {
+ log.error("Class '" + className + "' is not a validator implementation.", e);
+ throw e;
+ }
+
+ }
+
+ private Iterator createServiceIterator() {
+
+ try {
+ final Enumeration resources = classLoader.getResources(SERVICE_ID);
+ return new Iterator () {
+
+ @Override
+ public boolean hasNext() {
+ return resources.hasMoreElements();
+ }
+
+ @Override
+ public URL next() {
+ return resources.nextElement();
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ } catch (IOException e) {
+ log.error("Failed to enumerate resources " + SERVICE_ID);
+ List list = Collections.emptyList();
+ return list.iterator();
+ }
+
+ }
+
+}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java
index a650d67f..9e34d9ae 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java
@@ -68,6 +68,7 @@ import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
import at.buergerkarte.namespaces.securitylayer._1.SignatureInfoCreationType;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.slexceptions.SLViewerException;
import at.gv.egiz.bku.utils.urldereferencer.StreamData;
import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
@@ -361,7 +362,7 @@ public class SignatureTest {
}
- private void signAndMarshalSignature(Signature signature) throws MarshalException, XMLSignatureException, SLCommandException {
+ private void signAndMarshalSignature(Signature signature) throws MarshalException, XMLSignatureException, SLCommandException, SLViewerException {
Node parent = signature.getParent();
Node nextSibling = signature.getNextSibling();
@@ -387,7 +388,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_Base64Content_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_Base64Content_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Base64Content_1.xml");
@@ -427,7 +428,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_XMLContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_XMLContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_XMLContent_1.xml");
@@ -467,7 +468,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_XMLContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_XMLContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_XMLContent_2.xml");
@@ -508,7 +509,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_LocRefContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_LocRefContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_LocRefContent_1.xml");
@@ -546,7 +547,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_LocRefContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_LocRefContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_LocRefContent_2.xml");
@@ -584,7 +585,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_Reference_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_Reference_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Reference_1.xml");
@@ -622,7 +623,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_Detached_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_Detached_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_1.xml");
@@ -653,7 +654,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testDataObject_Detached_Base64Content() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testDataObject_Detached_Base64Content() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
List dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_Base64Content.xml");
@@ -704,7 +705,7 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
- public void testTransformsInfo_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException {
+ public void testTransformsInfo_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
CreateXMLSignatureRequestType requestType = unmarshalCreateXMLSignatureRequest("TransformsInfo_1.xml");
diff --git a/pom.xml b/pom.xml
index 352257f0..3438e596 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,17 +7,18 @@
1.0-SNAPSHOTBKUhttp://bku.egiz.gv.at
-
- utils
- bkucommon
- STAL
- BKUOnline
- smcc
- BKULocal
- BKUApplet
- smccSTAL
- STALService
- BKUCommonGUI
+
+ utils
+ bkucommon
+ STAL
+ BKUOnline
+ smcc
+ BKULocal
+ BKUApplet
+ smccSTAL
+ STALService
+ BKUCommonGUI
+ BKUViewer
@@ -161,6 +162,16 @@
4.4test
+
+ xerces
+ xercesImpl
+ 2.9.1
+
+
+ xalan
+ xalan
+ 2.7.0
+ iaikiaik_jce_full_signed
--
cgit v1.2.3
From 76bb812a3254be530e403f8db8c01323a31b30c1 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Thu, 11 Sep 2008 13:03:44 +0000
Subject: git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@33
8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUOnline/pom.xml | 317 ++++++++-------
.../at/gv/egiz/bku/online/conf/Configurator.java | 21 +-
.../egiz/bku/online/conf/SpringConfigurator.java | 17 +
.../gv/egiz/bku/online/webapp/ResultServlet.java | 246 ++++++------
.../egiz/bku/online/webapp/SpringBKUServlet.java | 6 +-
.../gv/egiz/bku/online/conf/defaultConf.properties | 2 +
BKUOnline/src/main/resources/log4j.properties | 21 +-
.../src/main/webapp/WEB-INF/applicationContext.xml | 4 +-
BKUOnline/src/main/webapp/appletPage.jsp | 8 +-
.../main/java/at/gv/egiz/bku/binding/DataUrl.java | 22 +-
.../at/gv/egiz/bku/binding/DataUrlConnection.java | 6 +-
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 444 +++++++++++----------
.../gv/egiz/bku/binding/DataUrlConnectionSPI.java | 9 +-
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 14 +-
.../slexceptions/SLExceptionMessages.properties | 165 ++++----
.../slexceptions/SLExceptionMessages_en.properties | 97 +++++
.../gv/egiz/bku/binding/TestDataUrlConnection.java | 9 +-
17 files changed, 812 insertions(+), 596 deletions(-)
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
(limited to 'bkucommon/src/main')
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml
index a0e45cf6..d31367a8 100644
--- a/BKUOnline/pom.xml
+++ b/BKUOnline/pom.xml
@@ -1,141 +1,180 @@
-
-
- bku
- at.gv.egiz
- 1.0-SNAPSHOT
-
- 4.0.0
- at.gv.egiz
- BKUOnline
- war
- BKU Online
- 1.0-SNAPSHOT
-
-
- at.gv.egiz
- bkucommon
- 1.0-SNAPSHOT
-
-
- commons-logging
- commons-logging
-
-
- org.springframework
- spring-core
- 2.5.5
-
-
- javax.servlet
- servlet-api
- 2.5
- provided
-
-
- org.springframework
- spring-web
- 2.5.5
-
-
- at.gv.egiz
- STALService
- 1.0-SNAPSHOT
- compile
-
-
-
-
- com.sun.xml.ws
-
- jaxws-rt
- 2.1.4
-
-
-
-
-
- Tomcat60
-
-
-
-
- maven-dependency-plugin
-
-
- copyapplet
-
- copy
-
-
-
-
- at.gv.egiz
- BKUApplet
- 1.0-SNAPSHOT
-
-
- commons-logging
- commons-logging
-
-
- iaik
- iaik_jce_me4se
-
-
- ${project.build.directory}/${project.build.finalName}/applet
-
-
-
-
-
-
-
+
+
+ bku
+ at.gv.egiz
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ at.gv.egiz
+ BKUOnline
+ war
+ BKU Online
+ 1.0-SNAPSHOT
+
+
+
+ tlc
+ TLC Repository
+ http://commons.ucalgary.ca/pub/m2
+
+
+
+
+
+ at.gv.egiz
+ bkucommon
+ 1.0-SNAPSHOT
+
+
+ at.gv.egiz
+ BKUViewer
+ 1.0-SNAPSHOT
+
+
+ commons-logging
+ commons-logging
+
+
+ org.springframework
+ spring-core
+ 2.5.5
+
+
+ javax.servlet
+ servlet-api
+ 2.5
+ provided
+
+
+ org.springframework
+ spring-web
+ 2.5.5
+
+
+ at.gv.egiz
+ STALService
+ 1.0-SNAPSHOT
+ compile
+
+
+
+
+ com.sun.xml.ws
+
+ jaxws-rt
+ 2.1.4
+
+
+
+
+
+ Tomcat60
+
+
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKUOnline
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKUOnline
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKUOnline
+
+
+
+
+ maven-dependency-plugin
+
+
+ copyapplet
+
+ copy
+
+
+
+
+ at.gv.egiz
+ BKUApplet
+ 1.0-SNAPSHOT
+
+
+ commons-logging
+ commons-logging
+
+
+ iaik
+ iaik_jce_me4se
+
+
+ ${project.build.directory}/${project.build.finalName}/applet
+
+
+
+
+
+
+ maven-war-plugin
+ 2.0.2
+
+
+
+ true
+
+
+
+
+
+ ${project.version}-r${buildNumber}
+
+
+
+
+
+
+ org.codehaus.mojo
+ maven-buildnumber-plugin
+ 0.9.6
+
+
+ validate
+
+ create
+
+
+
+
+ false
+ false
+
+
+
+
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
index de577139..c09abcc1 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
@@ -17,8 +17,10 @@
package at.gv.egiz.bku.online.conf;
import iaik.security.ecc.provider.ECCProvider;
+import iaik.security.provider.IAIK;
import iaik.xml.crypto.XSecProvider;
+import java.io.IOException;
import java.net.HttpURLConnection;
import java.security.Provider;
import java.security.Security;
@@ -29,22 +31,30 @@ import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import at.gv.egiz.bku.binding.DataUrl;
+import at.gv.egiz.bku.binding.DataUrlConnection;
+import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
-import iaik.security.provider.IAIK;
/**
*
* TODO currently only the code to get started.
*/
-public class Configurator {
+public abstract class Configurator {
private Log log = LogFactory.getLog(Configurator.class);
+
+ private static Configurator instance = new SpringConfigurator();
protected Properties properties;
- public Configurator() {
+ protected Configurator() {
}
+ public static Configurator getInstance() {
+ return instance;
+ }
+
protected void configUrlConnections() {
HttpsURLConnection.setFollowRedirects(false);
HttpURLConnection.setFollowRedirects(false);
@@ -65,9 +75,14 @@ public class Configurator {
log.debug(sb.toString());
}
+ protected void configViewer() {
+ DataObject.enableHashDataInputValidation(Boolean.parseBoolean(properties.getProperty("ValidateHashDataInputs")));
+ }
+
public void configure() {
configureProviders();
configUrlConnections();
+ configViewer();
}
public void setConfiguration(Properties props) {
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
index 545a69c9..9fe91708 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
@@ -49,6 +49,8 @@ import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
+import at.gv.egiz.bku.binding.DataUrl;
+import at.gv.egiz.bku.binding.DataUrlConnection;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
public class SpringConfigurator extends Configurator implements
@@ -71,9 +73,24 @@ public class SpringConfigurator extends Configurator implements
}
}
+ public void configureVersion() {
+ Properties p = new Properties();
+ try {
+ p.load(resourceLoader.getResource("META-INF/MANIFEST.MF").getInputStream());
+ String version = p.getProperty("Implementation-Build");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY, "citizen-card-environment/1.2 MOCCA "+version);
+ DataUrl.setConfiguration(properties);
+ log.debug("Setting user agent to: "+properties.getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+
+
public void configure() {
super.configure();
configureSSL();
+ configureVersion();
}
private Set getCACerts() throws IOException,
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index bc3edf18..28c714c1 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -1,121 +1,129 @@
/*
-* 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.bku.online.webapp;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.binding.HTTPBindingProcessor;
-import at.gv.egiz.bku.binding.IdFactory;
-
-/**
- * Delivers the result to the browser
- *
- */
-public class ResultServlet extends SpringBKUServlet {
-
- private final static Log log = LogFactory.getLog(ResultServlet.class);
-
- private String encoding = "UTF-8";
- private String expiredPage = "./expiredError.jsp";
-
- public ResultServlet() {
- }
-
- private void myInit() {
- String enc = getServletContext().getInitParameter("responseEncoding");
- if (enc != null) {
- log.debug("Init default encoding to: "+enc);
- encoding = enc;
- }
- String expP = getServletConfig().getInitParameter("expiredPage");
- if (expP != null) {
- log.debug("Init expired page to: "+expP);
- expiredPage = expP;
- }
- }
-
- @Override
- public void init() throws ServletException {
- super.init();
- myInit();
- }
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- super.init(config);
- myInit();
- }
-
-
-
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- doGet(req, resp);
- }
-
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, java.io.IOException {
-
- HttpSession session = req.getSession(false);
- if (session == null) {
- resp.sendRedirect(expiredPage);
- return;
- }
- String sessionId = session.getId();
- if (sessionId == null) {
- resp.sendRedirect(expiredPage);
- return;
- }
- log.debug("Got a result request for session: " + sessionId);
- HTTPBindingProcessor bp = (HTTPBindingProcessor) getBindingProcessorManager().getBindingProcessor(
- IdFactory.getInstance().createId(sessionId));
- if (bp == null) {
- session.invalidate();
- resp.sendRedirect(expiredPage);
- return;
- }
-
- if (bp.getRedirectURL() != null) {
- resp.sendRedirect(bp.getRedirectURL());
- return;
- }
- resp.setStatus(bp.getResponseCode());
- resp.setHeader("Cache-Control","no-store"); //HTTP 1.1
- resp.setHeader("Pragma","no-cache"); //HTTP 1.0
- resp.setDateHeader ("Expires", 0);
- for (Iterator it = bp.getResponseHeaders().keySet()
- .iterator(); it.hasNext();) {
- String header = it.next();
- resp.setHeader(header, bp.getResponseHeaders().get(header));
- }
- resp.setContentType(bp.getResultContentType());
- resp.setCharacterEncoding(encoding);
- bp.writeResultTo(resp.getOutputStream(), encoding);
+ * 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.bku.online.webapp;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.binding.HTTPBindingProcessor;
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.binding.IdFactory;
+import at.gv.egiz.bku.online.conf.Configurator;
+
+/**
+ * Delivers the result to the browser
+ *
+ */
+public class ResultServlet extends SpringBKUServlet {
+
+ private final static Log log = LogFactory.getLog(ResultServlet.class);
+ public final static String USER_AGENT_PROPERTY_KEY = "UserAgent";
+
+ private String encoding = "UTF-8";
+ private String expiredPage = "./expiredError.jsp";
+
+ public ResultServlet() {
+ }
+
+ private void myInit() {
+ String enc = getServletContext().getInitParameter("responseEncoding");
+ if (enc != null) {
+ log.debug("Init default encoding to: " + enc);
+ encoding = enc;
+ }
+ String expP = getServletConfig().getInitParameter("expiredPage");
+ if (expP != null) {
+ log.debug("Init expired page to: " + expP);
+ expiredPage = expP;
+ }
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ myInit();
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ myInit();
+ }
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doGet(req, resp);
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ HttpSession session = req.getSession(false);
+ if (session == null) {
+ resp.sendRedirect(expiredPage);
+ return;
+ }
+ String sessionId = session.getId();
+ if (sessionId == null) {
+ resp.sendRedirect(expiredPage);
+ return;
+ }
+ log.debug("Got a result request for session: " + sessionId);
+ HTTPBindingProcessor bp = (HTTPBindingProcessor) getBindingProcessorManager()
+ .getBindingProcessor(IdFactory.getInstance().createId(sessionId));
+ if (bp == null) {
+ session.invalidate();
+ resp.sendRedirect(expiredPage);
+ return;
+ }
+
+ if (bp.getRedirectURL() != null) {
+ resp.sendRedirect(bp.getRedirectURL());
+ return;
+ }
+ resp.setStatus(bp.getResponseCode());
+ resp.setHeader("Cache-Control", "no-store"); // HTTP 1.1
+ resp.setHeader("Pragma", "no-cache"); // HTTP 1.0
+ resp.setDateHeader("Expires", 0);
+ if (Configurator.getInstance().getProperty(USER_AGENT_PROPERTY_KEY) != null) {
+ resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, Configurator.getInstance().getProperty(
+ USER_AGENT_PROPERTY_KEY));
+ } else {
+ resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT,
+ "citizen-card-environment/1.2 MOCCA Unknown");
+ }
+ for (Iterator it = bp.getResponseHeaders().keySet().iterator(); it
+ .hasNext();) {
+ String header = it.next();
+ resp.setHeader(header, bp.getResponseHeaders().get(header));
+ }
+ resp.setContentType(bp.getResultContentType());
+ resp.setCharacterEncoding(encoding);
+ bp.writeResultTo(resp.getOutputStream(), encoding);
session.invalidate();
- getBindingProcessorManager().removeBindingProcessor(bp.getId());
- }
-}
+ getBindingProcessorManager().removeBindingProcessor(bp.getId());
+ }
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
index 6ee537b1..ec062e42 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
@@ -19,13 +19,13 @@ package at.gv.egiz.bku.online.webapp;
import javax.servlet.http.HttpServlet;
import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.online.conf.Configurator;
public abstract class SpringBKUServlet extends HttpServlet {
- public final static String BEAN_NAME="bindingProcessorManager";
-
+ public final static String BEAN_NAME="bindingProcessorManager";
+
protected BindingProcessorManager getBindingProcessorManager() {
return (BindingProcessorManager) getServletContext().getAttribute(BEAN_NAME);
}
-
}
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
index 108f8624..cdc2bfad 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
@@ -39,3 +39,5 @@ SSL.sslProtocol=TLS
# ------------ END SSL Config --------------------
+ValidateHashDataInputs=true
+
diff --git a/BKUOnline/src/main/resources/log4j.properties b/BKUOnline/src/main/resources/log4j.properties
index ed14b424..58f09511 100644
--- a/BKUOnline/src/main/resources/log4j.properties
+++ b/BKUOnline/src/main/resources/log4j.properties
@@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# loglever DEBUG, appender STDOUT
-log4j.rootLogger=TRACE, STDOUT
-#log4j.logger.at.gv.egiz.slbinding.RedirectEventFilter=DEBUG, STDOUT
+
+log4j.rootLogger=TRACE, STDOUT, file
# STDOUT appender
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
@@ -24,11 +23,11 @@ log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.appender.STDOUT.layout.ConversionPattern=%-5p | %t | %c %x - %m%n
-### FILE appender
-#log4j.appender.file=org.apache.log4j.RollingFileAppender
-#log4j.appender.file.maxFileSize=100KB
-#log4j.appender.file.maxBackupIndex=9
-#log4j.appender.file.File=egovbus_ca.log
-#log4j.appender.file.threshold=info
-#log4j.appender.file.layout=org.apache.log4j.PatternLayout
-#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
\ No newline at end of file
+# FILE appender
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.maxFileSize=500KB
+log4j.appender.file.maxBackupIndex=9
+log4j.appender.file.File=${catalina.home}/logs/bkuonline.log
+log4j.appender.file.threshold=trace
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p | %t | %c{1}:%L - %m%n
\ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index f87d09f5..04b07ba4 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -45,8 +45,8 @@
-
+
diff --git a/BKUOnline/src/main/webapp/appletPage.jsp b/BKUOnline/src/main/webapp/appletPage.jsp
index 684a8dca..fdd7072f 100644
--- a/BKUOnline/src/main/webapp/appletPage.jsp
+++ b/BKUOnline/src/main/webapp/appletPage.jsp
@@ -25,15 +25,15 @@
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
index 8eaeacbd..a8477ece 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
@@ -16,13 +16,14 @@
*/
package at.gv.egiz.bku.binding;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
/**
* Used to handle DataUrl connections as specified in the CCE's HTTP protocol binding.
@@ -30,7 +31,8 @@ import at.gv.egiz.bku.slexceptions.SLRuntimeException;
*/
public class DataUrl {
private static DataUrlConnectionSPI defaultDataUrlConnection = new DataUrlConnectionImpl();
- private static Log log = LogFactory.getLog(DataUrl.class);
+ private static Log log = LogFactory.getLog(DataUrl.class);
+ private static Properties configuration;
private URL url;
@@ -58,5 +60,9 @@ public class DataUrl {
log.error(e);
throw new SLRuntimeException("Cannot instantiate a dataurlconnection:",e);
}
+ }
+
+ public static void setConfiguration(Properties props) {
+ configuration = props;
}
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
index 6d654639..c6ffa32a 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
@@ -34,14 +34,16 @@ import at.gv.egiz.bku.slcommands.SLResult;
*/
public interface DataUrlConnection {
- public static final String DEFAULT_USERAGENT = "citizen-card-environment/1.2 BKU2 1.0";
+ public static final String DEFAULT_USERAGENT = "citizen-card-environment/1.2 MOCCA Unknown";
public static final String FORMPARAM_RESPONSETYPE = "ResponseType";
public static final String DEFAULT_RESPONSETYPE = "HTTP-Security-Layer-RESPONSE";
public static final String FORMPARAM_XMLRESPONSE = "XMLResponse";
public static final String FORMPARAM_BINARYRESPONSE = "BinaryResponse";
public static final String XML_RESPONSE_ENCODING = "UTF-8";
-
+
+ public final static String USER_AGENT_PROPERTY_KEY="UserAgent";
+
public String getProtocol();
public URL getUrl();
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
index 9f5d70cb..bb0314b5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -1,221 +1,235 @@
/*
-* 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.bku.binding;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
-
-import at.gv.egiz.bku.binding.multipart.InputStreamPartSource;
-import at.gv.egiz.bku.binding.multipart.SLResultPart;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.bku.utils.binding.Protocol;
-
-/**
- * not thread-safe thus newInsance always returns a new object
- *
- */
-public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
-
- public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
- Protocol.HTTPS };
- protected X509Certificate serverCertificate;
- protected Protocol protocol;
- protected URL url;
- private HttpURLConnection connection;
- protected Map requestHttpHeaders;
- protected ArrayList formParams;
- protected String boundary;
-
- protected DataUrlResponse result;
-
- public String getProtocol() {
- if (protocol == null) {
- return null;
- }
- return protocol.toString();
- }
-
- /**
- * opens a connection sets the headers gets the server certificate
- *
- * @throws java.net.SocketTimeoutException
- * @throws java.io.IOException
- * @pre url != null
- * @pre httpHeaders != null
- */
- public void connect() throws SocketTimeoutException, IOException {
- connection = (HttpURLConnection) url.openConnection();
-
+ * 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.bku.binding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
+
+import at.gv.egiz.bku.binding.multipart.InputStreamPartSource;
+import at.gv.egiz.bku.binding.multipart.SLResultPart;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.binding.Protocol;
+
+/**
+ * not thread-safe thus newInsance always returns a new object
+ *
+ */
+public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
+
+ public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
+ Protocol.HTTPS };
+ protected X509Certificate serverCertificate;
+ protected Protocol protocol;
+ protected URL url;
+ private HttpURLConnection connection;
+ protected Map requestHttpHeaders;
+ protected ArrayList formParams;
+ protected String boundary;
+ protected Properties config = null;
+
+ protected DataUrlResponse result;
+
+ public String getProtocol() {
+ if (protocol == null) {
+ return null;
+ }
+ return protocol.toString();
+ }
+
+ /**
+ * opens a connection sets the headers gets the server certificate
+ *
+ * @throws java.net.SocketTimeoutException
+ * @throws java.io.IOException
+ * @pre url != null
+ * @pre httpHeaders != null
+ */
+ public void connect() throws SocketTimeoutException, IOException {
+ connection = (HttpURLConnection) url.openConnection();
+
// FIXXME move this to config.
- HttpURLConnection.setFollowRedirects(false);
-
-
- connection.setDoOutput(true);
- Set headers = requestHttpHeaders.keySet();
- Iterator headerIt = headers.iterator();
- while (headerIt.hasNext()) {
- String name = headerIt.next();
- connection.setRequestProperty(name, requestHttpHeaders.get(name));
- }
- connection.connect();
- if (connection instanceof HttpsURLConnection) {
- HttpsURLConnection ssl = (HttpsURLConnection) connection;
- X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
- if ((certs != null) && (certs.length >= 1)) {
- serverCertificate = certs[0];
- }
- }
- }
-
- public X509Certificate getServerCertificate() {
- return serverCertificate;
- }
-
- public void setHTTPHeader(String name, String value) {
- if (name != null && value != null) {
- requestHttpHeaders.put(name, value);
- }
- }
-
- public void setHTTPFormParameter(String name, InputStream data,
- String contentType, String charSet, String transferEncoding) {
- InputStreamPartSource source = new InputStreamPartSource(null, data);
- FilePart formParam = new FilePart(name, source, contentType, charSet);
- if (transferEncoding != null) {
- formParam.setTransferEncoding(transferEncoding);
- } else {
- formParam.setTransferEncoding(null);
- }
- formParams.add(formParam);
- }
-
- /**
- * send all formParameters
- *
- * @throws java.io.IOException
- */
- public void transmit(SLResult slResult) throws IOException {
- SLResultPart slResultPart = new SLResultPart(slResult,
- XML_RESPONSE_ENCODING);
- if (slResult.getResultType() == SLResultType.XML) {
- slResultPart.setTransferEncoding(null);
- slResultPart.setContentType(slResult.getMimeType());
- slResultPart.setCharSet(XML_RESPONSE_ENCODING);
- } else {
- slResultPart.setTransferEncoding(null);
- slResultPart.setContentType(slResult.getMimeType());
- }
- formParams.add(slResultPart);
-
- OutputStream os = connection.getOutputStream();
-
- Part[] parts = new Part[formParams.size()];
- Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
- os.close();
+ HttpURLConnection.setFollowRedirects(false);
+
+ connection.setDoOutput(true);
+ Set headers = requestHttpHeaders.keySet();
+ Iterator headerIt = headers.iterator();
+ while (headerIt.hasNext()) {
+ String name = headerIt.next();
+ connection.setRequestProperty(name, requestHttpHeaders.get(name));
+ }
+ connection.connect();
+ if (connection instanceof HttpsURLConnection) {
+ HttpsURLConnection ssl = (HttpsURLConnection) connection;
+ X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
+ if ((certs != null) && (certs.length >= 1)) {
+ serverCertificate = certs[0];
+ }
+ }
+ }
+
+ public X509Certificate getServerCertificate() {
+ return serverCertificate;
+ }
+
+ public void setHTTPHeader(String name, String value) {
+ if (name != null && value != null) {
+ requestHttpHeaders.put(name, value);
+ }
+ }
+
+ public void setHTTPFormParameter(String name, InputStream data,
+ String contentType, String charSet, String transferEncoding) {
+ InputStreamPartSource source = new InputStreamPartSource(null, data);
+ FilePart formParam = new FilePart(name, source, contentType, charSet);
+ if (transferEncoding != null) {
+ formParam.setTransferEncoding(transferEncoding);
+ } else {
+ formParam.setTransferEncoding(null);
+ }
+ formParams.add(formParam);
+ }
+
+ /**
+ * send all formParameters
+ *
+ * @throws java.io.IOException
+ */
+ public void transmit(SLResult slResult) throws IOException {
+ SLResultPart slResultPart = new SLResultPart(slResult,
+ XML_RESPONSE_ENCODING);
+ if (slResult.getResultType() == SLResultType.XML) {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ slResultPart.setCharSet(XML_RESPONSE_ENCODING);
+ } else {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ }
+ formParams.add(slResultPart);
+
+ OutputStream os = connection.getOutputStream();
+
+ Part[] parts = new Part[formParams.size()];
+ Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
+ os.close();
// MultipartRequestEntity PostMethod
- result = new DataUrlResponse(url.toString(), connection.getResponseCode(),
- connection.getInputStream());
-
- Map responseHttpHeaders = new HashMap();
- Map> httpHeaders = connection.getHeaderFields();
- for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
- .hasNext();) {
- String key = keyIt.next();
- StringBuffer value = new StringBuffer();
- for (String val : httpHeaders.get(key)) {
- value.append(val);
- value.append(HttpUtil.SEPERATOR[0]);
- }
- String valString = value.substring(0, value.length() - 1);
- if ((key != null)&&(value.length() > 0)) {
- responseHttpHeaders.put(key, valString);
- }
- }
- result.setResponseHttpHeaders(responseHttpHeaders);
- }
-
- @Override
- public DataUrlResponse getResponse() throws IOException {
- return result;
- }
-
- /**
- * inits protocol, url, httpHeaders, formParams
- *
- * @param url
- * must not be null
- */
- @Override
- public void init(URL url) {
-
- for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
- if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) {
- protocol = SUPPORTED_PROTOCOLS[i];
- break;
- }
- }
- if (protocol == null) {
- throw new SLRuntimeException("Protocol " + url.getProtocol()
- + " not supported for data url");
- }
- this.url = url;
- boundary = "--" + IdFactory.getInstance().createId().toString();
- requestHttpHeaders = new HashMap();
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, DEFAULT_USERAGENT);
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
- HttpUtil.MULTIPART_FOTMDATA + HttpUtil.SEPERATOR[0]
- + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY + "=" + boundary);
-
- formParams = new ArrayList();
- StringPart responseType = new StringPart(FORMPARAM_RESPONSETYPE,
- DEFAULT_RESPONSETYPE);
- responseType.setCharSet("UTF-8");
- responseType.setTransferEncoding(null);
- formParams.add(responseType);
- }
-
- @Override
- public DataUrlConnectionSPI newInstance() {
- return new DataUrlConnectionImpl();
+ result = new DataUrlResponse(url.toString(), connection.getResponseCode(),
+ connection.getInputStream());
+
+ Map responseHttpHeaders = new HashMap();
+ Map> httpHeaders = connection.getHeaderFields();
+ for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
+ .hasNext();) {
+ String key = keyIt.next();
+ StringBuffer value = new StringBuffer();
+ for (String val : httpHeaders.get(key)) {
+ value.append(val);
+ value.append(HttpUtil.SEPERATOR[0]);
+ }
+ String valString = value.substring(0, value.length() - 1);
+ if ((key != null) && (value.length() > 0)) {
+ responseHttpHeaders.put(key, valString);
+ }
+ }
+ result.setResponseHttpHeaders(responseHttpHeaders);
}
- @Override
- public URL getUrl() {
- return url;
- }
+ @Override
+ public DataUrlResponse getResponse() throws IOException {
+ return result;
+ }
+
+ /**
+ * inits protocol, url, httpHeaders, formParams
+ *
+ * @param url
+ * must not be null
+ */
+ @Override
+ public void init(URL url) {
+
+ for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
+ if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) {
+ protocol = SUPPORTED_PROTOCOLS[i];
+ break;
+ }
+ }
+ if (protocol == null) {
+ throw new SLRuntimeException("Protocol " + url.getProtocol()
+ + " not supported for data url");
+ }
+ this.url = url;
+ boundary = "--" + IdFactory.getInstance().createId().toString();
+ requestHttpHeaders = new HashMap();
+ if ((config != null)
+ && (config.getProperty(USER_AGENT_PROPERTY_KEY) != null)) {
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, config
+ .getProperty(USER_AGENT_PROPERTY_KEY));
+ } else {
+ requestHttpHeaders
+ .put(HttpUtil.HTTP_HEADER_USER_AGENT, DEFAULT_USERAGENT);
+
+ }
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
+ HttpUtil.MULTIPART_FOTMDATA + HttpUtil.SEPERATOR[0]
+ + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY + "=" + boundary);
+
+ formParams = new ArrayList();
+ StringPart responseType = new StringPart(FORMPARAM_RESPONSETYPE,
+ DEFAULT_RESPONSETYPE);
+ responseType.setCharSet("UTF-8");
+ responseType.setTransferEncoding(null);
+ formParams.add(responseType);
+ }
+
+ @Override
+ public DataUrlConnectionSPI newInstance() {
+ DataUrlConnectionSPI uc = new DataUrlConnectionImpl();
+ uc.setConfiguration(config);
+ return uc;
+ }
+
+ @Override
+ public URL getUrl() {
+ return url;
+ }
+
+ @Override
+ public void setConfiguration(Properties config) {
+ this.config = config;
+ }
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
index 9e5a66f8..80cc3a0b 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
@@ -17,6 +17,7 @@
package at.gv.egiz.bku.binding;
import java.net.URL;
+import java.util.Properties;
/**
* Prototype of a DataurlconnectionSPI
@@ -36,7 +37,13 @@ public interface DataUrlConnectionSPI extends DataUrlConnection {
* Initializes the DataUrlConnection
* @param url
*/
- public void init(URL url);
+ public void init(URL url);
+
+ /**
+ * Sets configuration parameters for this connection
+ * @param config
+ */
+ public void setConfiguration(Properties config);
}
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 555f83bd..fb624211 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,12 +16,14 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.gv.egiz.bku.slcommands.ErrorResult;
-import at.gv.egiz.bku.slexceptions.SLException;
-
-import javax.xml.transform.Result;
+import java.util.Locale;
+
+import javax.xml.transform.Result;
+
+import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.gv.egiz.bku.slcommands.ErrorResult;
+import at.gv.egiz.bku.slexceptions.SLException;
/**
* This class implements the security layer result ErrorResponse.
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
index 8e0a09bc..cf52a4c3 100644
--- a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
@@ -13,85 +13,86 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-test.noerror=This is a test error-message. No error occurred.
-
-ec1000=Unclassified error.
-ec2000=Unclassified error in the transport binding.
-ec2001=HTTP/HTTPS binding: DataURL cannot be resolved.
-ec2002=HTTP/HTTPS binding: StylesheetURL cannot be resolved.
-ec2003=HTTP/HTTPS binding: RedirectURL cannot be resolved.
-ec2004=HTTP/HTTPS binding: XMLRequest parameter missing.
-ec2005=HTTP/HTTPS binding: Unknown parameter encoding.
-ec2006=HTTP/HTTPS binding: Incorrect parameter encoding.
-ec2007=HTTP/HTTPS binding: DataURL server transmits error or unexpected response.
-ec2008=HTTP/HTTPS binding: Error in stylesheet obtained from the StylesheetURL.
-ec2009=HTTP/HTTPS binding: HTTP request to local CCE directed to unauthorised URL.
-ec2010=HTTPS binding: Error while establishing the TLS connection.
-ec3000=Unclassified error in the XML structure of the command request.
-ec3001=XML structure of the command request is not well formed.
-ec3002=XML structure of the command request does not comply with the Security Layer schema.
-ec3003=XML structure of the command request contains an invalid combination of optional elements or attributes.
-ec3004=XML structure contains an element or attribute whose syntax does not match the Security Layer specification.
-ec3005=Protocol version of Security Layer not supported.
-ec4000=Unclassified error while processing command.
-ec4001=Unknown key box identifier.
-ec4002=Unknown info box identifier.
-ec4003=Date to be signed cannot be resolved.
-ec4004=Supplementary object cannot be resolved.
-ec4005=Date to be encrypted cannot be resolved.
-ec4006=Algorithm (signature, encryption, digest, canonicalisation, transformation) not supported.
-ec4007=Error while executing algorithm (signature, encryption, digest, canonicalisation, transformation).
-ec4008=Error while parsing CMS message
-ec4009=No matching decryption key.
-ec4010=Info box command parameters do not match info box type.
-ec4011=Command not implemented.
-ec4100=XML document in which the signature is to be integrated cannot be resolved.
-ec4101=XML document in which the signature is to be integrated cannot be parsed.
-ec4102=Signature cannot be integrated in the existing XML document at the specified location.
-ec4103=Signature certificate not contained in the CMS signature.
-ec4104=Signed data not contained in the CMS signature or XML request.
-ec4105=XML document containing the signature to be verified cannot be resolved.
-ec4106=XML document containing the signature to be verified cannot be parsed.
-ec4107=There is no XML signature at the specified location within the XML document.
-ec4108=Encrypted date cannot be inserted in the existing XML document at the specified location.
-ec4109=Existing XML document is required but missing.
-ec4110=Existing XML document cannot be resolved.
-ec4111=Existing XML document cannot be parsed.
-ec4112=Encrypted data encryption keys cannot be inserted in the existing XML document at the specified location.
-ec4113=Data to be decrypted not contained in either the CMS message or XML request.
-ec4114=XML document to be decrypted cannot be resolved.
-ec4115=XML document to be decrypted cannot be parsed.
-ec4116=At least one specified encryption element cannot be found in the XML document to be decrypted.
-ec4117=No encryption element for binary response.
-ec4118=Date to be hashed cannot be resolved.
-ec4119=Date for which the hash value is to be verified cannot be resolved.
-ec4120=Selected info box identifier already allocated.
-ec4121=Info box with specified identifier does not exist.
-ec4122=Contents of the selected info box cannot be displayed as XML.
-ec4123=Associative array: No entry for the specified key.
-ec5000=Unclassified error in the viewer component.
-ec5001=Display of data of the mime type specified in the command request not supported.
-ec5002=Character encoding of the data to be displayed is invalid or not supported.
-ec5003=Data to be displayed contains unsupported characters.
-ec5004=Standard display format: HTML does not conform to specification.
-ec5005=Standard display format: CSS does not conform to specification.
-ec5006=Standard display format: Format of an embedded image does not conform to specification.
-ec5007=Standard display format: Signature for embedded images missing or does not conform to specification.
-ec6000=Unclassified cancelling by the citizen.
-ec6001=Cancelled by the citizen via the user interface.
-ec6002=Cancelled because of insufficient rights to execute command.
-
-# 3xxx
-#
-
-ec3000.unclassified=Error in the XML structure of the command request. {0}
-ec3002.invalid=XML structure of the command request does not comply with the Security Layer schema. {0}
-
-# 4xxx
-#
-
-ec4000.infobox.invalid=The infobox '{0}' contains invalid content.
-ec4000.idlink.transfomation.failed=Failed to transform CompressedIdentityLink with Stylesheet {0}.
-ec4002.infobox.unknown=Unknown info box identifier {0}.
-ec4003.not.resolved=Data to be signed cannot be resolved from URI={0}.
-ec4011.notimplemented=Command {0} not implemented.
+test.noerror=Das ist eine Test-Fehlermeldung. Es ist kein Fehler aufgetreten.
+
+ec1000=Unklassifizierter Fehler.
+ec2000=Unklassifizierter Fehler in der Transportbindung.
+ec2001=HTTP/HTTPS-Bindung: DataURL kann nicht aufgelöst werden.
+ec2002=HTTP/HTTPS-Bindung: StylesheetURL kann nicht aufgelöst werden.
+ec2003=HTTP/HTTPS-Bindung: RedirectURL kann nicht aufgelöst werden.
+ec2004=HTTP/HTTPS-Bindung: Parameter XMLRequest fehlt.
+ec2005=HTTP/HTTPS-Bindung: Unbekannte Kodierung der Parameter.
+ec2006=HTTP/HTTPS-Bindung: Fehlerhafte Kodierung der Parameter.
+ec2007=HTTP/HTTPS-Bindung: DataURL-Server sendet Fehler oder unerwartete Antwort.
+ec2008=HTTP/HTTPS-Bindung: Fehler im Stylesheet, der von der StylesheetURL bezogen wurde.
+ec2009=HTTP/HTTPS-Bindung: HTTP-Anfrage an lokale BKU wurde an unerlaubte URL gerichtet.
+ec2010=HTTPS-Bindung: Fehler beim Aufbau der TLS-Verbindung.
+ec3000=Unklassifizierter Fehler in der XML-Struktur der Befehlsanfrage.
+ec3001=XML-Struktur der Befehlsanfrage ist nicht wohlgeformt.
+ec3002=XML-Struktur der Befehlsanfrage entspricht nicht dem Schema des Security-Layers.
+ec3003=XML-Struktur der Befehlsanfrage enthält eine unerlaubte Kombination aus optionalen Elementen oder Attributen.
+ec3004=XML-Struktur enthält ein Element oder Attribut, dessen Syntax nicht der Spezifikation des Security-Layer entspricht.
+ec3005=Protokollversion des Security-Layer wird nicht unterstützt.
+ec4000=Unklassifizierter Fehler in der Befehlsabarbeitung.
+ec4001=Unbekannter Keyboxbezeichner.
+ec4002=Unbekannter Infoboxbezeichner.
+ec4003=Zu signierendes Datum kann nicht aufgelöst werden.
+ec4004=Ergänzungsobjekt kann nicht aufgelöst werden.
+ec4005=Zu verschlüsselndes Datum kann nicht aufgelöst werden.
+ec4006=Algorithmus (Signatur, Verschlüsselung, Digest, Kanonisierung, Transformation) wird nicht unterstützt.
+ec4007=Fehler bei der Algorithmusausführung (Signatur, Verschlüsselung, Digest, Kanonisierung, Transformation).
+ec4008=Fehler beim Parsen der CMS-Nachricht.
+ec4009=Kein passender Entschlüsselungsschlüssel vorhanden.
+ec4010=Parameter des Infobox-Befehls passen nicht zum Typ der Infobox.
+ec4011=Befehl ist nicht implementiert.
+ec4100=XML-Dokument, in das die Signatur integriert werden soll, kann nicht aufgelöst werden.
+ec4101=XML-Dokument, in das die Signatur integriert werden soll, kann nicht geparst werden.
+ec4102=Signatur kann nicht am spezifizierten Ort in das bestehende XML-Dokument integriert werden.
+ec4103=Signatorzertifikat ist nicht in der CMS-Signatur enthalten.
+ec4104=Signierte Daten sind weder in der CMS-Signatur noch im XML-Request enthalten.
+ec4105=XML-Dokument, das die zu prüfende Signatur enthält, kann nicht aufgelöst werden.
+ec4106=XML-Dokument, das die zu prüfende Signatur enthält, kann nicht geparst werden.
+ec4107=Am spezifizierten Ort innerhalb des XML-Dokuments befindet sich keine XML-Signatur.
+ec4108=Verschlüsseltes Datum kann nicht am spezifizierten Ort in das bestehende XML-Dokument eingefügt werden.
+ec4109=Bestehendes XML-Dokument ist notwendig, aber nicht vorhanden.
+ec4110=Bestehendes XML-Dokument kann nicht aufgelöst werden.
+ec4111=Bestehendes XML-Dokument kann nicht geparst werden.
+ec4112=Verschlüsselte Datenverschlüsselungsschlüssel können nicht am spezifizierten Ort in das bestehende XML-Dokument eingefügt werden.
+ec4113=Zu entschlüsselnde Daten sind weder in der CMS-Nachricht noch im XML-Request enthalten.
+ec4114=Zu entschlüsselndes XML-Dokument kann nicht aufgelöst werden.
+ec4115=Zu entschlüsselndes XML-Dokument kann nicht geparst werden.
+ec4116=Zumindest ein spezifiziertes Verschlüsselungselement kann nicht im zu entschlüsselnden XML-Dokument gefunden werden.
+ec4117=Kein Verschlüsselungselement für Binärantwort vorhanden.
+ec4118=Zu hashendes Datum kann nicht aufgelöst werden.
+ec4119=Datum, für das der Hashwert zu prüfen ist, kann nicht aufgelöst werden.
+ec4120=Gewählter Infoboxbezeichner bereits vergeben.
+ec4121=Infobox mit spezifiziertem Bezeichner existiert nicht.
+ec4122=Inhalt der ausgewählten Infobox kann nicht als XML dargestellt werden.
+ec4123=Assoziatives Array: Zum spezifizierten Schlüssel existiert kein Eintrag.
+ec5000=Unklassifizierter Fehler in der Anzeigekomponente.
+ec5001=Anzeige von Daten des in der Befehlsanfrage angegebenen Mime-Types wird nicht unterstützt.
+ec5002=Zeichenkodierung der anzuzeigenden Daten ist fehlerhaft oder wird nicht unterstützt.
+ec5003=Anzuzeigende Daten enhalten nicht unterstützte Zeichen.
+ec5004=Standardanzeigeformat: HTML ist nicht spezifikationskonform.
+ec5005=Standardanzeigeformat: CSS ist nicht spezifikationskonform.
+ec5006=Standardanzeigeformat: Format eines eingebundenen Bildes ist nicht spezifikationskonform.
+ec5007=Standardanzeigeformat: Signatur über eingebundene Bilder fehlt oder ist nicht spezifikationskonform.
+ec6000=Unklassifizierter Abbruch durch den Bürger.
+ec6001=Abbruch durch den Bürger über die Benutzerschnittstelle.
+ec6002=Abbruch auf Grund mangelnder Rechte zur Befehlsausführung.
+
+# 3xxx
+#
+
+ec3000.unclassified=Unklassifizierter Fehler in der XML-Struktur der Befehlsanfrage. {0}
+ec3002.invalid=XML-Struktur der Befehlsanfrage entspricht nicht dem Schema des Security-Layers. {0}
+
+# 4xxx
+#
+
+ec4000.infobox.invalid=Die Infobox '{0}' enthält ungültige Daten.
+ec4000.idlink.transfomation.failed=Die komprimierte Personenbindung konnte mit dem Stylesheet {0} nicht transformiert werden.
+ec4002.infobox.unknown=Unbekannter Infoboxbezeichner {0}.
+ec4003.not.resolved=Zu signierendes Datum kann nicht aufgelöst werden (URI={0}).
+ec4011.notimplemented=Befehl {0} ist nicht implementiert.
+
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
new file mode 100644
index 00000000..8e0a09bc
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
@@ -0,0 +1,97 @@
+# 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.
+
+test.noerror=This is a test error-message. No error occurred.
+
+ec1000=Unclassified error.
+ec2000=Unclassified error in the transport binding.
+ec2001=HTTP/HTTPS binding: DataURL cannot be resolved.
+ec2002=HTTP/HTTPS binding: StylesheetURL cannot be resolved.
+ec2003=HTTP/HTTPS binding: RedirectURL cannot be resolved.
+ec2004=HTTP/HTTPS binding: XMLRequest parameter missing.
+ec2005=HTTP/HTTPS binding: Unknown parameter encoding.
+ec2006=HTTP/HTTPS binding: Incorrect parameter encoding.
+ec2007=HTTP/HTTPS binding: DataURL server transmits error or unexpected response.
+ec2008=HTTP/HTTPS binding: Error in stylesheet obtained from the StylesheetURL.
+ec2009=HTTP/HTTPS binding: HTTP request to local CCE directed to unauthorised URL.
+ec2010=HTTPS binding: Error while establishing the TLS connection.
+ec3000=Unclassified error in the XML structure of the command request.
+ec3001=XML structure of the command request is not well formed.
+ec3002=XML structure of the command request does not comply with the Security Layer schema.
+ec3003=XML structure of the command request contains an invalid combination of optional elements or attributes.
+ec3004=XML structure contains an element or attribute whose syntax does not match the Security Layer specification.
+ec3005=Protocol version of Security Layer not supported.
+ec4000=Unclassified error while processing command.
+ec4001=Unknown key box identifier.
+ec4002=Unknown info box identifier.
+ec4003=Date to be signed cannot be resolved.
+ec4004=Supplementary object cannot be resolved.
+ec4005=Date to be encrypted cannot be resolved.
+ec4006=Algorithm (signature, encryption, digest, canonicalisation, transformation) not supported.
+ec4007=Error while executing algorithm (signature, encryption, digest, canonicalisation, transformation).
+ec4008=Error while parsing CMS message
+ec4009=No matching decryption key.
+ec4010=Info box command parameters do not match info box type.
+ec4011=Command not implemented.
+ec4100=XML document in which the signature is to be integrated cannot be resolved.
+ec4101=XML document in which the signature is to be integrated cannot be parsed.
+ec4102=Signature cannot be integrated in the existing XML document at the specified location.
+ec4103=Signature certificate not contained in the CMS signature.
+ec4104=Signed data not contained in the CMS signature or XML request.
+ec4105=XML document containing the signature to be verified cannot be resolved.
+ec4106=XML document containing the signature to be verified cannot be parsed.
+ec4107=There is no XML signature at the specified location within the XML document.
+ec4108=Encrypted date cannot be inserted in the existing XML document at the specified location.
+ec4109=Existing XML document is required but missing.
+ec4110=Existing XML document cannot be resolved.
+ec4111=Existing XML document cannot be parsed.
+ec4112=Encrypted data encryption keys cannot be inserted in the existing XML document at the specified location.
+ec4113=Data to be decrypted not contained in either the CMS message or XML request.
+ec4114=XML document to be decrypted cannot be resolved.
+ec4115=XML document to be decrypted cannot be parsed.
+ec4116=At least one specified encryption element cannot be found in the XML document to be decrypted.
+ec4117=No encryption element for binary response.
+ec4118=Date to be hashed cannot be resolved.
+ec4119=Date for which the hash value is to be verified cannot be resolved.
+ec4120=Selected info box identifier already allocated.
+ec4121=Info box with specified identifier does not exist.
+ec4122=Contents of the selected info box cannot be displayed as XML.
+ec4123=Associative array: No entry for the specified key.
+ec5000=Unclassified error in the viewer component.
+ec5001=Display of data of the mime type specified in the command request not supported.
+ec5002=Character encoding of the data to be displayed is invalid or not supported.
+ec5003=Data to be displayed contains unsupported characters.
+ec5004=Standard display format: HTML does not conform to specification.
+ec5005=Standard display format: CSS does not conform to specification.
+ec5006=Standard display format: Format of an embedded image does not conform to specification.
+ec5007=Standard display format: Signature for embedded images missing or does not conform to specification.
+ec6000=Unclassified cancelling by the citizen.
+ec6001=Cancelled by the citizen via the user interface.
+ec6002=Cancelled because of insufficient rights to execute command.
+
+# 3xxx
+#
+
+ec3000.unclassified=Error in the XML structure of the command request. {0}
+ec3002.invalid=XML structure of the command request does not comply with the Security Layer schema. {0}
+
+# 4xxx
+#
+
+ec4000.infobox.invalid=The infobox '{0}' contains invalid content.
+ec4000.idlink.transfomation.failed=Failed to transform CompressedIdentityLink with Stylesheet {0}.
+ec4002.infobox.unknown=Unknown info box identifier {0}.
+ec4003.not.resolved=Data to be signed cannot be resolved from URI={0}.
+ec4011.notimplemented=Command {0} not implemented.
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
index 45e38674..8a607b80 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
@@ -25,6 +25,7 @@ import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -124,5 +125,11 @@ public class TestDataUrlConnection implements DataUrlConnectionSPI {
@Override
public URL getUrl() {
return url;
- }
+ }
+
+ @Override
+ public void setConfiguration(Properties config) {
+ // TODO Auto-generated method stub
+
+ }
}
--
cgit v1.2.3
From 0df8bb10302989f41ed420ec0ff29b2fc2005471 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Mon, 15 Sep 2008 14:18:53 +0000
Subject: Migrated BKULocal to BKUCommonGUI and minor bug fixes
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@37 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/online/applet/BKUWorker.java | 11 +
BKULocal/pom.xml | 5 +
.../at/gv/egiz/bku/local/stal/BKUGuiProxy.java | 130 ++++++++++
.../bku/local/stal/LocalSignRequestHandler.java | 84 +++++++
.../java/at/gv/egiz/bku/local/stal/PINDialog.java | 214 -----------------
.../gv/egiz/bku/local/stal/QuitRequestHandler.java | 41 ----
.../java/at/gv/egiz/bku/local/stal/SMCCSTAL.java | 100 ++------
.../at/gv/egiz/bku/local/stal/SMCCSTALFactory.java | 100 ++++++--
.../egiz/bku/local/stal/SwingInsertCardDialog.java | 147 ------------
.../gv/egiz/bku/local/stal/SwingPINProvider.java | 57 -----
.../at/gv/egiz/bku/local/stal/SwingPinDialog.java | 265 ---------------------
.../gv/egiz/bku/online/webapp/ResultServlet.java | 1 +
.../service/impl/RequestBrokerSTALFactory.java | 5 +
.../java/at/gv/egiz/bku/slxhtml/ValidatorTest.java | 5 +-
.../src/main/java/at/gv/egiz/stal/STALFactory.java | 6 +-
.../bku/binding/BindingProcessorManagerImpl.java | 1 +
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 20 +-
.../egiz/bku/slcommands/impl/xsect/Signature.java | 25 ++
.../at/gv/egiz/bku/binding/DummyStalFactory.java | 8 +
19 files changed, 382 insertions(+), 843 deletions(-)
create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
(limited to 'bkucommon/src/main')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index 51ac243c..cd96a481 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -75,6 +75,17 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
addRequestHandler(QuitRequest.class, this);
//register SignRequestHandler once we have a webservice port
}
+
+ /**
+ * Used for non applet variants
+ * @param gui
+ * @param errorMessageBundle
+ */
+ protected BKUWorker(BKUGUIFacade gui, ResourceBundle errorMessageBundle) {
+ this.gui = gui;
+ this.errorMessages = errorMessageBundle;
+ addRequestHandler(QuitRequest.class, this);
+ }
private STALPortType getSTALPort() throws MalformedURLException {
URL wsdlURL = null;
diff --git a/BKULocal/pom.xml b/BKULocal/pom.xml
index 3f77752a..341e574a 100644
--- a/BKULocal/pom.xml
+++ b/BKULocal/pom.xml
@@ -74,6 +74,11 @@
org.springframeworkspring-tx2.5.5
+
+
+ at.gv.egiz
+ BKUApplet
+ 1.0-SNAPSHOT
\ No newline at end of file
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
new file mode 100644
index 00000000..0bed928d
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
@@ -0,0 +1,130 @@
+package at.gv.egiz.bku.local.stal;
+
+import java.awt.Container;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.JDialog;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.smcc.PINSpec;
+import at.gv.egiz.stal.HashDataInput;
+
+public class BKUGuiProxy implements BKUGUIFacade {
+
+ private BKUGUIFacade delegate;
+ private JDialog dialog;
+
+ public BKUGuiProxy(JDialog dialog, BKUGUIFacade delegate) {
+ this.delegate = delegate;
+ this.dialog = dialog;
+ }
+
+ private void showDialog() {
+ dialog.setVisible(true);
+ dialog.setAlwaysOnTop(true);
+ }
+
+ @Override
+ public char[] getPin() {
+ return delegate.getPin();
+ }
+
+ @Override
+ public void init(Container contentPane, String localeString) {
+ delegate.init(contentPane, localeString);
+ }
+
+ @Override
+ public void showCardNotSupportedDialog(ActionListener cancelListener,
+ String actionCommand) {
+ showDialog();
+ delegate.showCardNotSupportedDialog(cancelListener, actionCommand);
+ }
+
+ @Override
+ public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener,
+ String okCommand, ActionListener cancelListener, String cancelCommand) {
+ showDialog();
+ delegate.showCardPINDialog(pinSpec, okListener, okCommand, cancelListener,
+ cancelCommand);
+ }
+
+ @Override
+ public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries,
+ ActionListener okListener, String okCommand,
+ ActionListener cancelListener, String cancelCommand) {
+ showDialog();
+ delegate.showCardPINRetryDialog(pinSpec, numRetries, okListener, okCommand,
+ cancelListener, cancelCommand);
+ }
+
+ @Override
+ public void showErrorDialog(String errorMsg, ActionListener okListener,
+ String actionCommand) {
+ showDialog();
+ delegate.showErrorDialog(errorMsg, okListener, actionCommand);
+ }
+
+ @Override
+ public void showErrorDialog(String errorMsg) {
+ showDialog();
+ delegate.showErrorDialog(errorMsg);
+ }
+
+ @Override
+ public void showHashDataInputDialog(List signedReferences,
+ ActionListener okListener, String actionCommand) {
+ showDialog();
+ delegate.showHashDataInputDialog(signedReferences, okListener,
+ actionCommand);
+ }
+
+ @Override
+ public void showInsertCardDialog(ActionListener cancelListener,
+ String actionCommand) {
+ showDialog();
+ delegate.showInsertCardDialog(cancelListener, actionCommand);
+ }
+
+ @Override
+ public void showLoginDialog(ActionListener loginListener, String actionCommand) {
+ showDialog();
+
+ delegate.showLoginDialog(loginListener, actionCommand);
+ }
+
+ @Override
+ public void showSignaturePINDialog(PINSpec pinSpec,
+ ActionListener signListener, String signCommand,
+ ActionListener cancelListener, String cancelCommand,
+ ActionListener hashdataListener, String hashdataCommand) {
+ showDialog();
+ delegate.showSignaturePINDialog(pinSpec, signListener, signCommand,
+ cancelListener, cancelCommand, hashdataListener, hashdataCommand);
+ }
+
+ @Override
+ public void showSignaturePINRetryDialog(PINSpec pinSpec, int numRetries,
+ ActionListener okListener, String okCommand,
+ ActionListener cancelListener, String cancelCommand,
+ ActionListener hashdataListener, String hashdataCommand) {
+ showDialog();
+ delegate.showSignaturePINRetryDialog(pinSpec, numRetries, okListener,
+ okCommand, cancelListener, cancelCommand, hashdataListener,
+ hashdataCommand);
+ }
+
+ @Override
+ public void showWaitDialog(String waitMessage) {
+ showDialog();
+ delegate.showWaitDialog(waitMessage);
+ }
+
+ @Override
+ public void showWelcomeDialog() {
+ showDialog();
+ delegate.showWelcomeDialog();
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
new file mode 100644
index 00000000..f8546e49
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
@@ -0,0 +1,84 @@
+/*
+ * 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.bku.local.stal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
+import at.gv.egiz.bku.smccstal.SignRequestHandler;
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.signedinfo.ReferenceType;
+
+/**
+ *
+ * @author clemens
+ */
+public class LocalSignRequestHandler extends SignRequestHandler {
+
+ private static final Log log = LogFactory
+ .getLog(LocalSignRequestHandler.class);
+ private List hashDataInput = Collections.EMPTY_LIST;
+
+ public LocalSignRequestHandler() {
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public STALResponse handleRequest(STALRequest request) {
+ if (request instanceof SignRequest) {
+ SignRequest signReq = (SignRequest) request;
+ hashDataInput = signReq.getHashDataInput();
+ }
+ return super.handleRequest(request);
+ }
+
+ @Override
+ protected List getHashDataInputs(
+ List dsigReferences) throws Exception {
+ ArrayList result = new ArrayList();
+ for (ReferenceType dsigRef : dsigReferences) {
+ // don't get Manifest, QualifyingProperties, ...
+ if (dsigRef.getType() == null) {
+ String dsigRefId = dsigRef.getId();
+ if (dsigRefId != null) {
+ for (HashDataInput hdi : hashDataInput) {
+ if (hdi.getReferenceId().equals(dsigRefId)) {
+ result.add(hdi);
+ }
+ }
+ } else {
+ throw new Exception(
+ "Cannot get HashDataInput for dsig:Reference without Id attribute");
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return new LocalSignRequestHandler();
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
deleted file mode 100644
index 5bc6bab5..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
+++ /dev/null
@@ -1,214 +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.bku.local.stal;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.swing.JButton;
-import javax.swing.JPasswordField;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.PlainDocument;
-
-import at.gv.egiz.smcc.PINSpec;
-
-public class PINDialog extends javax.swing.JDialog implements ActionListener {
-
- // Variables declaration - do not modify
- private javax.swing.JButton okButton;
- private javax.swing.JButton cancelButton;
- private javax.swing.JLabel label;
- private javax.swing.JPasswordField password;
- // End of variables declaration
-
- private PINSpec pinSpec;
- private String pinString;
- private boolean finished = false;
-
- class PinDocument extends PlainDocument {
- private Pattern pattern;
-
- public PinDocument() {
- pattern = Pattern.compile(pinSpec.getRexepPattern());
- }
-
- public void insertString(int offs, String str, AttributeSet a)
- throws BadLocationException {
- if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
- Matcher matcher = pattern.matcher(str);
- if (matcher.matches()) {
- super.insertString(offs, str, a);
- }
- }
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
-
- @Override
- public void remove(int offs, int len) throws BadLocationException {
- super.remove(offs, len);
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
- }
-
- public PINDialog() {
- }
-
- private synchronized void finished(boolean ok) {
- if (ok) {
- pinString = password.getText();
- } else {
- pinString = null;
- }
- finished = true;
- notifyAll();
- }
-
- public synchronized void waitFinished() {
- while (!finished) {
- try {
- wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- public String getPIN() {
- return pinString;
- }
-
- /** Creates new form NewJDialog */
- public PINDialog(java.awt.Frame parent, boolean modal, PINSpec pinSpec,
- int retries) {
- super(parent, modal);
- this.pinSpec = pinSpec;
- initComponents();
- }
-
- private void initComponents() {
- okButton = new javax.swing.JButton();
- cancelButton = new javax.swing.JButton();
- password = new javax.swing.JPasswordField();
- label = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-
- setTitle("PIN Dialog"); // NOI18N
- setName("Form"); // NOI18N
-
- okButton.setText("OK"); // NOI18N
- okButton.setName("okButton"); // NOI18N
- okButton.setEnabled(false);
- okButton.addActionListener(this);
-
- cancelButton.setText("Cancel"); // NOI18N
- cancelButton.setName("cancelButton"); // NOI18N
- cancelButton.addActionListener(this);
-
- password.setText(""); // NOI18N
- password.setName("password"); // NOI18N
- password.addActionListener(this);
- password.setDocument(new PinDocument());
-
- label.setText("PIN: "); // NOI18N
- label.setName("jLabel1"); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addComponent(label,
- javax.swing.GroupLayout.PREFERRED_SIZE, 61,
- javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED,
- javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(password,
- javax.swing.GroupLayout.PREFERRED_SIZE, 127,
- javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- layout.createSequentialGroup().addComponent(cancelButton)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(okButton))).addContainerGap()));
- layout.setVerticalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE).addComponent(label,
- javax.swing.GroupLayout.PREFERRED_SIZE, 33,
- javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(password,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14,
- Short.MAX_VALUE).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE).addComponent(
- okButton).addComponent(cancelButton)).addContainerGap()));
-
- pack();
- }
-
- /**
- * @param args
- * the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- PINDialog dialog = new PINDialog(new javax.swing.JFrame(), true,
- new PINSpec(1, 5, "[0-9]*", "Hansi"), 10);
- dialog.setResizable(false);
- dialog.addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent e) {
- System.exit(0);
- }
- });
- dialog.setVisible(true);
- }
- });
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() instanceof JButton) {
- JButton pressed = (JButton) e.getSource();
- if (pressed.getName().equals("okButton")) {
- finished(true);
- } else if (pressed.getName().equals("cancelButton")) {
- finished(false);
- }
- } else if (e.getSource() instanceof JPasswordField) {
- JPasswordField pwf = (JPasswordField) e.getSource();
- if (pwf.getName().equals("password")) {
- if (password.getPassword().length >= pinSpec.getMinLength()) {
- finished(true);
- }
- }
- }
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
deleted file mode 100644
index 5596b7bb..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
+++ /dev/null
@@ -1,41 +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.bku.local.stal;
-
-import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
-import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
-
-public class QuitRequestHandler extends AbstractRequestHandler {
-
- @Override
- public STALResponse handleRequest(STALRequest request) {
- return null;
- }
-
- @Override
- public boolean requireCard() {
- return false;
- }
-
- @Override
- public SMCCSTALRequestHandler newInstance() {
- return this;
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
index 26ec2aa8..6f9e72c5 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
@@ -1,95 +1,33 @@
-/*
-* 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.bku.local.stal;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Locale;
+import java.util.List;
+import java.util.ResourceBundle;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import javax.swing.JDialog;
import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.bku.local.ui.TrayIconDialog;
-import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
-import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
-import at.gv.egiz.bku.smccstal.STALMessageConsumer;
-import at.gv.egiz.smcc.PINProvider;
-import at.gv.egiz.smcc.util.SMCCHelper;
-import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.bku.online.applet.BKUWorker;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignRequest;
-public class SMCCSTAL extends AbstractSMCCSTAL implements STALMessageConsumer {
- private static Log log = LogFactory.getLog(SMCCSTAL.class);
+public class SMCCSTAL extends BKUWorker {
- protected PINProvider pinProvider = new SwingPINProvider();
- protected SwingInsertCardDialog insertCard = new SwingInsertCardDialog();
- private boolean canceled = false;
+ private JDialog container;
- static {
- addRequestHandler(QuitRequest.class, new QuitRequestHandler());
- }
-
- public SMCCSTAL() {
- AbstractRequestHandler.setMessageConsumer(this);
- }
-
- /**
- *
- * @return if the user canceled
- */
- protected boolean waitForCard() {
- canceled = false;
- while ((smccHelper.getResultCode() != SMCCHelper.CARD_FOUND) && (!canceled)) {
- insertCard.setVisible(true);
- insertCard.setAlwaysOnTop(true);
- insertCard.addCanceledListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- canceled = true;
- }
- });
- try {
- smccHelper.update(1000);
- } catch (Exception ex) {
- log.info(ex);
- }
- }
- insertCard.setVisible(false);
- signatureCard = smccHelper.getSignatureCard(locale);
- return canceled;
+ public SMCCSTAL(BKUGUIFacade gui, JDialog container,
+ ResourceBundle errorMessageBundle) {
+ super(gui, errorMessageBundle);
+ this.container = container;
+ addRequestHandler(SignRequest.class, new LocalSignRequestHandler());
}
@Override
- public void setLocale(Locale locale) {
- super.setLocale(locale);
- if (pinProvider instanceof SwingPINProvider) {
- ((SwingPINProvider) pinProvider).setLocale(locale);
- }
+ public List handleRequest(List requestList) {
+ signatureCard = null;
+ List responses = super.handleRequest(requestList);
+ container.setVisible(false);
+ return responses;
}
- @Override
- public void consumeNewSTALMessage(String captionId, String messageId) {
- TrayIconDialog.getInstance().displayInfo(captionId, messageId);
- }
-
- @Override
- protected BKUGUIFacade getGUI() {
- // TODO Auto-generated method stub
- //FIXME
- return null;
- }
}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
index 014d884a..97646d09 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
@@ -1,27 +1,75 @@
/*
-* 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.bku.local.stal;
-
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.stal.STALFactory;
-
-public class SMCCSTALFactory implements STALFactory {
- @Override
- public STAL createSTAL() {
- return new SMCCSTAL();
- }
-}
+ * 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.bku.local.stal;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.swing.JDialog;
+import javax.swing.WindowConstants;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.gui.BKUGUIFactory;
+import at.gv.egiz.bku.online.applet.BKUApplet;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALFactory;
+
+public class SMCCSTALFactory implements STALFactory {
+
+ private Locale locale;
+ private SMCCSTAL stal;
+ private JDialog dialog;
+
+ @Override
+ public STAL createSTAL() {
+ if (stal == null) {
+ ResourceBundle resourceBundle;
+ if (locale != null) {
+ resourceBundle = ResourceBundle.getBundle(
+ BKUApplet.RESOURCE_BUNDLE_BASE, locale);
+ } else {
+ resourceBundle = ResourceBundle
+ .getBundle(BKUApplet.RESOURCE_BUNDLE_BASE);
+ }
+ dialog = new JDialog();
+ BKUGUIFacade gui = BKUGUIFactory.createGUI();
+ gui.init(dialog.getContentPane(), locale.toString());
+ stal = new SMCCSTAL(new BKUGuiProxy(dialog, gui), dialog, resourceBundle);
+ dialog.setPreferredSize(new Dimension(400, 200));
+ dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = dialog.getSize();
+ if (frameSize.height > screenSize.height) {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width) {
+ frameSize.width = screenSize.width;
+ }
+ dialog.setLocation((screenSize.width - frameSize.width) / 2,
+ (screenSize.height - frameSize.height) / 2);
+ dialog.pack();
+ }
+ return stal;
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
deleted file mode 100644
index eb76f2f2..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
+++ /dev/null
@@ -1,147 +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.bku.local.stal;
-
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Toolkit;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import javax.swing.ImageIcon;
-import javax.swing.JDialog;
-
-import at.gv.egiz.bku.utils.StreamUtil;
-
-public class SwingInsertCardDialog extends JDialog {
-
- private javax.swing.JButton cancelButton;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private Locale locale = Locale.getDefault();
-
- public SwingInsertCardDialog() {
- super((java.awt.Frame) null, false);
- initComponents();
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- private void initComponents() {
- ResourceBundle rb = ResourceBundle.getBundle(
- "at/gv/egiz/bku/local/Userdialog", locale);
- setTitle(rb.getString("Insert.Header"));
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- cancelButton = new javax.swing.JButton();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- setName("Form"); // NOI18N
- setUndecorated(true);
-
- jLabel1.setFont(new Font("Tahoma", Font.BOLD, 14));
- jLabel1.setText(rb.getString("Insert.Text")); // NOI18N
- jLabel1.setName("text"); // NOI18N
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- InputStream is = getClass().getClassLoader().getResourceAsStream(
- "at/gv/egiz/bku/local/logo.png");
- try {
- StreamUtil.copyStream(is, os);
- jLabel2.setIcon(new ImageIcon(os.toByteArray())); // NOI18N
- } catch (IOException e) {
- jLabel2.setText("Chipperling image missing"); // NOI18N
- }
- jLabel2.setName("jLabel2"); // NOI18N
- cancelButton.setText(rb.getString("Insert.Button.Cancel")); // NOI18N
- cancelButton.setName("jButton1"); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)
- .addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING).addGroup(
- layout.createSequentialGroup().addGap(35, 35, 35)
- .addComponent(jLabel1,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)).addGroup(
- layout.createSequentialGroup().addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(cancelButton))).addGap(29, 29, 29)));
- layout.setVerticalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING).addComponent(
- jLabel2).addGroup(
- layout.createSequentialGroup().addComponent(jLabel1,
- javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
- .addGap(35, 35, 35).addComponent(cancelButton).addGap(9, 9,
- 9))).addContainerGap()));
-
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = getSize();
- if (frameSize.height > screenSize.height) {
- frameSize.height = screenSize.height;
- }
- if (frameSize.width > screenSize.width) {
- frameSize.width = screenSize.width;
- }
- setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
- setUndecorated(false);
- pack();
- }
-
- public void addCanceledListener(ActionListener al) {
- cancelButton.addActionListener(al);
- }
-
- /**
- * @param args
- * the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- SwingInsertCardDialog dialog = new SwingInsertCardDialog();
- dialog.addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent e) {
- System.exit(0);
- }
- });
- //
- }
- });
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
deleted file mode 100644
index 7d36e68e..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
+++ /dev/null
@@ -1,57 +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.bku.local.stal;
-
-import java.util.Locale;
-
-import at.gv.egiz.smcc.PINProvider;
-import at.gv.egiz.smcc.PINSpec;
-
-public class SwingPINProvider implements PINProvider {
-
- private Locale locale = Locale.getDefault();
- SwingPinDialog dialog;
-
- public SwingPINProvider() {
- this.locale = Locale.getDefault();
-
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- @Override
- public String providePIN(PINSpec pinSpec, int retries) {
- dialog = new SwingPinDialog(null, false);
- dialog.setResizable(false);
- dialog.setRetries(retries);
- dialog.setPinSpec(pinSpec);
- dialog.initComponents();
- dialog.setVisible(true);
- dialog.requestFocus();
- dialog.setAlwaysOnTop(true);
- dialog.waitFinished();
- dialog.dispose();
- return dialog.getPIN();
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
deleted file mode 100644
index 3e91972c..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
+++ /dev/null
@@ -1,265 +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.bku.local.stal;
-
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JPasswordField;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.PlainDocument;
-
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.smcc.PINSpec;
-
-public class SwingPinDialog extends javax.swing.JDialog implements
- ActionListener {
-
- private javax.swing.JButton okButton;
- private javax.swing.JButton cancelButton;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JPasswordField password;
-
- private PINSpec pinSpec;
- private String pinString;
- private boolean finished = false;
- private int retries = -1;
- private Locale locale = Locale.getDefault();
- private boolean setUp = false;
-
- class PinDocument extends PlainDocument {
- private Pattern pattern;
-
- public PinDocument() {
- if ((pinSpec != null) && (pinSpec.getRexepPattern() != null)) {
- pattern = Pattern.compile(pinSpec.getRexepPattern());
- } else {
- pattern = Pattern.compile(".");
- }
- }
-
- public void insertString(int offs, String str, AttributeSet a)
- throws BadLocationException {
- if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
- Matcher matcher = pattern.matcher(str);
- if (matcher.matches()) {
- super.insertString(offs, str, a);
- }
- }
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
-
- @Override
- public void remove(int offs, int len) throws BadLocationException {
- super.remove(offs, len);
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
- }
-
- /**
- * Make sure to call initComponents
- *
- * @param parent
- * @param modal
- */
- public SwingPinDialog(java.awt.Frame parent, boolean modal) {
- super(parent, modal);
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- public void setPinSpec(PINSpec pinSpec) {
- this.pinSpec = pinSpec;
- }
-
- public void setRetries(int retries) {
- this.retries = retries;
- }
-
- public void initComponents() {
- ResourceBundle rb = ResourceBundle.getBundle(
- "at/gv/egiz/bku/local/Userdialog", locale);
- okButton = new javax.swing.JButton();
- cancelButton = new javax.swing.JButton();
- password = new javax.swing.JPasswordField();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
-
- setTitle(rb.getString("Pin.Header"));
- setName("Form");
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
-
- okButton.setText(rb.getString("Pin.Button.OK"));
- okButton.setName("okButton");
- okButton.setEnabled(false);
- okButton.addActionListener(this);
-
- cancelButton.setText(rb.getString("Pin.Button.Cancel"));
- cancelButton.setName("cancelButton");
- cancelButton.addActionListener(this);
-
- password.setText("");
- password.setDocument(new PinDocument());
- password.setName("password");
- password.addActionListener(this);
- password.setDocument(new PinDocument());
- password.setRequestFocusEnabled(true);
- password.requestFocus();
-
- jLabel1.setFont(new Font("Tahoma", Font.BOLD, 14));
- String text = null;
- Object[] args;
- if (retries > 0) {
- text = rb.getString("Pin.Text.Retries");
- args = new Object[2];
- args[0] = pinSpec.getLocalizedName();
- args[1] = new Integer(retries);
- } else {
- text = rb.getString("Pin.Text.NoRetries");
- args = new Object[1];
- args[0] = pinSpec.getLocalizedName();
- }
- text = MessageFormat.format(text, args);
- jLabel1.setText(text); // NOI18N
- jLabel1.setName("jLabel1"); // NOI18N
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- InputStream is = getClass().getClassLoader().getResourceAsStream(
- "at/gv/egiz/bku/local/logo.png");
- try {
- StreamUtil.copyStream(is, os);
- jLabel2.setIcon(new ImageIcon(os.toByteArray())); // NOI18N
- } catch (Exception e) {
- jLabel2.setText("Chipperling image missing"); // NOI18N
- }
- jLabel2.setName("jLabel2"); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)
- .addGap(73, 73, 73).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addComponent(
- jLabel1).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(password,
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- javax.swing.GroupLayout.Alignment.LEADING,
- layout.createSequentialGroup().addComponent(
- cancelButton).addGap(18, 18, 18).addComponent(
- okButton)))).addContainerGap(31,
- Short.MAX_VALUE)));
- layout.setVerticalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2).addGroup(
- layout.createSequentialGroup().addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel1,
- javax.swing.GroupLayout.PREFERRED_SIZE, 33,
- javax.swing.GroupLayout.PREFERRED_SIZE).addGap(18,
- 18, 18).addComponent(password,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE).addGap(20,
- 20, 20).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(cancelButton).addComponent(
- okButton)))).addGap(36, 36, 36)));
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = getSize();
- if (frameSize.height > screenSize.height) {
- frameSize.height = screenSize.height;
- }
- if (frameSize.width > screenSize.width) {
- frameSize.width = screenSize.width;
- }
- setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
- setUndecorated(false);
- pack();
- }
-
- public String getPIN() {
- return pinString;
- }
-
- private synchronized void finished(boolean ok) {
- if (ok) {
- pinString = password.getText();
- } else {
- pinString = null;
- }
- finished = true;
- notifyAll();
- }
-
- public synchronized void waitFinished() {
- while (!finished) {
- try {
- wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() instanceof JButton) {
- JButton pressed = (JButton) e.getSource();
- if (pressed.getName().equals("okButton")) {
- finished(true);
- } else if (pressed.getName().equals("cancelButton")) {
- finished(false);
- }
- } else if (e.getSource() instanceof JPasswordField) {
- JPasswordField pwf = (JPasswordField) e.getSource();
- if (pwf.getName().equals("password")) {
- if (password.getPassword().length >= pinSpec.getMinLength()) {
- finished(true);
- }
- }
- }
- }
-
-}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index 28c714c1..b70a6274 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -123,6 +123,7 @@ public class ResultServlet extends SpringBKUServlet {
resp.setContentType(bp.getResultContentType());
resp.setCharacterEncoding(encoding);
bp.writeResultTo(resp.getOutputStream(), encoding);
+ resp.getOutputStream().flush();
session.invalidate();
getBindingProcessorManager().removeBindingProcessor(bp.getId());
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
index 38c568ab..8e61230c 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
@@ -21,6 +21,8 @@
package at.gv.egiz.stal.service.impl;
+import java.util.Locale;
+
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
@@ -35,4 +37,7 @@ public class RequestBrokerSTALFactory implements STALFactory {
return new STALRequestBrokerImpl();
}
+ @Override
+ public void setLocale(Locale locale) {
+ }
}
diff --git a/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
index 38c64262..4708d6e7 100644
--- a/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
+++ b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
@@ -16,19 +16,20 @@
*/
package at.gv.egiz.bku.slxhtml;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
import java.io.InputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
import org.junit.Test;
import at.gv.egiz.bku.viewer.ValidationException;
import at.gv.egiz.bku.viewer.Validator;
import at.gv.egiz.bku.viewer.ValidatorFactory;
-
+@Ignore
public class ValidatorTest {
private static Log log = LogFactory.getLog(ValidatorTest.class);
diff --git a/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java b/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java
index e7b3edd1..f9cf00c6 100644
--- a/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java
+++ b/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java
@@ -15,8 +15,10 @@
* limitations under the License.
*/
package at.gv.egiz.stal;
+
+import java.util.Locale;
public interface STALFactory {
-
- public STAL createSTAL();
+ public STAL createSTAL();
+ public void setLocale(Locale locale);
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 0082de26..22ee0d1d 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -187,6 +187,7 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
}
BindingProcessor bindingProcessor = new HTTPBindingProcessor(aSessionId,
commandInvokerClass.newInstance(), url);
+ stalFactory.setLocale(locale);
STAL stal = stalFactory.createSTAL();
bindingProcessor.init(stal, commandInvokerClass.newInstance());
if (locale != null) {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
index bb0314b5..775f4136 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -36,6 +36,8 @@ import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.binding.multipart.InputStreamPartSource;
import at.gv.egiz.bku.binding.multipart.SLResultPart;
@@ -49,6 +51,8 @@ import at.gv.egiz.bku.utils.binding.Protocol;
*
*/
public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
+
+ private final static Log log = LogFactory.getLog(DataUrlConnectionImpl.class);
public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
Protocol.HTTPS };
@@ -80,10 +84,6 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
*/
public void connect() throws SocketTimeoutException, IOException {
connection = (HttpURLConnection) url.openConnection();
-
- // FIXXME move this to config.
- HttpURLConnection.setFollowRedirects(false);
-
connection.setDoOutput(true);
Set headers = requestHttpHeaders.keySet();
Iterator headerIt = headers.iterator();
@@ -146,10 +146,14 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
Part[] parts = new Part[formParams.size()];
Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
os.close();
- // MultipartRequestEntity PostMethod
- result = new DataUrlResponse(url.toString(), connection.getResponseCode(),
- connection.getInputStream());
-
+ // MultipartRequestEntity PostMethod
+ InputStream is = null;
+ try {
+ is = connection.getInputStream();
+ } catch (IOException iox) {
+ log.info(iox);
+ }
+ result = new DataUrlResponse(url.toString(), connection.getResponseCode(), is);
Map responseHttpHeaders = new HashMap();
Map> httpHeaders = connection.getHeaderFields();
for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
index 2330ed3f..8baa0137 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
@@ -463,6 +463,31 @@ public class Signature {
log.trace("Reference caching is not enabled.");
}
}
+ for (Reference reference : getReferences()) {
+ if (reference.getType() != null) {
+ InputStream digestInputStream = reference.getDigestInputStream();
+ if (digestInputStream != null) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("DigestInput for Reference with id='");
+ sb.append(reference.getId());
+ sb.append("'; Type:");
+ sb.append(reference.getType());
+ sb.append("):\n");
+ try {
+ byte[] b = new byte[512];
+ for (int l; (l = digestInputStream.read(b)) != -1;) {
+ sb.append(new String(b, 0, l));
+ }
+ } catch (IOException e) {
+ log.error(e);
+ }
+ log.trace(sb.toString());
+ } else {
+ log.trace("Reference caching is not enabled.");
+ }
+
+ }
+ }
}
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java
index 45dcdc3a..f832f364 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java
@@ -16,6 +16,8 @@
*/
package at.gv.egiz.bku.binding;
+import java.util.Locale;
+
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
@@ -25,6 +27,12 @@ public class DummyStalFactory implements STALFactory {
public STAL createSTAL() {
// TODO Auto-generated method stub
return new at.gv.egiz.stal.dummy.DummySTAL();
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ // TODO Auto-generated method stub
+
}
}
--
cgit v1.2.3
From fd1db02bdc9fbd2a5beca0cc2b214c1adbcc1a7a Mon Sep 17 00:00:00 2001
From: clemenso
Date: Mon, 15 Sep 2008 18:01:32 +0000
Subject: encoding
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@39 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
bkucommon/pom.xml | 4 +-
.../src/main/java/at/gv/egiz/bku/binding/Id.java | 24 ++--
.../main/java/at/gv/egiz/bku/binding/IdImpl.java | 129 +++++++++++----------
.../bku/slcommands/impl/HashDataInputImpl.java | 11 +-
4 files changed, 92 insertions(+), 76 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml
index 2db0cc84..40b73e48 100644
--- a/bkucommon/pom.xml
+++ b/bkucommon/pom.xml
@@ -69,10 +69,10 @@
true
+ skip tests temporarily org.apache.maven.pluginsmaven-surefire-plugin
- true
+ true
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java
index 93ab2e8b..fc7c35c3 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/Id.java
@@ -14,14 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.binding;
-
-/**
- * The unique identifier for a BindingProcessor
- * @author wbauer
- *
- */
-public interface Id {
-
- public String toString();
+package at.gv.egiz.bku.binding;
+
+/**
+ * The unique identifier for a BindingProcessor
+ * @author wbauer
+ *
+ */
+public interface Id {
+
+ @Override
+ public String toString();
+
+ @Override
+ public boolean equals(Object id);
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java
index 5523992a..c8a76823 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/IdImpl.java
@@ -14,67 +14,70 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.binding;
-
-import iaik.utils.Base64OutputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.security.SecureRandom;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Implementation that uses a Base64 representation for self generated Ids.
- * @author wbauer
- *
- */
-public class IdImpl implements at.gv.egiz.bku.binding.Id {
- private static Log log = LogFactory.getLog(IdImpl.class);
-
- private String idString;
-
- public IdImpl(int bitNumber, SecureRandom random) {
- int byteSize = bitNumber/8;
- if (bitNumber % 8 != 0) {
- byteSize++;
- }
- byte[] randomBytes = new byte[byteSize];
- random.nextBytes(randomBytes);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Base64OutputStream b64 = new Base64OutputStream(baos);
- try {
- b64.write(randomBytes);
- b64.flush();
- b64.close();
- idString = new String(baos.toByteArray());
- } catch (IOException e) {
- log.error("Cannot create secure id: "+e);
- }
- }
-
- public IdImpl(String idString) {
- if (idString == null) {
- throw new NullPointerException("Provided idstring must not be null");
- }
- this.idString = idString;
- }
-
- public String toString() {
- return idString;
- }
-
- public int hashCode() {
- return idString.hashCode();
- }
-
- public boolean equals(Object other) {
- if (other instanceof Id) {
- Id otherId = (Id)other;
- return otherId.toString().equals(idString);
- } else {
- return false;
- }
- }
+package at.gv.egiz.bku.binding;
+
+import iaik.utils.Base64OutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.SecureRandom;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Implementation that uses a Base64 representation for self generated Ids.
+ * @author wbauer
+ *
+ */
+public class IdImpl implements at.gv.egiz.bku.binding.Id {
+ private static Log log = LogFactory.getLog(IdImpl.class);
+
+ private String idString;
+
+ public IdImpl(int bitNumber, SecureRandom random) {
+ int byteSize = bitNumber/8;
+ if (bitNumber % 8 != 0) {
+ byteSize++;
+ }
+ byte[] randomBytes = new byte[byteSize];
+ random.nextBytes(randomBytes);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Base64OutputStream b64 = new Base64OutputStream(baos);
+ try {
+ b64.write(randomBytes);
+ b64.flush();
+ b64.close();
+ idString = new String(baos.toByteArray());
+ } catch (IOException e) {
+ log.error("Cannot create secure id: "+e);
+ }
+ }
+
+ public IdImpl(String idString) {
+ if (idString == null) {
+ throw new NullPointerException("Provided idstring must not be null");
+ }
+ this.idString = idString;
+ }
+
+ @Override
+ public String toString() {
+ return idString;
+ }
+
+ @Override
+ public int hashCode() {
+ return idString.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof Id) {
+ Id otherId = (Id)other;
+ return otherId.toString().equals(idString);
+ } else {
+ return false;
+ }
+ }
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
index 49d3c63f..d6999404 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
@@ -4,6 +4,7 @@
*/
package at.gv.egiz.bku.slcommands.impl;
+import at.gv.egiz.bku.binding.HttpUtil;
import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
import at.gv.egiz.stal.HashDataInput;
import java.io.InputStream;
@@ -16,11 +17,14 @@ public class HashDataInputImpl implements HashDataInput {
String refId;
String mimeType;
+ String encoding;
InputStream hashDataInput;
public HashDataInputImpl(DataObject dataObject) {
refId = dataObject.getReference().getId();
- mimeType = dataObject.getMimeType();
+ String contentType = dataObject.getMimeType();
+ mimeType = contentType.split(";")[0].trim();
+ encoding = HttpUtil.getCharset(dataObject.getMimeType(), false);
hashDataInput = dataObject.getReference().getDigestInputStream();
}
@@ -39,4 +43,9 @@ public class HashDataInputImpl implements HashDataInput {
return hashDataInput;
}
+ @Override
+ public String getEncoding() {
+ return encoding;
+ }
+
}
--
cgit v1.2.3
From f72d5842828ec072813eb30051d24f7cc8613606 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 17 Sep 2008 17:18:14 +0000
Subject: hashdatainput digest verification
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@45 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../slcommands/impl/DataObjectHashDataInput.java | 50 +++++++++++++++++++++
.../bku/slcommands/impl/HashDataInputImpl.java | 51 ----------------------
.../bku/slcommands/impl/xsect/STALSignature.java | 4 +-
3 files changed, 52 insertions(+), 53 deletions(-)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
delete mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
new file mode 100644
index 00000000..71b62911
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
@@ -0,0 +1,50 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.bku.slcommands.impl;
+
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
+import at.gv.egiz.stal.HashDataInput;
+import java.io.InputStream;
+
+/**
+ *
+ * @author clemens
+ */
+public class DataObjectHashDataInput implements HashDataInput {
+
+ protected DataObject dataObject;
+
+ public DataObjectHashDataInput(DataObject dataObject) {
+ if (dataObject.getReference() == null)
+ throw new NullPointerException("DataObject reference must not be null");
+ this.dataObject = dataObject;
+ }
+
+ @Override
+ public String getReferenceId() {
+ return dataObject.getReference().getId();
+ }
+
+ @Override
+ public String getMimeType() {
+ return dataObject.getMimeType();
+ }
+
+ /**
+ *
+ * @return the pre-digested input stream if reference caching is enabled, null otherwise
+ */
+ @Override
+ public InputStream getHashDataInput() {
+ return dataObject.getReference().getDigestInputStream();
+ }
+
+ @Override
+ public String getEncoding() {
+ return HttpUtil.getCharset(dataObject.getMimeType(), false);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
deleted file mode 100644
index d6999404..00000000
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package at.gv.egiz.bku.slcommands.impl;
-
-import at.gv.egiz.bku.binding.HttpUtil;
-import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
-import at.gv.egiz.stal.HashDataInput;
-import java.io.InputStream;
-
-/**
- *
- * @author clemens
- */
-public class HashDataInputImpl implements HashDataInput {
-
- String refId;
- String mimeType;
- String encoding;
- InputStream hashDataInput;
-
- public HashDataInputImpl(DataObject dataObject) {
- refId = dataObject.getReference().getId();
- String contentType = dataObject.getMimeType();
- mimeType = contentType.split(";")[0].trim();
- encoding = HttpUtil.getCharset(dataObject.getMimeType(), false);
- hashDataInput = dataObject.getReference().getDigestInputStream();
- }
-
- @Override
- public String getReferenceId() {
- return refId;
- }
-
- @Override
- public String getMimeType() {
- return mimeType;
- }
-
- @Override
- public InputStream getHashDataInput() {
- return hashDataInput;
- }
-
- @Override
- public String getEncoding() {
- return encoding;
- }
-
-}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
index 2d89c8ae..dd7c7d8a 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
@@ -16,7 +16,7 @@
*/
package at.gv.egiz.bku.slcommands.impl.xsect;
-import at.gv.egiz.bku.slcommands.impl.HashDataInputImpl;
+import at.gv.egiz.bku.slcommands.impl.DataObjectHashDataInput;
import at.gv.egiz.bku.slexceptions.SLViewerException;
import java.io.ByteArrayOutputStream;
@@ -131,7 +131,7 @@ public class STALSignature extends SignatureSpi {
} catch (SLViewerException e) {
throw new STALSignatureException(e);
}
- hashDataInputs.add(new HashDataInputImpl(dataObject));
+ hashDataInputs.add(new DataObjectHashDataInput(dataObject));
}
SignRequest signRequest = new SignRequest();
--
cgit v1.2.3
From a20fb683943ce0893302b6dc25015c998cd9687f Mon Sep 17 00:00:00 2001
From: clemenso
Date: Thu, 18 Sep 2008 09:25:55 +0000
Subject: hashdatainput cached
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@46 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../src/main/java/at/gv/egiz/bku/gui/BKUGUI.java | 6 +++--
.../bku/local/stal/LocalSignRequestHandler.java | 28 ++++++++++++++++------
.../src/main/resources/commons-logging.properties | 16 +++++++++++++
BKULocal/src/main/resources/log4j.properties | 2 +-
.../slcommands/impl/DataObjectHashDataInput.java | 6 +++--
5 files changed, 46 insertions(+), 12 deletions(-)
create mode 100644 BKULocal/src/main/resources/commons-logging.properties
(limited to 'bkucommon/src/main')
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
index 5fb67982..be4aeded 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
@@ -871,8 +871,10 @@ public class BKUGUI implements BKUGUIFacade {
.addComponent(waitMsgLabel)
.addContainerGap()); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE));
mainPanelLayout.setVerticalGroup(
- mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(waitMsgLabel));
+ mainPanelLayout.createSequentialGroup()
+// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(waitMsgLabel)
+ .addContainerGap());
contentPanel.validate();
}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
index a288a716..ca420f13 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
@@ -16,6 +16,7 @@
*/
package at.gv.egiz.bku.local.stal;
+import at.gv.egiz.bku.slcommands.impl.DataObjectHashDataInput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -68,14 +69,27 @@ public class LocalSignRequestHandler extends SignRequestHandler {
if (dsigRefId != null) {
for (HashDataInput hdi : hashDataInput) {
if (hdi.getReferenceId().equals(dsigRefId)) {
- InputStream hdIs = hdi.getHashDataInput();
- ByteArrayOutputStream baos = new ByteArrayOutputStream(hdIs.available());
- int b;
- while ((b = hdIs.read()) != -1) {
- baos.write(b);
+ if (hdi instanceof DataObjectHashDataInput) {
+ if (log.isTraceEnabled())
+ log.trace("adding DataObjectHashDataInput");
+ result.add(hdi);
+ } else if (hdi instanceof ByteArrayHashDataInput) {
+ if (log.isTraceEnabled())
+ log.trace("adding ByteArrayHashDataInput");
+ result.add(hdi);
+ } else {
+ if (log.isDebugEnabled())
+ log.debug("provided HashDataInput not chaching enabled, creating ByteArrayHashDataInput");
+
+ InputStream hdIs = hdi.getHashDataInput();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(hdIs.available());
+ int b;
+ while ((b = hdIs.read()) != -1) {
+ baos.write(b);
+ }
+ ByteArrayHashDataInput baHdi = new ByteArrayHashDataInput(baos.toByteArray(), hdi.getReferenceId(), hdi.getMimeType(), hdi.getEncoding());
+ result.add(baHdi);
}
- ByteArrayHashDataInput baHdi = new ByteArrayHashDataInput(baos.toByteArray(), hdi.getReferenceId(), hdi.getMimeType(), hdi.getEncoding());
- result.add(baHdi);
}
}
} else {
diff --git a/BKULocal/src/main/resources/commons-logging.properties b/BKULocal/src/main/resources/commons-logging.properties
new file mode 100644
index 00000000..0d497b1b
--- /dev/null
+++ b/BKULocal/src/main/resources/commons-logging.properties
@@ -0,0 +1,16 @@
+# 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.
+
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
diff --git a/BKULocal/src/main/resources/log4j.properties b/BKULocal/src/main/resources/log4j.properties
index 49d763f8..3a730bac 100644
--- a/BKULocal/src/main/resources/log4j.properties
+++ b/BKULocal/src/main/resources/log4j.properties
@@ -14,7 +14,7 @@
# limitations under the License.
# loglever DEBUG, appender STDOUT
-log4j.rootLogger=TRACE, STDOUT, file
+log4j.rootLogger=DEBUG, STDOUT, file
# STDOUT appender
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
index 71b62911..0386bdd6 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
@@ -10,7 +10,9 @@ import at.gv.egiz.stal.HashDataInput;
import java.io.InputStream;
/**
- *
+ * DataObject-backed HashDataInput
+ * If reference caching is enabled,
+ * the hashdata input stream can be obtained repeatedly.
* @author clemens
*/
public class DataObjectHashDataInput implements HashDataInput {
@@ -34,7 +36,7 @@ public class DataObjectHashDataInput implements HashDataInput {
}
/**
- *
+ * may be called repeatedly
* @return the pre-digested input stream if reference caching is enabled, null otherwise
*/
@Override
--
cgit v1.2.3
From 40e57f6c9101ddcc00422d95086d6a485c3ceda2 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Thu, 18 Sep 2008 15:52:02 +0000
Subject: mimetype
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@52 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
index 0386bdd6..1a9b56fb 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
@@ -32,7 +32,8 @@ public class DataObjectHashDataInput implements HashDataInput {
@Override
public String getMimeType() {
- return dataObject.getMimeType();
+ String contentType = dataObject.getMimeType();
+ return contentType.split(";")[0].trim();
}
/**
--
cgit v1.2.3
From 9ca314eced8a73f58282684597468f98621ac502 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Fri, 19 Sep 2008 12:17:47 +0000
Subject: git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@53
8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../gv/egiz/bku/local/conf/SpringConfigurator.java | 73 ++++++++++++----------
.../gv/egiz/bku/local/conf/defaultConf.properties | 6 ++
.../egiz/bku/online/conf/SpringConfigurator.java | 17 +++++
.../gv/egiz/bku/online/conf/defaultConf.properties | 3 +
.../main/java/at/gv/egiz/bku/binding/DataUrl.java | 3 +-
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 7 ++-
6 files changed, 72 insertions(+), 37 deletions(-)
(limited to 'bkucommon/src/main')
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 3aeb1745..9326d904 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
@@ -42,11 +42,16 @@ import java.util.List;
import java.util.Properties;
import java.util.Set;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.LdapReferralException;
import javax.net.ssl.CertPathTrustManagerParameters;
+import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManager;
import javax.net.ssl.ManagerFactoryParameters;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
@@ -118,7 +123,14 @@ public class SpringConfigurator extends Configurator implements
}
public void configureNetwork() {
-
+ String proxy = getProperty("HTTPProxyHost");
+ String portString = getProperty("HTTPProxyPort");
+ if ((proxy == null) || (proxy.equals(""))) {
+ log.info("No proxy configured");
+ } else {
+ System.setProperty("proxyHost", proxy);
+ System.setProperty("proxyPort", portString);
+ }
}
private Set getCACerts() throws IOException,
@@ -258,13 +270,33 @@ public class SpringConfigurator extends Configurator implements
KeyManager[] km = null;
SSLContext sslCtx = SSLContext
.getInstance(getProperty("SSL.sslProtocol"));
- sslCtx.init(km, trustFab.getTrustManagers(), null);
- // sslCtx.init(km, new TrustManager[] { new MyTrustManager(caCerts,
- // certStoreList) }, null);
+ String disableAll = getProperty("SSL.disableAllChecks");
+ if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
+ log.warn("--------------------------------------");
+ log.warn(" Disabling SSL Certificate Validation ");
+ log.warn("--------------------------------------");
+
+ sslCtx.init(km, new TrustManager[] { new MyTrustManager(caCerts,
+ certStoreList) }, null);
+ } else {
+ sslCtx.init(km, trustFab.getTrustManagers(), null);
+ }
HttpsURLConnection.setDefaultSSLSocketFactory(sslCtx.getSocketFactory());
} catch (Exception e) {
log.error("Cannot configure SSL", e);
}
+ String disableAll = getProperty("SSL.disableAllChecks");
+ if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
+ log.warn("---------------------------------");
+ log.warn(" Disabling Hostname Verification ");
+ log.warn("---------------------------------");
+ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ }
}
@Override
@@ -275,20 +307,15 @@ public class SpringConfigurator extends Configurator implements
class MyTrustManager implements X509TrustManager {
private static Log log = LogFactory.getLog(MyTrustManager.class);
- private Set caCerts;
- private List certStoreList;
private X509Certificate[] trustedCerts;
public MyTrustManager(Set caCerts, List cs) {
- this.caCerts = caCerts;
- this.certStoreList = cs;
trustedCerts = new X509Certificate[caCerts.size()];
int i = 0;
for (Iterator it = caCerts.iterator(); it.hasNext();) {
TrustAnchor ta = it.next();
trustedCerts[i++] = ta.getTrustedCert();
}
-
}
@Override
@@ -301,31 +328,9 @@ class MyTrustManager implements X509TrustManager {
@Override
public void checkServerTrusted(X509Certificate[] certs, String arg1)
throws CertificateException {
- try {
- log.debug("Checking server certificate: " + certs[0].getSubjectDN());
- CertPathBuilder pathBuilder = CertPathBuilder.getInstance("PKIX");
- X509CertSelector selector = new X509CertSelector();
- selector.setCertificate(certs[0]);
- PKIXBuilderParameters pkixParams;
- pkixParams = new PKIXBuilderParameters(caCerts, selector);
- pkixParams.setRevocationEnabled(true); // FIXME
- for (CertStore cs : certStoreList) {
- pkixParams.addCertStore(cs);
- }
- PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) pathBuilder
- .build(pkixParams);
- if (log.isTraceEnabled()) {
- StringBuffer sb = new StringBuffer();
- for (Certificate cert : result.getCertPath().getCertificates()) {
- sb.append(((X509Certificate) cert).getSubjectDN());
- sb.append("->");
- }
- sb.append("End");
- log.trace(sb);
- }
- } catch (Exception e) {
- throw new CertificateException(e);
- }
+ log.warn("-------------------------------------");
+ log.warn("SSL Certificate Validation Disabled !");
+ log.warn("-------------------------------------");
}
@Override
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 93796a7e..31f55ed0 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
@@ -45,9 +45,15 @@ SSL.cache.lifetime=3600
# use authority info access extension to find ca certs.
SSL.useAIA=true
+# Don't set to true in production environments
+# Attention flag only used for debugging
+SSL.disableAllChecks=false
# ------------ END SSL Config --------------------
ValidateHashDataInputs=true
+#HTTPProxyHost=localhost
+#HTTPProxyPort=8888
+
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
index 9fe91708..54dbfdea 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
@@ -70,6 +70,8 @@ public class SpringConfigurator extends Configurator implements
} catch (IOException e) {
log.error("Cannot load config", e);
}
+ } else {
+ log.warn("Cannot load properties, resource: "+resource);
}
}
@@ -91,8 +93,23 @@ public class SpringConfigurator extends Configurator implements
super.configure();
configureSSL();
configureVersion();
+ configureNetwork();
}
+ public void configureNetwork() {
+ String proxyHost = getProperty("HTTPProxyHost");
+ String proxyPort = getProperty("HTTPProxyPort");
+ if (proxyPort == null) {
+ proxyPort = "80";
+ }
+ if (proxyHost != null) {
+ log.debug("Setting proxy server to: "+proxyHost+":"+proxyPort);
+ System.setProperty("http.proxyHost", proxyHost);
+ System.setProperty("http.proxyPort", proxyPort);
+ }
+ log.debug("No proxy specified");
+ }
+
private Set getCACerts() throws IOException,
CertificateException {
Set caCerts = new HashSet();
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
index cdc2bfad..42b0d93e 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
@@ -41,3 +41,6 @@ SSL.sslProtocol=TLS
ValidateHashDataInputs=true
+
+HTTPProxyHost=taranis.iaik.tugraz.at
+HTTPProxyPort=8888
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
index a8477ece..d462ac60 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
@@ -52,7 +52,8 @@ public class DataUrl {
}
public DataUrlConnection openConnection() {
- try {
+ try {
+ log.debug("Opening dataurl connection");
DataUrlConnectionSPI retVal = defaultDataUrlConnection.newInstance();
retVal.init(url);
return retVal;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
index 775f4136..6ad0bb78 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -91,11 +91,13 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
String name = headerIt.next();
connection.setRequestProperty(name, requestHttpHeaders.get(name));
}
+ log.trace("Connecting to: "+url);
connection.connect();
if (connection instanceof HttpsURLConnection) {
HttpsURLConnection ssl = (HttpsURLConnection) connection;
X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
if ((certs != null) && (certs.length >= 1)) {
+ log.trace("Server certificate: "+certs[0]);
serverCertificate = certs[0];
}
}
@@ -142,7 +144,7 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
formParams.add(slResultPart);
OutputStream os = connection.getOutputStream();
-
+ log.trace("Sending data");
Part[] parts = new Part[formParams.size()];
Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
os.close();
@@ -152,7 +154,8 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
is = connection.getInputStream();
} catch (IOException iox) {
log.info(iox);
- }
+ }
+ log.trace("Reading response");
result = new DataUrlResponse(url.toString(), connection.getResponseCode(), is);
Map responseHttpHeaders = new HashMap();
Map> httpHeaders = connection.getHeaderFields();
--
cgit v1.2.3
From 2a0fd44a7999dbcc6ee80fed4e39d3aab66d94ce Mon Sep 17 00:00:00 2001
From: wbauer
Date: Wed, 24 Sep 2008 07:48:54 +0000
Subject: git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@60
8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../bku/binding/BindingProcessorManagerImpl.java | 529 +++++++++++----------
1 file changed, 273 insertions(+), 256 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 22ee0d1d..11f5a160 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -1,270 +1,287 @@
/*
-* 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.bku.binding;
-
+ * 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.bku.binding;
+
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slcommands.SLCommandInvoker;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.bku.utils.binding.Protocol;
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.stal.STALFactory;
-
-/**
- * This class maintains all active BindingProcessor Objects. Currently, only
- * HTTPBinding is supported.
- */
-public class BindingProcessorManagerImpl implements BindingProcessorManager {
-
- public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
- Protocol.HTTPS };
-
- private static Log log = LogFactory.getLog(BindingProcessorManagerImpl.class);
-
- private RemovalStrategy removalStrategy;
- private STALFactory stalFactory;
- private SLCommandInvoker commandInvokerClass;
- private ExecutorService executorService;
- private Map bindingProcessorMap = Collections
- .synchronizedMap(new HashMap());
-
- /**
- * Container to hold a Future and Bindingprocessor object as map value.
- * @author wbauer
- * @see BindingProcessorManagerImpl#bindingProcessorMap
- */
- static class MapEntityWrapper {
- private Future> future;
- private BindingProcessor bindingProcessor;
-
- public MapEntityWrapper(Future> future, BindingProcessor bindingProcessor) {
- if ((bindingProcessor == null) || (future == null)) {
- throw new NullPointerException("Argument must not be null");
- }
- this.bindingProcessor = bindingProcessor;
- this.future = future;
- }
-
- public Future> getFuture() {
- return future;
- }
-
- public BindingProcessor getBindingProcessor() {
- return bindingProcessor;
- }
-
- public int hashCode() {
- return bindingProcessor.getId().hashCode();
- }
-
- public boolean equals(Object other) {
- if (other instanceof MapEntityWrapper) {
- MapEntityWrapper o = (MapEntityWrapper) other;
- return (o.bindingProcessor.getId().equals(bindingProcessor.getId()));
- } else {
- return false;
- }
- }
- }
-
- /**
- *
- * @param fab
- * must not be null
- * @param ci
- * must not be null (prototype to generate new instances)
- */
- public BindingProcessorManagerImpl(STALFactory fab, SLCommandInvoker ci) {
- if (fab == null) {
- throw new NullPointerException("STALFactory must not be null");
- }
- stalFactory = fab;
- if (ci == null) {
- throw new NullPointerException("SLCommandInvoker must not be null");
- }
- commandInvokerClass = ci;
- executorService = Executors.newCachedThreadPool();
- }
-
- /**
- *
- * @return the STALFactory currently used.
- */
- public STALFactory getStalFactory() {
- return stalFactory;
- }
-
- /**
- * Sets the STALFactory to be used.
- * @param stalFactory
- */
- public void setStalFactory(STALFactory stalFactory) {
- this.stalFactory = stalFactory;
- }
-
- /**
- * Could be used to setup a new executor service during application stratup.
- * @param executorService
- */
- public void setExecutorService(ExecutorService executorService) {
- this.executorService = executorService;
- }
-
- public void setRemovalStrategy(RemovalStrategy aStrategy) {
- removalStrategy = aStrategy;
- }
-
- public RemovalStrategy getRemovlaStrategy() {
- return removalStrategy;
- }
-
- public void shutdown() {
- log.info("Shutting down the BindingProcessorManager");
- executorService.shutdown();
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.binding.Protocol;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALFactory;
+
+/**
+ * This class maintains all active BindingProcessor Objects. Currently, only
+ * HTTPBinding is supported.
+ */
+public class BindingProcessorManagerImpl implements BindingProcessorManager {
+
+ public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
+ Protocol.HTTPS };
+
+ private static Log log = LogFactory.getLog(BindingProcessorManagerImpl.class);
+
+ private RemovalStrategy removalStrategy;
+ private STALFactory stalFactory;
+ private SLCommandInvoker commandInvokerClass;
+ private ExecutorService executorService;
+ private Map bindingProcessorMap = Collections
+ .synchronizedMap(new HashMap());
+
+ /**
+ * Container to hold a Future and Bindingprocessor object as map value.
+ *
+ * @author wbauer
+ * @see BindingProcessorManagerImpl#bindingProcessorMap
+ */
+ static class MapEntityWrapper {
+ private Future> future;
+ private BindingProcessor bindingProcessor;
+
+ public MapEntityWrapper(Future> future, BindingProcessor bindingProcessor) {
+ if ((bindingProcessor == null) || (future == null)) {
+ throw new NullPointerException("Argument must not be null");
+ }
+ this.bindingProcessor = bindingProcessor;
+ this.future = future;
+ }
+
+ public Future> getFuture() {
+ return future;
+ }
+
+ public BindingProcessor getBindingProcessor() {
+ return bindingProcessor;
+ }
+
+ public int hashCode() {
+ return bindingProcessor.getId().hashCode();
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof MapEntityWrapper) {
+ MapEntityWrapper o = (MapEntityWrapper) other;
+ return (o.bindingProcessor.getId().equals(bindingProcessor.getId()));
+ } else {
+ return false;
+ }
+ }
}
-
+
+ /**
+ *
+ * @param fab
+ * must not be null
+ * @param ci
+ * must not be null (prototype to generate new instances)
+ */
+ public BindingProcessorManagerImpl(STALFactory fab, SLCommandInvoker ci) {
+ if (fab == null) {
+ throw new NullPointerException("STALFactory must not be null");
+ }
+ stalFactory = fab;
+ if (ci == null) {
+ throw new NullPointerException("SLCommandInvoker must not be null");
+ }
+ commandInvokerClass = ci;
+ executorService = Executors.newCachedThreadPool();
+ }
+
+ /**
+ *
+ * @return the STALFactory currently used.
+ */
+ public STALFactory getStalFactory() {
+ return stalFactory;
+ }
+
+ /**
+ * Sets the STALFactory to be used.
+ *
+ * @param stalFactory
+ */
+ public void setStalFactory(STALFactory stalFactory) {
+ this.stalFactory = stalFactory;
+ }
+
+ /**
+ * Could be used to setup a new executor service during application stratup.
+ *
+ * @param executorService
+ */
+ public void setExecutorService(ExecutorService executorService) {
+ this.executorService = executorService;
+ }
+
+ public void setRemovalStrategy(RemovalStrategy aStrategy) {
+ removalStrategy = aStrategy;
+ }
+
+ public RemovalStrategy getRemovlaStrategy() {
+ return removalStrategy;
+ }
+
+ public void shutdown() {
+ log.info("Shutting down the BindingProcessorManager");
+ executorService.shutdown();
+ }
+
public void shutdownNow() {
- log.info("Shutting down the BindingProcessorManager NOW!");
+ log.info("Shutting down the BindingProcessorManager NOW!");
executorService.shutdownNow();
- }
-
- /**
- * Uses the default locale
- */
- public BindingProcessor createBindingProcessor(String srcUrl,
- String aSessionId) throws MalformedURLException {
- return createBindingProcessor(srcUrl, aSessionId, null);
- }
-
- /**
- * FactoryMethod creating a new BindingProcessor object.
- *
- * @param protocol
+ log.debug("Number of binding prcessors currently managed: "
+ + bindingProcessorMap.size());
+ if (log.isDebugEnabled()) {
+ for (Iterator it = bindingProcessorMap.values()
+ .iterator(); it.hasNext();) {
+ MapEntityWrapper entry = it.next();
+ log.debug(entry.getBindingProcessor().getId() + ": isDone: "
+ + entry.getFuture().isDone());
+ log.debug(entry.getBindingProcessor().getId() + ": isCanceled: "
+ + entry.getFuture().isCancelled());
+ }
+ }
+ }
+
+ /**
+ * Uses the default locale
+ */
+ public BindingProcessor createBindingProcessor(String srcUrl,
+ String aSessionId) throws MalformedURLException {
+ return createBindingProcessor(srcUrl, aSessionId, null);
+ }
+
+ /**
+ * FactoryMethod creating a new BindingProcessor object.
+ *
+ * @param protocol
* must not be null
- * @throws MalformedURLException
- */
- public BindingProcessor createBindingProcessor(String srcUrl,
+ * @throws MalformedURLException
+ */
+ public BindingProcessor createBindingProcessor(String srcUrl,
String aSessionId, Locale locale) throws MalformedURLException {
- URL url = new URL(srcUrl);
- String low = url.getProtocol().toLowerCase();
- Protocol proto = null;
- for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
- if (SUPPORTED_PROTOCOLS[i].toString().equals(low)) {
- proto = SUPPORTED_PROTOCOLS[i];
- break;
- }
- }
- if (proto == null) {
- throw new UnsupportedOperationException();
- }
- BindingProcessor bindingProcessor = new HTTPBindingProcessor(aSessionId,
- commandInvokerClass.newInstance(), url);
+ URL url = new URL(srcUrl);
+ String low = url.getProtocol().toLowerCase();
+ Protocol proto = null;
+ for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
+ if (SUPPORTED_PROTOCOLS[i].toString().equals(low)) {
+ proto = SUPPORTED_PROTOCOLS[i];
+ break;
+ }
+ }
+ if (proto == null) {
+ throw new UnsupportedOperationException();
+ }
+ BindingProcessor bindingProcessor = new HTTPBindingProcessor(aSessionId,
+ commandInvokerClass.newInstance(), url);
stalFactory.setLocale(locale);
- STAL stal = stalFactory.createSTAL();
- bindingProcessor.init(stal, commandInvokerClass.newInstance());
- if (locale != null) {
- bindingProcessor.setLocale(locale);
- stal.setLocale(locale);
- }
- return bindingProcessor;
- }
-
- /**
- * @return the bindingprocessor object for this id or null if no bindingprocessor was found.
- */
- public BindingProcessor getBindingProcessor(Id aId) {
- if (bindingProcessorMap.get(aId) != null) {
- return bindingProcessorMap.get(aId).getBindingProcessor();
- } else {
- return null;
- }
- }
-
+ STAL stal = stalFactory.createSTAL();
+ bindingProcessor.init(stal, commandInvokerClass.newInstance());
+ if (locale != null) {
+ bindingProcessor.setLocale(locale);
+ stal.setLocale(locale);
+ }
+ return bindingProcessor;
+ }
+
+ /**
+ * @return the bindingprocessor object for this id or null if no
+ * bindingprocessor was found.
+ */
+ public BindingProcessor getBindingProcessor(Id aId) {
+ if (bindingProcessorMap.get(aId) != null) {
+ return bindingProcessorMap.get(aId).getBindingProcessor();
+ } else {
+ return null;
+ }
+ }
+
/**
*
- */
- public void setSTALFactory(STALFactory aStalFactory) {
- if (aStalFactory == null) {
- throw new NullPointerException("Cannot set STALFactory to null");
- }
- stalFactory = aStalFactory;
- }
-
- /**
- * Causes the BindingProcessorManager to manage the provided BindingProcessor
- * @param aBindingProcessor must not be null
- */
- public void process(BindingProcessor aBindingProcessor) {
- if (bindingProcessorMap.containsKey(aBindingProcessor.getId())) {
- log.fatal("Clashing ids, cannot process bindingprocessor with id:"
- + aBindingProcessor.getId());
- throw new SLRuntimeException(
- "Clashing ids, cannot process bindingprocessor with id:"
- + aBindingProcessor.getId());
+ */
+ public void setSTALFactory(STALFactory aStalFactory) {
+ if (aStalFactory == null) {
+ throw new NullPointerException("Cannot set STALFactory to null");
+ }
+ stalFactory = aStalFactory;
+ }
+
+ /**
+ * Causes the BindingProcessorManager to manage the provided BindingProcessor
+ *
+ * @param aBindingProcessor
+ * must not be null
+ */
+ public void process(BindingProcessor aBindingProcessor) {
+ if (bindingProcessorMap.containsKey(aBindingProcessor.getId())) {
+ log.fatal("Clashing ids, cannot process bindingprocessor with id:"
+ + aBindingProcessor.getId());
+ throw new SLRuntimeException(
+ "Clashing ids, cannot process bindingprocessor with id:"
+ + aBindingProcessor.getId());
}
- log.debug("processing bindingprocessor: "+aBindingProcessor.getId());
- Future> f = executorService.submit(aBindingProcessor);
- bindingProcessorMap.put(aBindingProcessor.getId(), new MapEntityWrapper(f,
- aBindingProcessor));
- }
-
- @Override
- public void setSLCommandInvoker(SLCommandInvoker invoker) {
- commandInvokerClass = invoker;
- }
-
- @Override
+ log.debug("processing bindingprocessor: " + aBindingProcessor.getId());
+ Future> f = executorService.submit(aBindingProcessor);
+ bindingProcessorMap.put(aBindingProcessor.getId(), new MapEntityWrapper(f,
+ aBindingProcessor));
+ }
+
+ @Override
+ public void setSLCommandInvoker(SLCommandInvoker invoker) {
+ commandInvokerClass = invoker;
+ }
+
+ @Override
public void removeBindingProcessor(Id sessionId) {
- log.debug("Removing binding processor: "+sessionId);
- MapEntityWrapper wrapper = bindingProcessorMap
- .get(sessionId);
- if (wrapper == null) {
- return;
- }
- Future> f = wrapper.getFuture();
- if (!f.isDone()) {
- f.cancel(true);
- }
- bindingProcessorMap.remove(sessionId);
- }
-
- @Override
- public Set getManagedIds() {
- Set result = new HashSet();
- synchronized (bindingProcessorMap) {
- for (Iterator it = bindingProcessorMap.keySet().iterator(); it
- .hasNext();) {
- result.add(it.next());
- }
- }
- return result;
- }
+ log.debug("Removing binding processor: " + sessionId);
+ MapEntityWrapper wrapper = bindingProcessorMap.get(sessionId);
+ if (wrapper == null) {
+ return;
+ }
+ Future> f = wrapper.getFuture();
+ if (!f.isDone()) {
+ f.cancel(true);
+ }
+ bindingProcessorMap.remove(sessionId);
+ }
+
+ @Override
+ public Set getManagedIds() {
+ Set result = new HashSet();
+ synchronized (bindingProcessorMap) {
+ for (Iterator it = bindingProcessorMap.keySet().iterator(); it
+ .hasNext();) {
+ result.add(it.next());
+ }
+ }
+ return result;
+ }
}
\ No newline at end of file
--
cgit v1.2.3
From 3edfbe631f24d73324bc4dd0d182ca7737c4d5b5 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Wed, 24 Sep 2008 13:56:53 +0000
Subject: Improved SLResult marshalling.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@66 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 40 +--
.../java/at/gv/egiz/bku/slcommands/SLResult.java | 7 +-
.../impl/CreateXMLSignatureResultImpl.java | 73 ++---
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 21 +-
.../slcommands/impl/InfoboxReadCommandImpl.java | 320 ++++++++++++++++-----
.../slcommands/impl/InfoboxReadResultFileImpl.java | 141 +++++++++
.../bku/slcommands/impl/InfoboxReadResultImpl.java | 190 +++---------
.../slcommands/impl/NullOperationResultImpl.java | 5 +-
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 166 ++++++++---
9 files changed, 606 insertions(+), 357 deletions(-)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
(limited to 'bkucommon/src/main')
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 19f22126..8f72c3ee 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
@@ -35,6 +35,7 @@ import java.util.Locale;
import java.util.Map;
import javax.net.ssl.SSLHandshakeException;
+import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
@@ -108,7 +109,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
protected SLTargetContext targetContext = new SLTargetContext();
protected URL srcUrl;
protected State currentState = State.INIT;
- protected Transformer transformer = null;
+ protected Templates templates = null;
protected String resultContentType = null;
protected SLResult slResult = null;
protected int responseCode = 200;
@@ -471,10 +472,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
resultContentType = HttpUtil.TXT_XML;
}
}
- transformer = getTransformer(getStyleSheetUrl());
- if (transformer != null) {
+ templates = getTemplates(getStyleSheetUrl());
+ if (templates != null) {
log.debug("Output transformation required");
- resultContentType = transformer.getOutputProperty("media-type");
+ resultContentType = templates.getOutputProperties().getProperty("media-type");
log.debug("Got media type from stylesheet: " + resultContentType);
if (resultContentType == null) {
log.debug("Setting to default text/xml result conent type");
@@ -703,7 +704,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
return resultContentType;
}
- protected Transformer getTransformer(String styleSheetURL) {
+ protected Templates getTemplates(String styleSheetURL) {
if (styleSheetURL == null) {
log.debug("Stylesheet URL not set");
return null;
@@ -713,11 +714,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
URIResolver resolver = new URIResolverAdapter(URLDereferencer
.getInstance(), urlCtx);
TransformerFactory factory = TransformerFactory.newInstance();
+ factory.setURIResolver(resolver);
StreamData sd = URLDereferencer.getInstance().dereference(styleSheetURL,
urlCtx);
- Transformer t = factory.newTransformer(new StreamSource(sd.getStream()));
- t.setURIResolver(resolver);
- return t;
+ return factory.newTemplates(new StreamSource(sd.getStream()));
} catch (Exception ex) {
log.info("Cannot instantiate transformer", ex);
bindingProcessorError = new SLException(2002);
@@ -726,15 +726,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
}
protected void handleBindingProcessorError(OutputStream os, String encoding,
- Transformer transformer) throws IOException {
+ Templates templates) throws IOException {
log.debug("Writing error as result");
ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError);
- try {
- error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)),
- transformer);
- } catch (TransformerException e) {
- log.fatal("Cannot write error result to stream", e);
- }
+ error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)), templates);
}
@Override
@@ -745,7 +740,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
}
if (bindingProcessorError != null) {
log.debug("Detected error in binding processor, writing error as result");
- handleBindingProcessorError(os, encoding, transformer);
+ handleBindingProcessorError(os, encoding, templates);
return;
} else if (dataUrlResponse != null) {
log.debug("Writing data url response as result");
@@ -754,10 +749,11 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
InputStreamReader isr = new InputStreamReader(
dataUrlResponse.getStream(), charEnc);
OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
- if (transformer == null) {
+ if (templates == null) {
StreamUtil.copyStream(isr, osw);
} else {
try {
+ Transformer transformer = templates.newTransformer();
transformer.transform(new StreamSource(isr), new StreamResult(osw));
} catch (TransformerException e) {
log.fatal("Exception occured during result transformation", e);
@@ -771,18 +767,12 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
} else if (slResult == null) {
// result not yet assigned -> must be a cancel
bindingProcessorError = new SLException(6001);
- handleBindingProcessorError(os, encoding, transformer);
+ handleBindingProcessorError(os, encoding, templates);
return;
} else {
log.debug("Getting result from invoker");
OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
- try {
- slResult.writeTo(new StreamResult(osw), transformer);
- } catch (TransformerException e) {
- log.fatal("Cannot write result to stream", e);
- // bindingProcessorError = new SLException(2008);
- // handleBindingProcessorError(os, encoding, transformer);
- }
+ slResult.writeTo(new StreamResult(osw), templates);
osw.flush();
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
index 7cf43fda..7989a771 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
@@ -16,9 +16,8 @@
*/
package at.gv.egiz.bku.slcommands;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
public interface SLResult {
@@ -40,5 +39,5 @@ public interface SLResult {
* @param result
* @param transformer may be null.
*/
- public void writeTo(Result result, Transformer transformer) throws TransformerException;
+ public void writeTo(Result result, Templates templates);
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
index d2d2e678..092a13c4 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
@@ -16,28 +16,24 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
/**
* This calls implements the result of the security layer command CreateXMLSignature.
@@ -104,35 +100,10 @@ public class CreateXMLSignatureResultImpl extends SLResultImpl {
}
}
-
- @Override
- public void writeTo(Result result) {
-
- try {
- writeTo(result, null);
- } catch (TransformerException e) {
- log.error(e);
- }
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.bku.slcommands.impl.SLResultImpl#writeTo(javax.xml.transform.Result, javax.xml.transform.Transformer)
- */
- @Override
- public void writeTo(Result result, Transformer transformer) throws TransformerException {
-
- if (transformer == null) {
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- try {
- transformer = transformerFactory.newTransformer();
- } catch (TransformerConfigurationException e) {
- log.error("Failed to create Transformer.", e);
- throw new SLRuntimeException(e);
- }
- }
- transformer.transform(new DOMSource(doc), result);
-
+
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ writeTo(doc, result, templates);
}
}
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 fb624211..176ba001 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,12 +16,9 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import java.util.Locale;
-
import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
-import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
import at.gv.egiz.bku.slcommands.ErrorResult;
import at.gv.egiz.bku.slexceptions.SLException;
@@ -48,15 +45,9 @@ public class ErrorResultImpl extends SLResultImpl implements ErrorResult {
this.slException = slException;
}
- @Override
- public void writeTo(Result result) {
-
- ObjectFactory factory = new ObjectFactory();
- ErrorResponseType responseType = factory.createErrorResponseType();
- responseType.setErrorCode(slException.getErrorCode());
- responseType.setInfo(slException.getDetailedMsg());
-
- writeTo(factory.createErrorResponse(responseType), result);
-
- }
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ writeErrorTo(slException, result, templates);
+ }
+
}
\ 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 b6745e1f..4d64ae36 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
@@ -16,55 +16,66 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import iaik.asn1.CodingException;
-import iaik.asn1.DerCoder;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType;
-import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType;
-import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType;
-import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
-import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandContext;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.idlink.CompressedIdentityLinkFactory;
-import at.gv.egiz.idlink.IdentityLinkTransformer;
-import at.gv.egiz.idlink.ans1.IdentityLink;
-import at.gv.egiz.stal.InfoboxReadRequest;
-import at.gv.egiz.stal.InfoboxReadResponse;
-import at.gv.egiz.stal.STALRequest;
+import iaik.asn1.CodingException;
+import iaik.asn1.DerCoder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType;
+import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxAssocArrayPairType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadKeys;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadPairs;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadValue;
+import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.idlink.CompressedIdentityLinkFactory;
+import at.gv.egiz.idlink.IdentityLinkTransformer;
+import at.gv.egiz.idlink.ans1.IdentityLink;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.InfoboxReadResponse;
+import at.gv.egiz.stal.STALRequest;
/**
* This class implements the security layer command
@@ -82,23 +93,45 @@ public class InfoboxReadCommandImpl extends SLCommandImplInfoboxIdentifier
*/
protected String infoboxIdentifier;
/**
- * The IdentityLinkDomainIdentifier value of an IdentyLink infobox.
+ * The IdentityLinkDomainIdentifier value of an IdentyLink infobox.
*/
- protected String identityLinkDomainIdentifier;
+ protected String identityLinkDomainIdentifier;
+
+ /**
+ * The list of certificates to be read from an Certificates infobox.
+ */
+ protected List certificates;
+
+ /**
+ * The result type.
+ */
+ protected int assocArrayResult;
/**
* Is content XML entity?
@@ -125,12 +158,6 @@ public class InfoboxReadCommandImpl extends SLCommandImpl 1) {
+ log.info("UserMakesUnique not supported");
+ // TODO: give more specific error message
+ throw new SLCommandException(4010);
+ }
+ }
+
+ // ReadPairs?
+ if (assocArrayParameters.getReadPairs() != null) {
+ assocArrayResult = ASSOC_ARRAY_READ_PAIRS;
+ ReadPairs readPairs = assocArrayParameters.getReadPairs();
+ if (readPairs.isValuesAreXMLEntities()) {
+ log.info("Got valuesAreXMLEntities but infobox type is binary.");
+ throw new SLCommandException(4010);
+ }
+ certificates = findCertificates(readPairs.getSearchString());
+ if (readPairs.isUserMakesUnique() && certificates.size() > 1) {
+ log.info("UserMakesUnique not supported");
+ // TODO: give more specific error message
+ throw new SLCommandException(4010);
+ }
+ }
+
+ // ReadValue
+ if (assocArrayParameters.getReadValue() != null) {
+ assocArrayResult = ASSOC_ARRAY_READ_VALUE;
+ ReadValue readValue = assocArrayParameters.getReadValue();
+ if (readValue.isValueIsXMLEntity()) {
+ log.info("Got valuesAreXMLEntities but infobox type is binary.");
+ throw new SLCommandException(4010);
+ }
+ String key = readValue.getKey();
+ if (Arrays.asList(INFOXBOX_CERTIFICATES_KEYS).contains(key)) {
+ certificates = Collections.singletonList(key);
+ } else {
+ certificates = Collections.emptyList();
+ }
+ }
+
+ if (assocArrayResult == 0) {
+ log.info("Infobox type is AssocArray but got invalid AssocArrayParameters.");
+ throw new SLCommandException(4010);
+ }
} else {
throw new SLCommandException(4002,
@@ -168,9 +268,15 @@ public class InfoboxReadCommandImpl extends SLCommandImpl findCertificates(String searchString) throws SLCommandException {
+
+ if ("*".equals(searchString) || "**".equals(searchString)) {
+ return Arrays.asList(INFOXBOX_CERTIFICATES_KEYS);
+ }
+
+ if (Pattern.matches(SEARCH_STRING_PATTERN, searchString)) {
+
+// for (int i = 0; i < searchString.length(); i++) {
+// int codePoint = searchString.codePointAt(i);
+//
+// }
+
+ // TODO : build pattern
+ return Collections.emptyList();
+ } else {
+ log.info("Got invalid search string '" + searchString + "'");
+ throw new SLCommandException(4010);
+ }
+
+ }
+
+ private SLResult readCertificates() throws SLCommandException {
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory
+ .createInfoboxReadDataAssocArrayType();
+
+ if (assocArrayResult == ASSOC_ARRAY_READ_KEYS) {
- @Override
- public String getIdentityLinkDomainId() {
- return identityLinkDomainIdentifier;
- }
+ List keys = infoboxReadDataAssocArrayType.getKey();
+ keys.addAll(certificates);
+
+ } else {
+
+ if (certificates != null && !certificates.isEmpty()) {
+
+ List stalRequests = new ArrayList();
+
+ // get certificates
+ InfoboxReadRequest infoboxReadRequest;
+ for (int i = 0; i < certificates.size(); i++) {
+ infoboxReadRequest = new InfoboxReadRequest();
+ infoboxReadRequest.setInfoboxIdentifier(certificates.get(i));
+ stalRequests.add(infoboxReadRequest);
+ }
+
+ requestSTAL(stalRequests);
+
+ List x509Certs = getCertificatesFromResponses();
+
+ for (int i = 0; i < certificates.size(); i++) {
+ InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType();
+ infoboxAssocArrayPairType.setKey(certificates.get(i));
+ try {
+ infoboxAssocArrayPairType.setBase64Content(x509Certs.get(i).getEncoded());
+ } catch (CertificateEncodingException e) {
+ log.error("Failed to encode certificate.", e);
+ throw new SLCommandException(4000);
+ }
+ infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType);
+ }
+
+ }
+
+ }
+
+ return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType);
+
+ }
+
+ @Override
+ public String getIdentityLinkDomainId() {
+ return identityLinkDomainIdentifier;
+ }
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
new file mode 100644
index 00000000..6f41b562
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -0,0 +1,141 @@
+/*
+* 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.bku.slcommands.impl;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
+import javax.xml.transform.dom.DOMResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.buergerkarte.namespaces.securitylayer._1.XMLContentType;
+import at.gv.egiz.bku.slcommands.InfoboxReadResult;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+/**
+ * This class implements the result of the security layer command InfoboxReadRequest.
+ *
+ * @author mcentner
+ */
+public class InfoboxReadResultFileImpl extends SLResultImpl implements
+ InfoboxReadResult {
+
+ /**
+ * Logging facility.
+ */
+ protected static Log log = LogFactory.getLog(InfoboxReadResultFileImpl.class);
+
+ /**
+ * The XML document containing the infobox content.
+ */
+ Document xmlDocument;
+
+ /**
+ * Creates the response document from the given binaryContent.
+ *
+ * @param binaryContent the infobox content
+ * @param preserveSpace the value of the preserveSpace parameter
+ *
+ * @return the created response document
+ */
+ private Document createResponseDocument(byte[] binaryContent, boolean preserveSpace) {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ Document doc;
+ try {
+ doc = dbf.newDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException e) {
+ // it should always be possible to create a new Document
+ log.error("Failed to create XML document.", e);
+ throw new SLRuntimeException(e);
+ }
+
+ ObjectFactory factory = new ObjectFactory();
+
+ Base64XMLContentType base64XMLContentType = factory.createBase64XMLContentType();
+ if (binaryContent == null) {
+ XMLContentType xmlContentType = factory.createXMLContentType();
+ if (preserveSpace) {
+ xmlContentType.setSpace("preserve");
+ }
+ base64XMLContentType.setXMLContent(xmlContentType);
+ } else {
+ base64XMLContentType.setBase64Content(binaryContent);
+ }
+ InfoboxReadResponseType infoboxReadResponseType = factory.createInfoboxReadResponseType();
+ infoboxReadResponseType.setBinaryFileData(base64XMLContentType);
+
+ JAXBElement infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
+
+ JAXBContext context = SLCommandFactory.getJaxbContext();
+ try {
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.marshal(infoboxReadResponse, doc);
+ } catch (JAXBException e) {
+ log.error("Failed to marshal 'InfoboxReadResponse' document.", e);
+ throw new SLRuntimeException(e);
+ }
+
+ return doc;
+
+ }
+
+
+ /**
+ * @return an XMLResult for marshalling the infobox to
+ */
+ Result getXmlResult(boolean preserveSpace) {
+
+ xmlDocument = createResponseDocument(null, preserveSpace);
+
+ NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
+ return new DOMResult(nodeList.item(0));
+
+ }
+
+ /**
+ * Creates a new result document for this InfoboxReadResult
+ * and sets the given resultBytes as content.
+ *
+ * @param resultBytes
+ */
+ void setResultBytes(byte[] resultBytes) {
+
+ xmlDocument = createResponseDocument(resultBytes, false);
+
+ }
+
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ writeTo(xmlDocument, result, templates);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
index 6f07338f..8904eac6 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
@@ -14,158 +14,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.slcommands.impl;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-
-import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
-import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.buergerkarte.namespaces.securitylayer._1.XMLContentType;
-import at.gv.egiz.bku.slcommands.InfoboxReadResult;
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-
-/**
- * This class implements the result of the security layer command InfoboxReadRequest.
- *
- * @author mcentner
- */
-public class InfoboxReadResultImpl extends SLResultImpl implements
- InfoboxReadResult {
-
- /**
- * Logging facility.
- */
- protected static Log log = LogFactory.getLog(InfoboxReadResultImpl.class);
-
- /**
- * The XML document containing the infobox content.
- */
- Document xmlDocument;
-
- /**
- * Creates the response document from the given binaryContent.
- *
- * @param binaryContent the infobox content
- * @param preserveSpace the value of the preserveSpace parameter
- *
- * @return the created response document
- */
- private Document createResponseDocument(byte[] binaryContent, boolean preserveSpace) {
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- Document doc;
- try {
- doc = dbf.newDocumentBuilder().newDocument();
- } catch (ParserConfigurationException e) {
- // it should always be possible to create a new Document
- log.error("Failed to create XML document.", e);
- throw new SLRuntimeException(e);
- }
-
- ObjectFactory factory = new ObjectFactory();
-
- Base64XMLContentType base64XMLContentType = factory.createBase64XMLContentType();
- if (binaryContent == null) {
- XMLContentType xmlContentType = factory.createXMLContentType();
- if (preserveSpace) {
- xmlContentType.setSpace("preserve");
- }
- base64XMLContentType.setXMLContent(xmlContentType);
- } else {
- base64XMLContentType.setBase64Content(binaryContent);
- }
- InfoboxReadResponseType infoboxReadResponseType = factory.createInfoboxReadResponseType();
- infoboxReadResponseType.setBinaryFileData(base64XMLContentType);
-
- JAXBElement infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
-
- JAXBContext context = SLCommandFactory.getJaxbContext();
- try {
- Marshaller marshaller = context.createMarshaller();
- marshaller.marshal(infoboxReadResponse, doc);
- } catch (JAXBException e) {
- log.error("Failed to marshal 'InfoboxReadResponse' document.", e);
- throw new SLRuntimeException(e);
- }
-
- return doc;
-
- }
-
-
- /**
- * @return an XMLResult for marshalling the infobox to
- */
- Result getXmlResult(boolean preserveSpace) {
-
- xmlDocument = createResponseDocument(null, preserveSpace);
-
- NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
- return new DOMResult(nodeList.item(0));
-
- }
-
- /**
- * Creates a new result document for this InfoboxReadResult
- * and sets the given resultBytes as content.
- *
- * @param resultBytes
- */
- void setResultBytes(byte[] resultBytes) {
-
- xmlDocument = createResponseDocument(resultBytes, false);
-
- }
-
- @Override
- public void writeTo(Result result) {
-
- try {
- writeTo(result, null);
- } catch (TransformerException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.bku.slcommands.impl.SLResultImpl#writeTo(javax.xml.transform.Result, javax.xml.transform.Transformer)
- */
- @Override
- public void writeTo(Result result, Transformer transformer) throws TransformerException {
-
- if (transformer == null) {
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- try {
- transformer = transformerFactory.newTransformer();
- } catch (TransformerConfigurationException e) {
- log.error("Failed to create Transformer.", e);
- throw new SLRuntimeException(e);
- }
- }
- transformer.transform(new DOMSource(xmlDocument), result);
-
- }
-
-}
+package at.gv.egiz.bku.slcommands.impl;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
+
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+
+public class InfoboxReadResultImpl extends SLResultImpl {
+
+ /**
+ * The InfoboxReadResponse
+ */
+ protected InfoboxReadResponseType infoboxReadResponse;
+
+ public InfoboxReadResultImpl(InfoboxReadDataAssocArrayType assocArray) {
+
+ ObjectFactory objectFactory = new ObjectFactory();
+ InfoboxReadResponseType infoboxReadResponseType = objectFactory.createInfoboxReadResponseType();
+
+ infoboxReadResponseType.setAssocArrayData(assocArray);
+
+ this.infoboxReadResponse = infoboxReadResponseType;
+ }
+
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ ObjectFactory objectFactory = new ObjectFactory();
+ JAXBElement response = objectFactory.createInfoboxReadResponse(infoboxReadResponse);
+ writeTo(response, result, templates);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
index ae1f91ce..05986f85 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
@@ -18,6 +18,7 @@ package at.gv.egiz.bku.slcommands.impl;
import javax.xml.bind.JAXBElement;
import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
import at.buergerkarte.namespaces.securitylayer._1.NullOperationResponseType;
import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
@@ -40,8 +41,8 @@ public class NullOperationResultImpl extends SLResultImpl implements NullOperati
}
@Override
- public void writeTo(Result result) {
- writeTo(RESPONSE, result);
+ public void writeTo(Result result, Templates templates) {
+ writeTo(RESPONSE, result, templates);
}
}
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 a79382b6..57309182 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,24 +16,33 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Node;
+import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
import at.gv.egiz.bku.slcommands.SLCommandFactory;
import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slexceptions.SLBindingException;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
/**
* This class serves as an abstract base class for the implementation of a
@@ -72,46 +81,135 @@ public abstract class SLResultImpl implements SLResult {
return resultingMimeType;
}
+ private Marshaller getMarshaller() {
+ try {
+ JAXBContext context = SLCommandFactory.getJaxbContext();
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ return marshaller;
+ } catch (JAXBException e) {
+ log.fatal("Failed to marshall error response.", e);
+ throw new SLRuntimeException("Failed to marshall error response.", e);
+ }
+ }
+
+ private TransformerHandler getTransformerHandler(Templates templates, Result result) throws SLException {
+ try {
+ SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ TransformerHandler transformerHandler = transformerFactory.newTransformerHandler(templates);
+ transformerHandler.setResult(result);
+ return transformerHandler;
+ } catch (TransformerFactoryConfigurationError e) {
+ log.error("Failed to create an instance of SAXTransformerFactory.", e);
+ throw new SLBindingException(2000);
+ } catch (IllegalArgumentException e) {
+ log.error("Failed to set result for transformation.", e);
+ throw new SLBindingException(2000);
+ } catch (TransformerConfigurationException e) {
+ log.info("Failed to create an instance of SAXTransformerFactory.", e);
+ throw new SLBindingException(2008);
+ }
+ }
+
+ @Override
+ public void writeTo(Result result) {
+ writeTo(result, null);
+ }
+
+
/**
- * Writes the given response to the result.
+ * Writes the given response to the SAX result using
+ * the given transform templates.
*
- * @param response the security layer response element
- * @param result the result to marshal the response to
+ * @param response
+ * @param result
+ * @param templates
*/
- @SuppressWarnings("unchecked")
- public void writeTo(JAXBElement response, Result result) {
+ protected void writeTo(JAXBElement> response, Result result, Templates templates) {
+ TransformerHandler transformerHandler = null;
+ if (templates != null) {
+ try {
+ transformerHandler = getTransformerHandler(templates, result);
+ } catch (SLException e) {
+ writeErrorTo(e, result, templates);
+ }
+ }
+
+ Marshaller marshaller = getMarshaller();
try {
- JAXBContext context = SLCommandFactory.getJaxbContext();
- Marshaller marshaller = context.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- marshaller.marshal(response, result);
+ if (transformerHandler != null) {
+ marshaller.marshal(response, transformerHandler);
+ } else {
+ marshaller.marshal(response, result);
+ }
} catch (JAXBException e) {
- // TODO Add throws clause to interface
- log.fatal("Failed to marshall JAXBElement.", e);
- throw new RuntimeException("Failed to marshall JAXBElement.", e);
+ log.info("Failed to marshall " + response.getName() + " result." , e);
+ SLCommandException commandException = new SLCommandException(4000);
+ writeErrorTo(commandException, result, templates);
}
+
+ }
+
+ protected void writeTo(Node node, Result result, Templates templates) {
+ if (templates == null) {
+ try {
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.transform(new DOMSource(node), result);
+ } catch (TransformerConfigurationException e) {
+ log.error("Failed to create Transformer.", e);
+ writeErrorTo(new SLException(4000), result, null);
+ } catch (TransformerException e) {
+ log.error("Failed to transform result.", e);
+ writeErrorTo(new SLException(4000), result, null);
+ }
+ } else {
+ try {
+ Transformer transformer = templates.newTransformer();
+ transformer.transform(new DOMSource(node), result);
+ } catch (TransformerConfigurationException e) {
+ log.info("Failed to create transformer.", e);
+ writeErrorTo(new SLException(2008), result, templates);
+ } catch (TransformerException e) {
+ log.error("Failed to transform result.", e);
+ writeErrorTo(new SLException(2008), result, templates);
+ }
+ }
+
}
+
+ protected void writeErrorTo(SLException slException, Result result, Templates templates) {
+
+ TransformerHandler transformerHandler = null;
+ if (templates != null) {
+ try {
+ transformerHandler = getTransformerHandler(templates, result);
+ } catch (SLException e) {
+ // write the exception thrown instead of the given one
+ slException = e;
+ }
+ }
- /* (non-Javadoc)
- * @see at.gv.egiz.bku.slcommands.SLResult#writeTo(javax.xml.transform.Result, javax.xml.transform.Transformer)
- */
- @Override
- public void writeTo(Result result, Transformer transformer) throws TransformerException {
- // TODO Auto-generated method stub
- // fixxme: wb added for testing purposes to be completed
- // begin hack
- if (transformer == null) {
- writeTo(result);
- return;
+ ObjectFactory factory = new ObjectFactory();
+ ErrorResponseType responseType = factory.createErrorResponseType();
+ responseType.setErrorCode(slException.getErrorCode());
+ responseType.setInfo(slException.getDetailedMsg());
+ JAXBElement response = factory.createErrorResponse(responseType);
+
+ Marshaller marshaller = getMarshaller();
+ try {
+ if (transformerHandler != null) {
+ marshaller.marshal(response, transformerHandler);
+ } else {
+ marshaller.marshal(response, result);
+ }
+ } catch (JAXBException e) {
+ log.fatal("Failed to marshall error result." , e);
+ throw new SLRuntimeException("Failed to marshall error result.");
}
- // just a quick hack to proceed with testing
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- writeTo(new StreamResult(os));
- ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
- transformer.transform(new StreamSource(is), result);
- //end hack
+
}
}
--
cgit v1.2.3
From e21dd5249d5fa19c5619847922cf8cdea95e3145 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Thu, 25 Sep 2008 07:29:47 +0000
Subject: improved robustness of http binding processor
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@70 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../gv/egiz/bku/local/conf/SpringConfigurator.java | 6 +++-
.../gv/egiz/bku/local/conf/defaultConf.properties | 1 +
.../gv/egiz/stal/service/impl/STALServiceImpl.java | 2 +-
BKUOnline/src/main/webapp/META-INF/MANIFEST.MF | 7 ++--
.../at/gv/egiz/bku/binding/BindingProcessor.java | 4 ++-
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 9 ++++-
.../slcommands/impl/InfoboxReadCommandImpl.java | 8 +++--
.../gv/egiz/smcc/utils/SingletonPINProvider.java | 38 ----------------------
.../HTTPURLProtocolHandlerImpl.java | 3 +-
.../at/gv/egiz/idlink/IdentityLinkTransformer.java | 30 ++++++++++++-----
10 files changed, 52 insertions(+), 56 deletions(-)
delete mode 100644 smcc/src/main/java/at/gv/egiz/smcc/utils/SingletonPINProvider.java
(limited to 'bkucommon/src/main')
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 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 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 certificates = getCertificatesFromResponses();
@@ -413,10 +413,12 @@ public class InfoboxReadCommandImpl extends SLCommandImpl>();
}
- 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() {
--
cgit v1.2.3
From 7d3f6235a46f70323defa9910da240e61ca684b3 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Wed, 1 Oct 2008 07:30:55 +0000
Subject: Moved main parts of the configuration to bkucommon
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@78 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKULocal/pom.xml | 48 ++-
.../accesscontroller/SpringSecurityManager.java | 86 ++---
.../at/gv/egiz/bku/local/conf/Configurator.java | 103 ------
.../gv/egiz/bku/local/conf/SpringConfigurator.java | 320 ++++---------------
.../gv/egiz/bku/local/conf/defaultConf.properties | 7 +-
.../src/main/webapp/WEB-INF/applicationContext.xml | 6 +-
BKULocalApp/keystore.ks | Bin 0 -> 5635 bytes
BKULocalApp/pom.xml | 131 ++++++++
.../java/at/gv/egiz/bku/local/app/BKULauncher.java | 222 +++++++++++++
.../src/main/java/at/gv/egiz/bku/local/app/CA.java | 117 +++++++
.../java/at/gv/egiz/bku/local/app/Container.java | 98 ++++++
.../at/gv/egiz/bku/local/defaultConf/template.zip | Bin 0 -> 17759 bytes
.../at/gv/egiz/bku/local/ui/UIMessages.properties | 13 +
.../resources/at/gv/egiz/bku/local/ui/favicon.png | Bin 0 -> 2149 bytes
BKULocalApp/src/main/resources/log4j.properties | 16 +
.../accesscontroller/SpringSecurityManager.java | 3 +-
.../at/gv/egiz/bku/online/conf/Configurator.java | 98 ------
.../egiz/bku/online/conf/SpringConfigurator.java | 209 +++---------
.../gv/egiz/bku/online/webapp/ResultServlet.java | 6 +-
.../egiz/bku/online/webapp/SpringBKUServlet.java | 14 +-
.../gv/egiz/bku/online/conf/defaultConf.properties | 5 +
.../src/main/webapp/WEB-INF/applicationContext.xml | 4 +-
.../java/at/gv/egiz/bku/conf/Configurator.java | 351 +++++++++++++++++++++
pom.xml | 1 +
.../at/gv/egiz/bku/local/ui/TrayIconDialog.java | 2 +-
25 files changed, 1169 insertions(+), 691 deletions(-)
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java
create mode 100644 BKULocalApp/keystore.ks
create mode 100644 BKULocalApp/pom.xml
create mode 100644 BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
create mode 100644 BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java
create mode 100644 BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
create mode 100644 BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip
create mode 100644 BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties
create mode 100644 BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.png
create mode 100644 BKULocalApp/src/main/resources/log4j.properties
delete mode 100644 BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
(limited to 'bkucommon/src/main')
diff --git a/BKULocal/pom.xml b/BKULocal/pom.xml
index 49ec95a0..204fa6b9 100644
--- a/BKULocal/pom.xml
+++ b/BKULocal/pom.xml
@@ -13,7 +13,53 @@
warBKU Local1.0-SNAPSHOT
-
+
+
+
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKULocal
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKULocal
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKULocal
+
+
+
+
+ maven-war-plugin
+ 2.0.2
+
+
+
+ true
+
+
+
+
+
+ ${project.version}-r${buildNumber}
+
+
+
+
+
+
+ org.codehaus.mojo
+ maven-buildnumber-plugin
+ 0.9.6
+
+
+ validate
+
+ create
+
+
+
+
+ false
+ false
+
+
+
+
+
at.gv.egiz
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/accesscontroller/SpringSecurityManager.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/accesscontroller/SpringSecurityManager.java
index b547bf6a..3f50fc78 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/accesscontroller/SpringSecurityManager.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/accesscontroller/SpringSecurityManager.java
@@ -1,65 +1,65 @@
/*
-* 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.
-*/
+ * 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.bku.local.accesscontroller;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import at.gv.egiz.bku.accesscontroller.SecurityManagerFacade;
-import at.gv.egiz.bku.local.conf.Configurator;
+import at.gv.egiz.bku.conf.Configurator;
public class SpringSecurityManager extends SecurityManagerFacade implements
- ResourceLoaderAware {
+ ResourceLoaderAware {
- private ResourceLoader resourceLoader;
+ private ResourceLoader resourceLoader;
- private static Log log = LogFactory.getLog(SpringSecurityManager.class);
+ private static Log log = LogFactory.getLog(SpringSecurityManager.class);
- protected Configurator config;
+ protected Configurator config;
- public void setConfig(Configurator config) {
- this.config = config;
- }
+ public void setConfig(Configurator config) {
+ this.config = config;
+ }
- public void init() {
- String noMatch = config.getProperty("AccessController.acceptNoMatch");
- if (noMatch != null) {
- log.debug("Setting allow now match to: " + noMatch);
- setAllowUnmatched(Boolean.getBoolean(noMatch));
- }
- String policy = config.getProperty("AccessController.policyResource");
- log.info("Loading resource: " + policy);
- try {
- Resource res = resourceLoader.getResource(policy);
- init(res.getInputStream());
- } catch (IOException e) {
- log.error(e);
- }
- }
+ public void init() {
+ String noMatch = config.getProperty("AccessController.acceptNoMatch");
+ if (noMatch != null) {
+ log.debug("Setting allow now match to: " + noMatch);
+ setAllowUnmatched(Boolean.getBoolean(noMatch));
+ }
+ String policy = config.getProperty("AccessController.policyResource");
+ policy = policy.replace("${user.home}", System.getProperty("user.home"));
+ log.info("Loading resource: " + policy);
+ try {
+ Resource res = resourceLoader.getResource(policy);
+ init(res.getInputStream());
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
- @Override
- public void setResourceLoader(ResourceLoader loader) {
- this.resourceLoader = loader;
- }
+ @Override
+ public void setResourceLoader(ResourceLoader loader) {
+ this.resourceLoader = loader;
+ }
}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java
deleted file mode 100644
index 57a0f84f..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java
+++ /dev/null
@@ -1,103 +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.bku.local.conf;
-
-import iaik.security.ecc.provider.ECCProvider;
-import iaik.security.provider.IAIK;
-import iaik.xml.crypto.XSecProvider;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.security.Provider;
-import java.security.Security;
-import java.util.Properties;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.binding.DataUrl;
-import at.gv.egiz.bku.binding.DataUrlConnection;
-import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
-import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
-
-/**
- *
- * TODO currently only the code to get started.
- */
-public abstract class Configurator {
-
- private Log log = LogFactory.getLog(Configurator.class);
-
- private static Configurator instance = new SpringConfigurator();
-
- protected Properties properties;
-
- protected Configurator() {
- }
-
- public static Configurator getInstance() {
- return instance;
- }
-
- protected void configUrlConnections() {
- HttpsURLConnection.setFollowRedirects(false);
- HttpURLConnection.setFollowRedirects(false);
- }
-
- protected void configureProviders() {
- log.debug("Registering security providers");
- Security.insertProviderAt(new IAIK(), 1);
- Security.insertProviderAt(new ECCProvider(false), 2);
- Security.addProvider(new STALProvider());
- XSecProvider.addAsProvider(false);
- StringBuilder sb = new StringBuilder();
- sb.append("Registered providers: ");
- int i = 1;
- for (Provider prov : Security.getProviders()) {
- sb.append((i++) + ". : " + prov);
- }
- log.debug(sb.toString());
- }
-
- protected void configViewer() {
- String bv = properties.getProperty("ValidateHashDataInputs");
- if (bv != null) {
- DataObject.enableHashDataInputValidation(Boolean.parseBoolean(bv));
- } else {
- log.warn("ValidateHashDataInputs not set, falling back to default");
- }
- }
-
- public void configure() {
- configureProviders();
- configUrlConnections();
- configViewer();
- }
-
- public void setConfiguration(Properties props) {
- this.properties = props;
- }
-
- public String getProperty(String key) {
- if (properties != null) {
- return properties.getProperty(key);
- }
- return null;
- }
-}
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 46668667..bcb96c2f 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
@@ -19,41 +19,8 @@ package at.gv.egiz.bku.local.conf;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.Security;
-import java.security.cert.CertPathBuilder;
-import java.security.cert.CertStore;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CollectionCertStoreParameters;
-import java.security.cert.LDAPCertStoreParameters;
-import java.security.cert.PKIXBuilderParameters;
-import java.security.cert.PKIXCertPathBuilderResult;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509CertSelector;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
+import java.io.InputStream;
import java.util.Properties;
-import java.util.Set;
-
-import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.LdapReferralException;
-import javax.net.ssl.CertPathTrustManagerParameters;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.ManagerFactoryParameters;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -61,8 +28,7 @@ import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
-import at.gv.egiz.bku.binding.DataUrl;
-import at.gv.egiz.bku.binding.DataUrlConnection;
+import at.gv.egiz.bku.conf.Configurator;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
public class SpringConfigurator extends Configurator implements
@@ -73,15 +39,16 @@ public class SpringConfigurator extends Configurator implements
private ResourceLoader resourceLoader;
public SpringConfigurator() {
- File configDir = new File(System.getProperty("user.home") + "/.bku/conf");
- if (configDir.exists()) {
- log.debug("Found existing config directory: " + configDir);
- } else {
- log.info("Config dir not existing, creating new");
- if (!configDir.mkdirs()) {
- log.error("Cannot create directory: " + configDir);
- }
- }
+ // File configDir = new File(System.getProperty("user.home") +
+ // "/.bku/conf");
+ // if (configDir.exists()) {
+ // log.debug("Found existing config directory: " + configDir);
+ // } else {
+ // log.info("Config dir not existing, creating new");
+ // if (!configDir.mkdirs()) {
+ // log.error("Cannot create directory: " + configDir);
+ // }
+ // }
}
public void setResource(Resource resource) {
@@ -99,248 +66,75 @@ public class SpringConfigurator extends Configurator implements
}
}
- public void configureVersion() {
- Properties p = new Properties();
- try {
- p.load(resourceLoader.getResource("META-INF/MANIFEST.MF")
- .getInputStream());
- String version = p.getProperty("Implementation-Build");
- properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
- "citizen-card-environment/1.2 MOCCA " + version);
- DataUrl.setConfiguration(properties);
- log.debug("Setting user agent to: "
- + properties.getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
- } catch (IOException e) {
- log.error(e);
- }
- }
-
+ @Override
public void configure() {
+ if (properties == null) {
+ defaultInit();
+ }
super.configure();
- configureSSL();
- configureVersion();
- configureNetwork();
}
- public void configureNetwork() {
- String proxy = getProperty("HTTPProxyHost");
- String portString = getProperty("HTTPProxyPort");
- if ((proxy == null) || (proxy.equals(""))) {
- log.info("No proxy configured");
- } else {
- 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);
+ public void defaultInit() {
+ Properties props = new Properties();
+ try {
+ props.load(new FileInputStream(System.getProperty("user.home")
+ + "/.mocca/war/mocca.war"));
+ super.setConfiguration(props);
+ } catch (IOException e) {
+ log.error("Cannot load config", e);
}
}
- private Set getCACerts() throws IOException,
- CertificateException {
- Set caCerts = new HashSet();
- String caDirectory = getProperty("SSL.caDirectory");
- if (caDirectory != null) {
- Resource caDirRes = resourceLoader.getResource(caDirectory);
- File caDir = caDirRes.getFile();
- if (!caDir.isDirectory()) {
- log.error("Expecting directory as SSL.caDirectory parameter");
- throw new SLRuntimeException(
- "Expecting directory as SSL.caDirectory parameter");
- }
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- for (File f : caDir.listFiles()) {
- try {
- FileInputStream fis = new FileInputStream(f);
- X509Certificate cert = (X509Certificate) cf.generateCertificate(fis);
- fis.close();
- log.debug("Adding trusted cert " + cert.getSubjectDN());
- caCerts.add(new TrustAnchor(cert, null));
- } catch (Exception e) {
- log.error("Cannot add trusted ca", e);
- }
- }
- return caCerts;
-
- } else {
- log.warn("No CA certificates configured");
- }
- return null;
+ @Override
+ public void setResourceLoader(ResourceLoader loader) {
+ this.resourceLoader = loader;
}
- private List getCertstore() throws IOException,
- CertificateException, InvalidAlgorithmParameterException,
- NoSuchAlgorithmException {
- List resultList = new ArrayList();
- String certDirectory = getProperty("SSL.certDirectory");
- if (certDirectory != null) {
- Resource certDirRes = resourceLoader.getResource(certDirectory);
-
- File certDir = certDirRes.getFile();
+ private File getDirectory(String property) {
+ property = property
+ .replace("${user.home}", System.getProperty("user.home"));
+ if (property != null) {
+ Resource certDirRes = resourceLoader.getResource(property);
+ File certDir;
+ try {
+ certDir = certDirRes.getFile();
+ } catch (IOException e) {
+ log.error("Cannot get cert directory", e);
+ throw new SLRuntimeException(e);
+ }
if (!certDir.isDirectory()) {
log.error("Expecting directory as SSL.certDirectory parameter");
throw new SLRuntimeException(
"Expecting directory as SSL.certDirectory parameter");
}
- List certCollection = new LinkedList();
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- for (File f : certDir.listFiles()) {
- try {
- FileInputStream fis = new FileInputStream(f);
- X509Certificate cert = (X509Certificate) cf.generateCertificate(fis);
- certCollection.add(cert);
- fis.close();
- log
- .trace("Added following cert to certstore: "
- + cert.getSubjectDN());
- } catch (Exception ex) {
- log.error("Cannot add certificate", ex);
- }
- }
- CollectionCertStoreParameters csp = new CollectionCertStoreParameters(
- certCollection);
- resultList.add(CertStore.getInstance("Collection", csp));
- log.info("Added collection certstore");
- } else {
- log.warn("No certstore directory configured");
- }
- String ldapHost = getProperty("SSL.ldapServer");
- if ((ldapHost != null) && (!"".equals(ldapHost))) {
- String ldapPortString = getProperty("SSL.ldapPort");
- int ldapPort = 389;
- if (ldapPortString != null) {
- try {
- ldapPort = Integer.parseInt(ldapPortString);
- } catch (NumberFormatException nfe) {
- log.error("Invalid ldap port, using default 389");
- }
- } else {
- log.warn("ldap port not specified, using default 389");
- }
- LDAPCertStoreParameters ldapParams = new LDAPCertStoreParameters(
- ldapHost, ldapPort);
- resultList.add(CertStore.getInstance("LDAP", ldapParams));
- log.info("Added LDAP certstore");
+ return certDir;
}
- return resultList;
- }
-
- public void configureSSL() {
- Set caCerts = null;
- try {
- caCerts = getCACerts();
- } catch (Exception e1) {
- log.error("Cannot load CA certificates", e1);
- }
- List certStoreList = null;
- try {
- certStoreList = getCertstore();
- } catch (Exception e1) {
- log.error("Cannot load certstore certificates", e1);
- }
- String aia = getProperty("SSL.useAIA");
- if ((aia == null) || (aia.equals(""))) {
- System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
- } else {
- System.setProperty("com.sun.security.enableAIAcaIssuers", aia);
- }
- String lifetime = getProperty("SSL.cache.lifetime");
- if ((lifetime == null) || (lifetime.equals(""))) {
- System.setProperty("sun.security.certpath.ldap.cache.lifetime", "0");
- } else {
- System.setProperty("sun.security.certpath.ldap.cache.lifetime", lifetime);
- }
- X509CertSelector selector = new X509CertSelector();
- PKIXBuilderParameters pkixParams;
- try {
- pkixParams = new PKIXBuilderParameters(caCerts, selector);
- if ((getProperty("SSL.doRevocationChecking") != null)
- && (Boolean.valueOf(getProperty("SSL.doRevocationChecking")))) {
- log.info("Enable revocation checking");
- System.setProperty("com.sun.security.enableCRLDP", "true");
- Security.setProperty("ocsp.enable", "true");
- } else {
- log.warn("Revocation checking disabled");
- }
- for (CertStore cs : certStoreList) {
- pkixParams.addCertStore(cs);
- }
- ManagerFactoryParameters trustParams = new CertPathTrustManagerParameters(
- pkixParams);
- TrustManagerFactory trustFab;
- trustFab = TrustManagerFactory.getInstance("PKIX");
- trustFab.init(trustParams);
- KeyManager[] km = null;
- SSLContext sslCtx = SSLContext
- .getInstance(getProperty("SSL.sslProtocol"));
- String disableAll = getProperty("SSL.disableAllChecks");
- if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
- log.warn("--------------------------------------");
- log.warn(" Disabling SSL Certificate Validation ");
- log.warn("--------------------------------------");
-
- sslCtx.init(km, new TrustManager[] { new MyTrustManager(caCerts,
- certStoreList) }, null);
- } else {
- sslCtx.init(km, trustFab.getTrustManagers(), null);
- }
- HttpsURLConnection.setDefaultSSLSocketFactory(sslCtx.getSocketFactory());
- } catch (Exception e) {
- log.error("Cannot configure SSL", e);
- }
- String disableAll = getProperty("SSL.disableAllChecks");
- if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
- log.warn("---------------------------------");
- log.warn(" Disabling Hostname Verification ");
- log.warn("---------------------------------");
- HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- });
- }
- }
-
- @Override
- public void setResourceLoader(ResourceLoader loader) {
- this.resourceLoader = loader;
- }
-}
-
-class MyTrustManager implements X509TrustManager {
- private static Log log = LogFactory.getLog(MyTrustManager.class);
- private X509Certificate[] trustedCerts;
+ return null;
- public MyTrustManager(Set caCerts, List cs) {
- trustedCerts = new X509Certificate[caCerts.size()];
- int i = 0;
- for (Iterator it = caCerts.iterator(); it.hasNext();) {
- TrustAnchor ta = it.next();
- trustedCerts[i++] = ta.getTrustedCert();
- }
}
@Override
- public void checkClientTrusted(X509Certificate[] arg0, String arg1)
- throws CertificateException {
- log.error("Did not expect this method to get called");
- throw new CertificateException("Method not implemented");
+ protected File getCADir() {
+ String caDirectory = getProperty("SSL.caDirectory");
+ return getDirectory(caDirectory);
}
@Override
- public void checkServerTrusted(X509Certificate[] certs, String arg1)
- throws CertificateException {
- log.warn("-------------------------------------");
- log.warn("SSL Certificate Validation Disabled !");
- log.warn("-------------------------------------");
+ protected File getCertDir() {
+ String certDirectory = getProperty("SSL.certDirectory");
+ return getDirectory(certDirectory);
}
@Override
- public X509Certificate[] getAcceptedIssuers() {
- return trustedCerts;
+ protected InputStream getManifest() {
+ Resource r = resourceLoader.getResource("META-INF/MANIFEST.MF");
+ if ((r != null) && r.isReadable()) {
+ try {
+ return r.getInputStream();
+ } catch (IOException e) {
+ log.error("Cannot read manifest data:" + e);
+ }
+ }
+ return null;
}
-
}
\ No newline at end of file
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 29bdd1ed..8ae5bf6d 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
@@ -51,10 +51,11 @@ SSL.disableAllChecks=false
# ------------ END SSL Config --------------------
ValidateHashDataInputs=true
+AppletTimeout=300000
-HTTPProxyHost=
-HTTPProxyPort=
-DefaultSocketTimeout=200
+#HTTPProxyHost=
+#HTTPProxyPort=
+#DefaultSocketTimeout=200
diff --git a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
index c6a5088a..a4003a2a 100644
--- a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
@@ -21,6 +21,7 @@
+
@@ -47,10 +48,11 @@
-
-
+
diff --git a/BKULocalApp/keystore.ks b/BKULocalApp/keystore.ks
new file mode 100644
index 00000000..824c3a40
Binary files /dev/null and b/BKULocalApp/keystore.ks differ
diff --git a/BKULocalApp/pom.xml b/BKULocalApp/pom.xml
new file mode 100644
index 00000000..e2d17d7c
--- /dev/null
+++ b/BKULocalApp/pom.xml
@@ -0,0 +1,131 @@
+
+
+ bku
+ at.gv.egiz
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ at.gv.egiz.bku
+ BKULocalApp
+
+ 1.0-SNAPSHOT
+
+
+
+
+
+ maven-compiler-plugin
+ org.apache.maven.plugins
+ 2.0.2
+
+ 1.6
+ 1.6
+ true
+ true
+
+
+
+
+
+
+ maven-dependency-plugin
+
+
+
+ copywar
+
+ copy
+
+
+
+
+ at.gv.egiz
+ BKULocal
+ 1.0-SNAPSHOT
+ war
+
+
+
+ ${project.build.directory}/classes
+
+
+
+
+ unpack-dependencies
+
+ unpack-dependencies
+
+
+ javax/xml/crypto/**, demo/**,
+ junit/**, w3/**, org/etsi/**, META-INF/**
+ ${project.build.directory}/classes
+ true
+ true
+
+
+
+
+
+
+
+ maven-jar-plugin
+
+
+
+ sign
+
+
+
+
+
+ false
+ false
+
+ false
+ true
+
+
+ test-applet signer
+ ./keystore.ks
+ storepass
+ keypass
+ true
+
+
+
+
+
+
+
+
+ commons-logging
+ commons-logging
+ 1.1.1
+ compile
+
+
+ at.gv.egiz
+ BKULocal
+ 1.0-SNAPSHOT
+ war
+
+
+ utils
+ at.gv.egiz
+ 1.0-SNAPSHOT
+ compile
+
+
+ commons-cli
+ commons-cli
+ 1.0
+
+
+ org.mortbay.jetty
+ jetty
+ 6.1.10
+
+
+
+
\ No newline at end of file
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
new file mode 100644
index 00000000..091843e1
--- /dev/null
+++ b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
@@ -0,0 +1,222 @@
+package at.gv.egiz.bku.local.app;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.KeyStore;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.local.ui.BKUControllerInterface;
+import at.gv.egiz.bku.local.ui.TrayIconDialog;
+import at.gv.egiz.bku.utils.StreamUtil;
+
+public class BKULauncher implements BKUControllerInterface {
+ private static Log log = LogFactory.getLog(BKULauncher.class);
+
+ private ResourceBundle resourceBundle = null;
+ private Container server;
+
+ private void startUpServer() throws Exception {
+ server = new Container();
+ // XmlConfiguration xcfg = new XmlConfiguration(getClass().getClassLoader()
+ // .getResourceAsStream("at/gv/egiz/bku/local/app/jetty.xml"));
+ // xcfg.configure(server);
+ server.init();
+ server.start();
+ }
+
+ private void initTrayIcon() {
+ Locale loc = Locale.getDefault();
+ try {
+ resourceBundle = ResourceBundle.getBundle(
+ "at/gv/egiz/bku/local/ui/UIMessages", loc);
+ } catch (MissingResourceException mx) {
+ resourceBundle = ResourceBundle.getBundle(
+ "at/gv/egiz/bku/local/ui/UIMessages", Locale.ENGLISH);
+ }
+ TrayIconDialog.getInstance().init(resourceBundle);
+ TrayIconDialog.getInstance().setShutdownHook(this);
+ TrayIconDialog.getInstance().displayInfo("Greetings.Caption",
+ "Greetings.Message");
+ }
+
+ private void initFinished() {
+ try {
+ server.join();
+ } catch (InterruptedException e) {
+ log.info(e);
+ }
+ }
+
+ private void copyDirs(File srcDir, File dstDir) {
+ for (File cf : srcDir.listFiles()) {
+ File of = new File(dstDir, cf.getName());
+ if (cf.isDirectory()) {
+ log.debug("Creating directory: " + of);
+ of.mkdir();
+ copyDirs(cf, of);
+ } else {
+ log.debug("Writing file: " + of);
+ try {
+ FileInputStream fis = new FileInputStream(cf);
+ FileOutputStream fos = new FileOutputStream(of);
+ StreamUtil.copyStream(fis, fos);
+ fis.close();
+ fos.close();
+ } catch (IOException e) {
+ log.error("Cannot copy default configuration", e);
+ }
+ }
+ }
+ }
+
+ private void unzip(File zipfile) throws IOException {
+ File dir = zipfile.getParentFile();
+ ZipFile zipFile = new ZipFile(zipfile);
+ Enumeration extends ZipEntry> entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ ZipEntry entry = entries.nextElement();
+ File eF = new File(dir, entry.getName());
+ if (entry.isDirectory()) {
+ eF.mkdirs();
+ continue;
+ }
+ File f = new File(eF.getParent());
+ f.mkdirs();
+ StreamUtil.copyStream(zipFile.getInputStream(entry),
+ new FileOutputStream(eF));
+ }
+ zipFile.close();
+ }
+
+ private void checkConfig(String[] args) {
+ CommandLineParser parser = new PosixParser();
+ Options options = new Options();
+ options.addOption("c", true, "the configuration's base directory");
+ options.addOption("h", false, "print this message");
+ try {
+ File cfgDir = new File(System.getProperty("user.home") + "/.mocca/conf");
+ CommandLine cmd = parser.parse(options, args);
+ if (cmd.hasOption("h")) {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("BKULauncher", options);
+ System.exit(0);
+ }
+
+ if (cmd.hasOption("c")) {
+ cfgDir = new File(cmd.getOptionValue("c"));
+ }
+ log.debug("using config directory: " + cfgDir);
+ if (cfgDir.exists() && cfgDir.isFile()) {
+ log.error("Configuration directory must not be a file");
+ }
+ if (!cfgDir.exists()) {
+ log.debug("Creating config directory: " + cfgDir);
+ cfgDir.mkdirs();
+ try {
+ InputStream is = getClass().getClassLoader().getResourceAsStream(
+ "at/gv/egiz/bku/local/defaultConf/template.zip");
+ OutputStream os = new FileOutputStream(new File(cfgDir,
+ "template.zip"));
+ StreamUtil.copyStream(is, os);
+ os.close();
+ unzip(new File(cfgDir, "template.zip"));
+ } catch (IOException iox) {
+ log.error("Cannot create user directory", iox);
+ return;
+ }
+ CA ca = new CA();
+ char[] password = "changeMe".toCharArray();
+ KeyStore ks = ca.generateKeyStore(password);
+ if (ks != null) {
+ File ksdir = new File(cfgDir, "keystore");
+ ksdir.mkdirs();
+ FileOutputStream fos;
+ try {
+ fos = new FileOutputStream(new File(ksdir, "keystore.ks"));
+ ks.store(fos, password);
+ fos.close();
+ } catch (Exception e) {
+ log.error("Cannot store keystore", e);
+ }
+ } else {
+ log.error("Cannot create ssl certificate");
+ }
+ }
+ } catch (ParseException e1) {
+ log.error(e1);
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("BKULauncher", options);
+ System.exit(0);
+ }
+ }
+
+ public void jwsHack() {
+ InputStream is = getClass().getClassLoader().getResourceAsStream(
+ "BKULocal-1.0-SNAPSHOT.war");
+ File f = new File(System.getProperty("user.home") + "/.mocca/war");
+ f.mkdirs();
+ try {
+ OutputStream os = new FileOutputStream(new File(f, "mocca.war"));
+ StreamUtil.copyStream(is, os);
+ os.close();
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ try {
+ BKULauncher launcher = new BKULauncher();
+ //launcher.jwsHack();
+ launcher.checkConfig(args);
+ launcher.startUpServer();
+ launcher.initTrayIcon();
+ launcher.initFinished();
+ } catch (Exception e) {
+ log.fatal("Cannot launch BKU", e);
+ System.exit(-1000);
+ }
+
+ }
+
+ public void shutDown() {
+ log.info("Shutting down server");
+ if ((server != null) && (server.isRunning())) {
+ try {
+ if (server.isRunning()) {
+ server.stop();
+ }
+ } catch (Exception e) {
+ log.debug(e.toString());
+ } finally {
+ if (server.isRunning()) {
+ server.destroy();
+ }
+ }
+ }
+ System.exit(0);
+ }
+
+}
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java
new file mode 100644
index 00000000..31d21ef7
--- /dev/null
+++ b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java
@@ -0,0 +1,117 @@
+package at.gv.egiz.bku.local.app;
+
+import iaik.asn1.ObjectID;
+import iaik.asn1.structures.AlgorithmID;
+import iaik.asn1.structures.Name;
+import iaik.x509.X509Certificate;
+import iaik.x509.extensions.BasicConstraints;
+import iaik.x509.extensions.KeyUsage;
+
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.GeneralSecurityException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Random;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class CA {
+ private final static Log log = LogFactory.getLog(CA.class);
+
+ private KeyPair caKeyPair;
+ private X509Certificate caCert;
+
+ private KeyPair serverKeyPair;
+ private X509Certificate serverCert;
+
+ public CA() {
+ }
+
+ private KeyPair generateKeyPair() throws NoSuchAlgorithmException {
+ KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
+ gen.initialize(2048);
+ return gen.generateKeyPair();
+ }
+
+ private void generateCA() throws GeneralSecurityException {
+ log.debug("Generating CA certificate");
+ Name subject = new Name();
+ subject.addRDN(ObjectID.country, "AT");
+ subject.addRDN(ObjectID.organization, "MOCCA");
+ subject.addRDN(ObjectID.organizationalUnit, "MOCCA-CA");
+
+ caKeyPair = generateKeyPair();
+ caCert = new X509Certificate();
+ caCert.setSerialNumber(new BigInteger(20, new Random()));
+ caCert.setSubjectDN(subject);
+ caCert.setPublicKey(caKeyPair.getPublic());
+ caCert.setIssuerDN(subject);
+
+ caCert.addExtension(new BasicConstraints(true));
+ caCert.addExtension(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign
+ | KeyUsage.digitalSignature));
+
+ GregorianCalendar date = new GregorianCalendar();
+ date.add(Calendar.HOUR_OF_DAY, -1);
+ caCert.setValidNotBefore(date.getTime());
+ date.add(Calendar.YEAR, 7);
+ caCert.setValidNotAfter(date.getTime());
+ caCert.sign(AlgorithmID.sha1WithRSAEncryption, caKeyPair.getPrivate());
+ log.debug("Successfully signed CA certificate");
+ }
+
+ private void generateServerCert() throws GeneralSecurityException {
+ log.debug("Generating SSL certificate");
+ Name subject = new Name();
+ subject.addRDN(ObjectID.country, "AT");
+ subject.addRDN(ObjectID.organization, "MOCCA");
+ try {
+ subject.addRDN(ObjectID.commonName, InetAddress.getLocalHost()
+ .getHostName());
+ } catch (UnknownHostException e) {
+ subject.addRDN(ObjectID.commonName, "localhost");
+ }
+ serverKeyPair = generateKeyPair();
+ serverCert = new X509Certificate();
+ serverCert.setSerialNumber(new BigInteger(20, new Random()));
+ serverCert.setSubjectDN(subject);
+ serverCert.setPublicKey(serverKeyPair.getPublic());
+ serverCert.setIssuerDN(caCert.getSubjectDN());
+
+ serverCert.addExtension(new BasicConstraints(false));
+ serverCert.addExtension(new KeyUsage(KeyUsage.keyEncipherment
+ | KeyUsage.digitalSignature));
+
+ GregorianCalendar date = new GregorianCalendar();
+ date.add(Calendar.HOUR_OF_DAY, -1);
+ serverCert.setValidNotBefore(date.getTime());
+ date.add(Calendar.YEAR, 7);
+ date.add(Calendar.HOUR_OF_DAY, -1);
+ serverCert.setValidNotAfter(date.getTime());
+ serverCert.sign(AlgorithmID.sha1WithRSAEncryption, caKeyPair.getPrivate());
+ log.debug("Successfully signed server certificate");
+ caKeyPair = null;
+ }
+
+ public KeyStore generateKeyStore(char[] password) {
+ try {
+ generateCA();
+ generateServerCert();
+ KeyStore ks = KeyStore.getInstance("JKS");
+ ks.load(null, null);
+ ks.setKeyEntry("server", serverKeyPair.getPrivate(), password, new X509Certificate[]{serverCert, caCert});
+ return ks;
+ } catch (Exception e) {
+ log.error("Cannot generate certificate", e);
+ }
+ return null;
+ }
+
+}
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
new file mode 100644
index 00000000..690639f4
--- /dev/null
+++ b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
@@ -0,0 +1,98 @@
+package at.gv.egiz.bku.local.app;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.DefaultHandler;
+import org.mortbay.jetty.handler.HandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.webapp.WebAppClassLoader;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.thread.QueuedThreadPool;
+
+public class Container {
+
+ private static Log log = LogFactory.getLog(Container.class);
+
+ private Server server;
+
+ public Container() {
+ }
+
+ public void init() {
+ Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
+ log.debug("-----------------> "+ClassLoader.getSystemClassLoader());
+ server = new Server();
+ QueuedThreadPool qtp = new QueuedThreadPool();
+ qtp.setMaxThreads(5);
+ qtp.setMinThreads(2);
+ qtp.setLowThreads(0);
+ server.setThreadPool(qtp);
+ server.setStopAtShutdown(true);
+ server.setGracefulShutdown(3000);
+
+ SelectChannelConnector connector = new SelectChannelConnector();
+ connector.setPort(3495);
+ connector.setAcceptors(1);
+ connector.setConfidentialPort(3496);
+
+ SslSocketConnector sslConnector = new SslSocketConnector();
+ sslConnector.setPort(3496);
+ sslConnector.setAcceptors(1);
+ sslConnector.setKeystore(System.getProperty("user.home")
+ + "/.mocca/conf/keystore/keystore.ks");
+ sslConnector.setPassword("changeMe");
+ sslConnector.setKeyPassword("changeMe");
+
+ server.setConnectors(new Connector[] { connector, sslConnector });
+ HandlerCollection handlers = new HandlerCollection();
+
+ WebAppContext webappcontext = new WebAppContext();
+ webappcontext.setContextPath("/");
+ webappcontext.setExtractWAR(false);
+
+ File tmpDir = new File(System.getProperty("user.home") + "/.mocca/tmp");
+ // tmpDir.mkdirs();
+ // webappcontext.setTempDirectory(tmpDir);
+ try {
+ File f = new File(System.getProperty("user.home")
+ + "/.mocca/war/mocca.war");
+ log.debug("Deploying war: " + f.getCanonicalPath());
+ if (!f.exists()) {
+ log.error("WAR file does not exist, cannot run MOCCA");
+ }
+ webappcontext.setWar(f.getParent());
+ } catch (IOException e) {
+ log.error(e);
+ }
+ handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
+
+ server.setHandler(handlers);
+ }
+
+ public void start() throws Exception {
+ server.start();
+ }
+
+ public boolean isRunning() {
+ return server.isRunning();
+ }
+
+ public void stop() throws Exception {
+ server.stop();
+ }
+
+ public void destroy() {
+ server.destroy();
+ }
+
+ public void join() throws InterruptedException {
+ server.join();
+ }
+}
\ No newline at end of file
diff --git a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip
new file mode 100644
index 00000000..f57e8930
Binary files /dev/null and b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip differ
diff --git a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties
new file mode 100644
index 00000000..873d03ef
--- /dev/null
+++ b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties
@@ -0,0 +1,13 @@
+#-------- tray icon messages -------
+TrayMenu.Tooltip=MOCCA
+TrayMenu.Shutdown=MOCCA Beenden
+
+Greetings.Message=MOCCA up and running
+Greetings.Caption=MOCCA Started
+
+Message.RequestCaption=New Request
+Message.InfoboxReadRequest=Reading Infobox
+Message.SecureSignatureKeypair=Reading secure signature certificate
+Message.CertifiedKeypair=Reading certified certificate
+Message.IdentityLink=Reading Identitylink
+Message.SignRequest=Creating Signature
\ No newline at end of file
diff --git a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.png b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.png
new file mode 100644
index 00000000..2d0276de
Binary files /dev/null and b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.png differ
diff --git a/BKULocalApp/src/main/resources/log4j.properties b/BKULocalApp/src/main/resources/log4j.properties
new file mode 100644
index 00000000..fcdcb8e8
--- /dev/null
+++ b/BKULocalApp/src/main/resources/log4j.properties
@@ -0,0 +1,16 @@
+# loglever DEBUG, appender STDOUT
+log4j.rootLogger=TRACE, STDOUT, file
+
+# STDOUT appender
+log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
+log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
+#log4j.appender.STDOUT.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n
+#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+log4j.appender.STDOUT.layout.ConversionPattern=%-5p |%d | %t | %c %x- %m%n
+
+### FILE appender
+log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.file.datePattern='.'yyyy-MM-dd
+log4j.appender.file.File=${user.home}/.mocca/logs/mocca.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
\ No newline at end of file
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
index 3d0df8c4..5795478b 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/accesscontroller/SpringSecurityManager.java
@@ -25,7 +25,7 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import at.gv.egiz.bku.accesscontroller.SecurityManagerFacade;
-import at.gv.egiz.bku.online.conf.Configurator;
+import at.gv.egiz.bku.conf.Configurator;
public class SpringSecurityManager extends SecurityManagerFacade implements
ResourceLoaderAware {
@@ -60,5 +60,4 @@ public class SpringSecurityManager extends SecurityManagerFacade implements
public void setResourceLoader(ResourceLoader loader) {
this.resourceLoader = loader;
}
-
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
deleted file mode 100644
index c09abcc1..00000000
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
+++ /dev/null
@@ -1,98 +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.bku.online.conf;
-
-import iaik.security.ecc.provider.ECCProvider;
-import iaik.security.provider.IAIK;
-import iaik.xml.crypto.XSecProvider;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.security.Provider;
-import java.security.Security;
-import java.util.Properties;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.binding.DataUrl;
-import at.gv.egiz.bku.binding.DataUrlConnection;
-import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
-import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
-
-/**
- *
- * TODO currently only the code to get started.
- */
-public abstract class Configurator {
-
- private Log log = LogFactory.getLog(Configurator.class);
-
- private static Configurator instance = new SpringConfigurator();
-
- protected Properties properties;
-
- protected Configurator() {
- }
-
- public static Configurator getInstance() {
- return instance;
- }
-
- protected void configUrlConnections() {
- HttpsURLConnection.setFollowRedirects(false);
- HttpURLConnection.setFollowRedirects(false);
- }
-
- protected void configureProviders() {
- log.debug("Registering security providers");
- Security.insertProviderAt(new IAIK(), 1);
- Security.insertProviderAt(new ECCProvider(false), 2);
- Security.addProvider(new STALProvider());
- XSecProvider.addAsProvider(false);
- StringBuilder sb = new StringBuilder();
- sb.append("Registered providers: ");
- int i = 1;
- for (Provider prov : Security.getProviders()) {
- sb.append((i++) + ". : " + prov);
- }
- log.debug(sb.toString());
- }
-
- protected void configViewer() {
- DataObject.enableHashDataInputValidation(Boolean.parseBoolean(properties.getProperty("ValidateHashDataInputs")));
- }
-
- public void configure() {
- configureProviders();
- configUrlConnections();
- configViewer();
- }
-
- public void setConfiguration(Properties props) {
- this.properties = props;
- }
-
- public String getProperty(String key) {
- if (properties != null) {
- return properties.getProperty(key);
- }
- return null;
- }
-}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
index d213dd36..a369d829 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
@@ -17,31 +17,9 @@
package at.gv.egiz.bku.online.conf;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.Security;
-import java.security.cert.CertStore;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CollectionCertStoreParameters;
-import java.security.cert.PKIXBuilderParameters;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509CertSelector;
-import java.security.cert.X509Certificate;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
+import java.io.InputStream;
import java.util.Properties;
-import java.util.Set;
-
-import javax.net.ssl.CertPathTrustManagerParameters;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.ManagerFactoryParameters;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,8 +27,8 @@ import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
-import at.gv.egiz.bku.binding.DataUrl;
-import at.gv.egiz.bku.binding.DataUrlConnection;
+import at.gv.egiz.bku.conf.Configurator;
+import at.gv.egiz.bku.online.webapp.SpringBKUServlet;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
import at.gv.egiz.stal.service.impl.RequestBrokerSTALFactory;
@@ -76,41 +54,8 @@ public class SpringConfigurator extends Configurator implements
}
}
- public void configureVersion() {
- Properties p = new Properties();
- try {
- p.load(resourceLoader.getResource("META-INF/MANIFEST.MF")
- .getInputStream());
- String version = p.getProperty("Implementation-Build");
- properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
- "citizen-card-environment/1.2 MOCCA " + version);
- DataUrl.setConfiguration(properties);
- log.debug("Setting user agent to: "
- + properties.getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
- } catch (IOException e) {
- log.error(e);
- }
- }
-
- public void configure() {
- super.configure();
- configureSSL();
- configureVersion();
- configureNetwork();
- }
-
public void configureNetwork() {
- String proxyHost = getProperty("HTTPProxyHost");
- String proxyPort = getProperty("HTTPProxyPort");
- if (proxyPort == null) {
- proxyPort = "80";
- }
- if (proxyHost != null) {
- log.debug("Setting proxy server to: " + proxyHost + ":" + proxyPort);
- System.setProperty("http.proxyHost", proxyHost);
- System.setProperty("http.proxyPort", proxyPort);
- }
- log.debug("No proxy specified");
+ super.configureNetwork();
String appletTimeout = getProperty("AppletTimeout");
if ((appletTimeout != null)) {
try {
@@ -122,128 +67,60 @@ public class SpringConfigurator extends Configurator implements
}
}
-
- private Set getCACerts() throws IOException,
- CertificateException {
- Set caCerts = new HashSet();
- String caDirectory = getProperty("SSL.caDirectory");
- if (caDirectory != null) {
- Resource caDirRes = resourceLoader.getResource(caDirectory);
- File caDir = caDirRes.getFile();
- if (!caDir.isDirectory()) {
- log.error("Expecting directory as SSL.caDirectory parameter");
- throw new SLRuntimeException(
- "Expecting directory as SSL.caDirectory parameter");
- }
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- for (File f : caDir.listFiles()) {
- try {
- FileInputStream fis = new FileInputStream(f);
- X509Certificate cert = (X509Certificate) cf.generateCertificate(fis);
- fis.close();
- log.debug("Adding trusted cert " + cert.getSubjectDN());
- caCerts.add(new TrustAnchor(cert, null));
- } catch (Exception e) {
- log.error("Cannot add trusted ca", e);
- }
- }
- return caCerts;
-
- } else {
- log.warn("No CA certificates configured");
- }
- return null;
+
+ public void configure() {
+ super.configure();
+ SpringBKUServlet.setConfigurator(this);
}
- private CertStore getCertstore() throws IOException, CertificateException,
- InvalidAlgorithmParameterException, NoSuchAlgorithmException {
- String certDirectory = getProperty("SSL.certDirectory");
- if (certDirectory != null) {
- Resource certDirRes = resourceLoader.getResource(certDirectory);
+ @Override
+ public void setResourceLoader(ResourceLoader loader) {
+ this.resourceLoader = loader;
+ }
- File certDir = certDirRes.getFile();
+ private File getDirectory(String property) {
+ if (property != null) {
+ Resource certDirRes = resourceLoader.getResource(property);
+ File certDir;
+ try {
+ certDir = certDirRes.getFile();
+ } catch (IOException e) {
+ log.error("Cannot get cert directory", e);
+ throw new SLRuntimeException(e);
+ }
if (!certDir.isDirectory()) {
log.error("Expecting directory as SSL.certDirectory parameter");
throw new SLRuntimeException(
"Expecting directory as SSL.certDirectory parameter");
}
- List certCollection = new LinkedList();
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- for (File f : certDir.listFiles()) {
- try {
- FileInputStream fis = new FileInputStream(f);
- X509Certificate cert = (X509Certificate) cf.generateCertificate(fis);
- certCollection.add(cert);
- fis.close();
- log
- .trace("Added following cert to certstore: "
- + cert.getSubjectDN());
- } catch (Exception ex) {
- log.error("Cannot add certificate", ex);
- }
- }
- CollectionCertStoreParameters csp = new CollectionCertStoreParameters(
- certCollection);
- return CertStore.getInstance("Collection", csp);
-
- } else {
- log.warn("No certstore configured");
+ return certDir;
}
return null;
+
}
- public void configureSSL() {
- Set caCerts = null;
- try {
- caCerts = getCACerts();
- } catch (Exception e1) {
- log.error("Cannot load CA certificates", e1);
- }
- CertStore certStore = null;
- try {
- certStore = getCertstore();
- } catch (Exception e1) {
- log.error("Cannot load certstore certificates", e1);
- }
- System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
- try {
- X509CertSelector selector = new X509CertSelector();
- PKIXBuilderParameters pkixParams;
- pkixParams = new PKIXBuilderParameters(caCerts, selector);
- if ((getProperty("SSL.doRevocationChecking") != null)
- && (Boolean.valueOf(getProperty("SSL.doRevocationChecking")))) {
- log.info("Enable revocation checking");
- pkixParams.setRevocationEnabled(true);
- System.setProperty("com.sun.security.enableCRLDP", "true");
- Security.setProperty("ocsp.enable", "true");
- } else {
- log.warn("Revocation checking disabled");
- pkixParams.setRevocationEnabled(false);
- }
- pkixParams.addCertStore(certStore);
- ManagerFactoryParameters trustParams = new CertPathTrustManagerParameters(
- pkixParams);
- TrustManagerFactory trustFab;
- try {
- trustFab = TrustManagerFactory.getInstance("PKIX");
- trustFab.init(trustParams);
- KeyManager[] km = null;
- SSLContext sslCtx = SSLContext
- .getInstance(getProperty("SSL.sslProtocol"));
- sslCtx.init(km, trustFab.getTrustManagers(), null);
- HttpsURLConnection
- .setDefaultSSLSocketFactory(sslCtx.getSocketFactory());
- } catch (Exception e) {
- log.error("Cannot configure SSL", e);
- }
+ @Override
+ protected File getCADir() {
+ String caDirectory = getProperty("SSL.caDirectory");
+ return getDirectory(caDirectory);
+ }
- } catch (InvalidAlgorithmParameterException e) {
- log.error("Cannot configure SSL", e);
- }
+ @Override
+ protected File getCertDir() {
+ String certDirectory = getProperty("SSL.certDirectory");
+ return getDirectory(certDirectory);
}
@Override
- public void setResourceLoader(ResourceLoader loader) {
- this.resourceLoader = loader;
+ protected InputStream getManifest() {
+ Resource r = resourceLoader.getResource("META-INF/MANIFEST.MF");
+ if (r != null) {
+ try {
+ return r.getInputStream();
+ } catch (IOException e) {
+ log.error("Cannot read manifest data:", e);
+ }
+ }
+ return null;
}
}
\ No newline at end of file
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index b70a6274..9e69099d 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.binding.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.HttpUtil;
import at.gv.egiz.bku.binding.IdFactory;
-import at.gv.egiz.bku.online.conf.Configurator;
+import at.gv.egiz.bku.conf.Configurator;
/**
* Delivers the result to the browser
@@ -108,8 +108,8 @@ public class ResultServlet extends SpringBKUServlet {
resp.setHeader("Cache-Control", "no-store"); // HTTP 1.1
resp.setHeader("Pragma", "no-cache"); // HTTP 1.0
resp.setDateHeader("Expires", 0);
- if (Configurator.getInstance().getProperty(USER_AGENT_PROPERTY_KEY) != null) {
- resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, Configurator.getInstance().getProperty(
+ if (configurator.getProperty(USER_AGENT_PROPERTY_KEY) != null) {
+ resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, configurator.getProperty(
USER_AGENT_PROPERTY_KEY));
} else {
resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT,
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
index ec062e42..2c6f522e 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
@@ -16,16 +16,22 @@
*/
package at.gv.egiz.bku.online.webapp;
-import javax.servlet.http.HttpServlet;
-
-import at.gv.egiz.bku.binding.BindingProcessorManager;
-import at.gv.egiz.bku.online.conf.Configurator;
+import javax.servlet.http.HttpServlet;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.conf.Configurator;
public abstract class SpringBKUServlet extends HttpServlet {
public final static String BEAN_NAME="bindingProcessorManager";
+ protected static Configurator configurator;
+
protected BindingProcessorManager getBindingProcessorManager() {
return (BindingProcessorManager) getServletContext().getAttribute(BEAN_NAME);
+ }
+
+ public static void setConfigurator(Configurator conf) {
+ configurator = conf;
}
}
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
index 73d89f22..d7fc5ae9 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
@@ -36,6 +36,10 @@ SSL.caDirectory=classpath:at/gv/egiz/bku/online/conf/certs/CACerts
SSL.doRevocationChecking=true
SSL.sslProtocol=TLS
+SSL.cache.lifetime=3600
+
+# use authority info access extension to find ca certs.
+SSL.useAIA=true
# ------------ END SSL Config --------------------
@@ -44,3 +48,4 @@ AppletTimeout=300000
#HTTPProxyHost=taranis.iaik.tugraz.at
#HTTPProxyPort=8888
+#DefaultSocketTimeout=200
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index 04b07ba4..b074da59 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -45,8 +45,8 @@
-
+
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
new file mode 100644
index 00000000..9a1e7020
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
@@ -0,0 +1,351 @@
+package at.gv.egiz.bku.conf;
+
+import iaik.security.ecc.provider.ECCProvider;
+import iaik.security.provider.IAIK;
+import iaik.xml.crypto.XSecProvider;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.cert.CertStore;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.LDAPCertStoreParameters;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509CertSelector;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.net.ssl.CertPathTrustManagerParameters;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.ManagerFactoryParameters;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.binding.DataUrl;
+import at.gv.egiz.bku.binding.DataUrlConnection;
+import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
+import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+public abstract class Configurator {
+ private Log log = LogFactory.getLog(Configurator.class);
+
+ protected Properties properties;
+
+ protected Configurator() {
+ }
+
+ protected abstract File getCertDir();
+
+ protected abstract File getCADir();
+
+ protected abstract InputStream getManifest();
+
+ private Set getCACerts() throws IOException,
+ CertificateException {
+ Set caCerts = new HashSet();
+ File caDir = getCADir();
+ if (caDir != null) {
+ if (!caDir.isDirectory()) {
+ log.error("Expecting directory as SSL.caDirectory parameter");
+ throw new SLRuntimeException(
+ "Expecting directory as SSL.caDirectory parameter");
+ }
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ for (File f : caDir.listFiles()) {
+ try {
+ FileInputStream fis = new FileInputStream(f);
+ X509Certificate cert = (X509Certificate) cf.generateCertificate(fis);
+ fis.close();
+ log.debug("Adding trusted cert " + cert.getSubjectDN());
+ caCerts.add(new TrustAnchor(cert, null));
+ } catch (Exception e) {
+ log.error("Cannot add trusted ca", e);
+ }
+ }
+ return caCerts;
+
+ } else {
+ log.warn("No CA certificates configured");
+ }
+ return null;
+ }
+
+ protected List getCertstore() throws IOException,
+ CertificateException, InvalidAlgorithmParameterException,
+ NoSuchAlgorithmException {
+ List resultList = new ArrayList();
+ File certDir = getCertDir();
+ if (certDir != null) {
+ if (!certDir.isDirectory()) {
+ log.error("Expecting directory as SSL.certDirectory parameter");
+ throw new SLRuntimeException(
+ "Expecting directory as SSL.certDirectory parameter");
+ }
+ List certCollection = new LinkedList();
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ for (File f : certDir.listFiles()) {
+ try {
+ FileInputStream fis = new FileInputStream(f);
+ X509Certificate cert = (X509Certificate) cf.generateCertificate(fis);
+ certCollection.add(cert);
+ fis.close();
+ log
+ .trace("Added following cert to certstore: "
+ + cert.getSubjectDN());
+ } catch (Exception ex) {
+ log.error("Cannot add certificate", ex);
+ }
+ }
+ CollectionCertStoreParameters csp = new CollectionCertStoreParameters(
+ certCollection);
+ resultList.add(CertStore.getInstance("Collection", csp));
+ log.info("Added collection certstore");
+ } else {
+ log.warn("No certstore directory configured");
+ }
+ String ldapHost = getProperty("SSL.ldapServer");
+ if ((ldapHost != null) && (!"".equals(ldapHost))) {
+ String ldapPortString = getProperty("SSL.ldapPort");
+ int ldapPort = 389;
+ if (ldapPortString != null) {
+ try {
+ ldapPort = Integer.parseInt(ldapPortString);
+ } catch (NumberFormatException nfe) {
+ log.error("Invalid ldap port, using default 389");
+ }
+ } else {
+ log.warn("ldap port not specified, using default 389");
+ }
+ LDAPCertStoreParameters ldapParams = new LDAPCertStoreParameters(
+ ldapHost, ldapPort);
+ resultList.add(CertStore.getInstance("LDAP", ldapParams));
+ log.info("Added LDAP certstore");
+ }
+ return resultList;
+ }
+
+ protected void configUrlConnections() {
+ HttpsURLConnection.setFollowRedirects(false);
+ HttpURLConnection.setFollowRedirects(false);
+ }
+
+ protected void configureProviders() {
+ log.debug("Registering security providers");
+ Security.insertProviderAt(new IAIK(), 1);
+ Security.insertProviderAt(new ECCProvider(false), 2);
+ Security.addProvider(new STALProvider());
+ XSecProvider.addAsProvider(false);
+ StringBuilder sb = new StringBuilder();
+ sb.append("Registered providers: ");
+ int i = 1;
+ for (Provider prov : Security.getProviders()) {
+ sb.append((i++) + ". : " + prov);
+ }
+ log.debug(sb.toString());
+ }
+
+ protected void configViewer() {
+ String bv = properties.getProperty("ValidateHashDataInputs");
+ if (bv != null) {
+ DataObject.enableHashDataInputValidation(Boolean.parseBoolean(bv));
+ } else {
+ log.warn("ValidateHashDataInputs not set, falling back to default");
+ }
+ }
+
+ public void configureNetwork() {
+ String proxy = getProperty("HTTPProxyHost");
+ String portString = getProperty("HTTPProxyPort");
+ if ((proxy == null) || (proxy.equals(""))) {
+ log.info("No proxy configured");
+ } else {
+ 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);
+ }
+ }
+
+ public void configureVersion() {
+ Properties p = new Properties();
+ try {
+ InputStream is = getManifest();
+ if (is != null) {
+ p.load(getManifest());
+ String version = p.getProperty("Implementation-Build");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
+ "citizen-card-environment/1.2 MOCCA " + version);
+ DataUrl.setConfiguration(properties);
+ log
+ .debug("Setting user agent to: "
+ + properties
+ .getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
+ } else {
+ log.warn("Cannot read manifest");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
+ "citizen-card-environment/1.2 MOCCA UNKNOWN");
+ DataUrl.setConfiguration(properties);
+ }
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+
+ public void configure() {
+ configureProviders();
+ configUrlConnections();
+ configViewer();
+ configureSSL();
+ configureVersion();
+ configureNetwork();
+ }
+
+ public void setConfiguration(Properties props) {
+ this.properties = props;
+ }
+
+ public String getProperty(String key) {
+ if (properties != null) {
+ return properties.getProperty(key);
+ }
+ return null;
+ }
+
+ public void configureSSL() {
+ Set caCerts = null;
+ try {
+ caCerts = getCACerts();
+ } catch (Exception e1) {
+ log.error("Cannot load CA certificates", e1);
+ }
+ List certStoreList = null;
+ try {
+ certStoreList = getCertstore();
+ } catch (Exception e1) {
+ log.error("Cannot load certstore certificates", e1);
+ }
+ String aia = getProperty("SSL.useAIA");
+ if ((aia == null) || (aia.equals(""))) {
+ System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
+ } else {
+ System.setProperty("com.sun.security.enableAIAcaIssuers", aia);
+ }
+ String lifetime = getProperty("SSL.cache.lifetime");
+ if ((lifetime == null) || (lifetime.equals(""))) {
+ System.setProperty("sun.security.certpath.ldap.cache.lifetime", "0");
+ } else {
+ System.setProperty("sun.security.certpath.ldap.cache.lifetime", lifetime);
+ }
+ X509CertSelector selector = new X509CertSelector();
+ PKIXBuilderParameters pkixParams;
+ try {
+ pkixParams = new PKIXBuilderParameters(caCerts, selector);
+ if ((getProperty("SSL.doRevocationChecking") != null)
+ && (Boolean.valueOf(getProperty("SSL.doRevocationChecking")))) {
+ log.info("Enable revocation checking");
+ System.setProperty("com.sun.security.enableCRLDP", "true");
+ Security.setProperty("ocsp.enable", "true");
+ } else {
+ log.warn("Revocation checking disabled");
+ }
+ for (CertStore cs : certStoreList) {
+ pkixParams.addCertStore(cs);
+ }
+ ManagerFactoryParameters trustParams = new CertPathTrustManagerParameters(
+ pkixParams);
+ TrustManagerFactory trustFab;
+ trustFab = TrustManagerFactory.getInstance("PKIX");
+ trustFab.init(trustParams);
+ KeyManager[] km = null;
+ SSLContext sslCtx = SSLContext
+ .getInstance(getProperty("SSL.sslProtocol"));
+ String disableAll = getProperty("SSL.disableAllChecks");
+ if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
+ log.warn("--------------------------------------");
+ log.warn(" Disabling SSL Certificate Validation ");
+ log.warn("--------------------------------------");
+
+ sslCtx.init(km, new TrustManager[] { new MyTrustManager(caCerts,
+ certStoreList) }, null);
+ } else {
+ sslCtx.init(km, trustFab.getTrustManagers(), null);
+ }
+ HttpsURLConnection.setDefaultSSLSocketFactory(sslCtx.getSocketFactory());
+ } catch (Exception e) {
+ log.error("Cannot configure SSL", e);
+ }
+ String disableAll = getProperty("SSL.disableAllChecks");
+ if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
+ log.warn("---------------------------------");
+ log.warn(" Disabling Hostname Verification ");
+ log.warn("---------------------------------");
+ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ }
+ }
+
+ private static class MyTrustManager implements X509TrustManager {
+ private static Log log = LogFactory.getLog(MyTrustManager.class);
+ private X509Certificate[] trustedCerts;
+
+ public MyTrustManager(Set caCerts, List cs) {
+ trustedCerts = new X509Certificate[caCerts.size()];
+ int i = 0;
+ for (Iterator it = caCerts.iterator(); it.hasNext();) {
+ TrustAnchor ta = it.next();
+ trustedCerts[i++] = ta.getTrustedCert();
+ }
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] arg0, String arg1)
+ throws CertificateException {
+ log.error("Did not expect this method to get called");
+ throw new CertificateException("Method not implemented");
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] certs, String arg1)
+ throws CertificateException {
+ log.warn("-------------------------------------");
+ log.warn("SSL Certificate Validation Disabled !");
+ log.warn("-------------------------------------");
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return trustedCerts;
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index dbe2812e..c18a4c2c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,7 @@
STALServiceBKUCommonGUIBKUViewer
+ BKULocalApp
diff --git a/utils/src/main/java/at/gv/egiz/bku/local/ui/TrayIconDialog.java b/utils/src/main/java/at/gv/egiz/bku/local/ui/TrayIconDialog.java
index 5aa74d99..c7aae215 100644
--- a/utils/src/main/java/at/gv/egiz/bku/local/ui/TrayIconDialog.java
+++ b/utils/src/main/java/at/gv/egiz/bku/local/ui/TrayIconDialog.java
@@ -107,7 +107,7 @@ public class TrayIconDialog implements TrayIconDialogInterface {
if (isSupported) {
SystemTray tray = SystemTray.getSystemTray();
Image image = ImageIO.read(getClass().getClassLoader()
- .getResourceAsStream("at/gv/egiz/bku/local/ui/chipperling.png"));
+ .getResourceAsStream("at/gv/egiz/bku/local/ui/favicon.png"));
PopupMenu popup = new PopupMenu();
MenuItem exitItem = new MenuItem(resourceBundel
.getString("TrayMenu.Shutdown"));
--
cgit v1.2.3
From 5702f241064f90106e8495f3cf23b6e6798d6501 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Wed, 1 Oct 2008 10:49:31 +0000
Subject: added project for local MOCCA
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@79 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKULocalApp/pom.xml | 93 ++++-------
.../java/at/gv/egiz/bku/local/app/BKULauncher.java | 15 --
.../java/at/gv/egiz/bku/local/app/Container.java | 23 +--
BKULocalApp/src/main/resources/splash.png | Bin 0 -> 54978 bytes
.../egiz/bku/online/conf/SpringConfigurator.java | 1 +
.../service/impl/RequestBrokerSTALFactory.java | 2 +-
.../egiz/stal/service/impl/STALRequestBroker.java | 2 +-
.../stal/service/impl/STALRequestBrokerImpl.java | 2 +-
.../gv/egiz/bku/online/conf/defaultConf.properties | 2 +-
.../slexceptions/SLExceptionMessages.properties | 3 +-
.../slexceptions/SLExceptionMessages_de.properties | 3 +-
.../slexceptions/SLExceptionMessages_en.properties | 1 +
utils/pom.xml | 181 +++++++++------------
13 files changed, 119 insertions(+), 209 deletions(-)
create mode 100644 BKULocalApp/src/main/resources/splash.png
(limited to 'bkucommon/src/main')
diff --git a/BKULocalApp/pom.xml b/BKULocalApp/pom.xml
index e2d17d7c..9ad6f50b 100644
--- a/BKULocalApp/pom.xml
+++ b/BKULocalApp/pom.xml
@@ -28,76 +28,41 @@
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ true
+ at.gv.egiz.bku.local.app.BKULauncher
+
+
+
+
- maven-dependency-plugin
-
-
-
- copywar
-
- copy
-
-
-
-
- at.gv.egiz
- BKULocal
- 1.0-SNAPSHOT
- war
-
-
-
- ${project.build.directory}/classes
-
-
-
-
- unpack-dependencies
-
- unpack-dependencies
-
-
- javax/xml/crypto/**, demo/**,
- junit/**, w3/**, org/etsi/**, META-INF/**
- ${project.build.directory}/classes
- true
- true
-
-
-
-
+ maven-dependency-plugin
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}
+ false
+ false
+ true
+
+
+
+
-
- maven-jar-plugin
-
-
-
- sign
-
-
-
-
-
- false
- false
-
- false
- true
-
-
- test-applet signer
- ./keystore.ks
- storepass
- keypass
- true
-
-
-
-
commons-loggingcommons-logging
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
index 091843e1..9a953f9e 100644
--- a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
+++ b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
@@ -168,20 +168,6 @@ public class BKULauncher implements BKUControllerInterface {
}
}
- public void jwsHack() {
- InputStream is = getClass().getClassLoader().getResourceAsStream(
- "BKULocal-1.0-SNAPSHOT.war");
- File f = new File(System.getProperty("user.home") + "/.mocca/war");
- f.mkdirs();
- try {
- OutputStream os = new FileOutputStream(new File(f, "mocca.war"));
- StreamUtil.copyStream(is, os);
- os.close();
- } catch (Exception e) {
- log.error(e);
- }
- }
-
/**
* @param args
*/
@@ -189,7 +175,6 @@ public class BKULauncher implements BKUControllerInterface {
try {
BKULauncher launcher = new BKULauncher();
- //launcher.jwsHack();
launcher.checkConfig(args);
launcher.startUpServer();
launcher.initTrayIcon();
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
index 690639f4..a8a6431a 100644
--- a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
+++ b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
@@ -2,6 +2,8 @@ package at.gv.egiz.bku.local.app;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -12,7 +14,6 @@ import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerCollection;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.webapp.WebAppClassLoader;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.thread.QueuedThreadPool;
@@ -26,8 +27,6 @@ public class Container {
}
public void init() {
- Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
- log.debug("-----------------> "+ClassLoader.getSystemClassLoader());
server = new Server();
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setMaxThreads(5);
@@ -56,21 +55,9 @@ public class Container {
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/");
webappcontext.setExtractWAR(false);
-
- File tmpDir = new File(System.getProperty("user.home") + "/.mocca/tmp");
- // tmpDir.mkdirs();
- // webappcontext.setTempDirectory(tmpDir);
- try {
- File f = new File(System.getProperty("user.home")
- + "/.mocca/war/mocca.war");
- log.debug("Deploying war: " + f.getCanonicalPath());
- if (!f.exists()) {
- log.error("WAR file does not exist, cannot run MOCCA");
- }
- webappcontext.setWar(f.getParent());
- } catch (IOException e) {
- log.error(e);
- }
+ System.out.println(getClass().getClassLoader().getResource("log4j.properties"));
+ webappcontext.setWar("BKULocal-1.0-SNAPSHOT.war");
+
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
server.setHandler(handlers);
diff --git a/BKULocalApp/src/main/resources/splash.png b/BKULocalApp/src/main/resources/splash.png
new file mode 100644
index 00000000..72c1d868
Binary files /dev/null and b/BKULocalApp/src/main/resources/splash.png differ
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
index a369d829..6030c1c0 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
@@ -60,6 +60,7 @@ public class SpringConfigurator extends Configurator implements
if ((appletTimeout != null)) {
try {
long ato = Long.parseLong(appletTimeout);
+ log.debug("Setting applet timeout to:"+ato);
RequestBrokerSTALFactory.setTimeout(ato);
} catch (NumberFormatException nfe) {
log.error("Cannot set Applettimeout", nfe);
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
index 45ee67d0..9c4aca28 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
@@ -32,7 +32,7 @@ import at.gv.egiz.stal.STALFactory;
*/
public class RequestBrokerSTALFactory implements STALFactory {
- private static long timeout;
+ private static long timeout = -1;
@Override
public STAL createSTAL() {
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
index af886eec..63eac311 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
@@ -32,7 +32,7 @@ import java.util.List;
*/
public interface STALRequestBroker extends STAL {
- public static final int ERR_6000 = 6000;
+ public static final int ERR_4500 = 4500;
public static final long DEFAULT_TIMEOUT_MS = 1000*60*5; //5mn
public List connect();
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
index bfa83dd4..4aa5130a 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
@@ -150,7 +150,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
// reqMon.setHashDataInput(null);
requests.clear(); //TODO sync on requests?
hashDataInputs.clear();
- return Collections.singletonList((STALResponse) new ErrorResponse(ERR_6000));
+ return Collections.singletonList((STALResponse) new ErrorResponse(ERR_4500));
}
}
log.trace("consuming responses");
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
index d7fc5ae9..9766ae26 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
@@ -48,4 +48,4 @@ AppletTimeout=300000
#HTTPProxyHost=taranis.iaik.tugraz.at
#HTTPProxyPort=8888
-#DefaultSocketTimeout=200
+DefaultSocketTimeout=200
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
index cf52a4c3..73409c8b 100644
--- a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
@@ -68,7 +68,8 @@ ec4119=Datum, f
ec4120=Gewählter Infoboxbezeichner bereits vergeben.
ec4121=Infobox mit spezifiziertem Bezeichner existiert nicht.
ec4122=Inhalt der ausgewählten Infobox kann nicht als XML dargestellt werden.
-ec4123=Assoziatives Array: Zum spezifizierten Schlüssel existiert kein Eintrag.
+ec4123=Assoziatives Array: Zum spezifizierten Schlüssel existiert kein Eintrag.
+ec4500=Die Sitzung ist abgelaufen.
ec5000=Unklassifizierter Fehler in der Anzeigekomponente.
ec5001=Anzeige von Daten des in der Befehlsanfrage angegebenen Mime-Types wird nicht unterstützt.
ec5002=Zeichenkodierung der anzuzeigenden Daten ist fehlerhaft oder wird nicht unterstützt.
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties
index cf52a4c3..73409c8b 100644
--- a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_de.properties
@@ -68,7 +68,8 @@ ec4119=Datum, f
ec4120=Gewählter Infoboxbezeichner bereits vergeben.
ec4121=Infobox mit spezifiziertem Bezeichner existiert nicht.
ec4122=Inhalt der ausgewählten Infobox kann nicht als XML dargestellt werden.
-ec4123=Assoziatives Array: Zum spezifizierten Schlüssel existiert kein Eintrag.
+ec4123=Assoziatives Array: Zum spezifizierten Schlüssel existiert kein Eintrag.
+ec4500=Die Sitzung ist abgelaufen.
ec5000=Unklassifizierter Fehler in der Anzeigekomponente.
ec5001=Anzeige von Daten des in der Befehlsanfrage angegebenen Mime-Types wird nicht unterstützt.
ec5002=Zeichenkodierung der anzuzeigenden Daten ist fehlerhaft oder wird nicht unterstützt.
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
index 8e0a09bc..91ca20e8 100644
--- a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
@@ -69,6 +69,7 @@ ec4120=Selected info box identifier already allocated.
ec4121=Info box with specified identifier does not exist.
ec4122=Contents of the selected info box cannot be displayed as XML.
ec4123=Associative array: No entry for the specified key.
+ec4500=The session expired.
ec5000=Unclassified error in the viewer component.
ec5001=Display of data of the mime type specified in the command request not supported.
ec5002=Character encoding of the data to be displayed is invalid or not supported.
diff --git a/utils/pom.xml b/utils/pom.xml
index 7408f12b..d6b58234 100644
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -1,108 +1,77 @@
-
-
- bku
- at.gv.egiz
- 1.0-SNAPSHOT
-
- 4.0.0
- at.gv.egiz
- utils
- BKU Utils
- jar
- 1.0-SNAPSHOT
- http://bku.egiz.gv.at
-
-
-
-
-
-
-
- commons-logging
- commons-logging
-
-
- iaik
- iaik_jce_full_signed
-
-
- iaik
- iaik_ecc_signed
-
-
- iaik
- iaik_xsect
-
-
-
-
+
+
+ bku
+ at.gv.egiz
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ at.gv.egiz
+ utils
+ BKU Utils
+ jar
+ 1.0-SNAPSHOT
+ http://bku.egiz.gv.at
+
+
+
+
+
+
+
+ commons-logging
+ commons-logging
+
+
+ iaik
+ iaik_jce_full_signed
+
+
+ iaik
+ iaik_ecc_signed
+
+
+ iaik
+ iaik_xsect
+
+
+
+
--
cgit v1.2.3
From 27d91275555207f9e152c2867d52fbbf83f92ba7 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Wed, 8 Oct 2008 08:39:17 +0000
Subject: changed ssl certificate validation, now using iaik_pki
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@83 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../src/main/webapp/WEB-INF/applicationContext.xml | 2 +
.../at/gv/egiz/bku/local/defaultConf/template.zip | Bin 17759 -> 23517 bytes
.../egiz/bku/online/webapp/BKURequestHandler.java | 4 +-
.../bku/online/webapp/HashDataInputServlet.java | 96 +++++
.../stal/service/impl/STALRequestBrokerImpl.java | 6 +-
.../online/conf/certs/certStore/a-sign-SSL-03.cer | 26 --
.../conf/certs/certStore/a-sign-corporate-03.cer | 27 --
.../certs/certStore/a-sign-corporate-light-01a.cer | 21 -
.../certs/certStore/a-sign-corporate-light-02a.cer | 27 --
.../certs/certStore/a-sign-corporate-light-03.cer | 27 --
.../certStore/a-sign-corporate-medium-01a.cer | 21 -
.../certStore/a-sign-corporate-medium-02a.cer | 27 --
.../certs/certStore/tobeadded/A-Trust-Qual-01a.cer | Bin 0 -> 1111 bytes
.../certs/certStore/tobeadded/A-Trust-Qual-02a.cer | Bin 0 -> 975 bytes
.../certs/certStore/tobeadded/A-Trust-Qual-03a.cer | Bin 0 -> 975 bytes
.../certStore/tobeadded/A-Trust-nQual-01a.cer | Bin 0 -> 865 bytes
.../certs/certStore/tobeadded/A-Trust-nQual-03.cer | Bin 0 -> 979 bytes
.../certs/certStore/tobeadded/a-sign-SSL-03.cer | 26 ++
.../certStore/tobeadded/a-sign-corporate-03.cer | 27 ++
.../tobeadded/a-sign-corporate-light-01a.cer | 21 +
.../tobeadded/a-sign-corporate-light-02a.cer | 27 ++
.../tobeadded/a-sign-corporate-light-03.cer | 27 ++
.../tobeadded/a-sign-corporate-medium-01a.cer | 21 +
.../tobeadded/a-sign-corporate-medium-02a.cer | 27 ++
.../gv/egiz/bku/online/conf/defaultConf.properties | 10 +-
.../src/main/webapp/WEB-INF/applicationContext.xml | 4 +
BKUOnline/src/main/webapp/WEB-INF/web.xml | 191 +++++-----
.../src/test/resources/applicationContext.xml | 2 +
STALService/pom.xml | 5 +
.../at/gv/egiz/stal/util/HashDataInputProxy.java | 67 ++++
bkucommon/pom.xml | 159 ++++----
.../java/at/gv/egiz/bku/conf/CertValidator.java | 13 +
.../at/gv/egiz/bku/conf/CertValidatorImpl.java | 83 ++++
.../java/at/gv/egiz/bku/conf/Configurator.java | 140 +++----
.../at/gv/egiz/bku/conf/CertValidatorTest.java | 32 ++
.../bku/conf/certs/CACerts/A-Trust-Qual-01a.cer | Bin 0 -> 1111 bytes
.../bku/conf/certs/CACerts/A-Trust-Qual-02a.cer | Bin 0 -> 975 bytes
.../bku/conf/certs/CACerts/A-Trust-Qual-03a.cer | Bin 0 -> 975 bytes
.../bku/conf/certs/CACerts/A-Trust-nQual-01a.cer | Bin 0 -> 865 bytes
.../bku/conf/certs/CACerts/A-Trust-nQual-03.cer | Bin 0 -> 979 bytes
.../bku/conf/certs/certStore/A-Trust-Qual-01a.cer | Bin 0 -> 1111 bytes
.../bku/conf/certs/certStore/A-Trust-Qual-02a.cer | Bin 0 -> 975 bytes
.../bku/conf/certs/certStore/A-Trust-Qual-03a.cer | Bin 0 -> 975 bytes
.../bku/conf/certs/certStore/A-Trust-nQual-01a.cer | Bin 0 -> 865 bytes
.../bku/conf/certs/certStore/A-Trust-nQual-03.cer | Bin 0 -> 979 bytes
.../bku/conf/certs/certStore/a-sign-SSL-03.cer | 26 ++
.../conf/certs/certStore/a-sign-corporate-03.cer | 27 ++
.../certs/certStore/a-sign-corporate-light-01a.cer | 21 +
.../certs/certStore/a-sign-corporate-light-02a.cer | 27 ++
.../certs/certStore/a-sign-corporate-light-03.cer | 27 ++
.../certStore/a-sign-corporate-medium-01a.cer | 21 +
.../certStore/a-sign-corporate-medium-02a.cer | 27 ++
.../bku/conf/certs/testCerts/www.a-trust.at.der | Bin 0 -> 1230 bytes
pom.xml | 424 +++++++++++----------
54 files changed, 1142 insertions(+), 624 deletions(-)
create mode 100644 BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java
delete mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-SSL-03.cer
delete mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-03.cer
delete mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-01a.cer
delete mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-02a.cer
delete mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-03.cer
delete mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-01a.cer
delete mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-02a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-01a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-02a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-03a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-01a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-03.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-SSL-03.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-03.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-01a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-02a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-03.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-01a.cer
create mode 100644 BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-02a.cer
create mode 100644 STALService/src/main/java/at/gv/egiz/stal/util/HashDataInputProxy.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidator.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java
create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/conf/CertValidatorTest.java
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-01a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-02a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-03a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-01a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-03.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-01a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-02a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-03a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-01a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-03.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-SSL-03.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-03.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-01a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-02a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-03.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-01a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-02a.cer
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/testCerts/www.a-trust.at.der
(limited to 'bkucommon/src/main')
diff --git a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
index a4003a2a..a951f056 100644
--- a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
@@ -48,11 +48,13 @@
+
+
diff --git a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip
index f57e8930..8bdcbb0d 100644
Binary files a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip and b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip differ
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
index 20320d8e..544bbc99 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.binding.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.binding.IdFactory;
import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
/**
@@ -51,7 +52,8 @@ public class BKURequestHandler extends SpringBKUServlet {
log.debug("Using locale: " + locale);
HttpSession session = req.getSession();
if (session != null) {
- session.invalidate();
+ log.warn("Already a session with id: "+session.getId()+ " active, deleting this one");
+ getBindingProcessorManager().removeBindingProcessor(IdFactory.getInstance().createId(session.getId()));
}
String id = req.getSession(true).getId();
log.debug("Using session id: " + id);
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java
new file mode 100644
index 00000000..59766586
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java
@@ -0,0 +1,96 @@
+package at.gv.egiz.bku.online.webapp;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.binding.BindingProcessor;
+import at.gv.egiz.bku.binding.Id;
+import at.gv.egiz.bku.binding.IdFactory;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.service.impl.STALRequestBroker;
+import at.gv.egiz.stal.service.impl.STALRequestBrokerImpl;
+import at.gv.egiz.stal.service.impl.STALServiceImpl;
+
+public class HashDataInputServlet extends SpringBKUServlet {
+
+ private static Log log = LogFactory.getLog(HashDataInputServlet.class);
+
+ public HashDataInputServlet() {
+ }
+
+ private STALRequestBroker getSTAL(Id id) {
+ BindingProcessor bp = getBindingProcessorManager().getBindingProcessor(id);
+ if (bp == null) {
+ return null;
+ }
+ STAL stal = bp.getSTAL();
+ if (stal instanceof STALRequestBroker) {
+ return (STALRequestBroker) stal;
+ } else {
+ throw new SLRuntimeException("Unexpected STAL type");
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ if ((req.getSession() == null) && (req.getSession().getId() != null)) {
+ log.warn("Got request for hashdatainput without session info");
+ resp.sendRedirect("expired.html");
+ return;
+ }
+ Id sessionId = IdFactory.getInstance().createId(req.getSession().getId());
+ log.debug("Got request for hashdata for session " + sessionId);
+ STALRequestBroker rb = getSTAL(sessionId);
+ if (rb == null) {
+ log.info("STAL instance not found for session: " + sessionId);
+ resp.sendRedirect("expired.html");
+ return;
+ }
+ List hdi = rb.getHashDataInput();
+ log.debug("Got hashdata list with " + hdi.size() + " entries");
+ String param = req.getParameter("number");
+ int num = 0;
+ if (param != null) {
+ log.debug("Got request for hashdata#" + num);
+ num = Integer.parseInt(param);
+ }
+ if ((hdi.size() <= num) || (num < 0)){
+ log.warn("Requested hashdatainput exceeds listsize");
+ resp.sendError(-1);
+ return;
+ }
+ resp.setCharacterEncoding(req.getCharacterEncoding());
+ resp.setContentType(hdi.get(num).getMimeType());
+ String charSet = req.getCharacterEncoding();
+ if (charSet == null) {
+ charSet = "UTF-8";
+ }
+ Reader r = new InputStreamReader(hdi.get(num).getHashDataInput(), charSet);
+ Writer w = new OutputStreamWriter(resp.getOutputStream(), charSet);
+ StreamUtil.copyStream(r, w);
+ w.close();
+ return;
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doGet(req, resp);
+ }
+
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
index 4aa5130a..074aff2d 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
@@ -32,6 +32,7 @@ import at.gv.egiz.stal.service.types.QuitRequestType;
import at.gv.egiz.stal.service.types.RequestType;
import at.gv.egiz.stal.service.types.ResponseType;
import at.gv.egiz.stal.service.types.SignRequestType;
+import at.gv.egiz.stal.util.HashDataInputProxy;
import at.gv.egiz.stal.util.STALTranslator;
import java.util.ArrayList;
import java.util.Collections;
@@ -108,7 +109,10 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
req.setKeyIdentifier(((SignRequest) stalRequest).getKeyIdentifier());
req.setSignedInfo(((SignRequest) stalRequest).getSignedInfo());
requests.add(req);
- hashDataInputs.addAll(((SignRequest) stalRequest).getHashDataInput());
+ for (HashDataInput hdi : ((SignRequest) stalRequest).getHashDataInput()) {
+ hashDataInputs.add(new HashDataInputProxy(hdi));
+ }
+ //hashDataInputs.addAll(((SignRequest) stalRequest).getHashDataInput());
break;
} else if (stalRequest instanceof InfoboxReadRequest) {
log.trace("Received InfoboxReadRequest");
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-SSL-03.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-SSL-03.cer
deleted file mode 100644
index ee859434..00000000
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-SSL-03.cer
+++ /dev/null
@@ -1,26 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEdzCCA1+gAwIBAgIDAmU4MA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
-VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
-bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
-dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA2MDgxNjIyMDAw
-MFoXDTE2MDgxNjIyMDAwMFowgYcxCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
-dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
-ZXJrZWhyIEdtYkgxFjAUBgNVBAsMDWEtc2lnbi1TU0wtMDMxFjAUBgNVBAMMDWEt
-c2lnbi1TU0wtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMjPM6
-PqgdPBPV4Efudpytt2Y4GZJfjeRdZo5SCuULDvvL+23xxBWnR3scFvfE1ekHN/YK
-k+2/qhU2B2ntoSNJSyDchNM8YPc9Lx67zZyhQTZgbBzh3IZAVb/hwuRRRV68JCBj
-r3r6v7IbwjH5XcVISdB4szx0z93aAQyKW9QkV+tD5a1vWFETvdHsZeVmDzfqcdsG
-AznPJw+9HrImCsswCWYUgPcFRkPNjj2r2NoyckVN781aWmNTAqJPf/Ckj9l9pUIt
-Vjhy8XNJW4iVDBkkykBXcGSkIau0ypJrRjsD1jKqUTIRZ/y2HlyltmwWi8OuyBLd
-LaHDbjc0b6JmqoivAgMBAAGjgeMwgeAwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4E
-CgQIQD6h02K0A90wEwYDVR0jBAwwCoAIRGqVZ1V5EU8wDgYDVR0PAQH/BAQDAgEG
-MIGUBgNVHR8EgYwwgYkwgYaggYOggYCGfmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQv
-b3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEtVHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJl
-dm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2VydGlmaWNhdGlvbkF1
-dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAQEAHKlnV3R9sbXojtONugyazkZCEzmC
-nZF1Dz4cOL0vPzzvS8MVWtG43zAgVI1NT/0ETSWsXD3YfzRi+f+/CxrGn0gwZX2t
-VGx+Z9w5ufiy1vuhxDUPmpos1TbJ4Wv3Une0E7iuHmNLg5qVlKeHWpcU8t1Y0nCt
-eRz34Qm87AVAykta33XST1fYvGoPKsDtn3qx9ye/pcbDvWjPwmqF2UUoql+d5hmJ
-Umgzwezqk4I+FS98BrnaPgC5UVFHg+yUjiUDLjYy7UvDZ5Led6kkLXuzVhQolLvr
-KTrGp5k42PG2MMkw8f6GMF/6yePXgzFMCRN8ReR7J5Htv33SytLRmFRd8g==
------END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-03.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-03.cer
deleted file mode 100644
index 7e67be95..00000000
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-03.cer
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEgzCCA2ugAwIBAgIDAarsMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
-VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
-bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
-dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA1MTExMzIzMDAw
-MFoXDTE1MTExMzIzMDAwMFowgZMxCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
-dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
-ZXJrZWhyIEdtYkgxHDAaBgNVBAsME2Etc2lnbi1jb3Jwb3JhdGUtMDMxHDAaBgNV
-BAMME2Etc2lnbi1jb3Jwb3JhdGUtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
-ggEKAoIBAQCp44qY+AiVXlcnHoKvch9s3ujoWFNktvcteIPwK7s0mb/uxTUW9UIF
-Die9n3AbyTsJE6R3nZYSJVHHi+1DKD72/WEo/B5NOOtd6KUMfJgca1tDmcsIwhFn
-82qkZrbNQwdIIdLe6+nDmjd9UBIaKv7yy1kq20jh09HOK3/bWhafVQE7EAgDfNrn
-8f0JfnnF0EA/La5kkg878L22fh9lRzt8H21THqJPtK4/e9SttjrJnPhFk2/MjAGS
-uaDufG6BV5Hnn7klR5qm5q32ypleLA6Zi4m9jRCVtPd4jRPYM40XpRkrJuFw+lxp
-rejfEZt/SRh1eQXiXDUgtgX8OaIylH9pAgMBAAGjgeMwgeAwDwYDVR0TAQH/BAUw
-AwEB/zARBgNVHQ4ECgQIQj75YZ1a5XIwEwYDVR0jBAwwCoAIRGqVZ1V5EU8wDgYD
-VR0PAQH/BAQDAgEGMIGUBgNVHR8EgYwwgYkwgYaggYOggYCGfmxkYXA6Ly9sZGFw
-LmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEtVHJ1c3QsYz1BVD9j
-ZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2Vy
-dGlmaWNhdGlvbkF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAQEARu7e1SyBRjlA
-g/thtFwtKQRvopTZKWj2LWpEdvPvwThOvf8Depnas+ly5af8r8YzsqJzfX3XWvhN
-qOOI24g5FmXfCUTq/kbtaeTq/AqV94793IJfcilPnpMOEHMqXNDiRUoAgR/9EVj8
-mDVvL2lLlJzeAltqOD5Bi9QwguaD2/3/E5ymFnqkf1dnlXbo8AhcwPEzReNKn1eM
-Ilg4FwP1bP0HUK3Fyz1UQ/Hncg+MS7c+SkjpNEd4sH7/GdxuQs5Sk7IRwot1+sbX
-3CkkPhSqiUzig9raxJYrtbb2kyiUO8+d5HzRyoP4BNzsdZdPc0gDYweXg5qarHOQ
-16IEOtBmKg==
------END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-01a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-01a.cer
deleted file mode 100644
index 0c68e593..00000000
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-01a.cer
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEJjCCAw6gAwIBAgIDAOJEMA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNVBAYTAkFUMRAwDgYDVQQK
-EwdBLVRydXN0MRkwFwYDVQQLExBBLVRydXN0LW5RdWFsLTAxMRkwFwYDVQQDExBBLVRydXN0LW5R
-dWFsLTAxMB4XDTA0MTEzMDIzMDAwMFoXDTA4MTEzMDIzMDAwMFowgZ8xCzAJBgNVBAYTAkFUMUgw
-RgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0
-ZW52ZXJrZWhyIEdtYkgxIjAgBgNVBAsTGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDExIjAgBgNV
-BAMTGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
-AoIBAQDGC65v8rni63DojEBriynPwRqNCp14/SkN5ROkTUGNvLSabfSJV4PKGLTzasPAaChwX0g/
-kebahFM3R7nIyeVx2YB8VRvC4I/spP/mCs5+6pf1N+6Kiq4NcswgNBBfqAteaQIylBMy6HDkjoXY
-X/c+SxjyrqAkeZCK+SHMOraXCO1PZHWbYwleKXf4R2Z6ayEfJ2XWeVuqqon76WHp/POI0RADBchA
-6Vm1ROzSAHz39bay1TZunQXSs3VQ9cE3uQPjN+80efmf0ZgNF0sXsDTssoZg2feTANSOkTGM1bMC
-5xe1hWFL8MZNe4yZ+NSgFN2fofb8BPvyQAW0no2PNA6PAgMBAAGjgbMwgbAwDwYDVR0TAQH/BAUw
-AwEB/zARBgNVHQ4ECgQITp5/1C/JHx8wEwYDVR0jBAwwCoAITlnOxwIyhzAwDgYDVR0PAQH/BAQD
-AgEGMGUGA1UdHwReMFwwWqBYoFaGVGxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1u
-UXVhbC0wMSxvPUEtVHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0PzANBgkqhkiG
-9w0BAQUFAAOCAQEAOtuz2GqnTibk/poCLrdYKpZSrLyfWFsJJpfBYA9HMasnfpJBCHgRHJud6DAO
-xD900Vhmwy66D8dqsN3+fR8Bx8ZMKspnFN1B2Wz7LWOxMaKqP3JolJ/oVwzJRm0afcUMAfAumkc5
-Yqu0nC5qCF9zYY9YbJklh84uEzEg9j85kuRBHOCUc+5MVrnv7WPbirx6c95YFqXBQ0arA5QE9zYq
-MDO8aUYPOWEHgtrVI+kMwELYHqLDX7i9VqsXhgFPeVz1wIV7s/i3budGeHMS6hjnyIc30FqM7CTY
-fcvqVNZliErbjD1k1W1gMgvjLJowNvQC0W7K9/yoQhwTqtNMR4WZwA==
------END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-02a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-02a.cer
deleted file mode 100644
index c300891d..00000000
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-02a.cer
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEizCCA3OgAwIBAgIDAOSoMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYDVQQGEwJB
-VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
-bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRgwFgYDVQQLDA9BLVRydXN0LVF1
-YWwtMDIxGDAWBgNVBAMMD0EtVHJ1c3QtUXVhbC0wMjAeFw0wNDEyMTQyMzAwMDBa
-Fw0xNDEyMTMyMzAwMDBaMIGfMQswCQYDVQQGEwJBVDFIMEYGA1UECgw/QS1UcnVz
-dCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy
-a2VociBHbWJIMSIwIAYDVQQLDBlhLXNpZ24tY29ycG9yYXRlLWxpZ2h0LTAyMSIw
-IAYDVQQDDBlhLXNpZ24tY29ycG9yYXRlLWxpZ2h0LTAyMIIBIjANBgkqhkiG9w0B
-AQEFAAOCAQ8AMIIBCgKCAQEAk6V4oEauvXgEICqgjTbGHaiDhBVo2nosX23osoKM
-LTkkO/nOCgpdCYpLKgURxwrgHgVh9XT99yxhy6lDwt2rASajj0sQ1fY5BmWVyrXS
-dQ78ISMPb73XaG4M8H7PJFcsVEo9n8veVQwnMY5mSWy0r1IO8n93Bjbmmi4Zt8oS
-p9olWo5/8ByYW8S/AKZuQx+q+bFJv7geuApVjK2iVFe8yQqHhAgDsAsDlMvxDAQ/
-vhrGwHRv8N3sLsjirnbf5S2dGLDjASOMUFvwfLQd7gHH7PV37Xa+aQqa97eE6O4O
-sIhcGRYhoLk/tWTBDapcgHJ0yTtrftuwORVteLUAy0gBNwIDAQABo4HhMIHeMA8G
-A1UdEwEB/wQFMAMBAf8wEQYDVR0OBAoECEkcWDpP6A0DMBMGA1UdIwQMMAqACEI9
-KySmwUXOMA4GA1UdDwEB/wQEAwIBBjCBkgYDVR0fBIGKMIGHMIGEoIGBoH+GfWxk
-YXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1RdWFsLTAyLG89QS1UcnVz
-dCxjPUFUP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q/YmFzZT9vYmplY3RjbGFz
-cz1laWRDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5MA0GCSqGSIb3DQEBBQUAA4IBAQBH
-opWG7LKmPBvuGjZnRV4KGKzzUYVuxSRS1E0VIUPbVLf5xW2r5uUpR8ud5EpiPrcw
-k6K0dzu2Vb4ZbMIP+6J16S/0qvTp/3A/3q87+nJ+ot+IT8GZFJfSw18th2WmZdzR
-ShbM6sgViPtGsFROCdWeiHl248w2+zG+09sf8Bu3UyvwLRAiiKaxuwVdQ9kc0TL3
-gvv+K5eisWWthQOX2IF2jGSEqoAVwfHhl7bc9Vt7XnJSpQFebHnsIVuV4Mv6w4ww
-86hQPCLLvvV7wWDiBQ8l2FWneX0pNH3Wg+A1TRUoptc+pPDdpoP272MDm4fXyPKV
-7QgIaIK+gXNUj2GGt1K9
------END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-03.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-03.cer
deleted file mode 100644
index 2251ca22..00000000
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-light-03.cer
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEjzCCA3egAwIBAgIDAartMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
-VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
-bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
-dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA1MTExMzIzMDAw
-MFoXDTE1MTExMzIzMDAwMFowgZ8xCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
-dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
-ZXJrZWhyIEdtYkgxIjAgBgNVBAsMGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDMx
-IjAgBgNVBAMMGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDMwggEiMA0GCSqGSIb3
-DQEBAQUAA4IBDwAwggEKAoIBAQC359oitbHkkEgdErRPeBdkcYRK2DLdxfcnn+SI
-umSEYzWVscRTchPKSzb7f1a6EHPbB5WZsGJaUDX9KfTqsJNMo+7bASKk3gsLVxNZ
-qY2t2G+y8HvREYYejDOIzjAkcBQrt+nvuBUlGYVJQjEuyAn18f2vG0Y3VNvZFGKn
-PK8AVycUMk0Uw21RbK3vX5tbbPgQ/kcZkN4czi5VHepMvf6hAwwLoJj+KL9zxm8j
-yPK88qCBKAjMNCpZKsEhyanw1CjYbVmHs45Q5W6FBtqDcS6Iq4mC6TtUPGtCTuoH
-7/JLuhEp075ohp87v3fSlzeLJjBpkUDP9U8Tv7l2euD0t1UVAgMBAAGjgeMwgeAw
-DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQIQZFpHL+t2JgwEwYDVR0jBAwwCoAI
-RGqVZ1V5EU8wDgYDVR0PAQH/BAQDAgEGMIGUBgNVHR8EgYwwgYkwgYaggYOggYCG
-fmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEt
-VHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0
-Y2xhc3M9ZWlkQ2VydGlmaWNhdGlvbkF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOC
-AQEADTRIaQtPwoPS6/TpyBhOw4wAHk/RM4gkLT76URPY2sUHihxqy+8qEElN+f5l
-I61myCP3IFTClflcHVR1QCoMg0ZI5/EcQTI8Dgd5iQkXuVjh3wCj87Ka2Tu7d1K+
-i9VJ4BR/ph/qmPKR7Lx/PtATw/vWo4k2rbt5o1QwixZ7CPt+BF9xCaAC4uL0bB0M
-9M3i9W2ePmqX6WIB3jMkT9FQC0KihPPfw/17KddNi4rFMMEiTyKvJTtTqDnIAwWW
-TqsL1G7oxMMtnnYaKWMQ6gQiOiRzCY7efcAi/3YwUX6ULW5zxqapNs1vqEbSGsQE
-l1eFl67HBZHYAPdoHGUnZF0KaQ==
------END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-01a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-01a.cer
deleted file mode 100644
index 2d7f1a03..00000000
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-01a.cer
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEKDCCAxCgAwIBAgIDAOKKMA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNVBAYTAkFUMRAwDgYDVQQK
-EwdBLVRydXN0MRkwFwYDVQQLExBBLVRydXN0LW5RdWFsLTAxMRkwFwYDVQQDExBBLVRydXN0LW5R
-dWFsLTAxMB4XDTA0MTIwNTIzMDAwMFoXDTA4MTEzMDIzMDAwMFowgaExCzAJBgNVBAYTAkFUMUgw
-RgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0
-ZW52ZXJrZWhyIEdtYkgxIzAhBgNVBAsTGmEtc2lnbi1jb3Jwb3JhdGUtbWVkaXVtLTAxMSMwIQYD
-VQQDExphLXNpZ24tY29ycG9yYXRlLW1lZGl1bS0wMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
-AQoCggEBANEbZyIMIXZYBjTj/+3TrNGssRKNNdTedQlWB3vJQWLzeG89Kzmhy1WDX8IqDrMtvpXH
-5w6urK3ZT7HGu2Jldrib8rkEOdE9+uNGRtkP8Kuz//CvdXCbIDvBLqgvWn9a3Sl/rUicPqKwcEcN
-bP2Q0iU6NvvALmoqs93PymfTZlkGOwzUe+O88huXkauGWT/DkJd4JYDNJ0wlaGrJa+OorT4Izk1J
-EipqqedUjsAj4Gq3SKrZKG/H/CkoH9uWTzrzFgg8zQhCES4AClo84XVk//EIv3ABDw4hr+lqV1nF
-eXch9o4mLIe5u045471YLJLmyuCPDopb8U2VUoyldpMx+Y8CAwEAAaOBszCBsDAPBgNVHRMBAf8E
-BTADAQH/MBEGA1UdDgQKBAhOuHKxmCmfZDATBgNVHSMEDDAKgAhOWc7HAjKHMDAOBgNVHQ8BAf8E
-BAMCAQYwZQYDVR0fBF4wXDBaoFigVoZUbGRhcDovL2xkYXAuYS10cnVzdC5hdC9vdT1BLVRydXN0
-LW5RdWFsLTAxLG89QS1UcnVzdCxjPUFUP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q/MA0GCSqG
-SIb3DQEBBQUAA4IBAQDaukYSeJVxWAh8QShqGqA6Plp9aXCTzwl9hE2gb+/xGPASo+NVQi/sUa0+
-bx29oSJaW6lKzdHQLAx4dwW9XTpJ+0mebB4fQfYHH0lGc1O4au/4O9k+C3SrD6x4WeY9k/SpUFu1
-qjzH+tjta81UWtU7Jve1BhckNwdOFx7cR8fdW+pUQSDV9XnPJfyb+gb9KWhvX+XAbgJoXW1HjJOO
-P5sx6mFhMb3UqAfKQVoAuGbl4+uxIThBTqpICkaaD8WLdukqQjomUMDRbWIf6SblPuOEpPi1G/WM
-qkTkpqX77Wkj08QY/yj5DDrsYJ5NymnWvu7jcoxCFCKvEQ8Q4g7AYKnG
------END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-02a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-02a.cer
deleted file mode 100644
index 194d4d7c..00000000
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/a-sign-corporate-medium-02a.cer
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEjTCCA3WgAwIBAgIDAOSpMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYDVQQGEwJB
-VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
-bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRgwFgYDVQQLDA9BLVRydXN0LVF1
-YWwtMDIxGDAWBgNVBAMMD0EtVHJ1c3QtUXVhbC0wMjAeFw0wNDEyMTQyMzAwMDBa
-Fw0xNDEyMTMyMzAwMDBaMIGhMQswCQYDVQQGEwJBVDFIMEYGA1UECgw/QS1UcnVz
-dCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy
-a2VociBHbWJIMSMwIQYDVQQLDBphLXNpZ24tY29ycG9yYXRlLW1lZGl1bS0wMjEj
-MCEGA1UEAwwaYS1zaWduLWNvcnBvcmF0ZS1tZWRpdW0tMDIwggEiMA0GCSqGSIb3
-DQEBAQUAA4IBDwAwggEKAoIBAQCuaTBb6rHd5JZqAdvpmGIl5ne0Hg6GbpJvBeCI
-U6l9Rs8ebMY6aIS++qJOE9rnJHdfZNzLzduuoWEzEuwm9a/azQThM+eT+xlG/Vcf
-NuOQTTjAuXHLvYQ7WxSrBIT/kmAyqJgq/DEPvdX4jmCtVkuZ1gbxYIChLOVBWkVC
-FCK49BuXECtNy5fzK/GyfouZOVoQgiQ1YfecqzibcwO0t+f68Pvp/s6HESAH5tXY
-PdENDw4c/W/qKaeR87jPq98AJ8Lr4bmjWLjK8/ITtGglnJy8osFz22oR7f6fbWl6
-5LdhJ3giM68WEabQcZkw8cx3RDOzbnL2Kn+PVNHHyp3Wh849AgMBAAGjgeEwgd4w
-DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISoLnpz/+q98wEwYDVR0jBAwwCoAI
-Qj0rJKbBRc4wDgYDVR0PAQH/BAQDAgEGMIGSBgNVHR8EgYowgYcwgYSggYGgf4Z9
-bGRhcDovL2xkYXAuYS10cnVzdC5hdC9vdT1BLVRydXN0LVF1YWwtMDIsbz1BLVRy
-dXN0LGM9QVQ/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdD9iYXNlP29iamVjdGNs
-YXNzPWVpZENlcnRpZmljYXRpb25BdXRob3JpdHkwDQYJKoZIhvcNAQEFBQADggEB
-ABqg1oRs/TZ0hJLJRV/xJglFzgn2fDAXeoVvWnAE09F1d0n+ZorKAKbMfiZ2CuKs
-M0AhU23/5zM90DdrtYWXpa+P8ONALZtHJIqGfVuRKYJq7jY5TpE3yRkTcrp47smp
-WqTwUgG+0aBeU9m+ZtGUFOsBkq+MudD8IZGc7VcLd1n4ltND9ITjX20hu01ju56c
-YC69vFa5hmIccXg/Q3dGEV5Amx8MTQJluG3QvqBOY74yrAFICvK1zsvu+vOGvJQj
-i+PxKlbQdehrV82VDxyfSjpEUADWMGRfE5vg4YBGgfRosh4w7a6ThD2LMLFPmIhy
-P6+VGUBCm2tMDDOo9DVkXFs=
------END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-01a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-01a.cer
new file mode 100644
index 00000000..f9fef65f
Binary files /dev/null and b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-01a.cer differ
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-02a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-02a.cer
new file mode 100644
index 00000000..36a442b8
Binary files /dev/null and b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-02a.cer differ
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-03a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-03a.cer
new file mode 100644
index 00000000..ab9e0cd7
Binary files /dev/null and b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-Qual-03a.cer differ
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-01a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-01a.cer
new file mode 100644
index 00000000..efa28178
Binary files /dev/null and b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-01a.cer differ
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-03.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-03.cer
new file mode 100644
index 00000000..33e77636
Binary files /dev/null and b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/A-Trust-nQual-03.cer differ
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-SSL-03.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-SSL-03.cer
new file mode 100644
index 00000000..ee859434
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-SSL-03.cer
@@ -0,0 +1,26 @@
+-----BEGIN CERTIFICATE-----
+MIIEdzCCA1+gAwIBAgIDAmU4MA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
+dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA2MDgxNjIyMDAw
+MFoXDTE2MDgxNjIyMDAwMFowgYcxCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
+dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
+ZXJrZWhyIEdtYkgxFjAUBgNVBAsMDWEtc2lnbi1TU0wtMDMxFjAUBgNVBAMMDWEt
+c2lnbi1TU0wtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMjPM6
+PqgdPBPV4Efudpytt2Y4GZJfjeRdZo5SCuULDvvL+23xxBWnR3scFvfE1ekHN/YK
+k+2/qhU2B2ntoSNJSyDchNM8YPc9Lx67zZyhQTZgbBzh3IZAVb/hwuRRRV68JCBj
+r3r6v7IbwjH5XcVISdB4szx0z93aAQyKW9QkV+tD5a1vWFETvdHsZeVmDzfqcdsG
+AznPJw+9HrImCsswCWYUgPcFRkPNjj2r2NoyckVN781aWmNTAqJPf/Ckj9l9pUIt
+Vjhy8XNJW4iVDBkkykBXcGSkIau0ypJrRjsD1jKqUTIRZ/y2HlyltmwWi8OuyBLd
+LaHDbjc0b6JmqoivAgMBAAGjgeMwgeAwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4E
+CgQIQD6h02K0A90wEwYDVR0jBAwwCoAIRGqVZ1V5EU8wDgYDVR0PAQH/BAQDAgEG
+MIGUBgNVHR8EgYwwgYkwgYaggYOggYCGfmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQv
+b3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEtVHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJl
+dm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2VydGlmaWNhdGlvbkF1
+dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAQEAHKlnV3R9sbXojtONugyazkZCEzmC
+nZF1Dz4cOL0vPzzvS8MVWtG43zAgVI1NT/0ETSWsXD3YfzRi+f+/CxrGn0gwZX2t
+VGx+Z9w5ufiy1vuhxDUPmpos1TbJ4Wv3Une0E7iuHmNLg5qVlKeHWpcU8t1Y0nCt
+eRz34Qm87AVAykta33XST1fYvGoPKsDtn3qx9ye/pcbDvWjPwmqF2UUoql+d5hmJ
+Umgzwezqk4I+FS98BrnaPgC5UVFHg+yUjiUDLjYy7UvDZ5Led6kkLXuzVhQolLvr
+KTrGp5k42PG2MMkw8f6GMF/6yePXgzFMCRN8ReR7J5Htv33SytLRmFRd8g==
+-----END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-03.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-03.cer
new file mode 100644
index 00000000..7e67be95
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-03.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEgzCCA2ugAwIBAgIDAarsMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
+dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA1MTExMzIzMDAw
+MFoXDTE1MTExMzIzMDAwMFowgZMxCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
+dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
+ZXJrZWhyIEdtYkgxHDAaBgNVBAsME2Etc2lnbi1jb3Jwb3JhdGUtMDMxHDAaBgNV
+BAMME2Etc2lnbi1jb3Jwb3JhdGUtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQCp44qY+AiVXlcnHoKvch9s3ujoWFNktvcteIPwK7s0mb/uxTUW9UIF
+Die9n3AbyTsJE6R3nZYSJVHHi+1DKD72/WEo/B5NOOtd6KUMfJgca1tDmcsIwhFn
+82qkZrbNQwdIIdLe6+nDmjd9UBIaKv7yy1kq20jh09HOK3/bWhafVQE7EAgDfNrn
+8f0JfnnF0EA/La5kkg878L22fh9lRzt8H21THqJPtK4/e9SttjrJnPhFk2/MjAGS
+uaDufG6BV5Hnn7klR5qm5q32ypleLA6Zi4m9jRCVtPd4jRPYM40XpRkrJuFw+lxp
+rejfEZt/SRh1eQXiXDUgtgX8OaIylH9pAgMBAAGjgeMwgeAwDwYDVR0TAQH/BAUw
+AwEB/zARBgNVHQ4ECgQIQj75YZ1a5XIwEwYDVR0jBAwwCoAIRGqVZ1V5EU8wDgYD
+VR0PAQH/BAQDAgEGMIGUBgNVHR8EgYwwgYkwgYaggYOggYCGfmxkYXA6Ly9sZGFw
+LmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEtVHJ1c3QsYz1BVD9j
+ZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2Vy
+dGlmaWNhdGlvbkF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAQEARu7e1SyBRjlA
+g/thtFwtKQRvopTZKWj2LWpEdvPvwThOvf8Depnas+ly5af8r8YzsqJzfX3XWvhN
+qOOI24g5FmXfCUTq/kbtaeTq/AqV94793IJfcilPnpMOEHMqXNDiRUoAgR/9EVj8
+mDVvL2lLlJzeAltqOD5Bi9QwguaD2/3/E5ymFnqkf1dnlXbo8AhcwPEzReNKn1eM
+Ilg4FwP1bP0HUK3Fyz1UQ/Hncg+MS7c+SkjpNEd4sH7/GdxuQs5Sk7IRwot1+sbX
+3CkkPhSqiUzig9raxJYrtbb2kyiUO8+d5HzRyoP4BNzsdZdPc0gDYweXg5qarHOQ
+16IEOtBmKg==
+-----END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-01a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-01a.cer
new file mode 100644
index 00000000..0c68e593
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-01a.cer
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIEJjCCAw6gAwIBAgIDAOJEMA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNVBAYTAkFUMRAwDgYDVQQK
+EwdBLVRydXN0MRkwFwYDVQQLExBBLVRydXN0LW5RdWFsLTAxMRkwFwYDVQQDExBBLVRydXN0LW5R
+dWFsLTAxMB4XDTA0MTEzMDIzMDAwMFoXDTA4MTEzMDIzMDAwMFowgZ8xCzAJBgNVBAYTAkFUMUgw
+RgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0
+ZW52ZXJrZWhyIEdtYkgxIjAgBgNVBAsTGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDExIjAgBgNV
+BAMTGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
+AoIBAQDGC65v8rni63DojEBriynPwRqNCp14/SkN5ROkTUGNvLSabfSJV4PKGLTzasPAaChwX0g/
+kebahFM3R7nIyeVx2YB8VRvC4I/spP/mCs5+6pf1N+6Kiq4NcswgNBBfqAteaQIylBMy6HDkjoXY
+X/c+SxjyrqAkeZCK+SHMOraXCO1PZHWbYwleKXf4R2Z6ayEfJ2XWeVuqqon76WHp/POI0RADBchA
+6Vm1ROzSAHz39bay1TZunQXSs3VQ9cE3uQPjN+80efmf0ZgNF0sXsDTssoZg2feTANSOkTGM1bMC
+5xe1hWFL8MZNe4yZ+NSgFN2fofb8BPvyQAW0no2PNA6PAgMBAAGjgbMwgbAwDwYDVR0TAQH/BAUw
+AwEB/zARBgNVHQ4ECgQITp5/1C/JHx8wEwYDVR0jBAwwCoAITlnOxwIyhzAwDgYDVR0PAQH/BAQD
+AgEGMGUGA1UdHwReMFwwWqBYoFaGVGxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1u
+UXVhbC0wMSxvPUEtVHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0PzANBgkqhkiG
+9w0BAQUFAAOCAQEAOtuz2GqnTibk/poCLrdYKpZSrLyfWFsJJpfBYA9HMasnfpJBCHgRHJud6DAO
+xD900Vhmwy66D8dqsN3+fR8Bx8ZMKspnFN1B2Wz7LWOxMaKqP3JolJ/oVwzJRm0afcUMAfAumkc5
+Yqu0nC5qCF9zYY9YbJklh84uEzEg9j85kuRBHOCUc+5MVrnv7WPbirx6c95YFqXBQ0arA5QE9zYq
+MDO8aUYPOWEHgtrVI+kMwELYHqLDX7i9VqsXhgFPeVz1wIV7s/i3budGeHMS6hjnyIc30FqM7CTY
+fcvqVNZliErbjD1k1W1gMgvjLJowNvQC0W7K9/yoQhwTqtNMR4WZwA==
+-----END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-02a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-02a.cer
new file mode 100644
index 00000000..c300891d
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-02a.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEizCCA3OgAwIBAgIDAOSoMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRgwFgYDVQQLDA9BLVRydXN0LVF1
+YWwtMDIxGDAWBgNVBAMMD0EtVHJ1c3QtUXVhbC0wMjAeFw0wNDEyMTQyMzAwMDBa
+Fw0xNDEyMTMyMzAwMDBaMIGfMQswCQYDVQQGEwJBVDFIMEYGA1UECgw/QS1UcnVz
+dCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy
+a2VociBHbWJIMSIwIAYDVQQLDBlhLXNpZ24tY29ycG9yYXRlLWxpZ2h0LTAyMSIw
+IAYDVQQDDBlhLXNpZ24tY29ycG9yYXRlLWxpZ2h0LTAyMIIBIjANBgkqhkiG9w0B
+AQEFAAOCAQ8AMIIBCgKCAQEAk6V4oEauvXgEICqgjTbGHaiDhBVo2nosX23osoKM
+LTkkO/nOCgpdCYpLKgURxwrgHgVh9XT99yxhy6lDwt2rASajj0sQ1fY5BmWVyrXS
+dQ78ISMPb73XaG4M8H7PJFcsVEo9n8veVQwnMY5mSWy0r1IO8n93Bjbmmi4Zt8oS
+p9olWo5/8ByYW8S/AKZuQx+q+bFJv7geuApVjK2iVFe8yQqHhAgDsAsDlMvxDAQ/
+vhrGwHRv8N3sLsjirnbf5S2dGLDjASOMUFvwfLQd7gHH7PV37Xa+aQqa97eE6O4O
+sIhcGRYhoLk/tWTBDapcgHJ0yTtrftuwORVteLUAy0gBNwIDAQABo4HhMIHeMA8G
+A1UdEwEB/wQFMAMBAf8wEQYDVR0OBAoECEkcWDpP6A0DMBMGA1UdIwQMMAqACEI9
+KySmwUXOMA4GA1UdDwEB/wQEAwIBBjCBkgYDVR0fBIGKMIGHMIGEoIGBoH+GfWxk
+YXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1RdWFsLTAyLG89QS1UcnVz
+dCxjPUFUP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q/YmFzZT9vYmplY3RjbGFz
+cz1laWRDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5MA0GCSqGSIb3DQEBBQUAA4IBAQBH
+opWG7LKmPBvuGjZnRV4KGKzzUYVuxSRS1E0VIUPbVLf5xW2r5uUpR8ud5EpiPrcw
+k6K0dzu2Vb4ZbMIP+6J16S/0qvTp/3A/3q87+nJ+ot+IT8GZFJfSw18th2WmZdzR
+ShbM6sgViPtGsFROCdWeiHl248w2+zG+09sf8Bu3UyvwLRAiiKaxuwVdQ9kc0TL3
+gvv+K5eisWWthQOX2IF2jGSEqoAVwfHhl7bc9Vt7XnJSpQFebHnsIVuV4Mv6w4ww
+86hQPCLLvvV7wWDiBQ8l2FWneX0pNH3Wg+A1TRUoptc+pPDdpoP272MDm4fXyPKV
+7QgIaIK+gXNUj2GGt1K9
+-----END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-03.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-03.cer
new file mode 100644
index 00000000..2251ca22
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-light-03.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEjzCCA3egAwIBAgIDAartMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
+dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA1MTExMzIzMDAw
+MFoXDTE1MTExMzIzMDAwMFowgZ8xCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
+dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
+ZXJrZWhyIEdtYkgxIjAgBgNVBAsMGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDMx
+IjAgBgNVBAMMGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDMwggEiMA0GCSqGSIb3
+DQEBAQUAA4IBDwAwggEKAoIBAQC359oitbHkkEgdErRPeBdkcYRK2DLdxfcnn+SI
+umSEYzWVscRTchPKSzb7f1a6EHPbB5WZsGJaUDX9KfTqsJNMo+7bASKk3gsLVxNZ
+qY2t2G+y8HvREYYejDOIzjAkcBQrt+nvuBUlGYVJQjEuyAn18f2vG0Y3VNvZFGKn
+PK8AVycUMk0Uw21RbK3vX5tbbPgQ/kcZkN4czi5VHepMvf6hAwwLoJj+KL9zxm8j
+yPK88qCBKAjMNCpZKsEhyanw1CjYbVmHs45Q5W6FBtqDcS6Iq4mC6TtUPGtCTuoH
+7/JLuhEp075ohp87v3fSlzeLJjBpkUDP9U8Tv7l2euD0t1UVAgMBAAGjgeMwgeAw
+DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQIQZFpHL+t2JgwEwYDVR0jBAwwCoAI
+RGqVZ1V5EU8wDgYDVR0PAQH/BAQDAgEGMIGUBgNVHR8EgYwwgYkwgYaggYOggYCG
+fmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEt
+VHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0
+Y2xhc3M9ZWlkQ2VydGlmaWNhdGlvbkF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOC
+AQEADTRIaQtPwoPS6/TpyBhOw4wAHk/RM4gkLT76URPY2sUHihxqy+8qEElN+f5l
+I61myCP3IFTClflcHVR1QCoMg0ZI5/EcQTI8Dgd5iQkXuVjh3wCj87Ka2Tu7d1K+
+i9VJ4BR/ph/qmPKR7Lx/PtATw/vWo4k2rbt5o1QwixZ7CPt+BF9xCaAC4uL0bB0M
+9M3i9W2ePmqX6WIB3jMkT9FQC0KihPPfw/17KddNi4rFMMEiTyKvJTtTqDnIAwWW
+TqsL1G7oxMMtnnYaKWMQ6gQiOiRzCY7efcAi/3YwUX6ULW5zxqapNs1vqEbSGsQE
+l1eFl67HBZHYAPdoHGUnZF0KaQ==
+-----END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-01a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-01a.cer
new file mode 100644
index 00000000..2d7f1a03
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-01a.cer
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIEKDCCAxCgAwIBAgIDAOKKMA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNVBAYTAkFUMRAwDgYDVQQK
+EwdBLVRydXN0MRkwFwYDVQQLExBBLVRydXN0LW5RdWFsLTAxMRkwFwYDVQQDExBBLVRydXN0LW5R
+dWFsLTAxMB4XDTA0MTIwNTIzMDAwMFoXDTA4MTEzMDIzMDAwMFowgaExCzAJBgNVBAYTAkFUMUgw
+RgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0
+ZW52ZXJrZWhyIEdtYkgxIzAhBgNVBAsTGmEtc2lnbi1jb3Jwb3JhdGUtbWVkaXVtLTAxMSMwIQYD
+VQQDExphLXNpZ24tY29ycG9yYXRlLW1lZGl1bS0wMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
+AQoCggEBANEbZyIMIXZYBjTj/+3TrNGssRKNNdTedQlWB3vJQWLzeG89Kzmhy1WDX8IqDrMtvpXH
+5w6urK3ZT7HGu2Jldrib8rkEOdE9+uNGRtkP8Kuz//CvdXCbIDvBLqgvWn9a3Sl/rUicPqKwcEcN
+bP2Q0iU6NvvALmoqs93PymfTZlkGOwzUe+O88huXkauGWT/DkJd4JYDNJ0wlaGrJa+OorT4Izk1J
+EipqqedUjsAj4Gq3SKrZKG/H/CkoH9uWTzrzFgg8zQhCES4AClo84XVk//EIv3ABDw4hr+lqV1nF
+eXch9o4mLIe5u045471YLJLmyuCPDopb8U2VUoyldpMx+Y8CAwEAAaOBszCBsDAPBgNVHRMBAf8E
+BTADAQH/MBEGA1UdDgQKBAhOuHKxmCmfZDATBgNVHSMEDDAKgAhOWc7HAjKHMDAOBgNVHQ8BAf8E
+BAMCAQYwZQYDVR0fBF4wXDBaoFigVoZUbGRhcDovL2xkYXAuYS10cnVzdC5hdC9vdT1BLVRydXN0
+LW5RdWFsLTAxLG89QS1UcnVzdCxjPUFUP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q/MA0GCSqG
+SIb3DQEBBQUAA4IBAQDaukYSeJVxWAh8QShqGqA6Plp9aXCTzwl9hE2gb+/xGPASo+NVQi/sUa0+
+bx29oSJaW6lKzdHQLAx4dwW9XTpJ+0mebB4fQfYHH0lGc1O4au/4O9k+C3SrD6x4WeY9k/SpUFu1
+qjzH+tjta81UWtU7Jve1BhckNwdOFx7cR8fdW+pUQSDV9XnPJfyb+gb9KWhvX+XAbgJoXW1HjJOO
+P5sx6mFhMb3UqAfKQVoAuGbl4+uxIThBTqpICkaaD8WLdukqQjomUMDRbWIf6SblPuOEpPi1G/WM
+qkTkpqX77Wkj08QY/yj5DDrsYJ5NymnWvu7jcoxCFCKvEQ8Q4g7AYKnG
+-----END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-02a.cer b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-02a.cer
new file mode 100644
index 00000000..194d4d7c
--- /dev/null
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/certs/certStore/tobeadded/a-sign-corporate-medium-02a.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEjTCCA3WgAwIBAgIDAOSpMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRgwFgYDVQQLDA9BLVRydXN0LVF1
+YWwtMDIxGDAWBgNVBAMMD0EtVHJ1c3QtUXVhbC0wMjAeFw0wNDEyMTQyMzAwMDBa
+Fw0xNDEyMTMyMzAwMDBaMIGhMQswCQYDVQQGEwJBVDFIMEYGA1UECgw/QS1UcnVz
+dCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy
+a2VociBHbWJIMSMwIQYDVQQLDBphLXNpZ24tY29ycG9yYXRlLW1lZGl1bS0wMjEj
+MCEGA1UEAwwaYS1zaWduLWNvcnBvcmF0ZS1tZWRpdW0tMDIwggEiMA0GCSqGSIb3
+DQEBAQUAA4IBDwAwggEKAoIBAQCuaTBb6rHd5JZqAdvpmGIl5ne0Hg6GbpJvBeCI
+U6l9Rs8ebMY6aIS++qJOE9rnJHdfZNzLzduuoWEzEuwm9a/azQThM+eT+xlG/Vcf
+NuOQTTjAuXHLvYQ7WxSrBIT/kmAyqJgq/DEPvdX4jmCtVkuZ1gbxYIChLOVBWkVC
+FCK49BuXECtNy5fzK/GyfouZOVoQgiQ1YfecqzibcwO0t+f68Pvp/s6HESAH5tXY
+PdENDw4c/W/qKaeR87jPq98AJ8Lr4bmjWLjK8/ITtGglnJy8osFz22oR7f6fbWl6
+5LdhJ3giM68WEabQcZkw8cx3RDOzbnL2Kn+PVNHHyp3Wh849AgMBAAGjgeEwgd4w
+DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISoLnpz/+q98wEwYDVR0jBAwwCoAI
+Qj0rJKbBRc4wDgYDVR0PAQH/BAQDAgEGMIGSBgNVHR8EgYowgYcwgYSggYGgf4Z9
+bGRhcDovL2xkYXAuYS10cnVzdC5hdC9vdT1BLVRydXN0LVF1YWwtMDIsbz1BLVRy
+dXN0LGM9QVQ/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdD9iYXNlP29iamVjdGNs
+YXNzPWVpZENlcnRpZmljYXRpb25BdXRob3JpdHkwDQYJKoZIhvcNAQEFBQADggEB
+ABqg1oRs/TZ0hJLJRV/xJglFzgn2fDAXeoVvWnAE09F1d0n+ZorKAKbMfiZ2CuKs
+M0AhU23/5zM90DdrtYWXpa+P8ONALZtHJIqGfVuRKYJq7jY5TpE3yRkTcrp47smp
+WqTwUgG+0aBeU9m+ZtGUFOsBkq+MudD8IZGc7VcLd1n4ltND9ITjX20hu01ju56c
+YC69vFa5hmIccXg/Q3dGEV5Amx8MTQJluG3QvqBOY74yrAFICvK1zsvu+vOGvJQj
+i+PxKlbQdehrV82VDxyfSjpEUADWMGRfE5vg4YBGgfRosh4w7a6ThD2LMLFPmIhy
+P6+VGUBCm2tMDDOo9DVkXFs=
+-----END CERTIFICATE-----
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
index 9766ae26..eebe36cd 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
@@ -28,18 +28,18 @@ AccessController.policyResource=classpath:at/gv/egiz/bku/online/conf/accessContr
# directory where certificates for
# chain constructions can be placed
+#SSL.certDirectory=classpath:at/gv/egiz/bku/online/conf/certs/certStore
SSL.certDirectory=classpath:at/gv/egiz/bku/online/conf/certs/certStore
+
# Directory where trusted CA
# certificates are placed
SSL.caDirectory=classpath:at/gv/egiz/bku/online/conf/certs/CACerts
-
-SSL.doRevocationChecking=true
SSL.sslProtocol=TLS
-SSL.cache.lifetime=3600
-# use authority info access extension to find ca certs.
-SSL.useAIA=true
+# warning do not set the following property to true
+# its intended for debugging and testing only
+SSL.disableAllChecks=false
# ------------ END SSL Config --------------------
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index b074da59..4069cdc9 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -45,9 +45,13 @@
+
+
+
+
diff --git a/BKUOnline/src/main/webapp/WEB-INF/web.xml b/BKUOnline/src/main/webapp/WEB-INF/web.xml
index 282d4db2..6b2ec35c 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/web.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/web.xml
@@ -1,97 +1,104 @@
-
+
+ http-security-layer-request
- http://www.apache.org/licenses/LICENSE-2.0
+
+
+ contextConfigLocation
+ /WEB-INF/applicationContext.xml
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
- 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.
--->
-
- http-security-layer-request
-
-
-
- contextConfigLocation
- /WEB-INF/applicationContext.xml
-
-
-
- org.springframework.web.context.ContextLoaderListener
-
-
-
-
-
-
- at.gv.egiz.bku.online.webapp.SessionTimeout
-
-
- BKUServlet
- at.gv.egiz.bku.online.webapp.BKURequestHandler
-
-
- ResultServlet
- at.gv.egiz.bku.online.webapp.ResultServlet
-
- responseEncoding
- UTF-8
-
-
- expiredPage
-
- expired.html
-
-
-
- BKUServlet
- /http-security-layer-request
-
-
- BKUServlet
- /https-security-layer-request
-
-
- ResultServlet
- /bkuResult
-
-
-
-
-
-
-
- com.sun.xml.ws.transport.http.servlet.WSServletContextListener
-
-
- STALPort
- com.sun.xml.ws.transport.http.servlet.WSServlet
- 1
-
-
- STALPort
- /stal
-
-
-
- index.html
- index.htm
- index.jsp
- default.html
- default.htm
- default.jsp
-
-
- 5
-
+
+
+ at.gv.egiz.bku.online.webapp.SessionTimeout
+
+
+ BKUServlet
+ at.gv.egiz.bku.online.webapp.BKURequestHandler
+
+
+ ResultServlet
+ at.gv.egiz.bku.online.webapp.ResultServlet
+
+ responseEncoding
+ UTF-8
+
+
+ expiredPage
+
+ expired.html
+
+
+
+ HashDataInputServlet
+ at.gv.egiz.bku.online.webapp.HashDataInputServlet
+
+
+ BKUServlet
+ /http-security-layer-request
+
+
+ BKUServlet
+ /https-security-layer-request
+
+
+ ResultServlet
+ /bkuResult
+
+
+ HashDataInputServlet
+ /hashDataInput
+
+
+
+
+
+
+
+
+
+
+ com.sun.xml.ws.transport.http.servlet.WSServletContextListener
+
+
+ STALPort
+ com.sun.xml.ws.transport.http.servlet.WSServlet
+ 1
+
+
+ STALPort
+ /stal
+
+
+
+
+ index.html
+ index.htm
+ index.jsp
+ default.html
+ default.htm
+ default.jsp
+
+
+ 5
+
\ No newline at end of file
diff --git a/BKUOnline/src/test/resources/applicationContext.xml b/BKUOnline/src/test/resources/applicationContext.xml
index 4bb5e8e2..5f2487bf 100644
--- a/BKUOnline/src/test/resources/applicationContext.xml
+++ b/BKUOnline/src/test/resources/applicationContext.xml
@@ -45,9 +45,11 @@
+
+
\ No newline at end of file
diff --git a/STALService/pom.xml b/STALService/pom.xml
index 93181adb..e9c573f1 100644
--- a/STALService/pom.xml
+++ b/STALService/pom.xml
@@ -18,5 +18,10 @@
STAL1.0-SNAPSHOT
+
+ at.gv.egiz
+ utils
+ 1.0-SNAPSHOT
+
\ No newline at end of file
diff --git a/STALService/src/main/java/at/gv/egiz/stal/util/HashDataInputProxy.java b/STALService/src/main/java/at/gv/egiz/stal/util/HashDataInputProxy.java
new file mode 100644
index 00000000..dda20968
--- /dev/null
+++ b/STALService/src/main/java/at/gv/egiz/stal/util/HashDataInputProxy.java
@@ -0,0 +1,67 @@
+package at.gv.egiz.stal.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.stal.HashDataInput;
+
+/**
+ * Enables multiple read requests.
+ *
+ */
+public class HashDataInputProxy implements HashDataInput {
+
+ private static Log log = LogFactory.getLog(HashDataInputProxy.class);
+
+ private HashDataInput delegate;
+ private byte[] hashInput;
+
+ /**
+ *
+ * @param delegate
+ * != null
+ */
+ public HashDataInputProxy(HashDataInput delegate) {
+ if (delegate == null) {
+ throw new NullPointerException("Constructor argument must not be null");
+ }
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String getEncoding() {
+ return delegate.getEncoding();
+ }
+
+ @Override
+ public InputStream getHashDataInput() {
+ if (hashInput == null) {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ try {
+ StreamUtil.copyStream(delegate.getHashDataInput(), os);
+ hashInput = os.toByteArray();
+ } catch (IOException e) {
+ log.error("Cannot access hashdatainput stream", e);
+ hashInput = new byte[0];
+ }
+ }
+ return new ByteArrayInputStream(hashInput);
+ }
+
+ @Override
+ public String getMimeType() {
+ return delegate.getMimeType();
+ }
+
+ @Override
+ public String getReferenceId() {
+ return delegate.getReferenceId();
+ }
+
+}
diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml
index 40b73e48..a90aebf5 100644
--- a/bkucommon/pom.xml
+++ b/bkucommon/pom.xml
@@ -1,78 +1,85 @@
-
-
- bku
- at.gv.egiz
- 1.0-SNAPSHOT
-
- 4.0.0
- at.gv.egiz
- bkucommon
- BKU Common
- 1.0-SNAPSHOT
- http://maven.apache.org
-
-
- at.gv.egiz
- utils
- 1.0-SNAPSHOT
-
-
- at.gv.egiz
- STAL
- 1.0-SNAPSHOT
-
-
- commons-logging
- commons-logging
-
-
- iaik
- iaik_jce_full_signed
-
-
- commons-fileupload
- commons-fileupload
- compile
-
-
- commons-httpclient
- commons-httpclient
- compile
-
-
- xerces
- xercesImpl
-
-
- xalan
- xalan
-
-
- iaik
- iaik_xsect
-
-
-
-
-
-
-
-
+
+
+ bku
+ at.gv.egiz
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ at.gv.egiz
+ bkucommon
+ BKU Common
+ 1.0-SNAPSHOT
+ http://maven.apache.org
+
+
+ at.gv.egiz
+ utils
+ 1.0-SNAPSHOT
+
+
+ at.gv.egiz
+ STAL
+ 1.0-SNAPSHOT
+
+
+ commons-logging
+ commons-logging
+
+
+ iaik
+ iaik_jce_full_signed
+
+
+ commons-fileupload
+ commons-fileupload
+ compile
+
+
+ commons-httpclient
+ commons-httpclient
+ compile
+
+
+ xerces
+ xercesImpl
+
+
+ xalan
+ xalan
+
+
+ iaik
+ iaik_xsect
+
+
+ iaik
+ iaik_pki
+ compile
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidator.java
new file mode 100644
index 00000000..6a95b369
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidator.java
@@ -0,0 +1,13 @@
+package at.gv.egiz.bku.conf;
+
+import iaik.x509.X509Certificate;
+
+import java.io.File;
+
+public interface CertValidator {
+
+ public abstract void init(File certDir, File caDir);
+
+ public abstract boolean isCertificateValid(String transactionId, X509Certificate[] certs);
+
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java
new file mode 100644
index 00000000..125233c1
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java
@@ -0,0 +1,83 @@
+package at.gv.egiz.bku.conf;
+
+import iaik.logging.TransactionId;
+import iaik.logging.impl.TransactionIdImpl;
+import iaik.pki.DefaultPKIConfiguration;
+import iaik.pki.DefaultPKIProfile;
+import iaik.pki.PKIConfiguration;
+import iaik.pki.PKIException;
+import iaik.pki.PKIFactory;
+import iaik.pki.PKIModule;
+import iaik.pki.PKIProfile;
+import iaik.pki.store.certstore.CertStoreParameters;
+import iaik.pki.store.certstore.directory.DefaultDirectoryCertStoreParameters;
+import iaik.pki.store.truststore.DefaultTrustStoreProfile;
+import iaik.pki.store.truststore.TrustStoreProfile;
+import iaik.pki.store.truststore.TrustStoreTypes;
+import iaik.x509.X509Certificate;
+
+import java.io.File;
+import java.util.Date;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class CertValidatorImpl implements CertValidator {
+
+ private static Log log = LogFactory.getLog(CertValidatorImpl.class);
+
+ private PKIFactory pkiFactory;
+ private PKIProfile profile;
+
+ public CertValidatorImpl() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.conf.CertValidator#init(java.io.File, java.io.File)
+ */
+ public void init(File certDir, File caDir) {
+ // the parameters specifying the directory certstore
+ CertStoreParameters[] certStoreParameters = { new DefaultDirectoryCertStoreParameters(
+ "CS-001", certDir.getAbsolutePath(), true, false) };
+
+ // create a new PKI configuration using the certstore parameters
+ PKIConfiguration pkiConfig = new DefaultPKIConfiguration(
+ certStoreParameters);
+
+ // Transaction ID for logging
+ TransactionId tid = new TransactionIdImpl("Configure-PKI");
+ // get PKI factory for creating PKI module(s)
+ pkiFactory = PKIFactory.getInstance();
+ // configure the factory
+ try {
+ pkiFactory.configure(pkiConfig, tid);
+ } catch (PKIException e) {
+ log.error("Cannot configure PKI module", e);
+ }
+ // the truststore to be used
+ TrustStoreProfile trustProfile = new DefaultTrustStoreProfile("TS-001",
+ TrustStoreTypes.DIRECTORY, caDir.getAbsolutePath());
+ profile = new DefaultPKIProfile(trustProfile);
+ ((DefaultPKIProfile)profile).setAutoAddCertificates(true);
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.conf.CertValidator#isCertificateValid(java.lang.String, iaik.x509.X509Certificate[])
+ */
+ public boolean isCertificateValid(String transactionId,
+ X509Certificate[] certs) {
+ // Transaction ID for logging
+ TransactionId tid = new TransactionIdImpl(transactionId);
+ // get a PKIModule
+ PKIModule pkiModule;
+ try {
+ pkiModule = pkiFactory.getPKIModule(profile);
+ return pkiModule.validateCertificate(new Date(), certs[0], certs, null,
+ tid).isCertificateValid();
+ } catch (PKIException e) {
+ log.error("Cannot validate certificate", e);
+ }
+ return false;
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
index 9a1e7020..9ed99190 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
@@ -9,6 +9,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
@@ -18,27 +19,18 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.CollectionCertStoreParameters;
import java.security.cert.LDAPCertStoreParameters;
-import java.security.cert.PKIXBuilderParameters;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509CertSelector;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
-import java.util.Set;
-import javax.net.ssl.CertPathTrustManagerParameters;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManager;
-import javax.net.ssl.ManagerFactoryParameters;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.logging.Log;
@@ -55,6 +47,8 @@ public abstract class Configurator {
protected Properties properties;
+ protected CertValidator certValidator;
+
protected Configurator() {
}
@@ -64,9 +58,9 @@ public abstract class Configurator {
protected abstract InputStream getManifest();
- private Set getCACerts() throws IOException,
+ private X509Certificate[] getCACerts() throws IOException,
CertificateException {
- Set caCerts = new HashSet();
+ List caCerts = new ArrayList();
File caDir = getCADir();
if (caDir != null) {
if (!caDir.isDirectory()) {
@@ -81,13 +75,12 @@ public abstract class Configurator {
X509Certificate cert = (X509Certificate) cf.generateCertificate(fis);
fis.close();
log.debug("Adding trusted cert " + cert.getSubjectDN());
- caCerts.add(new TrustAnchor(cert, null));
+ caCerts.add(cert);
} catch (Exception e) {
log.error("Cannot add trusted ca", e);
}
}
- return caCerts;
-
+ return caCerts.toArray(new X509Certificate[caCerts.size()]);
} else {
log.warn("No CA certificates configured");
}
@@ -239,69 +232,33 @@ public abstract class Configurator {
}
public void configureSSL() {
- Set caCerts = null;
+ X509Certificate[] caCerts = null;
try {
caCerts = getCACerts();
} catch (Exception e1) {
log.error("Cannot load CA certificates", e1);
}
- List certStoreList = null;
- try {
- certStoreList = getCertstore();
- } catch (Exception e1) {
- log.error("Cannot load certstore certificates", e1);
- }
- String aia = getProperty("SSL.useAIA");
- if ((aia == null) || (aia.equals(""))) {
- System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
- } else {
- System.setProperty("com.sun.security.enableAIAcaIssuers", aia);
- }
- String lifetime = getProperty("SSL.cache.lifetime");
- if ((lifetime == null) || (lifetime.equals(""))) {
- System.setProperty("sun.security.certpath.ldap.cache.lifetime", "0");
- } else {
- System.setProperty("sun.security.certpath.ldap.cache.lifetime", lifetime);
- }
- X509CertSelector selector = new X509CertSelector();
- PKIXBuilderParameters pkixParams;
+ String disableAll = getProperty("SSL.disableAllChecks");
try {
- pkixParams = new PKIXBuilderParameters(caCerts, selector);
- if ((getProperty("SSL.doRevocationChecking") != null)
- && (Boolean.valueOf(getProperty("SSL.doRevocationChecking")))) {
- log.info("Enable revocation checking");
- System.setProperty("com.sun.security.enableCRLDP", "true");
- Security.setProperty("ocsp.enable", "true");
- } else {
- log.warn("Revocation checking disabled");
- }
- for (CertStore cs : certStoreList) {
- pkixParams.addCertStore(cs);
- }
- ManagerFactoryParameters trustParams = new CertPathTrustManagerParameters(
- pkixParams);
- TrustManagerFactory trustFab;
- trustFab = TrustManagerFactory.getInstance("PKIX");
- trustFab.init(trustParams);
KeyManager[] km = null;
SSLContext sslCtx = SSLContext
.getInstance(getProperty("SSL.sslProtocol"));
- String disableAll = getProperty("SSL.disableAllChecks");
if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
log.warn("--------------------------------------");
log.warn(" Disabling SSL Certificate Validation ");
log.warn("--------------------------------------");
- sslCtx.init(km, new TrustManager[] { new MyTrustManager(caCerts,
- certStoreList) }, null);
+ sslCtx.init(km,
+ new TrustManager[] { new MyAlwaysTrustManager(caCerts) }, null);
} else {
- sslCtx.init(km, trustFab.getTrustManagers(), null);
+ MyPKITrustManager pkixTM = new MyPKITrustManager(certValidator,
+ getCertDir(), getCADir(), caCerts);
+ sslCtx.init(km, new TrustManager[] { pkixTM }, null);
}
HttpsURLConnection.setDefaultSSLSocketFactory(sslCtx.getSocketFactory());
} catch (Exception e) {
log.error("Cannot configure SSL", e);
}
- String disableAll = getProperty("SSL.disableAllChecks");
if ((disableAll != null) && (Boolean.parseBoolean(disableAll))) {
log.warn("---------------------------------");
log.warn(" Disabling Hostname Verification ");
@@ -315,19 +272,74 @@ public abstract class Configurator {
}
}
- private static class MyTrustManager implements X509TrustManager {
- private static Log log = LogFactory.getLog(MyTrustManager.class);
+
+
+ public void setCertValidator(CertValidator certValidator) {
+ this.certValidator = certValidator;
+ }
+
+ private static class MyPKITrustManager implements X509TrustManager {
+ private static Log log = LogFactory.getLog(MyPKITrustManager.class);
+
+ private CertValidator certValidator;
private X509Certificate[] trustedCerts;
- public MyTrustManager(Set caCerts, List cs) {
- trustedCerts = new X509Certificate[caCerts.size()];
+ public MyPKITrustManager(CertValidator cv, File certStore, File trustStore,
+ X509Certificate[] trustedCerts) {
+ certValidator = cv;
+ certValidator.init(certStore, trustStore);
+ this.trustedCerts = trustedCerts;
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException {
+ log.error("Did not expect this method to get called");
+ throw new CertificateException("Method not implemented");
+ }
+
+ private static iaik.x509.X509Certificate[] convertCerts(
+ X509Certificate[] certs) throws GeneralSecurityException {
+ iaik.x509.X509Certificate[] retVal = new iaik.x509.X509Certificate[certs.length];
int i = 0;
- for (Iterator it = caCerts.iterator(); it.hasNext();) {
- TrustAnchor ta = it.next();
- trustedCerts[i++] = ta.getTrustedCert();
+ for (X509Certificate cert : certs) {
+ if (cert instanceof iaik.x509.X509Certificate) {
+ retVal[i++] = (iaik.x509.X509Certificate) cert;
+ } else {
+ retVal[i++] = new iaik.x509.X509Certificate(cert.getEncoded());
+ }
+ }
+ return retVal;
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException {
+ try {
+ boolean valid = certValidator.isCertificateValid(Thread.currentThread()
+ .getName(), convertCerts(chain));
+ if (!valid) {
+ throw new CertificateException("Certificate not valid");
+ }
+ } catch (GeneralSecurityException e) {
+ throw new CertificateException(e);
}
}
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return trustedCerts;
+ }
+ }
+
+ private static class MyAlwaysTrustManager implements X509TrustManager {
+ private static Log log = LogFactory.getLog(MyAlwaysTrustManager.class);
+ private X509Certificate[] trustedCerts;
+
+ public MyAlwaysTrustManager(X509Certificate[] trustedCerts) {
+ this.trustedCerts = trustedCerts;
+ }
+
@Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/conf/CertValidatorTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/conf/CertValidatorTest.java
new file mode 100644
index 00000000..7bc0daa5
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/conf/CertValidatorTest.java
@@ -0,0 +1,32 @@
+package at.gv.egiz.bku.conf;
+
+import iaik.x509.X509Certificate;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.cert.CertificateException;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class CertValidatorTest {
+
+ private CertValidator cv;
+
+ @Before
+ public void setUp() {
+ cv = new CertValidatorImpl();
+ String caDir = getClass().getClassLoader().getResource("at/gv/egiz/bku/conf/certs/CACerts").getPath();
+ String certDir = getClass().getClassLoader().getResource("at/gv/egiz/bku/conf/certs/certStore").getPath();
+ cv.init(new File(caDir), new File(certDir));
+ }
+
+ @Test
+ public void testValid() throws CertificateException, IOException {
+ X509Certificate cert = new X509Certificate(getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/conf/certs/testCerts/www.a-trust.at.der"));
+ assertTrue(cv.isCertificateValid("TID", new X509Certificate[]{cert}));
+ }
+
+}
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-01a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-01a.cer
new file mode 100644
index 00000000..f9fef65f
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-01a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-02a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-02a.cer
new file mode 100644
index 00000000..36a442b8
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-02a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-03a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-03a.cer
new file mode 100644
index 00000000..ab9e0cd7
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-Qual-03a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-01a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-01a.cer
new file mode 100644
index 00000000..efa28178
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-01a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-03.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-03.cer
new file mode 100644
index 00000000..33e77636
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/CACerts/A-Trust-nQual-03.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-01a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-01a.cer
new file mode 100644
index 00000000..f9fef65f
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-01a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-02a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-02a.cer
new file mode 100644
index 00000000..36a442b8
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-02a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-03a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-03a.cer
new file mode 100644
index 00000000..ab9e0cd7
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-Qual-03a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-01a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-01a.cer
new file mode 100644
index 00000000..efa28178
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-01a.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-03.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-03.cer
new file mode 100644
index 00000000..33e77636
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/A-Trust-nQual-03.cer differ
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-SSL-03.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-SSL-03.cer
new file mode 100644
index 00000000..ee859434
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-SSL-03.cer
@@ -0,0 +1,26 @@
+-----BEGIN CERTIFICATE-----
+MIIEdzCCA1+gAwIBAgIDAmU4MA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
+dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA2MDgxNjIyMDAw
+MFoXDTE2MDgxNjIyMDAwMFowgYcxCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
+dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
+ZXJrZWhyIEdtYkgxFjAUBgNVBAsMDWEtc2lnbi1TU0wtMDMxFjAUBgNVBAMMDWEt
+c2lnbi1TU0wtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMjPM6
+PqgdPBPV4Efudpytt2Y4GZJfjeRdZo5SCuULDvvL+23xxBWnR3scFvfE1ekHN/YK
+k+2/qhU2B2ntoSNJSyDchNM8YPc9Lx67zZyhQTZgbBzh3IZAVb/hwuRRRV68JCBj
+r3r6v7IbwjH5XcVISdB4szx0z93aAQyKW9QkV+tD5a1vWFETvdHsZeVmDzfqcdsG
+AznPJw+9HrImCsswCWYUgPcFRkPNjj2r2NoyckVN781aWmNTAqJPf/Ckj9l9pUIt
+Vjhy8XNJW4iVDBkkykBXcGSkIau0ypJrRjsD1jKqUTIRZ/y2HlyltmwWi8OuyBLd
+LaHDbjc0b6JmqoivAgMBAAGjgeMwgeAwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4E
+CgQIQD6h02K0A90wEwYDVR0jBAwwCoAIRGqVZ1V5EU8wDgYDVR0PAQH/BAQDAgEG
+MIGUBgNVHR8EgYwwgYkwgYaggYOggYCGfmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQv
+b3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEtVHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJl
+dm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2VydGlmaWNhdGlvbkF1
+dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAQEAHKlnV3R9sbXojtONugyazkZCEzmC
+nZF1Dz4cOL0vPzzvS8MVWtG43zAgVI1NT/0ETSWsXD3YfzRi+f+/CxrGn0gwZX2t
+VGx+Z9w5ufiy1vuhxDUPmpos1TbJ4Wv3Une0E7iuHmNLg5qVlKeHWpcU8t1Y0nCt
+eRz34Qm87AVAykta33XST1fYvGoPKsDtn3qx9ye/pcbDvWjPwmqF2UUoql+d5hmJ
+Umgzwezqk4I+FS98BrnaPgC5UVFHg+yUjiUDLjYy7UvDZ5Led6kkLXuzVhQolLvr
+KTrGp5k42PG2MMkw8f6GMF/6yePXgzFMCRN8ReR7J5Htv33SytLRmFRd8g==
+-----END CERTIFICATE-----
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-03.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-03.cer
new file mode 100644
index 00000000..7e67be95
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-03.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEgzCCA2ugAwIBAgIDAarsMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
+dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA1MTExMzIzMDAw
+MFoXDTE1MTExMzIzMDAwMFowgZMxCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
+dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
+ZXJrZWhyIEdtYkgxHDAaBgNVBAsME2Etc2lnbi1jb3Jwb3JhdGUtMDMxHDAaBgNV
+BAMME2Etc2lnbi1jb3Jwb3JhdGUtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQCp44qY+AiVXlcnHoKvch9s3ujoWFNktvcteIPwK7s0mb/uxTUW9UIF
+Die9n3AbyTsJE6R3nZYSJVHHi+1DKD72/WEo/B5NOOtd6KUMfJgca1tDmcsIwhFn
+82qkZrbNQwdIIdLe6+nDmjd9UBIaKv7yy1kq20jh09HOK3/bWhafVQE7EAgDfNrn
+8f0JfnnF0EA/La5kkg878L22fh9lRzt8H21THqJPtK4/e9SttjrJnPhFk2/MjAGS
+uaDufG6BV5Hnn7klR5qm5q32ypleLA6Zi4m9jRCVtPd4jRPYM40XpRkrJuFw+lxp
+rejfEZt/SRh1eQXiXDUgtgX8OaIylH9pAgMBAAGjgeMwgeAwDwYDVR0TAQH/BAUw
+AwEB/zARBgNVHQ4ECgQIQj75YZ1a5XIwEwYDVR0jBAwwCoAIRGqVZ1V5EU8wDgYD
+VR0PAQH/BAQDAgEGMIGUBgNVHR8EgYwwgYkwgYaggYOggYCGfmxkYXA6Ly9sZGFw
+LmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEtVHJ1c3QsYz1BVD9j
+ZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2Vy
+dGlmaWNhdGlvbkF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAQEARu7e1SyBRjlA
+g/thtFwtKQRvopTZKWj2LWpEdvPvwThOvf8Depnas+ly5af8r8YzsqJzfX3XWvhN
+qOOI24g5FmXfCUTq/kbtaeTq/AqV94793IJfcilPnpMOEHMqXNDiRUoAgR/9EVj8
+mDVvL2lLlJzeAltqOD5Bi9QwguaD2/3/E5ymFnqkf1dnlXbo8AhcwPEzReNKn1eM
+Ilg4FwP1bP0HUK3Fyz1UQ/Hncg+MS7c+SkjpNEd4sH7/GdxuQs5Sk7IRwot1+sbX
+3CkkPhSqiUzig9raxJYrtbb2kyiUO8+d5HzRyoP4BNzsdZdPc0gDYweXg5qarHOQ
+16IEOtBmKg==
+-----END CERTIFICATE-----
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-01a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-01a.cer
new file mode 100644
index 00000000..0c68e593
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-01a.cer
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIEJjCCAw6gAwIBAgIDAOJEMA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNVBAYTAkFUMRAwDgYDVQQK
+EwdBLVRydXN0MRkwFwYDVQQLExBBLVRydXN0LW5RdWFsLTAxMRkwFwYDVQQDExBBLVRydXN0LW5R
+dWFsLTAxMB4XDTA0MTEzMDIzMDAwMFoXDTA4MTEzMDIzMDAwMFowgZ8xCzAJBgNVBAYTAkFUMUgw
+RgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0
+ZW52ZXJrZWhyIEdtYkgxIjAgBgNVBAsTGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDExIjAgBgNV
+BAMTGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
+AoIBAQDGC65v8rni63DojEBriynPwRqNCp14/SkN5ROkTUGNvLSabfSJV4PKGLTzasPAaChwX0g/
+kebahFM3R7nIyeVx2YB8VRvC4I/spP/mCs5+6pf1N+6Kiq4NcswgNBBfqAteaQIylBMy6HDkjoXY
+X/c+SxjyrqAkeZCK+SHMOraXCO1PZHWbYwleKXf4R2Z6ayEfJ2XWeVuqqon76WHp/POI0RADBchA
+6Vm1ROzSAHz39bay1TZunQXSs3VQ9cE3uQPjN+80efmf0ZgNF0sXsDTssoZg2feTANSOkTGM1bMC
+5xe1hWFL8MZNe4yZ+NSgFN2fofb8BPvyQAW0no2PNA6PAgMBAAGjgbMwgbAwDwYDVR0TAQH/BAUw
+AwEB/zARBgNVHQ4ECgQITp5/1C/JHx8wEwYDVR0jBAwwCoAITlnOxwIyhzAwDgYDVR0PAQH/BAQD
+AgEGMGUGA1UdHwReMFwwWqBYoFaGVGxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1u
+UXVhbC0wMSxvPUEtVHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0PzANBgkqhkiG
+9w0BAQUFAAOCAQEAOtuz2GqnTibk/poCLrdYKpZSrLyfWFsJJpfBYA9HMasnfpJBCHgRHJud6DAO
+xD900Vhmwy66D8dqsN3+fR8Bx8ZMKspnFN1B2Wz7LWOxMaKqP3JolJ/oVwzJRm0afcUMAfAumkc5
+Yqu0nC5qCF9zYY9YbJklh84uEzEg9j85kuRBHOCUc+5MVrnv7WPbirx6c95YFqXBQ0arA5QE9zYq
+MDO8aUYPOWEHgtrVI+kMwELYHqLDX7i9VqsXhgFPeVz1wIV7s/i3budGeHMS6hjnyIc30FqM7CTY
+fcvqVNZliErbjD1k1W1gMgvjLJowNvQC0W7K9/yoQhwTqtNMR4WZwA==
+-----END CERTIFICATE-----
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-02a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-02a.cer
new file mode 100644
index 00000000..c300891d
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-02a.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEizCCA3OgAwIBAgIDAOSoMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRgwFgYDVQQLDA9BLVRydXN0LVF1
+YWwtMDIxGDAWBgNVBAMMD0EtVHJ1c3QtUXVhbC0wMjAeFw0wNDEyMTQyMzAwMDBa
+Fw0xNDEyMTMyMzAwMDBaMIGfMQswCQYDVQQGEwJBVDFIMEYGA1UECgw/QS1UcnVz
+dCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy
+a2VociBHbWJIMSIwIAYDVQQLDBlhLXNpZ24tY29ycG9yYXRlLWxpZ2h0LTAyMSIw
+IAYDVQQDDBlhLXNpZ24tY29ycG9yYXRlLWxpZ2h0LTAyMIIBIjANBgkqhkiG9w0B
+AQEFAAOCAQ8AMIIBCgKCAQEAk6V4oEauvXgEICqgjTbGHaiDhBVo2nosX23osoKM
+LTkkO/nOCgpdCYpLKgURxwrgHgVh9XT99yxhy6lDwt2rASajj0sQ1fY5BmWVyrXS
+dQ78ISMPb73XaG4M8H7PJFcsVEo9n8veVQwnMY5mSWy0r1IO8n93Bjbmmi4Zt8oS
+p9olWo5/8ByYW8S/AKZuQx+q+bFJv7geuApVjK2iVFe8yQqHhAgDsAsDlMvxDAQ/
+vhrGwHRv8N3sLsjirnbf5S2dGLDjASOMUFvwfLQd7gHH7PV37Xa+aQqa97eE6O4O
+sIhcGRYhoLk/tWTBDapcgHJ0yTtrftuwORVteLUAy0gBNwIDAQABo4HhMIHeMA8G
+A1UdEwEB/wQFMAMBAf8wEQYDVR0OBAoECEkcWDpP6A0DMBMGA1UdIwQMMAqACEI9
+KySmwUXOMA4GA1UdDwEB/wQEAwIBBjCBkgYDVR0fBIGKMIGHMIGEoIGBoH+GfWxk
+YXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1RdWFsLTAyLG89QS1UcnVz
+dCxjPUFUP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q/YmFzZT9vYmplY3RjbGFz
+cz1laWRDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5MA0GCSqGSIb3DQEBBQUAA4IBAQBH
+opWG7LKmPBvuGjZnRV4KGKzzUYVuxSRS1E0VIUPbVLf5xW2r5uUpR8ud5EpiPrcw
+k6K0dzu2Vb4ZbMIP+6J16S/0qvTp/3A/3q87+nJ+ot+IT8GZFJfSw18th2WmZdzR
+ShbM6sgViPtGsFROCdWeiHl248w2+zG+09sf8Bu3UyvwLRAiiKaxuwVdQ9kc0TL3
+gvv+K5eisWWthQOX2IF2jGSEqoAVwfHhl7bc9Vt7XnJSpQFebHnsIVuV4Mv6w4ww
+86hQPCLLvvV7wWDiBQ8l2FWneX0pNH3Wg+A1TRUoptc+pPDdpoP272MDm4fXyPKV
+7QgIaIK+gXNUj2GGt1K9
+-----END CERTIFICATE-----
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-03.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-03.cer
new file mode 100644
index 00000000..2251ca22
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-light-03.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEjzCCA3egAwIBAgIDAartMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5R
+dWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5RdWFsLTAzMB4XDTA1MTExMzIzMDAw
+MFoXDTE1MTExMzIzMDAwMFowgZ8xCzAJBgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRy
+dXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0ZW52
+ZXJrZWhyIEdtYkgxIjAgBgNVBAsMGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDMx
+IjAgBgNVBAMMGWEtc2lnbi1jb3Jwb3JhdGUtbGlnaHQtMDMwggEiMA0GCSqGSIb3
+DQEBAQUAA4IBDwAwggEKAoIBAQC359oitbHkkEgdErRPeBdkcYRK2DLdxfcnn+SI
+umSEYzWVscRTchPKSzb7f1a6EHPbB5WZsGJaUDX9KfTqsJNMo+7bASKk3gsLVxNZ
+qY2t2G+y8HvREYYejDOIzjAkcBQrt+nvuBUlGYVJQjEuyAn18f2vG0Y3VNvZFGKn
+PK8AVycUMk0Uw21RbK3vX5tbbPgQ/kcZkN4czi5VHepMvf6hAwwLoJj+KL9zxm8j
+yPK88qCBKAjMNCpZKsEhyanw1CjYbVmHs45Q5W6FBtqDcS6Iq4mC6TtUPGtCTuoH
+7/JLuhEp075ohp87v3fSlzeLJjBpkUDP9U8Tv7l2euD0t1UVAgMBAAGjgeMwgeAw
+DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQIQZFpHL+t2JgwEwYDVR0jBAwwCoAI
+RGqVZ1V5EU8wDgYDVR0PAQH/BAQDAgEGMIGUBgNVHR8EgYwwgYkwgYaggYOggYCG
+fmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9QS1UcnVzdC1uUXVhbC0wMyxvPUEt
+VHJ1c3QsYz1BVD9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0
+Y2xhc3M9ZWlkQ2VydGlmaWNhdGlvbkF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOC
+AQEADTRIaQtPwoPS6/TpyBhOw4wAHk/RM4gkLT76URPY2sUHihxqy+8qEElN+f5l
+I61myCP3IFTClflcHVR1QCoMg0ZI5/EcQTI8Dgd5iQkXuVjh3wCj87Ka2Tu7d1K+
+i9VJ4BR/ph/qmPKR7Lx/PtATw/vWo4k2rbt5o1QwixZ7CPt+BF9xCaAC4uL0bB0M
+9M3i9W2ePmqX6WIB3jMkT9FQC0KihPPfw/17KddNi4rFMMEiTyKvJTtTqDnIAwWW
+TqsL1G7oxMMtnnYaKWMQ6gQiOiRzCY7efcAi/3YwUX6ULW5zxqapNs1vqEbSGsQE
+l1eFl67HBZHYAPdoHGUnZF0KaQ==
+-----END CERTIFICATE-----
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-01a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-01a.cer
new file mode 100644
index 00000000..2d7f1a03
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-01a.cer
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIEKDCCAxCgAwIBAgIDAOKKMA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNVBAYTAkFUMRAwDgYDVQQK
+EwdBLVRydXN0MRkwFwYDVQQLExBBLVRydXN0LW5RdWFsLTAxMRkwFwYDVQQDExBBLVRydXN0LW5R
+dWFsLTAxMB4XDTA0MTIwNTIzMDAwMFoXDTA4MTEzMDIzMDAwMFowgaExCzAJBgNVBAYTAkFUMUgw
+RgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0
+ZW52ZXJrZWhyIEdtYkgxIzAhBgNVBAsTGmEtc2lnbi1jb3Jwb3JhdGUtbWVkaXVtLTAxMSMwIQYD
+VQQDExphLXNpZ24tY29ycG9yYXRlLW1lZGl1bS0wMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
+AQoCggEBANEbZyIMIXZYBjTj/+3TrNGssRKNNdTedQlWB3vJQWLzeG89Kzmhy1WDX8IqDrMtvpXH
+5w6urK3ZT7HGu2Jldrib8rkEOdE9+uNGRtkP8Kuz//CvdXCbIDvBLqgvWn9a3Sl/rUicPqKwcEcN
+bP2Q0iU6NvvALmoqs93PymfTZlkGOwzUe+O88huXkauGWT/DkJd4JYDNJ0wlaGrJa+OorT4Izk1J
+EipqqedUjsAj4Gq3SKrZKG/H/CkoH9uWTzrzFgg8zQhCES4AClo84XVk//EIv3ABDw4hr+lqV1nF
+eXch9o4mLIe5u045471YLJLmyuCPDopb8U2VUoyldpMx+Y8CAwEAAaOBszCBsDAPBgNVHRMBAf8E
+BTADAQH/MBEGA1UdDgQKBAhOuHKxmCmfZDATBgNVHSMEDDAKgAhOWc7HAjKHMDAOBgNVHQ8BAf8E
+BAMCAQYwZQYDVR0fBF4wXDBaoFigVoZUbGRhcDovL2xkYXAuYS10cnVzdC5hdC9vdT1BLVRydXN0
+LW5RdWFsLTAxLG89QS1UcnVzdCxjPUFUP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q/MA0GCSqG
+SIb3DQEBBQUAA4IBAQDaukYSeJVxWAh8QShqGqA6Plp9aXCTzwl9hE2gb+/xGPASo+NVQi/sUa0+
+bx29oSJaW6lKzdHQLAx4dwW9XTpJ+0mebB4fQfYHH0lGc1O4au/4O9k+C3SrD6x4WeY9k/SpUFu1
+qjzH+tjta81UWtU7Jve1BhckNwdOFx7cR8fdW+pUQSDV9XnPJfyb+gb9KWhvX+XAbgJoXW1HjJOO
+P5sx6mFhMb3UqAfKQVoAuGbl4+uxIThBTqpICkaaD8WLdukqQjomUMDRbWIf6SblPuOEpPi1G/WM
+qkTkpqX77Wkj08QY/yj5DDrsYJ5NymnWvu7jcoxCFCKvEQ8Q4g7AYKnG
+-----END CERTIFICATE-----
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-02a.cer b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-02a.cer
new file mode 100644
index 00000000..194d4d7c
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/certStore/a-sign-corporate-medium-02a.cer
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEjTCCA3WgAwIBAgIDAOSpMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRgwFgYDVQQLDA9BLVRydXN0LVF1
+YWwtMDIxGDAWBgNVBAMMD0EtVHJ1c3QtUXVhbC0wMjAeFw0wNDEyMTQyMzAwMDBa
+Fw0xNDEyMTMyMzAwMDBaMIGhMQswCQYDVQQGEwJBVDFIMEYGA1UECgw/QS1UcnVz
+dCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy
+a2VociBHbWJIMSMwIQYDVQQLDBphLXNpZ24tY29ycG9yYXRlLW1lZGl1bS0wMjEj
+MCEGA1UEAwwaYS1zaWduLWNvcnBvcmF0ZS1tZWRpdW0tMDIwggEiMA0GCSqGSIb3
+DQEBAQUAA4IBDwAwggEKAoIBAQCuaTBb6rHd5JZqAdvpmGIl5ne0Hg6GbpJvBeCI
+U6l9Rs8ebMY6aIS++qJOE9rnJHdfZNzLzduuoWEzEuwm9a/azQThM+eT+xlG/Vcf
+NuOQTTjAuXHLvYQ7WxSrBIT/kmAyqJgq/DEPvdX4jmCtVkuZ1gbxYIChLOVBWkVC
+FCK49BuXECtNy5fzK/GyfouZOVoQgiQ1YfecqzibcwO0t+f68Pvp/s6HESAH5tXY
+PdENDw4c/W/qKaeR87jPq98AJ8Lr4bmjWLjK8/ITtGglnJy8osFz22oR7f6fbWl6
+5LdhJ3giM68WEabQcZkw8cx3RDOzbnL2Kn+PVNHHyp3Wh849AgMBAAGjgeEwgd4w
+DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISoLnpz/+q98wEwYDVR0jBAwwCoAI
+Qj0rJKbBRc4wDgYDVR0PAQH/BAQDAgEGMIGSBgNVHR8EgYowgYcwgYSggYGgf4Z9
+bGRhcDovL2xkYXAuYS10cnVzdC5hdC9vdT1BLVRydXN0LVF1YWwtMDIsbz1BLVRy
+dXN0LGM9QVQ/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdD9iYXNlP29iamVjdGNs
+YXNzPWVpZENlcnRpZmljYXRpb25BdXRob3JpdHkwDQYJKoZIhvcNAQEFBQADggEB
+ABqg1oRs/TZ0hJLJRV/xJglFzgn2fDAXeoVvWnAE09F1d0n+ZorKAKbMfiZ2CuKs
+M0AhU23/5zM90DdrtYWXpa+P8ONALZtHJIqGfVuRKYJq7jY5TpE3yRkTcrp47smp
+WqTwUgG+0aBeU9m+ZtGUFOsBkq+MudD8IZGc7VcLd1n4ltND9ITjX20hu01ju56c
+YC69vFa5hmIccXg/Q3dGEV5Amx8MTQJluG3QvqBOY74yrAFICvK1zsvu+vOGvJQj
+i+PxKlbQdehrV82VDxyfSjpEUADWMGRfE5vg4YBGgfRosh4w7a6ThD2LMLFPmIhy
+P6+VGUBCm2tMDDOo9DVkXFs=
+-----END CERTIFICATE-----
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/testCerts/www.a-trust.at.der b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/testCerts/www.a-trust.at.der
new file mode 100644
index 00000000..61ce8dff
Binary files /dev/null and b/bkucommon/src/test/resources/at/gv/egiz/bku/conf/certs/testCerts/www.a-trust.at.der differ
diff --git a/pom.xml b/pom.xml
index c18a4c2c..d2fe06a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,211 +1,217 @@
-
- 4.0.0
- at.gv.egiz
- bku
- pom
- 1.0-SNAPSHOT
- BKU
- http://bku.egiz.gv.at
-
- utils
- bkucommon
- STAL
- BKUOnline
- smcc
- BKULocal
- BKUApplet
- smccSTAL
- STALService
- BKUCommonGUI
- BKUViewer
- BKULocalApp
-
-
-
- mcentner
- Martin Centner
- mcentner@egiz.gv.at
-
-
- wbauer
- Wolfgang Bauer
- wbauer@egiz.gv.at
-
-
- corthacker
- Clemens Orthacker
- corthacker@egiz.gv.at
-
-
-
- svn://svn.egovlabs.gv.at/svnroot/mocca
-
-
- E-Government Innovation Center (EGIZ)
- http://www.egiz.gv.at
-
-
-
-
-
- maven-compiler-plugin
- org.apache.maven.plugins
- 2.0.2
-
-
- 1.6
- 1.6
- true
- true
-
-
-
- maven-assembly-plugin
- org.apache.maven.plugins
- 2.2-beta-2
-
-
- maven-dependency-plugin
- org.apache.maven.plugins
- 2.0
-
-
-
- jaxws-maven-plugin
- org.codehaus.mojo
- 1.10
-
-
-
-
-
- maven-assembly-plugin
-
-
- ${basedir}/src/main/assemblies/assembly-test.xml
-
-
-
-
-
-
-
-
-
- mocca-egovlabs
- MOCCA EGovLabs
- http://mocca.egovlabs.gv.at/m2/repository/
-
-
- maven2-repository.dev.java.net
- Java.net Repository for Maven 2
- http://download.java.net/maven/2/
-
-
- maven1-repository.dev.java.net
- Java.net Repository for Maven 1
- http://download.java.net/maven/1/
- legacy
-
-
-
-
- log4j
- log4j
- runtime
-
-
- junit
- junit
- test
-
-
-
-
-
- log4j
- log4j
- 1.2.12
- runtime
-
-
- commons-logging
- commons-logging
- 1.1.1
- compile
-
-
- junit
- junit
- 4.4
- test
-
-
- xerces
- xercesImpl
- 2.9.1
-
-
- xalan
- xalan
- 2.7.0
-
-
- iaik
- iaik_jce_full_signed
- 3.16
- compile
-
-
- iaik
- iaik_jce_me4se
- 3.04
-
-
- iaik
- iaik_ecc_signed
- 2.15
-
-
- iaik
- iaik_xsect
- 1.14
-
-
- commons-fileupload
- commons-fileupload
- 1.2.1
- compile
-
-
- commons-httpclient
- commons-httpclient
- 3.1
- compile
-
-
-
+
+ 4.0.0
+ at.gv.egiz
+ bku
+ pom
+ 1.0-SNAPSHOT
+ BKU
+ http://bku.egiz.gv.at
+
+ utils
+ bkucommon
+ STAL
+ BKUOnline
+ smcc
+ BKULocal
+ BKUApplet
+ smccSTAL
+ STALService
+ BKUCommonGUI
+ BKUViewer
+ BKULocalApp
+
+
+
+ mcentner
+ Martin Centner
+ mcentner@egiz.gv.at
+
+
+ wbauer
+ Wolfgang Bauer
+ wbauer@egiz.gv.at
+
+
+ corthacker
+ Clemens Orthacker
+ corthacker@egiz.gv.at
+
+
+
+ svn://svn.egovlabs.gv.at/svnroot/mocca
+
+
+ E-Government Innovation Center (EGIZ)
+ http://www.egiz.gv.at
+
+
+
+
+
+ maven-compiler-plugin
+ org.apache.maven.plugins
+ 2.0.2
+
+
+ 1.6
+ 1.6
+ true
+ true
+
+
+
+ maven-assembly-plugin
+ org.apache.maven.plugins
+ 2.2-beta-2
+
+
+ maven-dependency-plugin
+ org.apache.maven.plugins
+ 2.0
+
+
+
+ jaxws-maven-plugin
+ org.codehaus.mojo
+ 1.10
+
+
+
+
+
+ maven-assembly-plugin
+
+
+ ${basedir}/src/main/assemblies/assembly-test.xml
+
+
+
+
+
+
+
+
+
+ mocca-egovlabs
+ MOCCA EGovLabs
+ http://mocca.egovlabs.gv.at/m2/repository/
+
+
+ maven2-repository.dev.java.net
+ Java.net Repository for Maven 2
+ http://download.java.net/maven/2/
+
+
+ maven1-repository.dev.java.net
+ Java.net Repository for Maven 1
+ http://download.java.net/maven/1/
+ legacy
+
+
+
+
+ log4j
+ log4j
+ runtime
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+ log4j
+ log4j
+ 1.2.12
+ runtime
+
+
+ commons-logging
+ commons-logging
+ 1.1.1
+ compile
+
+
+ junit
+ junit
+ 4.4
+ test
+
+
+ xerces
+ xercesImpl
+ 2.9.1
+
+
+ xalan
+ xalan
+ 2.7.0
+
+
+ iaik
+ iaik_jce_full_signed
+ 3.16
+ compile
+
+
+ iaik
+ iaik_jce_me4se
+ 3.04
+
+
+ iaik
+ iaik_ecc_signed
+ 2.15
+
+
+ iaik
+ iaik_xsect
+ 1.14
+
+
+ iaik
+ iaik_pki
+ 1.0-SNAPSHOT
+ compile
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.2.1
+ compile
+
+
+ commons-httpclient
+ commons-httpclient
+ 3.1
+ compile
+
+
+
\ No newline at end of file
--
cgit v1.2.3
From bd7c3ec609f1527db42601c65c3990423300ceca Mon Sep 17 00:00:00 2001
From: mcentner
Date: Tue, 21 Oct 2008 15:00:33 +0000
Subject: Simplified IdentityLinkTransformer.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@124 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../slcommands/impl/InfoboxReadCommandImpl.java | 20 +-
.../at/gv/egiz/idlink/IdentityLinkTransformer.java | 223 +++++----------------
2 files changed, 71 insertions(+), 172 deletions(-)
(limited to 'bkucommon/src/main')
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 b6c89e5b..d23c0598 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
@@ -23,6 +23,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.MalformedURLException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
@@ -415,11 +416,22 @@ public class InfoboxReadCommandImpl extends SLCommandImpltrue if this transformer is in use, or false otherwise
- */
- public boolean isInUse() {
- return inUse;
- }
-
- @Override
- public String toString() {
- StringBuffer str = new StringBuffer();
- str.append("Transformer ").append(stylesheetURL)
- .append("\n created ").append(new Date(created)).append(" used ").append(
- timesUsed).append(" times, (init ").append(initTime).append("ms / ")
- .append(((float) time) / timesUsed).append("ms avg) last time ").append(new Date(lastTimeUsed));
- return str.toString();
- }
-
- }
-
/**
- * The transfomer factory.
+ * The transformer factory.
*/
private static SAXTransformerFactory factory;
@@ -232,70 +122,67 @@ public class IdentityLinkTransformer {
}
- /**
- * The pool of Transformer.
- */
- private Map> pool;
+ /**
+ * Mapping of issuer template URIs to transformation templates.
+ */
+ private Map templates = new HashMap();
/**
* Private constructor.
*/
private IdentityLinkTransformer() {
- pool = new HashMap>();
- }
-
- private IdLTransformer getFreeTransfomer(String stylesheetURL) throws TransformerConfigurationException, IOException {
-
- IdLTransformer transformer = null;
-
- List transfomerList = pool.get(stylesheetURL);
- if (transfomerList == null) {
- transfomerList = new ArrayList();
- pool.put(stylesheetURL, transfomerList);
- }
-
- for (IdLTransformer candTransformer : transfomerList) {
- if (!candTransformer.inUse) {
- transformer = candTransformer;
- break;
- }
- }
-
- if (transformer == null) {
- transformer = new IdLTransformer(stylesheetURL);
- transfomerList.add(transformer);
- }
-
- transformer.inUse = true;
- return transformer;
-
- }
-
+ }
+
+ /**
+ * Transforms an identity link source to result with
+ * the given issuer template from the stylesheetURL.
+ *
+ * @param stylesheetURL
+ * the URL of the issuer template to be used for transformation
+ * @param source
+ * the compressed identity link source
+ * @param result
+ * the transformed identity link result
+ *
+ * @throws MalformedURLException
+ * if the given stylesheetURL is not a valid
+ * http or https URL.
+ * @throws IOException
+ * if dereferencing the stylesheetURL fails.
+ * @throws TransformerConfigurationException
+ * if creating a transformation template from the dereferenced
+ * stylesheet fails.
+ * @throws TransformerException
+ * if transforming the identity link fails.
+ */
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.");
+
+ Templates templ = templates.get(stylesheetURL);
+
+ if (templ == null) {
+
+ // TODO: implement stylesheet cache
+ URL url = new URL(stylesheetURL);
+
+ if (!"http".equalsIgnoreCase(url.getProtocol()) && !"https".equalsIgnoreCase(url.getProtocol())) {
+ throw new MalformedURLException("Protocol " + url.getProtocol() + " not supported for IssuerTemplate URL.");
+ }
+
+ URLDereferencer dereferencer = URLDereferencer.getInstance();
+ StreamData data = dereferencer.dereference(url.toExternalForm(), null);
+
+ log.trace("Trying to create issuer template.");
+ templ = factory.newTemplates(new StreamSource(data.getStream()));
+ log.trace("Successfully created issuer template");
+
+ templates.put(stylesheetURL, templ);
+
+ }
+
+ Transformer transformer = templ.newTransformer();
+
transformer.transform(source, result);
- log.trace("IdentityLink transformed successfully. " + getStatistics());
- }
-
- public String getStatistics() {
-
- StringBuffer str = new StringBuffer();
- Iterator keys = pool.keySet().iterator();
- int count = 0;
- while (keys.hasNext()) {
- String stylesheetURL = (String) keys.next();
- str.append("Stylesheet URL: ").append(stylesheetURL);
- Iterator transformer = pool.get(stylesheetURL).iterator();
- while (transformer.hasNext()) {
- IdLTransformer idLTransformer = (IdLTransformer) transformer.next();
- str.append("\n ").append(idLTransformer);
- count++;
- }
- }
- str.append("\n(").append(count).append(" transformer)");
- return str.toString();
+
}
}
--
cgit v1.2.3
From 990e50c61d1b92dbd0e063fe6811783c2d479e42 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Tue, 28 Oct 2008 10:56:44 +0000
Subject: ProcessingContext removed old background imgs
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@125 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../src/main/resources/images/chipperling_only.png | Bin 3291 -> 0 bytes
BKUCommonGUI/src/main/resources/images/logo.png | Bin 4035 -> 0 bytes
BKUCommonGUI/src/main/resources/images/mocca.png | Bin 1450 -> 0 bytes
.../main/resources/images/mocca_chipperling.png | Bin 4103 -> 0 bytes
.../src/main/resources/images/mocca_default.png | Bin 1287 -> 0 bytes
.../src/main/resources/images/mocca_tiny.png | Bin 1025 -> 0 bytes
BKUOnline/src/main/webapp/META-INF/context.xml | 4 +-
.../egiz/bku/binding/BindingProcessorManager.java | 172 +++++++++++----------
.../bku/binding/BindingProcessorManagerImpl.java | 153 +++++++++++-------
.../at/gv/egiz/bku/binding/ProcessingContext.java | 39 +++++
10 files changed, 221 insertions(+), 147 deletions(-)
delete mode 100644 BKUCommonGUI/src/main/resources/images/chipperling_only.png
delete mode 100644 BKUCommonGUI/src/main/resources/images/logo.png
delete mode 100644 BKUCommonGUI/src/main/resources/images/mocca.png
delete mode 100644 BKUCommonGUI/src/main/resources/images/mocca_chipperling.png
delete mode 100644 BKUCommonGUI/src/main/resources/images/mocca_default.png
delete mode 100644 BKUCommonGUI/src/main/resources/images/mocca_tiny.png
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java
(limited to 'bkucommon/src/main')
diff --git a/BKUCommonGUI/src/main/resources/images/chipperling_only.png b/BKUCommonGUI/src/main/resources/images/chipperling_only.png
deleted file mode 100644
index 57063b9a..00000000
Binary files a/BKUCommonGUI/src/main/resources/images/chipperling_only.png and /dev/null differ
diff --git a/BKUCommonGUI/src/main/resources/images/logo.png b/BKUCommonGUI/src/main/resources/images/logo.png
deleted file mode 100644
index eee4be4f..00000000
Binary files a/BKUCommonGUI/src/main/resources/images/logo.png and /dev/null differ
diff --git a/BKUCommonGUI/src/main/resources/images/mocca.png b/BKUCommonGUI/src/main/resources/images/mocca.png
deleted file mode 100644
index 881a65c1..00000000
Binary files a/BKUCommonGUI/src/main/resources/images/mocca.png and /dev/null differ
diff --git a/BKUCommonGUI/src/main/resources/images/mocca_chipperling.png b/BKUCommonGUI/src/main/resources/images/mocca_chipperling.png
deleted file mode 100644
index 4ee2d054..00000000
Binary files a/BKUCommonGUI/src/main/resources/images/mocca_chipperling.png and /dev/null differ
diff --git a/BKUCommonGUI/src/main/resources/images/mocca_default.png b/BKUCommonGUI/src/main/resources/images/mocca_default.png
deleted file mode 100644
index 349d9ff0..00000000
Binary files a/BKUCommonGUI/src/main/resources/images/mocca_default.png and /dev/null differ
diff --git a/BKUCommonGUI/src/main/resources/images/mocca_tiny.png b/BKUCommonGUI/src/main/resources/images/mocca_tiny.png
deleted file mode 100644
index 1f125d9b..00000000
Binary files a/BKUCommonGUI/src/main/resources/images/mocca_tiny.png and /dev/null differ
diff --git a/BKUOnline/src/main/webapp/META-INF/context.xml b/BKUOnline/src/main/webapp/META-INF/context.xml
index cd11ce8e..f38215a1 100644
--- a/BKUOnline/src/main/webapp/META-INF/context.xml
+++ b/BKUOnline/src/main/webapp/META-INF/context.xml
@@ -15,5 +15,5 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-
+
+
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
index aaf81e51..9cad95a4 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
@@ -14,92 +14,94 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.binding;
-
+package at.gv.egiz.bku.binding;
+
import java.net.MalformedURLException;
-import java.util.Locale;
-import java.util.Set;
-
-import at.gv.egiz.bku.slcommands.SLCommandInvoker;
-import at.gv.egiz.stal.STALFactory;
-
-/**
- * Central player that handles the protocol binding.
- *
- * @author wbauer
- *
- */
-public interface BindingProcessorManager {
-
- /**
- * FactoryMethod creating a new BindingProcessor object.
- * The created binding processor must be passed to the process method to execute.
- *
- * @param urlString
- * the source url
- * @param aSessionId
- * optional an external sessionId (e.g. http session) could be
- * provided. This parameter may be null.
- * @param locale the locale used for user interaction, may be null
- */
- public BindingProcessor createBindingProcessor(String urlString,
- String aSessionId, Locale locale) throws MalformedURLException;
-
- /**
- * FactoryMethod creating a new BindingProcessor object.
- * The created binding processor must be passed to the process method to execute.
- *
- * @param protcol
- * the source url
- * @param aSessionId
- * optional an external sessionId (e.g. http session) could be
- * provided. This parameter may be null.
- */
- public BindingProcessor createBindingProcessor(String urlString,
- String aSessionId) throws MalformedURLException;
-
-
- /**
- * Gets the binding processor with a certain id. The binding processor must be passed to the
- * process method before it is managed and thus returned by this method.
- * @param aId must not be null
- * @return null if the binding processor was not "processed" before.
- */
- public BindingProcessor getBindingProcessor(Id aId);
-
- /**
- * Sets the STAL factory that is used for creating STAL objects that are used by BindingProcessor objects.
- * For each new BindingProcessor a new STAL object is created.
- * @param aStalFactory the factory to be used. Must not be null.
- */
- public void setSTALFactory(STALFactory aStalFactory);
-
- /**
- * Sets the invoker to be used.
- * @param invoker
- */
- public void setSLCommandInvoker(SLCommandInvoker invoker);
-
- /**
- * Schedules the provided binding processor for processing and immediately returns.
- *
- * @param aBindingProcessor
- */
- public void process(BindingProcessor aBindingProcessor);
-
- /**
- * Removes a formerly added (by calling the process method) binding processor.
- * @param bindingProcessor must not be null
- */
- public void removeBindingProcessor(Id sessionId);
-
- /**
- * A set of all managed binding processors.
- * @return
- */
- public Set getManagedIds();
-
+import java.util.Locale;
+import java.util.Set;
+
+import at.gv.egiz.bku.slcommands.SLCommandInvoker;
+import at.gv.egiz.stal.STALFactory;
+
+/**
+ * Central player that handles the protocol binding.
+ *
+ * @author wbauer
+ *
+ */
+public interface BindingProcessorManager {
+
+ /**
+ * FactoryMethod creating a new BindingProcessor object.
+ * The created binding processor must be passed to the process method to execute.
+ *
+ * @param urlString
+ * the source url
+ * @param aSessionId
+ * optional an external sessionId (e.g. http session) could be
+ * provided. This parameter may be null.
+ * @param locale the locale used for user interaction, may be null
+ */
+ public BindingProcessor createBindingProcessor(String urlString,
+ String aSessionId, Locale locale) throws MalformedURLException;
+
+ /**
+ * FactoryMethod creating a new BindingProcessor object.
+ * The created binding processor must be passed to the process method to execute.
+ *
+ * @param protcol
+ * the source url
+ * @param aSessionId
+ * optional an external sessionId (e.g. http session) could be
+ * provided. This parameter may be null.
+ */
+ public BindingProcessor createBindingProcessor(String urlString,
+ String aSessionId) throws MalformedURLException;
+
+
+ /**
+ * Gets the binding processor with a certain id. The binding processor must be passed to the
+ * process method before it is managed and thus returned by this method.
+ * @param aId must not be null
+ * @return null if the binding processor was not "processed" before.
+ */
+ public BindingProcessor getBindingProcessor(Id aId);
+
+ /**
+ * Sets the STAL factory that is used for creating STAL objects that are used by BindingProcessor objects.
+ * For each new BindingProcessor a new STAL object is created.
+ * @param aStalFactory the factory to be used. Must not be null.
+ */
+ public void setSTALFactory(STALFactory aStalFactory);
+
+ /**
+ * Sets the invoker to be used.
+ * @param invoker
+ */
+ public void setSLCommandInvoker(SLCommandInvoker invoker);
+
+ /**
+ * Creates a processing context,
+ * schedules the provided binding processor for processing and
+ * immediately returns the context.
+ *
+ * @param aBindingProcessor
+ */
+ public ProcessingContext process(BindingProcessor aBindingProcessor);
+
+ /**
+ * Removes a formerly added (by calling the process method) binding processor.
+ * @param bindingProcessor must not be null
+ */
+ public void removeBindingProcessor(Id sessionId);
+
+ /**
+ * A set of all managed binding processors.
+ * @return
+ */
+ public Set getManagedIds();
+
public void shutdown();
- public void shutdownNow();
+ public void shutdownNow();
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 11f5a160..cc1b7532 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -53,8 +53,9 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
private STALFactory stalFactory;
private SLCommandInvoker commandInvokerClass;
private ExecutorService executorService;
- private Map bindingProcessorMap = Collections
- .synchronizedMap(new HashMap());
+ private Map contextMap = Collections.synchronizedMap(new HashMap());
+// private Map bindingProcessorMap = Collections
+// .synchronizedMap(new HashMap());
/**
* Container to hold a Future and Bindingprocessor object as map value.
@@ -62,39 +63,39 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
* @author wbauer
* @see BindingProcessorManagerImpl#bindingProcessorMap
*/
- static class MapEntityWrapper {
- private Future> future;
- private BindingProcessor bindingProcessor;
-
- public MapEntityWrapper(Future> future, BindingProcessor bindingProcessor) {
- if ((bindingProcessor == null) || (future == null)) {
- throw new NullPointerException("Argument must not be null");
- }
- this.bindingProcessor = bindingProcessor;
- this.future = future;
- }
-
- public Future> getFuture() {
- return future;
- }
-
- public BindingProcessor getBindingProcessor() {
- return bindingProcessor;
- }
-
- public int hashCode() {
- return bindingProcessor.getId().hashCode();
- }
-
- public boolean equals(Object other) {
- if (other instanceof MapEntityWrapper) {
- MapEntityWrapper o = (MapEntityWrapper) other;
- return (o.bindingProcessor.getId().equals(bindingProcessor.getId()));
- } else {
- return false;
- }
- }
- }
+// static class MapEntityWrapper {
+// private Future> future;
+// private BindingProcessor bindingProcessor;
+//
+// public MapEntityWrapper(Future> future, BindingProcessor bindingProcessor) {
+// if ((bindingProcessor == null) || (future == null)) {
+// throw new NullPointerException("Argument must not be null");
+// }
+// this.bindingProcessor = bindingProcessor;
+// this.future = future;
+// }
+//
+// public Future> getFuture() {
+// return future;
+// }
+//
+// public BindingProcessor getBindingProcessor() {
+// return bindingProcessor;
+// }
+//
+// public int hashCode() {
+// return bindingProcessor.getId().hashCode();
+// }
+//
+// public boolean equals(Object other) {
+// if (other instanceof MapEntityWrapper) {
+// MapEntityWrapper o = (MapEntityWrapper) other;
+// return (o.bindingProcessor.getId().equals(bindingProcessor.getId()));
+// } else {
+// return false;
+// }
+// }
+// }
/**
*
@@ -157,17 +158,24 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
public void shutdownNow() {
log.info("Shutting down the BindingProcessorManager NOW!");
executorService.shutdownNow();
- log.debug("Number of binding prcessors currently managed: "
- + bindingProcessorMap.size());
+ log.debug("Number of binding contexts currently managed: "
+ + contextMap.size());
+// + bindingProcessorMap.size());
if (log.isDebugEnabled()) {
- for (Iterator it = bindingProcessorMap.values()
- .iterator(); it.hasNext();) {
- MapEntityWrapper entry = it.next();
- log.debug(entry.getBindingProcessor().getId() + ": isDone: "
- + entry.getFuture().isDone());
- log.debug(entry.getBindingProcessor().getId() + ": isCanceled: "
- + entry.getFuture().isCancelled());
+ for (ProcessingContext ctx : contextMap.values()) {
+ Id bpId = ctx.getBindingProcessor().getId();
+ Future future = ctx.getFuture();
+ log.debug(bpId + " cancelled: " + future.isCancelled());
+ log.debug(bpId + " done: " + future.isDone());
}
+// for (Iterator it = bindingProcessorMap.values()
+// .iterator(); it.hasNext();) {
+// MapEntityWrapper entry = it.next();
+// log.debug(entry.getBindingProcessor().getId() + ": isDone: "
+// + entry.getFuture().isDone());
+// log.debug(entry.getBindingProcessor().getId() + ": isCanceled: "
+// + entry.getFuture().isCancelled());
+// }
}
}
@@ -216,17 +224,22 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
* @return the bindingprocessor object for this id or null if no
* bindingprocessor was found.
*/
+ @Override
public BindingProcessor getBindingProcessor(Id aId) {
- if (bindingProcessorMap.get(aId) != null) {
- return bindingProcessorMap.get(aId).getBindingProcessor();
+// if (bindingProcessorMap.get(aId) != null) {
+// return bindingProcessorMap.get(aId).getBindingProcessor();
+ ProcessingContext ctx = contextMap.get(aId);
+ if (ctx != null) {
+ return ctx.getBindingProcessor();
} else {
return null;
}
}
- /**
- *
+ /**
+ *
*/
+ @Override
public void setSTALFactory(STALFactory aStalFactory) {
if (aStalFactory == null) {
throw new NullPointerException("Cannot set STALFactory to null");
@@ -236,12 +249,17 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
/**
* Causes the BindingProcessorManager to manage the provided BindingProcessor
+ * Creates a processing context,
+ * schedules the provided binding processor for processing and
+ * immediately returns the context.
*
* @param aBindingProcessor
* must not be null
*/
- public void process(BindingProcessor aBindingProcessor) {
- if (bindingProcessorMap.containsKey(aBindingProcessor.getId())) {
+ @Override
+ public ProcessingContext process(BindingProcessor aBindingProcessor) {
+ if (contextMap.containsKey(aBindingProcessor.getId())) {
+// if (bindingProcessorMap.containsKey(aBindingProcessor.getId())) {
log.fatal("Clashing ids, cannot process bindingprocessor with id:"
+ aBindingProcessor.getId());
throw new SLRuntimeException(
@@ -250,8 +268,11 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
}
log.debug("processing bindingprocessor: " + aBindingProcessor.getId());
Future> f = executorService.submit(aBindingProcessor);
- bindingProcessorMap.put(aBindingProcessor.getId(), new MapEntityWrapper(f,
- aBindingProcessor));
+ ProcessingContext ctx = new ProcessingContext(aBindingProcessor, f);
+ contextMap.put(aBindingProcessor.getId(), ctx);
+// bindingProcessorMap.put(aBindingProcessor.getId(), new MapEntityWrapper(f,
+// aBindingProcessor));
+ return ctx;
}
@Override
@@ -262,26 +283,38 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
@Override
public void removeBindingProcessor(Id sessionId) {
log.debug("Removing binding processor: " + sessionId);
- MapEntityWrapper wrapper = bindingProcessorMap.get(sessionId);
- if (wrapper == null) {
+ ProcessingContext ctx = contextMap.get(sessionId);
+ if (ctx == null) {
return;
}
- Future> f = wrapper.getFuture();
+ Future f = ctx.getFuture();
+
+// MapEntityWrapper wrapper = bindingProcessorMap.get(sessionId);
+// if (wrapper == null) {
+// return;
+// }
+// Future> f = wrapper.getFuture();
if (!f.isDone()) {
f.cancel(true);
}
- bindingProcessorMap.remove(sessionId);
+ contextMap.remove(sessionId);
+// bindingProcessorMap.remove(sessionId);
}
@Override
public Set getManagedIds() {
Set result = new HashSet();
- synchronized (bindingProcessorMap) {
- for (Iterator it = bindingProcessorMap.keySet().iterator(); it
- .hasNext();) {
- result.add(it.next());
+ synchronized (contextMap) {
+ for (Id id : contextMap.keySet()) {
+ result.add(id);
}
}
+// synchronized (bindingProcessorMap) {
+// for (Iterator it = bindingProcessorMap.keySet().iterator(); it
+// .hasNext();) {
+// result.add(it.next());
+// }
+// }
return result;
}
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java
new file mode 100644
index 00000000..ae7f01eb
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java
@@ -0,0 +1,39 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.binding;
+
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+/**
+ * BindingContext?
+ * RequestBindingContext?
+ *
+ * @author clemens
+ */
+public class ProcessingContext {
+
+ public static final String BINDING_PROCESSOR = "binding.processor";
+ public static final String FUTURE = "future";
+
+ protected Map properties = new Hashtable();
+
+ public ProcessingContext(BindingProcessor bp, Future future) {
+ properties.put(BINDING_PROCESSOR, bp);
+ properties.put(FUTURE, future);
+ }
+
+
+
+ public BindingProcessor getBindingProcessor() {
+ return (BindingProcessor) properties.get(BINDING_PROCESSOR);
+ }
+
+ public Future getFuture() {
+ return (Future) properties.get(FUTURE);
+ }
+}
--
cgit v1.2.3
From c2ae3db1bc6dcb8ba3eb3461c05e293917c004ca Mon Sep 17 00:00:00 2001
From: mcentner
Date: Thu, 30 Oct 2008 10:33:29 +0000
Subject: 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
---
.../main/java/at/gv/egiz/bku/gui/PinDocument.java | 2 +-
.../egiz/bku/online/webapp/BKURequestHandler.java | 20 +-
BKUOnline/src/main/webapp/HTTP-ohne.html | 11 +-
BKUOnline/src/main/webapp/appletPage.jsp | 29 +-
.../at/gv/egiz/stal/util/JCEAlgorithmNames.java | 4 +-
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 3 +-
.../gv/egiz/bku/slcommands/SLCommandContext.java | 17 +-
.../impl/CreateXMLSignatureCommandImpl.java | 4 +-
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 42 ++-
.../slcommands/impl/InfoboxReadCommandImpl.java | 2 +-
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 8 +-
.../bku/slcommands/impl/ErrorResultImplTest.java | 3 +-
smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java | 348 ++++++++++++---------
.../at/gv/egiz/smcc/AbstractSignatureCard.java | 169 +++++++---
.../at/gv/egiz/smcc/FileNotFoundException.java | 38 +++
.../main/java/at/gv/egiz/smcc/LockedException.java | 38 +++
.../at/gv/egiz/smcc/NotActivatedException.java | 44 +++
.../src/main/java/at/gv/egiz/smcc/STARCOSCard.java | 339 ++++++++++++--------
smcc/src/main/java/at/gv/egiz/smcc/SWCard.java | 79 ++++-
.../at/gv/egiz/smcc/SignatureCardException.java | 2 +-
.../java/at/gv/egiz/smcc/SignatureCardFactory.java | 223 +++++++++++--
.../java/at/gv/egiz/smcc/util/SmartCardIO.java | 3 +-
.../test/java/at/gv/egiz/smcc/STARCOSCardTest.java | 92 ++++++
.../bku/smccstal/InfoBoxReadRequestHandler.java | 8 +
.../gv/egiz/bku/smccstal/SignRequestHandler.java | 10 +-
25 files changed, 1149 insertions(+), 389 deletions(-)
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/FileNotFoundException.java
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/LockedException.java
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/NotActivatedException.java
create mode 100644 smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
(limited to 'bkucommon/src/main')
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
index 8ae9d7a3..2054ae86 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
@@ -46,7 +46,7 @@ class PINDocument extends PlainDocument {
@Override
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
- if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
+ if (pinSpec.getMaxLength() < 0 || pinSpec.getMaxLength() >= (getLength() + str.length())) {
boolean matches = true;
for (int i = 0; i < str.length(); i++) {
Matcher m = pinPattern.matcher(str.substring(i, i + 1));
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
index 6f3b9d7f..9092e3f9 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
@@ -44,6 +44,8 @@ import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
*/
public class BKURequestHandler extends SpringBKUServlet {
+ private static final long serialVersionUID = 1L;
+
public final static String REDIRECT_URL = "appletPage.jsp";
protected Log log = LogFactory.getLog(BKURequestHandler.class);
@@ -105,6 +107,8 @@ public class BKURequestHandler extends SpringBKUServlet {
String width = getStringFromStream(bindingProcessor.getFormData("appletWidth"), charset);
String height = getStringFromStream(bindingProcessor.getFormData("appletHeight"), charset);
String background = getStringFromStream(bindingProcessor.getFormData("appletBackground"), charset);
+ String guiStyle = getStringFromStream(bindingProcessor.getFormData("appletGuiStyle"), charset);
+ String hashDataDisplay = getStringFromStream(bindingProcessor.getFormData("appletHashDataDisplay"), charset);
if (width != null) {
try {
log.trace("Found applet width parameter: " + width);
@@ -124,12 +128,16 @@ public class BKURequestHandler extends SpringBKUServlet {
}
}
if (background != null) {
- try {
- log.trace("Found applet background parameter: " + background);
- session.setAttribute("appletBackground", background);
- } catch (NumberFormatException nfe) {
- log.warn(nfe);
- }
+ log.trace("Found applet background parameter: " + background);
+ session.setAttribute("appletBackground", background);
+ }
+ if (guiStyle != null) {
+ log.trace("Found applet GUI style parameter: " + guiStyle);
+ session.setAttribute("appletGuiStyle", guiStyle);
+ }
+ if (hashDataDisplay != null) {
+ log.trace("Found applet hash data display parameter: " + hashDataDisplay);
+ session.setAttribute("appletHashDataDisplay", hashDataDisplay);
}
resp.sendRedirect(REDIRECT_URL);
diff --git a/BKUOnline/src/main/webapp/HTTP-ohne.html b/BKUOnline/src/main/webapp/HTTP-ohne.html
index 1923113e..044432ce 100644
--- a/BKUOnline/src/main/webapp/HTTP-ohne.html
+++ b/BKUOnline/src/main/webapp/HTTP-ohne.html
@@ -92,8 +92,17 @@ legend {
name="appletHeight" value="130" id="appletHeight">
+
+
+ simple
+ advanced
+
+
+
+ external
+ internal
+
-
-
\ No newline at end of file
+
--
cgit v1.2.3
From 7201a18efa2f9aac4109b1accb5de9d8449dd558 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Fri, 14 Nov 2008 10:34:30 +0000
Subject: git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@169
8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUOnline/src/main/resources/log4j.properties | 5 +-
.../webapp/helpfiles/de/help.hashdataviewer.html | 39 ++
.../webapp/helpfiles/de/help.hashdataviewer.png | Bin 0 -> 11310 bytes
.../impl/CreateXMLSignatureCommandImpl.java | 446 +++++++++++----------
4 files changed, 273 insertions(+), 217 deletions(-)
create mode 100644 BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html
create mode 100644 BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.png
(limited to 'bkucommon/src/main')
diff --git a/BKUOnline/src/main/resources/log4j.properties b/BKUOnline/src/main/resources/log4j.properties
index 58f09511..f608c83d 100644
--- a/BKUOnline/src/main/resources/log4j.properties
+++ b/BKUOnline/src/main/resources/log4j.properties
@@ -14,7 +14,10 @@
# limitations under the License.
-log4j.rootLogger=TRACE, STDOUT, file
+#log4j.rootLogger=INFO, STDOUT, file
+log4j.rootLogger=INFO, file
+#log4j.logger.at.gv = INFO
+
# STDOUT appender
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
diff --git a/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html b/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html
new file mode 100644
index 00000000..3a56e88a
--- /dev/null
+++ b/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html
@@ -0,0 +1,39 @@
+
+
+
+
+Untitled Document
+
+
+
+
+
+
+
+
+
Online-Hilfe
+
+
+
+
Hinweis: Das Bildschirmfoto oben kann von der Darstellung in der Webseite abweichen.
+
+
+
Anzeige der Signaturdaten
+
Dieses Fenster zeigt die zu signierenden Daten an. Dies können entweder reine Textdaten oder XHTML sein. Im Falle von XHML erhalten Sie den Hinweis, dass es sich bei den dargestellten Daten nur um eine Voransicht handelt. Um die Daten gesetzeskonform darzustellen, müssen diese abgespeichert und mit einem geeigneten XHTML Betrachter geöffnen werden.
+
In jedem Fall können die zu signierenden abgespeichert werden.
+
+
+
+
+
diff --git a/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.png b/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.png
new file mode 100644
index 00000000..83004322
Binary files /dev/null and b/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.png differ
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 6462bcf6..b2e3b303 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
@@ -1,230 +1,244 @@
/*
-* 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.bku.slcommands.impl;
-
-import java.io.ByteArrayInputStream;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.Collections;
-import java.util.Date;
-
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.URIReferenceException;
-import javax.xml.crypto.dsig.XMLSignatureException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSSerializer;
-
-import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureRequestType;
-import at.buergerkarte.namespaces.securitylayer._1.DataObjectInfoType;
-import at.gv.egiz.bku.slcommands.CreateXMLSignatureCommand;
-import at.gv.egiz.bku.slcommands.SLCommandContext;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slcommands.impl.xsect.AlgorithmMethodFactory;
-import at.gv.egiz.bku.slcommands.impl.xsect.AlgorithmMethodFactoryImpl;
-import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactory;
-import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactoryImpl;
-import at.gv.egiz.bku.slcommands.impl.xsect.Signature;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
+ * 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.bku.slcommands.impl;
+
+import java.io.ByteArrayInputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Collections;
+import java.util.Date;
+
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.URIReferenceException;
+import javax.xml.crypto.dsig.XMLSignatureException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSSerializer;
+
+import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.DataObjectInfoType;
+import at.gv.egiz.bku.slcommands.CreateXMLSignatureCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.impl.xsect.AlgorithmMethodFactory;
+import at.gv.egiz.bku.slcommands.impl.xsect.AlgorithmMethodFactoryImpl;
+import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactory;
+import at.gv.egiz.bku.slcommands.impl.xsect.IdValueFactoryImpl;
+import at.gv.egiz.bku.slcommands.impl.xsect.Signature;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLException;
-import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLViewerException;
-import at.gv.egiz.dom.DOMUtils;
-import at.gv.egiz.stal.InfoboxReadRequest;
-import at.gv.egiz.stal.InfoboxReadResponse;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
-
-/**
- * This class implements the security layer command CreateXMLSignatureRequest.
- *
- * @author mcentner
- */
-public class CreateXMLSignatureCommandImpl extends SLCommandImpl implements
- CreateXMLSignatureCommand {
-
- /**
- * Logging facility.
- */
- protected static Log log = LogFactory.getLog(CreateXMLSignatureCommandImpl.class);
-
- /**
- * The signing certificate.
- */
- protected X509Certificate signingCertificate;
-
- /**
- * The keybox identifier of the key used for signing.
- */
- protected String keyboxIdentifier;
-
- /**
- * The to-be signed signature.
- */
- protected Signature signature;
-
- @Override
- public void init(SLCommandContext ctx, Object unmarshalledRequest)
- throws SLCommandException {
- super.init(ctx, unmarshalledRequest);
- }
-
- @Override
- public void prepareXMLSignature() throws SLCommandException, SLRequestException {
-
- CreateXMLSignatureRequestType request = getRequestValue();
-
+import at.gv.egiz.dom.DOMUtils;
+import at.gv.egiz.stal.ErrorResponse;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.InfoboxReadResponse;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+
+/**
+ * This class implements the security layer command
+ * CreateXMLSignatureRequest.
+ *
+ * @author mcentner
+ */
+public class CreateXMLSignatureCommandImpl extends
+ SLCommandImpl implements
+ CreateXMLSignatureCommand {
+
+ /**
+ * Logging facility.
+ */
+ protected static Log log = LogFactory
+ .getLog(CreateXMLSignatureCommandImpl.class);
+
+ /**
+ * The signing certificate.
+ */
+ protected X509Certificate signingCertificate;
+
+ /**
+ * The keybox identifier of the key used for signing.
+ */
+ protected String keyboxIdentifier;
+
+ /**
+ * The to-be signed signature.
+ */
+ protected Signature signature;
+
+ @Override
+ public void init(SLCommandContext ctx, Object unmarshalledRequest)
+ throws SLCommandException {
+ super.init(ctx, unmarshalledRequest);
+ }
+
+ @Override
+ public void prepareXMLSignature() throws SLCommandException,
+ SLRequestException {
+
+ CreateXMLSignatureRequestType request = getRequestValue();
+
// TODO: make configurable?
- IdValueFactory idValueFactory = new IdValueFactoryImpl();
-
+ IdValueFactory idValueFactory = new IdValueFactoryImpl();
+
// TODO: make configurable?
- AlgorithmMethodFactory algorithmMethodFactory;
- try {
- algorithmMethodFactory = new AlgorithmMethodFactoryImpl(signingCertificate);
- } catch (NoSuchAlgorithmException e) {
- log.error("Failed to get DigestMethod.", e);
- throw new SLCommandException(4006);
- }
-
- signature = new Signature(getCmdCtx().getURLDereferencerContext(), idValueFactory, algorithmMethodFactory);
-
+ AlgorithmMethodFactory algorithmMethodFactory;
+ try {
+ algorithmMethodFactory = new AlgorithmMethodFactoryImpl(
+ signingCertificate);
+ } catch (NoSuchAlgorithmException e) {
+ log.error("Failed to get DigestMethod.", e);
+ throw new SLCommandException(4006);
+ }
+
+ signature = new Signature(getCmdCtx().getURLDereferencerContext(),
+ idValueFactory, algorithmMethodFactory);
+
// SigningTime
- signature.setSigningTime(new Date());
-
+ signature.setSigningTime(new Date());
+
// SigningCertificate
- signature.setSignerCeritifcate(signingCertificate);
-
+ signature.setSignerCeritifcate(signingCertificate);
+
// SignatureInfo
- if (request.getSignatureInfo() != null) {
- signature.setSignatureInfo(request.getSignatureInfo());
- }
-
+ if (request.getSignatureInfo() != null) {
+ signature.setSignatureInfo(request.getSignatureInfo());
+ }
+
// DataObjects
- for (DataObjectInfoType dataObjectInfo : request.getDataObjectInfo()) {
- signature.addDataObject(dataObjectInfo);
- }
-
- signature.buildXMLSignature();
-
- }
-
- /**
- * Gets the signing certificate from STAL.
- *
- * @throws SLCommandException
- * if getting the singing certificate fails
- */
- private void getSigningCertificate() throws SLCommandException {
-
- CreateXMLSignatureRequestType request = getRequestValue();
- keyboxIdentifier = request.getKeyboxIdentifier();
-
- InfoboxReadRequest stalRequest = new InfoboxReadRequest();
- stalRequest.setInfoboxIdentifier(keyboxIdentifier);
-
- requestSTAL(Collections.singletonList((STALRequest) stalRequest));
-
- STALResponse stalResponse = stalResponses.next();
-
- if (stalResponse instanceof InfoboxReadResponse) {
- byte[] infobox = ((InfoboxReadResponse) stalResponse).getInfoboxValue();
-
- try {
- CertificateFactory certFactory = CertificateFactory.getInstance("X509");
- signingCertificate = (X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(infobox));
- } catch (CertificateException e) {
- log.info("Failed to decode signing certificate.", e);
+ for (DataObjectInfoType dataObjectInfo : request.getDataObjectInfo()) {
+ signature.addDataObject(dataObjectInfo);
+ }
+
+ signature.buildXMLSignature();
+
+ }
+
+ /**
+ * Gets the signing certificate from STAL.
+ *
+ * @throws SLCommandException
+ * if getting the singing certificate fails
+ */
+ private void getSigningCertificate() throws SLCommandException {
+
+ CreateXMLSignatureRequestType request = getRequestValue();
+ keyboxIdentifier = request.getKeyboxIdentifier();
+
+ InfoboxReadRequest stalRequest = new InfoboxReadRequest();
+ stalRequest.setInfoboxIdentifier(keyboxIdentifier);
+
+ requestSTAL(Collections.singletonList((STALRequest) stalRequest));
+
+ STALResponse stalResponse = stalResponses.next();
+
+ if (stalResponse instanceof InfoboxReadResponse) {
+ byte[] infobox = ((InfoboxReadResponse) stalResponse).getInfoboxValue();
+
+ try {
+ CertificateFactory certFactory = CertificateFactory.getInstance("X509");
+ signingCertificate = (X509Certificate) certFactory
+ .generateCertificate(new ByteArrayInputStream(infobox));
+ } catch (CertificateException e) {
+ log.info("Failed to decode signing certificate.", e);
// TODO: issue appropriate error
- throw new SLCommandException(4000);
- }
-
- } else {
- log.info("Failed to get signing certificate.");
- // TODO: issue appropriate error
- throw new SLCommandException(4000);
- }
-
- }
-
- /**
- * Signs the signature.
- *
- * @throws SLCommandException
+ throw new SLCommandException(4000);
+ }
+
+ } else if (stalResponse instanceof ErrorResponse) {
+ ErrorResponse err = (ErrorResponse) stalResponse;
+ log.info("Received an error response from STAL with code: "
+ + err.getErrorCode());
+ throw new SLCommandException(err.getErrorCode());
+
+ } else {
+ log.info("Failed to get signing certificate.");
+ throw new SLCommandException(4000);
+ }
+
+ }
+
+ /**
+ * Signs the signature.
+ *
+ * @throws SLCommandException
* if signing the signature fails
- * @throws SLViewerException
- */
- private void signXMLSignature() throws SLCommandException, SLViewerException {
-
- try {
- signature.sign(getCmdCtx().getSTAL(), keyboxIdentifier);
- } catch (MarshalException e) {
- log.error("Failed to marshall XMLSignature.", e);
- throw new SLCommandException(4000);
- } catch (XMLSignatureException e) {
- if (e.getCause() instanceof URIReferenceException) {
- URIReferenceException uriReferenceException = (URIReferenceException) e.getCause();
- if (uriReferenceException.getCause() instanceof SLCommandException) {
- throw (SLCommandException) uriReferenceException.getCause();
- }
- }
- log.error("Failed to sign XMLSignature.", e);
- throw new SLCommandException(4000);
- }
-
- }
-
- @Override
- public SLResult execute() {
- try {
-
- // get certificate in order to select appropriate algorithms for hashing and signing
- getSigningCertificate();
-
+ * @throws SLViewerException
+ */
+ private void signXMLSignature() throws SLCommandException, SLViewerException {
+
+ try {
+ signature.sign(getCmdCtx().getSTAL(), keyboxIdentifier);
+ } catch (MarshalException e) {
+ log.error("Failed to marshall XMLSignature.", e);
+ throw new SLCommandException(4000);
+ } catch (XMLSignatureException e) {
+ if (e.getCause() instanceof URIReferenceException) {
+ URIReferenceException uriReferenceException = (URIReferenceException) e
+ .getCause();
+ if (uriReferenceException.getCause() instanceof SLCommandException) {
+ throw (SLCommandException) uriReferenceException.getCause();
+ }
+ }
+ log.error("Failed to sign XMLSignature.", e);
+ throw new SLCommandException(4000);
+ }
+
+ }
+
+ @Override
+ public SLResult execute() {
+ try {
+
+ // get certificate in order to select appropriate algorithms for hashing
+ // and signing
+ getSigningCertificate();
+
// prepare the XMLSignature for signing
- prepareXMLSignature();
-
+ prepareXMLSignature();
+
// sign the XMLSignature
- signXMLSignature();
-
- if (log.isTraceEnabled()) {
-
- DOMImplementationLS domImplLS = DOMUtils.getDOMImplementationLS();
- LSSerializer serializer = domImplLS.createLSSerializer();
- String debugString = serializer.writeToString(signature.getDocument());
-
- log.trace(debugString);
-
- }
-
- return new CreateXMLSignatureResultImpl(signature.getDocument());
-
+ signXMLSignature();
+
+ if (log.isTraceEnabled()) {
+
+ DOMImplementationLS domImplLS = DOMUtils.getDOMImplementationLS();
+ LSSerializer serializer = domImplLS.createLSSerializer();
+ String debugString = serializer.writeToString(signature.getDocument());
+
+ log.trace(debugString);
+
+ }
+
+ return new CreateXMLSignatureResultImpl(signature.getDocument());
+
} catch (SLException e) {
- return new ErrorResultImpl(e, cmdCtx.getLocale());
- }
- }
-
- @Override
- public String getName() {
- return "CreateXMLSignatureRequest";
- }
-
-
-}
+ return new ErrorResultImpl(e, cmdCtx.getLocale());
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "CreateXMLSignatureRequest";
+ }
+
+}
--
cgit v1.2.3
From d379980f1c64bcf174c9706ff5aa746314a6666f Mon Sep 17 00:00:00 2001
From: clemenso
Date: Thu, 27 Nov 2008 15:21:37 +0000
Subject: typo
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@220 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 58 +++++++++++-----------
1 file changed, 29 insertions(+), 29 deletions(-)
(limited to 'bkucommon/src/main')
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 4a22874c..98b5b775 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
@@ -139,8 +139,8 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
srcContex.setSourceIsDataURL(false);
}
- //----------------------------------------------------------------------------
- // ----------- BEGIN CONVENIENCE METHODS -----------
+ //----------------------------------------------------------------------------
+ // ----------- BEGIN CONVENIENCE METHODS -----------
protected void sendSTALQuit() {
log.info("Sending QUIT command to STAL");
@@ -217,24 +217,24 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
}
}
- //----------------------------------------------------------------------------
- // ----------- END CONVENIENCE METHODS -----------
+ //----------------------------------------------------------------------------
+ // ----------- END CONVENIENCE METHODS -----------
- //----------------------------------------------------------------------------
- // -- BEGIN Methods that handle the http binding activities as defined in the
- // activity diagram --
+ //----------------------------------------------------------------------------
+ // -- BEGIN Methods that handle the http binding activities as defined in the
+ // activity diagram --
protected void init() {
log.info("Starting Bindingprocessor in Thread: "
+ Thread.currentThread().getId());
if (bindingProcessorError != null) {
log.debug("Detected binding processor error, sending quit command");
- // sendSTALQuit();
+ // sendSTALQuit();
currentState = State.FINISHED;
} else if (slCommand == null) {
log.error("SLCommand not set (consumeRequest not called ??)");
bindingProcessorError = new SLException(2000);
- // sendSTALQuit();
+ // sendSTALQuit();
currentState = State.FINISHED;
} else {
currentState = State.PROCESS;
@@ -270,7 +270,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
DataUrl dataUrl = new DataUrl(getDataUrl());
DataUrlConnection conn = dataUrl.openConnection();
- // set transfer headers
+ // set transfer headers
for (FormParameter fp : getTransferHeaders()) {
String paramString = getFormParameterAsString(fp);
if (paramString == null) {
@@ -288,7 +288,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
}
}
- // set transfer form parameters
+ // set transfer form parameters
for (FormParameter fp : getTransferForms()) {
String contentTransferEncoding = null;
String contentType = fp.getFormParameterContentType();
@@ -311,18 +311,18 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
contentTransferEncoding);
}
- // connect
+ // connect
conn.connect();
- // fetch and set SL result
+ // fetch and set SL result
targetContext.setTargetIsDataURL(true);
targetContext.setTargetCertificate(conn.getServerCertificate());
targetContext.setTargetUrl(conn.getUrl());
SLResult result = commandInvoker.getResult(targetContext);
- // transfer result
+ // transfer result
conn.transmit(result);
- // process Dataurl response
+ // process Dataurl response
dataUrlResponse = conn.getResponse();
log.debug("Received data url response code: "
+ dataUrlResponse.getResponseCode());
@@ -335,7 +335,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
if ((contentType.startsWith(HttpUtil.APPLICATION_URL_ENCODED))
|| (contentType.startsWith(HttpUtil.MULTIPART_FOTMDATA))) {
log.debug("Detected SL Request in dataurl response");
- // process headers and request
+ // process headers and request
setHTTPHeaders(dataUrlResponse.getResponseHeaders());
consumeRequestStream(dataUrlResponse.getStream());
closeDataUrlConnection();
@@ -363,7 +363,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
srcContex.setSourceIsDataURL(true);
srcContex.setSourceUrl(conn.getUrl());
currentState = State.PROCESS;
- // just to be complete, actually not used
+ // just to be complete, actually not used
srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders()
.get(HttpUtil.HTTP_HEADER_REFERER));
} else {
@@ -390,7 +390,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
.error("Did not get a location header for a 307 data url response");
throw new SLBindingException(2003);
}
- // consumeRequestStream(dataUrlResponse.getStream());
+ // consumeRequestStream(dataUrlResponse.getStream());
FormParameterStore fp = new FormParameterStore();
fp.init(location.getBytes(HttpUtil.DEFAULT_CHARSET),
FixedFormParameters.DATAURL, null, null);
@@ -403,7 +403,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
srcContex.setSourceIsDataURL(true);
srcContex.setSourceUrl(conn.getUrl());
currentState = State.PROCESS;
- // just to be complete, actually not used
+ // just to be complete, actually not used
srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders()
.get(HttpUtil.HTTP_HEADER_REFERER));
@@ -427,7 +427,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
break;
default:
- // issue error
+ // issue error
log.info("Unexpected response code from dataurl server: "
+ dataUrlResponse.getResponseCode());
throw new SLBindingException(2007);
@@ -499,9 +499,9 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
finished = true;
}
- // -- END Methods that handle the http binding activities as defined in the
- // activity diagram --
- //----------------------------------------------------------------------------
+ // -- END Methods that handle the http binding activities as defined in the
+ // activity diagram --
+ //----------------------------------------------------------------------------
/**
* Sets the headers of the SL Request. IMPORTANT: make sure to set all headers
@@ -512,7 +512,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
*/
public void setHTTPHeaders(Map aHeaderMap) {
headerMap = new HashMap();
- // ensure lowercase keys
+ // ensure lowercase keys
if (aHeaderMap != null) {
for (String s : aHeaderMap.keySet()) {
if (s != null) {
@@ -673,7 +673,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
FormParameterStore fps = new FormParameterStore();
fps.init(fp);
if (!fps.isEmpty()) {
- log.debug("Setting from parameter: " + fps.getFormParameterName());
+ log.debug("Setting form parameter: " + fps.getFormParameterName());
formParameterMap.put(fps.getFormParameterName(), fps);
}
}
@@ -683,7 +683,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
}
if (is.read() != -1) {
log.error("Request input stream not completely read");
- // consume rest of stream, should never occur
+ // consume rest of stream, should never occur
throw new SLRuntimeException(
"request input stream not consumed till end");
}
@@ -761,15 +761,15 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
transformer.transform(new StreamSource(isr), new StreamResult(osw));
} catch (TransformerException e) {
log.fatal("Exception occured during result transformation", e);
- // bindingProcessorError = new SLException(2008);
- // handleBindingProcessorError(os, encoding, null);
+ // bindingProcessorError = new SLException(2008);
+ // handleBindingProcessorError(os, encoding, null);
return;
}
}
osw.flush();
isr.close();
} else if (slResult == null) {
- // result not yet assigned -> must be a cancel
+ // result not yet assigned -> must be a cancel
bindingProcessorError = new SLException(6001);
handleBindingProcessorError(os, encoding, templates);
return;
--
cgit v1.2.3
From 06ae669734a4888432db83599b2bb259a3164021 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Mon, 1 Dec 2008 12:40:23 +0000
Subject: set/get property
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@227 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/binding/ProcessingContext.java | 44 ++++++++++++++++------
1 file changed, 32 insertions(+), 12 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java
index ae7f01eb..913259f6 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java
@@ -1,6 +1,18 @@
/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ * 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.bku.binding;
@@ -8,32 +20,40 @@ package at.gv.egiz.bku.binding;
import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.Future;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
- * BindingContext?
- * RequestBindingContext?
- *
- * @author clemens
+ *
+ * @author Clemens Orthacker
*/
public class ProcessingContext {
public static final String BINDING_PROCESSOR = "binding.processor";
public static final String FUTURE = "future";
-
+
+ protected static final Log log = LogFactory.getLog(ProcessingContext.class);
+
protected Map properties = new Hashtable();
public ProcessingContext(BindingProcessor bp, Future future) {
properties.put(BINDING_PROCESSOR, bp);
properties.put(FUTURE, future);
}
-
-
-
+
public BindingProcessor getBindingProcessor() {
return (BindingProcessor) properties.get(BINDING_PROCESSOR);
}
-
+
public Future getFuture() {
- return (Future) properties.get(FUTURE);
+ return (Future) properties.get(FUTURE);
+ }
+
+ public Object get(String key) {
+ return properties.get(key);
+ }
+
+ public void put(String key, Object value) {
+ properties.put(key, value);
}
}
--
cgit v1.2.3
From 99134c1be5db0fedadc051922e70c9bf563ce16d Mon Sep 17 00:00:00 2001
From: wbauer
Date: Tue, 2 Dec 2008 10:13:09 +0000
Subject: Changed SLCommandFactory configuration mechanism and moved the actual
configuration to spring's application context
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@231 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUOnline/pom.xml | 1 -
.../src/main/webapp/WEB-INF/applicationContext.xml | 41 +++++--
.../webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar | Bin 0 -> 182140 bytes
bkucommon/pom.xml | 5 +
.../gv/egiz/bku/slcommands/SLCommandFactory.java | 124 ++++++++++-----------
.../impl/CreateXMLSignatureResultImpl.java | 2 +-
.../slcommands/impl/InfoboxReadResultFileImpl.java | 2 +-
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 2 +-
.../egiz/bku/slcommands/testApplicationContext.xml | 36 ++++++
.../egiz/bku/binding/HttpBindingProcessorTest.java | 13 ++-
.../egiz/bku/slcommands/SLCommandFactoryTest.java | 9 ++
pom.xml | 51 ++++++---
12 files changed, 189 insertions(+), 97 deletions(-)
create mode 100644 BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml
(limited to 'bkucommon/src/main')
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml
index 53025800..1ea2c1a1 100644
--- a/BKUOnline/pom.xml
+++ b/BKUOnline/pom.xml
@@ -37,7 +37,6 @@
org.springframeworkspring-core
- 2.5.5javax.servlet
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index 4069cdc9..9c7194dd 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -18,15 +18,33 @@
-
-
-
+
+
+
+
+
+
+
+
@@ -46,16 +64,17 @@
-
-
+
+
-
+ init-method="configure" scope="singleton">
+
-
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar b/BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar
new file mode 100644
index 00000000..74f00509
Binary files /dev/null and b/BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar differ
diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml
index e0cb1f7c..beb4b3c7 100644
--- a/bkucommon/pom.xml
+++ b/bkucommon/pom.xml
@@ -57,6 +57,11 @@
iaik_pkicompile
+
+ org.springframework
+ spring-context
+ test
+
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
index e13b29a1..9c98ef8a 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
@@ -16,40 +16,37 @@
*/
package at.gv.egiz.bku.slcommands;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.UnmarshalException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl;
-import at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl;
-import at.gv.egiz.bku.slcommands.impl.NullOperationCommandImpl;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
-import at.gv.egiz.bku.slexceptions.SLRequestException;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.slbinding.RedirectEventFilter;
-import at.gv.egiz.slbinding.RedirectUnmarshallerListener;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.UnmarshalException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.slbinding.RedirectEventFilter;
+import at.gv.egiz.slbinding.RedirectUnmarshallerListener;
public class SLCommandFactory {
@@ -72,29 +69,30 @@ public class SLCommandFactory {
/**
* Schema for Security Layer command validation.
*/
- private static Schema slSchema;
+ private Schema slSchema;
/**
* The JAXBContext.
*/
- private static JAXBContext jaxbContext;
+ private JAXBContext jaxbContext;
/**
* The map of : to implementation class of the
* corresponding {@link SLCommand}.
*/
- private static Map> slRequestTypeMap = new HashMap>();
-
-
- static {
-
- // TODO: implement dynamic registration
-
- // register all known implementation classes
- putImplClass(SLCommand.NAMESPACE_URI, "NullOperationRequest",
- NullOperationCommandImpl.class);
- putImplClass(SLCommand.NAMESPACE_URI, "InfoboxReadRequest",
- InfoboxReadCommandImpl.class);
- putImplClass(SLCommand.NAMESPACE_URI, "CreateXMLSignatureRequest",
- CreateXMLSignatureCommandImpl.class);
+ private Map> slRequestTypeMap = new HashMap>();
+
+ /**
+ * Configures the singleton instance with command implementations
+ * @param commandImplMap
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ public void setCommandImpl(Map commandImplMap) throws ClassNotFoundException {
+ ClassLoader cl = getClass().getClassLoader();
+ for (String key : commandImplMap.keySet()) {
+ Class extends SLCommand> impl = (Class extends SLCommand>) cl.loadClass(commandImplMap.get(key));
+ log.debug("Registering sl command implementation for :"+key+ "; implementation class: "+impl.getCanonicalName());
+ slRequestTypeMap.put(key, impl);
+ }
}
/**
@@ -110,7 +108,7 @@ public class SLCommandFactory {
* the implementation class, or null to deregister a
* currently registered class
*/
- public static void putImplClass(String namespaceUri, String localname,
+ public void setImplClass(String namespaceUri, String localname,
Class extends SLCommand> slCommandClass) {
if (slCommandClass != null) {
slRequestTypeMap.put(namespaceUri + ":" + localname, slCommandClass);
@@ -128,7 +126,7 @@ public class SLCommandFactory {
* @return the implementation class, or null if no class is
* registered for the given name
*/
- public static Class extends SLCommand> getImplClass(QName name) {
+ public Class extends SLCommand> getImplClass(QName name) {
String namespaceURI = name.getNamespaceURI();
String localPart = name.getLocalPart();
return slRequestTypeMap.get(namespaceURI + ":" + localPart);
@@ -139,14 +137,14 @@ public class SLCommandFactory {
*
* @param slSchema the schema to validate Security Layer commands with
*/
- public static void setSLSchema(Schema slSchema) {
- SLCommandFactory.slSchema = slSchema;
+ public void setSLSchema(Schema slSchema) {
+ this.slSchema = slSchema;
}
/**
* @return the jaxbContext
*/
- public static JAXBContext getJaxbContext() {
+ public JAXBContext getJaxbContext() {
ensureJaxbContext();
return jaxbContext;
}
@@ -154,14 +152,14 @@ public class SLCommandFactory {
/**
* @param jaxbContext the jaxbContext to set
*/
- public static void setJaxbContext(JAXBContext jaxbContext) {
- SLCommandFactory.jaxbContext = jaxbContext;
+ public void setJaxbContext(JAXBContext jaxbContext) {
+ this.jaxbContext = jaxbContext;
}
/**
* Initialize the JAXBContext.
*/
- private synchronized static void ensureJaxbContext() {
+ private synchronized void ensureJaxbContext() {
if (jaxbContext == null) {
try {
String slPkg = at.buergerkarte.namespaces.securitylayer._1.ObjectFactory.class.getPackage().getName();
@@ -177,7 +175,7 @@ public class SLCommandFactory {
/**
* Initialize the security layer schema.
*/
- private synchronized static void ensureSchema() {
+ private synchronized void ensureSchema() {
if (slSchema == null) {
try {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -194,7 +192,7 @@ public class SLCommandFactory {
}
Schema schema = schemaFactory.newSchema(sources);
log.debug("Schema successfully created.");
- SLCommandFactory.setSLSchema(schema);
+ setSLSchema(schema);
} catch (SAXException e) {
log.error("Failed to load security layer schema.", e);
throw new SLRuntimeException("Failed to load security layer schema.", e);
@@ -211,9 +209,9 @@ public class SLCommandFactory {
*/
public synchronized static SLCommandFactory getInstance() {
if (instance == null) {
- ensureJaxbContext();
- ensureSchema();
- instance = new SLCommandFactory();
+ instance = new SLCommandFactory();
+ instance.ensureJaxbContext();
+ instance.ensureSchema();
}
return instance;
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
index 092a13c4..4969c85a 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
@@ -84,7 +84,7 @@ public class CreateXMLSignatureResultImpl extends SLResultImpl {
DocumentFragment fragment = doc.createDocumentFragment();
- JAXBContext jaxbContext = SLCommandFactory.getJaxbContext();
+ JAXBContext jaxbContext = SLCommandFactory.getInstance().getJaxbContext();
try {
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.marshal(createCreateXMLSignatureResponse, fragment);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
index 6f41b562..78e2e7fa 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -95,7 +95,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
JAXBElement infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
- JAXBContext context = SLCommandFactory.getJaxbContext();
+ JAXBContext context = SLCommandFactory.getInstance().getJaxbContext();
try {
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(infoboxReadResponse, doc);
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 7306b237..80bbdca8 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
@@ -85,7 +85,7 @@ public abstract class SLResultImpl implements SLResult {
private Marshaller getMarshaller() {
try {
- JAXBContext context = SLCommandFactory.getJaxbContext();
+ JAXBContext context = SLCommandFactory.getInstance().getJaxbContext();
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
return marshaller;
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml
new file mode 100644
index 00000000..885e35f3
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java
index 6a0792d5..58941401 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java
@@ -27,7 +27,10 @@ import java.util.List;
import java.util.Map;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import at.gv.egiz.bku.binding.MultiTestDataUrlConnection.DataSourceProvider;
import at.gv.egiz.bku.utils.StreamUtil;
@@ -80,7 +83,15 @@ public class HttpBindingProcessorTest {
protected Map serverHeaderMap;
protected Map clientHeaderMap;
protected TestDataUrlConnection server;
-
+
+ protected static ApplicationContext appCtx;
+
+ @BeforeClass
+ public static void setUpClass() {
+ appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml");
+ }
+
+
@Before
public void setUp() throws IOException {
server = new TestDataUrlConnection();
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java
index 7b35723d..e0b09508 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java
@@ -25,7 +25,10 @@ import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
@@ -33,9 +36,15 @@ import at.gv.egiz.bku.slexceptions.SLRuntimeException;
public class SLCommandFactoryTest {
+ protected static ApplicationContext appCtx;
SLCommandFactory factory;
SLCommandContext context;
+ @BeforeClass
+ public static void setUpClass() {
+ appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml");
+ }
+
@Before
public void setUp() {
factory = SLCommandFactory.getInstance();
diff --git a/pom.xml b/pom.xml
index 874dce5b..74c449e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,5 @@
-
+4.0.0at.gv.egizbku
@@ -38,15 +39,15 @@
- scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk
- scm:svn:svn+ssh://svn.egovlabs.gv.at/svnroot/mocca/trunk
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk
+ scm:svn:svn+ssh://svn.egovlabs.gv.at/svnroot/mocca/trunksvn://svn.egovlabs.gv.at/svnroot/mocca/trunkE-Government Innovation Center (EGIZ)http://www.egiz.gv.at
-
+
@@ -56,20 +57,21 @@
+ 1.61.61.6truetrue
- UTF-8
+ UTF-8
+
+
+
+ maven-resources-plugin
+
+ UTF-8
-
- maven-resources-plugin
-
- UTF-8
-
- maven-assembly-pluginorg.apache.maven.plugins
@@ -83,16 +85,17 @@
+ jaxws-maven-pluginorg.codehaus.mojo1.10
- org.apache.maven.plugins
- maven-release-plugin
- 2.0-beta-7
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.0-beta-7
@@ -105,7 +108,8 @@
+ ${basedir}/src/main/assemblies/assembly-server.xml
+
@@ -219,6 +224,16 @@
3.1compile
+
+ org.springframework
+ spring-core
+ 2.5.5
+
+
+ org.springframework
+ spring-context
+ 2.5.5
+
\ No newline at end of file
--
cgit v1.2.3
From 3aadcf8f877a560bed75af7e0db918aa26ef2a03 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Thu, 4 Dec 2008 10:00:31 +0000
Subject: Refactoring of infobox implementation.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@232 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../src/main/webapp/WEB-INF/applicationContext.xml | 34 ++
.../src/main/webapp/WEB-INF/applicationContext.xml | 17 +
.../main/java/at/gv/egiz/bku/binding/DataUrl.java | 1 +
.../bku/binding/LegacyDataUrlConnectionImpl.java | 230 +++++++++
.../java/at/gv/egiz/bku/conf/Configurator.java | 41 +-
.../egiz/bku/slcommands/InfoboxUpdateCommand.java | 23 +
.../egiz/bku/slcommands/InfoboxUpdateResult.java | 21 +
.../slcommands/impl/AbstractAssocArrayInfobox.java | 284 ++++++++++
.../slcommands/impl/AbstractBinaryFileInfobox.java | 68 +++
.../impl/AbstractInfoboxCommandImpl.java | 55 ++
.../bku/slcommands/impl/AbstractInfoboxImpl.java | 26 +
.../bku/slcommands/impl/AssocArrayInfobox.java | 27 +
.../bku/slcommands/impl/BinaryFileInfobox.java | 27 +
.../slcommands/impl/CertificatesInfoboxImpl.java | 112 ++++
.../impl/CreateXMLSignatureCommandImpl.java | 37 +-
.../slcommands/impl/IdentityLinkInfoboxImpl.java | 291 +++++++++++
.../at/gv/egiz/bku/slcommands/impl/Infobox.java | 53 ++
.../egiz/bku/slcommands/impl/InfoboxFactory.java | 151 ++++++
.../slcommands/impl/InfoboxReadCommandImpl.java | 569 ++-------------------
.../bku/slcommands/impl/InfoboxReadResultImpl.java | 3 +-
.../slcommands/impl/InfoboxUpdateCommandImpl.java | 158 ++++++
.../slcommands/impl/InfoboxUpdateResultImpl.java | 43 ++
.../gv/egiz/bku/slcommands/impl/SLCommandImpl.java | 107 +---
.../at/gv/egiz/bku/slcommands/impl/STALHelper.java | 218 ++++++++
.../egiz/bku/slcommands/testApplicationContext.xml | 36 --
.../egiz/bku/slcommands/testApplicationContext.xml | 53 ++
26 files changed, 1968 insertions(+), 717 deletions(-)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateCommand.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateResult.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AssocArrayInfobox.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/BinaryFileInfobox.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CertificatesInfoboxImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxFactory.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java
delete mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml
(limited to 'bkucommon/src/main')
diff --git a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
index 1d09aa7e..5ac12ece 100644
--- a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
@@ -48,6 +48,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index 9c7194dd..321e1e98 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -45,6 +45,23 @@
+
+
+
+
+
+
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
index d462ac60..531772cf 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
@@ -65,5 +65,6 @@ public class DataUrl {
public static void setConfiguration(Properties props) {
configuration = props;
+ defaultDataUrlConnection.setConfiguration(configuration);
}
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
new file mode 100644
index 00000000..5339d689
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
@@ -0,0 +1,230 @@
+package at.gv.egiz.bku.binding;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.binding.Protocol;
+
+/**
+ * not thread-safe thus newInsance always returns a new object
+ *
+ */
+public class LegacyDataUrlConnectionImpl implements DataUrlConnectionSPI {
+
+ private final static Log log = LogFactory.getLog(DataUrlConnectionImpl.class);
+
+ public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
+ Protocol.HTTPS };
+ protected X509Certificate serverCertificate;
+ protected Protocol protocol;
+ protected URL url;
+ private HttpURLConnection connection;
+ protected Map requestHttpHeaders;
+ protected Map formParams;
+ protected String boundary;
+ protected Properties config = null;
+
+ protected DataUrlResponse result;
+
+ public String getProtocol() {
+ if (protocol == null) {
+ return null;
+ }
+ return protocol.toString();
+ }
+
+ /**
+ * opens a connection sets the headers gets the server certificate
+ *
+ * @throws java.net.SocketTimeoutException
+ * @throws java.io.IOException
+ * @pre url != null
+ * @pre httpHeaders != null
+ */
+ public void connect() throws SocketTimeoutException, IOException {
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setDoOutput(true);
+ Set headers = requestHttpHeaders.keySet();
+ Iterator headerIt = headers.iterator();
+ while (headerIt.hasNext()) {
+ String name = headerIt.next();
+ connection.setRequestProperty(name, requestHttpHeaders.get(name));
+ }
+ log.trace("Connecting to: "+url);
+ connection.connect();
+ if (connection instanceof HttpsURLConnection) {
+ HttpsURLConnection ssl = (HttpsURLConnection) connection;
+ X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
+ if ((certs != null) && (certs.length >= 1)) {
+ log.trace("Server certificate: "+certs[0]);
+ serverCertificate = certs[0];
+ }
+ }
+ }
+
+ public X509Certificate getServerCertificate() {
+ return serverCertificate;
+ }
+
+ public void setHTTPHeader(String name, String value) {
+ if (name != null && value != null) {
+ requestHttpHeaders.put(name, value);
+ }
+ }
+
+ public void setHTTPFormParameter(String name, InputStream data,
+ String contentType, String charSet, String transferEncoding) {
+ StringBuilder sb = new StringBuilder();
+ try {
+ InputStreamReader reader = new InputStreamReader(data, (charSet != null) ? charSet : "UTF-8");
+ char[] c = new char[512];
+ for (int l; (l = reader.read(c)) != -1;) {
+ sb.append(c, 0, l);
+ }
+ } catch (IOException e) {
+ throw new SLRuntimeException("Failed to set HTTP form parameter.", e);
+ }
+ formParams.put(name, sb.toString());
+ }
+
+ /**
+ * send all formParameters
+ *
+ * @throws java.io.IOException
+ */
+ public void transmit(SLResult slResult) throws IOException {
+ StringWriter writer = new StringWriter();
+ slResult.writeTo(new StreamResult(writer));
+ formParams.put(
+ (slResult.getResultType() == SLResultType.XML)
+ ? DataUrlConnection.FORMPARAM_XMLRESPONSE
+ : DataUrlConnection.FORMPARAM_BINARYRESPONSE,
+ writer.toString());
+
+ OutputStream os = connection.getOutputStream();
+ OutputStreamWriter streamWriter = new OutputStreamWriter(os, HttpUtil.DEFAULT_CHARSET);
+
+ log.trace("Sending data");
+ Iterator keys = formParams.keySet().iterator();
+ while(keys.hasNext()) {
+ String key = keys.next();
+ streamWriter.write(URLEncoder.encode(key, "UTF-8"));
+ streamWriter.write("=");
+ streamWriter.write(URLEncoder.encode(formParams.get(key), "UTF-8"));
+ if (keys.hasNext()) {
+ streamWriter.write("&");
+ }
+ }
+ streamWriter.flush();
+ os.close();
+
+ // MultipartRequestEntity PostMethod
+ InputStream is = null;
+ try {
+ is = connection.getInputStream();
+ } catch (IOException iox) {
+ log.info(iox);
+ }
+ log.trace("Reading response");
+ result = new DataUrlResponse(url.toString(), connection.getResponseCode(), is);
+ Map responseHttpHeaders = new HashMap();
+ Map> httpHeaders = connection.getHeaderFields();
+ for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
+ .hasNext();) {
+ String key = keyIt.next();
+ StringBuffer value = new StringBuffer();
+ for (String val : httpHeaders.get(key)) {
+ value.append(val);
+ value.append(HttpUtil.SEPERATOR[0]);
+ }
+ String valString = value.substring(0, value.length() - 1);
+ if ((key != null) && (value.length() > 0)) {
+ responseHttpHeaders.put(key, valString);
+ }
+ }
+ result.setResponseHttpHeaders(responseHttpHeaders);
+ }
+
+ @Override
+ public DataUrlResponse getResponse() throws IOException {
+ return result;
+ }
+
+ /**
+ * inits protocol, url, httpHeaders, formParams
+ *
+ * @param url
+ * must not be null
+ */
+ @Override
+ public void init(URL url) {
+
+ for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
+ if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) {
+ protocol = SUPPORTED_PROTOCOLS[i];
+ break;
+ }
+ }
+ if (protocol == null) {
+ throw new SLRuntimeException("Protocol " + url.getProtocol()
+ + " not supported for data url");
+ }
+ this.url = url;
+ requestHttpHeaders = new HashMap();
+ if ((config != null)
+ && (config.getProperty(USER_AGENT_PROPERTY_KEY) != null)) {
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, config
+ .getProperty(USER_AGENT_PROPERTY_KEY));
+ } else {
+ requestHttpHeaders
+ .put(HttpUtil.HTTP_HEADER_USER_AGENT, DEFAULT_USERAGENT);
+
+ }
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
+ HttpUtil.APPLICATION_URL_ENCODED);
+
+ formParams = new HashMap();
+ }
+
+ @Override
+ public DataUrlConnectionSPI newInstance() {
+ DataUrlConnectionSPI uc = new LegacyDataUrlConnectionImpl();
+ uc.setConfiguration(config);
+ return uc;
+ }
+
+ @Override
+ public URL getUrl() {
+ return url;
+ }
+
+ @Override
+ public void setConfiguration(Properties config) {
+ this.config = config;
+ }
+}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
index 9ed99190..6078de36 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
@@ -187,28 +187,29 @@ public abstract class Configurator {
}
public void configureVersion() {
- Properties p = new Properties();
- try {
- InputStream is = getManifest();
- if (is != null) {
- p.load(getManifest());
- String version = p.getProperty("Implementation-Build");
- properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
- "citizen-card-environment/1.2 MOCCA " + version);
- DataUrl.setConfiguration(properties);
- log
- .debug("Setting user agent to: "
- + properties
- .getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
- } else {
- log.warn("Cannot read manifest");
- properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
- "citizen-card-environment/1.2 MOCCA UNKNOWN");
- DataUrl.setConfiguration(properties);
+ if (properties.getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY) == null) {
+ Properties p = new Properties();
+ try {
+ InputStream is = getManifest();
+ if (is != null) {
+ p.load(getManifest());
+ String version = p.getProperty("Implementation-Build");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
+ "citizen-card-environment/1.2 MOCCA " + version);
+ log
+ .debug("Setting user agent to: "
+ + properties
+ .getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
+ } else {
+ log.warn("Cannot read manifest");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
+ "citizen-card-environment/1.2 MOCCA UNKNOWN");
+ }
+ } catch (IOException e) {
+ log.error(e);
}
- } catch (IOException e) {
- log.error(e);
}
+ DataUrl.setConfiguration(properties);
}
public void configure() {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateCommand.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateCommand.java
new file mode 100644
index 00000000..c2974785
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateCommand.java
@@ -0,0 +1,23 @@
+/*
+* 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.bku.slcommands;
+
+public interface InfoboxUpdateCommand extends SLCommand {
+
+ public String getInfoboxIdentifier();
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateResult.java
new file mode 100644
index 00000000..d180facf
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateResult.java
@@ -0,0 +1,21 @@
+/*
+* 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.bku.slcommands;
+
+public interface InfoboxUpdateResult extends SLResult {
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
new file mode 100644
index 00000000..e49ed6c0
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
@@ -0,0 +1,284 @@
+/*
+ * 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.bku.slcommands.impl;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxAssocArrayPairType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.buergerkarte.namespaces.securitylayer._1.XMLContentType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadKeys;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadPairs;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadValue;
+import at.gv.egiz.bku.slcommands.InfoboxReadResult;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+
+/**
+ * An abstract base class for {@link Infobox} implementations of type associative array.
+ *
+ * @author mcentner
+ */
+public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
+ implements AssocArrayInfobox {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(AbstractAssocArrayInfobox.class);
+
+ /**
+ * The search string pattern.
+ */
+ public static final String SEARCH_STRING_PATTERN = ".&&[^/](/.&&[^/])*";
+
+ /**
+ * @return the keys available in this infobox.
+ */
+ public abstract String[] getKeys();
+
+ /**
+ * @return true if the values are XML entities, or false otherwise.
+ */
+ public abstract boolean isValuesAreXMLEntities();
+
+ /**
+ * Returns a key to value mapping for the given keys.
+ *
+ * @param keys a list of keys
+ * @param cmdCtx the command context
+ *
+ * @return a key to value mapping for the given keys.
+ *
+ * @throws SLCommandException if obtaining the values fails
+ */
+ public abstract Map getValues(List keys, SLCommandContext cmdCtx) throws SLCommandException;
+
+ /**
+ * Returns all keys that match the given searchString.
+ *
+ * @param searchString the search string
+ *
+ * @return all keys that match the given searchString
+ *
+ * @throws SLCommandException if the given search string is invalid
+ */
+ protected List selectKeys(String searchString) throws SLCommandException {
+
+ if ("*".equals(searchString) || "**".equals(searchString)) {
+ return Arrays.asList(getKeys());
+ }
+
+ if (Pattern.matches(SEARCH_STRING_PATTERN, searchString)) {
+
+// for (int i = 0; i < searchString.length(); i++) {
+// int codePoint = searchString.codePointAt(i);
+//
+// }
+
+ // TODO : build pattern
+ return Collections.emptyList();
+ } else {
+ log.info("Got invalid search string '" + searchString + "'");
+ throw new SLCommandException(4010);
+ }
+
+ }
+
+ /**
+ * Read all keys specified by readKeys.
+ *
+ * @param readKeys
+ * the ReadKeys element
+ * @param cmdCtx
+ * the command context
+ * @return a corresponding InfoboxReadResult
+ *
+ * @throws SLCommandException
+ * if the ReadKeys element is invalid or obtaining the corresponding
+ * values fails
+ */
+ protected InfoboxReadResult readKeys(ReadKeys readKeys, SLCommandContext cmdCtx) throws SLCommandException {
+
+ List selectedKeys = selectKeys(readKeys.getSearchString());
+
+ if (readKeys.isUserMakesUnique() && selectedKeys.size() > 1) {
+ log.info("UserMakesUnique not supported");
+ // TODO: give more specific error message
+ throw new SLCommandException(4010);
+ }
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory
+ .createInfoboxReadDataAssocArrayType();
+
+ List keys = infoboxReadDataAssocArrayType.getKey();
+ keys.addAll(selectedKeys);
+
+ return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType);
+
+ }
+
+ /**
+ * Read all pairs specified by readPairs.
+ *
+ * @param readPairs
+ * the readPairs element
+ * @param cmdCtx
+ * the command context
+ * @return a corresponding InfoboxReadResult
+ *
+ * @throws SLCommandException
+ * if the ReadPairs element is invalid or obtaining the corresponding
+ * values fails
+ */
+ protected InfoboxReadResult readPairs(ReadPairs readPairs, SLCommandContext cmdCtx) throws SLCommandException {
+
+ if (readPairs.isValuesAreXMLEntities() && !isValuesAreXMLEntities()) {
+ log.info("Got valuesAreXMLEntities=" + readPairs + " but infobox type is binary.");
+ throw new SLCommandException(4010);
+ }
+
+ if (!readPairs.isValuesAreXMLEntities() && isValuesAreXMLEntities()) {
+ log.info("Got valuesAreXMLEntities=" + readPairs + " but infobox type is XML.");
+ throw new SLCommandException(4010);
+ }
+
+ List selectedKeys = selectKeys(readPairs.getSearchString());
+
+ if (readPairs.isUserMakesUnique() && selectedKeys.size() > 1) {
+ log.info("UserMakesUnique not supported");
+ // TODO: give more specific error message
+ throw new SLCommandException(4010);
+ }
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory.createInfoboxReadDataAssocArrayType();
+
+ Map values = getValues(selectedKeys, cmdCtx);
+ for (String key : selectedKeys) {
+ InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType();
+ infoboxAssocArrayPairType.setKey(key);
+ Object value = values.get(key);
+ if (value instanceof byte[]) {
+ infoboxAssocArrayPairType.setBase64Content((byte[]) value);
+ } else {
+ infoboxAssocArrayPairType.setXMLContent((XMLContentType) value);
+ }
+ infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType);
+ }
+
+ return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType);
+ }
+
+ /**
+ * Read the value specified by readPairs.
+ *
+ * @param readValue
+ * the readValue element
+ * @param cmdCtx
+ * the command context
+ * @return a corresponding InfoboxReadResult
+ *
+ * @throws SLCommandException
+ * if the ReadValue element is invalid or obtaining the corresponding
+ * values fails
+ */
+ protected InfoboxReadResult readValue(ReadValue readValue, SLCommandContext cmdCtx) throws SLCommandException {
+
+ if (readValue.isValueIsXMLEntity() && !isValuesAreXMLEntities()) {
+ log.info("Got valuesAreXMLEntities=" + readValue + " but infobox type is binary.");
+ throw new SLCommandException(4010);
+ }
+
+ if (!readValue.isValueIsXMLEntity() && isValuesAreXMLEntities()) {
+ log.info("Got valuesAreXMLEntities=" + readValue + " but infobox type is XML.");
+ throw new SLCommandException(4010);
+ }
+
+ List selectedKeys;
+
+ if (Arrays.asList(getKeys()).contains(readValue.getKey())) {
+ selectedKeys = Collections.singletonList(readValue.getKey());
+ } else {
+ selectedKeys = Collections.emptyList();
+ }
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory.createInfoboxReadDataAssocArrayType();
+
+ Map values = getValues(selectedKeys, cmdCtx);
+ for (String key : selectedKeys) {
+ InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType();
+ infoboxAssocArrayPairType.setKey(key);
+ Object value = values.get(key);
+ if (value instanceof byte[]) {
+ infoboxAssocArrayPairType.setBase64Content((byte[]) value);
+ } else {
+ infoboxAssocArrayPairType.setXMLContent((XMLContentType) value);
+ }
+ infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType);
+ }
+
+ return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType);
+ }
+
+ @Override
+ public InfoboxReadResult read(InfoboxReadRequestType req,
+ SLCommandContext cmdCtx) throws SLCommandException {
+
+ InfoboxReadParamsAssocArrayType assocArrayParameters = req
+ .getAssocArrayParameters();
+
+ if (assocArrayParameters == null) {
+ log.info("Infobox type is AssocArray but got no AssocArrayParameters.");
+ throw new SLCommandException(4010);
+ }
+
+ if (assocArrayParameters.getReadKeys() != null) {
+ return readKeys(assocArrayParameters.getReadKeys(), cmdCtx);
+ }
+
+ if (assocArrayParameters.getReadPairs() != null) {
+ return readPairs(assocArrayParameters.getReadPairs(), cmdCtx);
+ }
+
+ // ReadValue
+ if (assocArrayParameters.getReadValue() != null) {
+ return readValue(assocArrayParameters.getReadValue(), cmdCtx);
+ }
+
+ log
+ .info("Infobox type is AssocArray but got invalid AssocArrayParameters.");
+ throw new SLCommandException(4010);
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java
new file mode 100644
index 00000000..07ca639c
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java
@@ -0,0 +1,68 @@
+/*
+* 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.bku.slcommands.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+
+/**
+ * An abstract base class for {@link Infobox} implementations of type binary file.
+ *
+ * @author mcentner
+ */
+public abstract class AbstractBinaryFileInfobox extends AbstractInfoboxImpl implements BinaryFileInfobox {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(AbstractBinaryFileInfobox.class);
+
+ /**
+ * Is this infobox' content an XML entity?
+ */
+ private boolean isXMLEntity = false;
+
+ /**
+ * @return true if this infobox' content is an XML entity or false otherwise.
+ */
+ public boolean isXMLEntity() {
+ return isXMLEntity;
+ }
+
+ /**
+ * Sets the value returned by {@link #isXMLEntity()} according to the given
+ * request.
+ *
+ * @param request the InfoboxReadRequest
+ */
+ public void setIsXMLEntity(InfoboxReadRequestType request) {
+
+ InfoboxReadParamsBinaryFileType binaryFileParameters = request.getBinaryFileParameters();
+ if (binaryFileParameters != null) {
+ isXMLEntity = binaryFileParameters.isContentIsXMLEntity();
+ log.debug("Got ContentIsXMLEntity=" + isXMLEntity + ".");
+ }
+
+ }
+
+
+
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java
new file mode 100644
index 00000000..305769a8
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java
@@ -0,0 +1,55 @@
+/*
+* 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.bku.slcommands.impl;
+
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+
+/**
+ * An abstract base class for implementations of security layer infobox requests.
+ *
+ * @author mcentner
+ *
+ * @param
+ */
+public abstract class AbstractInfoboxCommandImpl extends SLCommandImpl {
+
+ /**
+ * The infobox implementation.
+ */
+ protected Infobox infobox;
+
+ @Override
+ public void init(SLCommandContext ctx, Object request)
+ throws SLCommandException {
+ super.init(ctx, request);
+
+ String infoboxIdentifier = getInfoboxIdentifier(getRequestValue());
+
+ infobox = InfoboxFactory.getInstance().createInfobox(infoboxIdentifier);
+ }
+
+ /**
+ * Returns the infobox identifier given in request.
+ *
+ * @param request the request value
+ *
+ * @return the infobox identifier givne in request
+ */
+ protected abstract String getInfoboxIdentifier(T request);
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java
new file mode 100644
index 00000000..e5c7afcc
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java
@@ -0,0 +1,26 @@
+/*
+ * 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.bku.slcommands.impl;
+
+/**
+ * An abstract base class for {@link Infobox} implementations.
+ *
+ * @author mcentner
+ */
+public abstract class AbstractInfoboxImpl implements Infobox {
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AssocArrayInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AssocArrayInfobox.java
new file mode 100644
index 00000000..908d95da
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AssocArrayInfobox.java
@@ -0,0 +1,27 @@
+/*
+ * 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.bku.slcommands.impl;
+
+/**
+ * An {@link Infobox} of type associative array as defined in Security Layer
+ * 1.2.
+ *
+ * @author mcentner
+ */
+public interface AssocArrayInfobox extends Infobox {
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/BinaryFileInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/BinaryFileInfobox.java
new file mode 100644
index 00000000..c27f9446
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/BinaryFileInfobox.java
@@ -0,0 +1,27 @@
+/*
+* 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.bku.slcommands.impl;
+
+/**
+ * An {@link Infobox} of type binary file as defined in Security Layer
+ * 1.2.
+ *
+ * @author mcentner
+ */
+public interface BinaryFileInfobox extends Infobox {
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CertificatesInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CertificatesInfoboxImpl.java
new file mode 100644
index 00000000..0208f137
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CertificatesInfoboxImpl.java
@@ -0,0 +1,112 @@
+/*
+* 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.bku.slcommands.impl;
+
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.STALRequest;
+
+/**
+ * An implementation of the {@link Infobox} Certificates as
+ * specified in Security Layer 1.2.
+ *
+ * @author mcentner
+ */
+public class CertificatesInfoboxImpl extends AbstractAssocArrayInfobox {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(CertificatesInfoboxImpl.class);
+
+ /**
+ * The valid keys.
+ */
+ public static final String[] CERTIFICATES_KEYS = new String[] {
+ "SecureSignatureKeypair",
+ "CertifiedKeypair" };
+
+ @Override
+ public String getIdentifier() {
+ return "Certificates";
+ }
+
+ @Override
+ public String[] getKeys() {
+ return CERTIFICATES_KEYS;
+ }
+
+ @Override
+ public boolean isValuesAreXMLEntities() {
+ return false;
+ }
+
+ @Override
+ public Map getValues(List certificates, SLCommandContext cmdCtx) throws SLCommandException {
+
+ STALHelper stalHelper = new STALHelper(cmdCtx.getSTAL());
+
+ if (certificates != null && !certificates.isEmpty()) {
+
+ List stalRequests = new ArrayList();
+
+ // get certificates
+ InfoboxReadRequest infoboxReadRequest;
+ for (int i = 0; i < certificates.size(); i++) {
+ infoboxReadRequest = new InfoboxReadRequest();
+ infoboxReadRequest.setInfoboxIdentifier(certificates.get(i));
+ stalRequests.add(infoboxReadRequest);
+ }
+
+ stalHelper.transmitSTALRequest(stalRequests);
+
+ List x509Certs = stalHelper.getCertificatesFromResponses();
+
+ Map values = new HashMap();
+
+ for (int i = 0; i < certificates.size(); i++) {
+ try {
+ values.put(certificates.get(i), x509Certs.get(i).getEncoded());
+ } catch (CertificateEncodingException e) {
+ log.error("Failed to encode certificate.", e);
+ throw new SLCommandException(4000);
+ }
+ }
+
+ return values;
+
+ } else {
+
+ return new HashMap();
+
+ }
+
+
+ }
+
+}
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 b2e3b303..01686641 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
@@ -16,13 +16,11 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import java.io.ByteArrayInputStream;
import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.Date;
+import java.util.List;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.URIReferenceException;
@@ -48,11 +46,8 @@ import at.gv.egiz.bku.slexceptions.SLException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLViewerException;
import at.gv.egiz.dom.DOMUtils;
-import at.gv.egiz.stal.ErrorResponse;
import at.gv.egiz.stal.InfoboxReadRequest;
-import at.gv.egiz.stal.InfoboxReadResponse;
import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
/**
* This class implements the security layer command
@@ -147,33 +142,13 @@ public class CreateXMLSignatureCommandImpl extends
InfoboxReadRequest stalRequest = new InfoboxReadRequest();
stalRequest.setInfoboxIdentifier(keyboxIdentifier);
- requestSTAL(Collections.singletonList((STALRequest) stalRequest));
-
- STALResponse stalResponse = stalResponses.next();
-
- if (stalResponse instanceof InfoboxReadResponse) {
- byte[] infobox = ((InfoboxReadResponse) stalResponse).getInfoboxValue();
-
- try {
- CertificateFactory certFactory = CertificateFactory.getInstance("X509");
- signingCertificate = (X509Certificate) certFactory
- .generateCertificate(new ByteArrayInputStream(infobox));
- } catch (CertificateException e) {
- log.info("Failed to decode signing certificate.", e);
- // TODO: issue appropriate error
- throw new SLCommandException(4000);
- }
-
- } else if (stalResponse instanceof ErrorResponse) {
- ErrorResponse err = (ErrorResponse) stalResponse;
- log.info("Received an error response from STAL with code: "
- + err.getErrorCode());
- throw new SLCommandException(err.getErrorCode());
-
- } else {
- log.info("Failed to get signing certificate.");
+ stalHelper.transmitSTALRequest(Collections.singletonList((STALRequest) stalRequest));
+ List certificates = stalHelper.getCertificatesFromResponses();
+ if (certificates == null || certificates.size() != 1) {
+ log.info("Got an unexpected number of certificates from STAL.");
throw new SLCommandException(4000);
}
+ signingCertificate = certificates.get(0);
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
new file mode 100644
index 00000000..20d20c9d
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
@@ -0,0 +1,291 @@
+/*
+* 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.bku.slcommands.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType;
+import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.gv.egiz.bku.slcommands.InfoboxReadResult;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.idlink.CompressedIdentityLinkFactory;
+import at.gv.egiz.idlink.IdentityLinkTransformer;
+import at.gv.egiz.idlink.ans1.IdentityLink;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.STALRequest;
+
+/**
+ * An implementation of the {@link Infobox} IdentityLink as
+ * specified in Security Layer 1.2
+ *
+ * @author mcentner
+ */
+public class IdentityLinkInfoboxImpl extends AbstractBinaryFileInfobox {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(IdentityLinkInfoboxImpl.class);
+
+ /**
+ * The box specific parameter IdentityLinkDomainIdentifier.
+ */
+ public static final String BOX_SPECIFIC_PARAMETER_IDENTITY_LINK_DOMAIN_IDENTIFIER = "IdentityLinkDomainIdentifier";
+
+ /**
+ * The value of the box specific parameter IdentityLinkDomainIdentifier.
+ */
+ private String domainIdentifier;
+
+ @Override
+ public String getIdentifier() {
+ return "IdentityLink";
+ }
+
+ /**
+ * @return the value of the box specific parameter IdentityLinkDomainIdentifier
+ */
+ public String getDomainIdentifier() {
+ return domainIdentifier;
+ }
+
+ @Override
+ public InfoboxReadResult read(InfoboxReadRequestType req, SLCommandContext cmdCtx) throws SLCommandException {
+
+ AnyChildrenType boxSpecificParameters = req.getBoxSpecificParameters();
+
+ if (boxSpecificParameters != null) {
+ // check BoxSpecificParameters
+ List
--
cgit v1.2.3
From 5bd89b042a7d72fbb94feeaac38d6d4519f50dcd Mon Sep 17 00:00:00 2001
From: clemenso
Date: Fri, 5 Dec 2008 13:54:23 +0000
Subject: bindingProcessor (coordinator, bpManager, requesthandler)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@235 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 9757f7cc..5b061850 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -49,9 +49,10 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
private static Log log = LogFactory.getLog(BindingProcessorManagerImpl.class);
+ protected STALFactory stalFactory;
+ protected SLCommandInvoker commandInvokerClass;
+
private RemovalStrategy removalStrategy;
- private STALFactory stalFactory;
- private SLCommandInvoker commandInvokerClass;
private ExecutorService executorService;
private Map contextMap = Collections.synchronizedMap(new HashMap());
// private Map bindingProcessorMap = Collections
--
cgit v1.2.3
From 2df9621154ad057f6cace73efe49c9ef42515fde Mon Sep 17 00:00:00 2001
From: mcentner
Date: Tue, 9 Dec 2008 08:14:43 +0000
Subject: Refactored STAL interface. Additional infobox functionality.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@236 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/local/stal/LocalBKUWorker.java | 4 +-
.../src/main/webapp/WEB-INF/applicationContext.xml | 9 +-
.../stal/service/impl/STALRequestBrokerImpl.java | 2 +-
STAL/src/main/java/at/gv/egiz/stal/STAL.java | 2 +-
.../gv/egiz/bku/slcommands/SLCommandFactory.java | 38 +++-
.../slcommands/impl/AbstractBinaryFileInfobox.java | 4 +-
.../impl/AbstractInfoboxCommandImpl.java | 9 +
.../bku/slcommands/impl/AbstractInfoboxImpl.java | 19 ++
.../slcommands/impl/CardChannelInfoboxImpl.java | 235 +++++++++++++++++++++
.../at/gv/egiz/bku/slcommands/impl/Infobox.java | 21 +-
.../slcommands/impl/InfoboxReadCommandImpl.java | 9 -
.../bku/slcommands/impl/InfoboxReadResultImpl.java | 12 ++
.../slcommands/impl/InfoboxUpdateCommandImpl.java | 124 ++---------
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 56 +++++
.../at/gv/egiz/bku/slcommands/impl/STALHelper.java | 2 +-
.../test/java/at/gv/egiz/stal/dummy/DummySTAL.java | 2 +-
.../at/gv/egiz/smcc/AbstractSignatureCard.java | 30 ++-
smcc/src/main/java/at/gv/egiz/smcc/SWCard.java | 12 +-
.../main/java/at/gv/egiz/smcc/SignatureCard.java | 12 +-
.../java/at/gv/egiz/smcc/SignatureCardFactory.java | 8 +-
.../main/java/at/gv/egiz/smcc/util/SMCCHelper.java | 4 +-
.../java/at/gv/egiz/smcc/util/SmartCardIO.java | 9 +-
.../at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java | 2 +-
.../java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java | 15 +-
.../at/gv/egiz/bku/utils/DebugOutputStream.java | 48 +++++
.../java/at/gv/egiz/bku/utils/DebugReader.java | 58 +++++
.../java/at/gv/egiz/bku/utils/DebugWriter.java | 55 +++++
27 files changed, 657 insertions(+), 144 deletions(-)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CardChannelInfoboxImpl.java
create mode 100644 utils/src/main/java/at/gv/egiz/bku/utils/DebugOutputStream.java
create mode 100644 utils/src/main/java/at/gv/egiz/bku/utils/DebugReader.java
create mode 100644 utils/src/main/java/at/gv/egiz/bku/utils/DebugWriter.java
(limited to 'bkucommon/src/main')
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java
index 57b159ad..91d0aba0 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java
@@ -22,6 +22,8 @@ import at.gv.egiz.stal.QuitRequest;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.ext.APDUScriptRequest;
+
import java.util.List;
import javax.swing.JDialog;
@@ -40,7 +42,7 @@ public class LocalBKUWorker extends AbstractBKUWorker {
}
@Override
- public List handleRequest(List requestList) {
+ public List handleRequest(List extends STALRequest> requestList) {
signatureCard = null;
List responses = super.handleRequest(requestList);
// container.setVisible(false);
diff --git a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
index 5ac12ece..eb7d5b7a 100644
--- a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
@@ -59,6 +59,9 @@
+
@@ -76,9 +79,9 @@
-
-
-
+
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
index e7fb928a..5e3a1a99 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
@@ -85,7 +85,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
* @pre requests: either single SignRequest, QuitRequest or multiple ReadInfoboxRequests
*/
@Override
- public List handleRequest(List stalRequests) {
+ public List handleRequest(List extends STALRequest> stalRequests) {
if (interrupted) {
return null;
}
diff --git a/STAL/src/main/java/at/gv/egiz/stal/STAL.java b/STAL/src/main/java/at/gv/egiz/stal/STAL.java
index de29de9a..7fa7cb45 100644
--- a/STAL/src/main/java/at/gv/egiz/stal/STAL.java
+++ b/STAL/src/main/java/at/gv/egiz/stal/STAL.java
@@ -32,7 +32,7 @@ public interface STAL {
* @param aRequestList
* @return
*/
- public List handleRequest(List aRequestList);
+ public List handleRequest(List extends STALRequest> aRequestList);
/**
* Sets the preferred locale for userinteraction (e.g. PIN dialogs).
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
index 9c98ef8a..bec2b253 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
@@ -17,6 +17,7 @@
package at.gv.egiz.bku.slcommands;
import java.io.IOException;
+import java.io.Reader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -41,10 +42,12 @@ import org.apache.commons.logging.LogFactory;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+import at.buergerkarte.namespaces.cardchannel.ObjectFactory;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.DebugReader;
import at.gv.egiz.slbinding.RedirectEventFilter;
import at.gv.egiz.slbinding.RedirectUnmarshallerListener;
@@ -163,8 +166,9 @@ public class SLCommandFactory {
if (jaxbContext == null) {
try {
String slPkg = at.buergerkarte.namespaces.securitylayer._1.ObjectFactory.class.getPackage().getName();
- String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName();
- setJaxbContext(JAXBContext.newInstance(slPkg + ":" + xmldsigPkg));
+ String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName();
+ String cardChannelPkg = at.buergerkarte.namespaces.cardchannel.ObjectFactory.class.getPackage().getName();
+ setJaxbContext(JAXBContext.newInstance(slPkg + ":" + xmldsigPkg + ":" + cardChannelPkg));
} catch (JAXBException e) {
log.error("Failed to setup JAXBContext security layer request.", e);
throw new SLRuntimeException(e);
@@ -325,12 +329,31 @@ public class SLCommandFactory {
*/
@SuppressWarnings("unchecked")
public SLCommand createSLCommand(Source source, SLCommandContext context)
- throws SLCommandException, SLRuntimeException, SLRequestException {
+ throws SLCommandException, SLRuntimeException, SLRequestException {
+
+ DebugReader dr = null;
+ if (log.isTraceEnabled() && source instanceof StreamSource) {
+ StreamSource streamSource = (StreamSource) source;
+ if (streamSource.getReader() != null) {
+ dr = new DebugReader(streamSource.getReader(), "SLCommand unmarshalled from:\n");
+ streamSource.setReader(dr);
+ }
+ }
- Object object = unmarshal(source);
+ Object object;
+ try {
+ object = unmarshal(source);
+ } catch (SLRequestException e) {
+ throw e;
+ } finally {
+ if (dr != null) {
+ log.trace(dr.getCachedString());
+ }
+ }
+
if (!(object instanceof JAXBElement)) {
// invalid request
- log.info("Invalid security layer request. " + object.toString());
+ log.info("Invalid security layer request. " + object.toString());
throw new SLRequestException(3002, SLExceptionMessages.EC3002_INVALID,
new Object[]{object.toString()});
}
@@ -343,7 +366,9 @@ public class SLCommandFactory {
throw new SLCommandException(4011,
SLExceptionMessages.EC4011_NOTIMPLEMENTED, new Object[]{qName.toString()});
}
-
+
+
+
// try to instantiate
SLCommand slCommand;
try {
@@ -360,6 +385,7 @@ public class SLCommandFactory {
e);
throw new SLRuntimeException(e);
}
+
slCommand.init(context, (JAXBElement) object);
return slCommand;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java
index 07ca639c..23394bd5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java
@@ -37,7 +37,7 @@ public abstract class AbstractBinaryFileInfobox extends AbstractInfoboxImpl impl
/**
* Is this infobox' content an XML entity?
*/
- private boolean isXMLEntity = false;
+ protected boolean isXMLEntity = false;
/**
* @return true if this infobox' content is an XML entity or false otherwise.
@@ -61,8 +61,6 @@ public abstract class AbstractBinaryFileInfobox extends AbstractInfoboxImpl impl
}
}
-
-
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java
index 305769a8..8a7edb71 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java
@@ -52,4 +52,13 @@ public abstract class AbstractInfoboxCommandImpl extends SLCommandImpl {
*/
protected abstract String getInfoboxIdentifier(T request);
+
+ public String getInfoboxIdentifier() {
+ if (infobox != null) {
+ return infobox.getIdentifier();
+ } else {
+ return null;
+ }
+ }
+
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java
index e5c7afcc..564cb8ff 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java
@@ -16,6 +16,13 @@
*/
package at.gv.egiz.bku.slcommands.impl;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType;
+import at.gv.egiz.bku.slcommands.InfoboxReadResult;
+import at.gv.egiz.bku.slcommands.InfoboxUpdateResult;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+
/**
* An abstract base class for {@link Infobox} implementations.
*
@@ -23,4 +30,16 @@ package at.gv.egiz.bku.slcommands.impl;
*/
public abstract class AbstractInfoboxImpl implements Infobox {
+ @Override
+ public InfoboxReadResult read(InfoboxReadRequestType request,
+ SLCommandContext cmdCtx) throws SLCommandException {
+ throw new SLCommandException(4011);
+ }
+
+ @Override
+ public InfoboxUpdateResult update(InfoboxUpdateRequestType request,
+ SLCommandContext cmdCtx) throws SLCommandException {
+ throw new SLCommandException(4011);
+ }
+
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CardChannelInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CardChannelInfoboxImpl.java
new file mode 100644
index 00000000..4b1cc779
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CardChannelInfoboxImpl.java
@@ -0,0 +1,235 @@
+/*
+* 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.bku.slcommands.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.WeakHashMap;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.buergerkarte.namespaces.cardchannel.ATRType;
+import at.buergerkarte.namespaces.cardchannel.CommandAPDUType;
+import at.buergerkarte.namespaces.cardchannel.ObjectFactory;
+import at.buergerkarte.namespaces.cardchannel.ResetType;
+import at.buergerkarte.namespaces.cardchannel.ResponseAPDUType;
+import at.buergerkarte.namespaces.cardchannel.ResponseType;
+import at.buergerkarte.namespaces.cardchannel.ScriptType;
+import at.buergerkarte.namespaces.cardchannel.VerifyAPDUType;
+import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.XMLContentType;
+import at.gv.egiz.bku.slcommands.InfoboxReadResult;
+import at.gv.egiz.bku.slcommands.InfoboxUpdateResult;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.ext.APDUScriptRequest;
+import at.gv.egiz.stal.ext.APDUScriptResponse;
+import at.gv.egiz.stal.ext.APDUScriptRequest.RequestScriptElement;
+import at.gv.egiz.stal.ext.APDUScriptResponse.ResponseScriptElement;
+
+public class CardChannelInfoboxImpl extends AbstractBinaryFileInfobox {
+
+ private static Log log = LogFactory.getLog(CardChannelInfoboxImpl.class);
+
+ private static WeakHashMap> scriptResults = new WeakHashMap>();
+
+ private static JAXBContext jaxbContext;
+
+ static {
+ try {
+ jaxbContext = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
+ } catch (JAXBException e) {
+ throw new SLRuntimeException("Failed to initalize CardChannel infobox.", e);
+ }
+ }
+
+ public CardChannelInfoboxImpl() {
+ isXMLEntity = true;
+ }
+
+ @Override
+ public String getIdentifier() {
+ return "CardChannel";
+ }
+
+ @Override
+ public InfoboxReadResult read(InfoboxReadRequestType request,
+ SLCommandContext cmdCtx) throws SLCommandException {
+
+ at.buergerkarte.namespaces.securitylayer._1.ObjectFactory objectFactory
+ = new at.buergerkarte.namespaces.securitylayer._1.ObjectFactory();
+
+ Base64XMLContentType content = objectFactory.createBase64XMLContentType();
+ XMLContentType xmlContent = objectFactory.createXMLContentType();
+ content.setXMLContent(xmlContent);
+
+ JAXBElement response = scriptResults.get(cmdCtx.getSTAL());
+ if (response != null) {
+ xmlContent.getContent().add(response);
+ }
+
+ return new InfoboxReadResultImpl(content);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public InfoboxUpdateResult update(InfoboxUpdateRequestType request,
+ SLCommandContext cmdCtx) throws SLCommandException {
+
+ Base64XMLContentType binaryFileParameters = request.getBinaryFileParameters();
+
+ if (binaryFileParameters.getBase64Content() != null) {
+ log.info("Got Base64Content but ContentIsXMLEntity is true.");
+ throw new SLCommandException(4010);
+ }
+
+ XMLContentType content = binaryFileParameters.getXMLContent();
+ if (content instanceof at.gv.egiz.slbinding.impl.XMLContentType) {
+
+ ByteArrayOutputStream redirectedStream = ((at.gv.egiz.slbinding.impl.XMLContentType) content).getRedirectedStream();
+ if (redirectedStream != null) {
+
+ if (log.isDebugEnabled()) {
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("CardChannel script:\n");
+ try {
+ sb.append(new String(redirectedStream.toByteArray(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ sb.append(e.getMessage());
+ }
+ log.debug(sb.toString());
+ }
+
+ Object object;
+ try {
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ object = unmarshaller.unmarshal(new ByteArrayInputStream(redirectedStream.toByteArray()));
+ } catch (JAXBException e) {
+ log.info("Failed to parse CardChannel script.", e);
+ throw new SLCommandException(4011);
+ }
+
+ if (object instanceof JAXBElement) {
+ executeCardChannelScript(((JAXBElement) object).getValue(), cmdCtx);
+ return new InfoboxUpdateResultImpl();
+ }
+
+ }
+
+
+ }
+ log.info("Infobox identifier is '" + getIdentifier() + "' but XMLContent does not contain 'Script'.");
+ throw new SLCommandException(4010);
+
+ }
+
+ protected void executeCardChannelScript(ScriptType script,
+ SLCommandContext cmdCtx) throws SLCommandException {
+
+ List resetOrCommandAPDUOrVerifyAPDU = script.getResetOrCommandAPDUOrVerifyAPDU();
+ List requestScript = new ArrayList();
+
+ for (Object element : resetOrCommandAPDUOrVerifyAPDU) {
+
+ if (element instanceof ResetType) {
+
+ requestScript.add(new APDUScriptRequest.Reset());
+
+ } else if (element instanceof CommandAPDUType) {
+
+ CommandAPDUType commandAPDU = (CommandAPDUType) element;
+ int sequence = (commandAPDU.getSequence() != null)
+ ? commandAPDU.getSequence().intValue()
+ : 0;
+
+ requestScript.add(
+ new APDUScriptRequest.Command(
+ sequence,
+ commandAPDU.getValue(),
+ commandAPDU.getExpectedSW()));
+
+ } else if (element instanceof VerifyAPDUType) {
+ log.warn("CardChannel script command 'VerifyAPDU' not implemented.");
+ throw new SLCommandException(4011);
+ }
+ }
+
+ APDUScriptRequest scriptRequest = new APDUScriptRequest(requestScript);
+
+ STAL stal = cmdCtx.getSTAL();
+ STALHelper helper = new STALHelper(stal);
+
+ helper.transmitSTALRequest(Collections.singletonList(scriptRequest));
+
+ List responseScript = ((APDUScriptResponse) helper
+ .nextResponse(APDUScriptResponse.class)).getScript();
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ ResponseType responseType = objectFactory.createResponseType();
+
+
+ for (ResponseScriptElement element : responseScript) {
+
+ if (element instanceof APDUScriptResponse.ATR) {
+
+ byte[] atr = ((APDUScriptResponse.ATR) element).getAtr();
+
+ ATRType atrType = objectFactory.createATRType();
+ atrType.setValue(atr);
+ atrType.setRc(BigInteger.ZERO);
+ responseType.getATROrResponseAPDU().add(atrType);
+
+ } else if (element instanceof APDUScriptResponse.Response) {
+
+ APDUScriptResponse.Response response = (APDUScriptResponse.Response) element;
+
+ ResponseAPDUType responseAPDUType = objectFactory.createResponseAPDUType();
+ responseAPDUType.setSequence(BigInteger.valueOf(response.getSequence()));
+// if (response.getRc() != 0) {
+ responseAPDUType.setRc(BigInteger.valueOf(response.getRc()));
+// }
+ responseAPDUType.setSw(response.getSw());
+ responseAPDUType.setValue(response.getApdu());
+
+ responseType.getATROrResponseAPDU().add(responseAPDUType);
+ }
+
+ }
+
+ scriptResults.put(stal, objectFactory.createResponse(responseType));
+ }
+
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java
index a6f8cbb2..99d62721 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java
@@ -17,7 +17,9 @@
package at.gv.egiz.bku.slcommands.impl;
import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType;
import at.gv.egiz.bku.slcommands.InfoboxReadResult;
+import at.gv.egiz.bku.slcommands.InfoboxUpdateResult;
import at.gv.egiz.bku.slcommands.SLCommandContext;
import at.gv.egiz.bku.slexceptions.SLCommandException;
@@ -44,10 +46,25 @@ public interface Infobox {
*
* @return the data read from this infobox as InfoboxReadResult
*
- * @throws SLCommandException
- * if reading from this infobox fails
+ * @throws SLCommandException
+ *
+ * if reading from this infobox fails
*/
public InfoboxReadResult read(InfoboxReadRequestType request,
SLCommandContext cmdCtx) throws SLCommandException;
+ /**
+ * Update data in this infobox.
+ *
+ * @param request
+ * the InfoboxUpdateRequest
+ * @param cmdCtx
+ * the command context
+ * @return a corresponding InfoboxUpdateResult
+ * @throws SLCommandException
+ * if updating this infobox fails
+ */
+ public InfoboxUpdateResult update(InfoboxUpdateRequestType request,
+ SLCommandContext cmdCtx) throws SLCommandException;
+
}
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 aaa786a6..693f444f 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
@@ -83,7 +83,6 @@ public class InfoboxReadCommandImpl extends AbstractInfoboxCommandImpl implements InfoboxUpdateCommand {
+ AbstractInfoboxCommandImpl implements InfoboxUpdateCommand {
private static Log log = LogFactory.getLog(InfoboxUpdateCommandImpl.class);
- public static final String INFOBOX_IDENTIFIER_CARD_CHANNEL = "CardChannel";
+ @Override
+ public String getName() {
+ return "InfoboxUpdateRequest";
+ }
- protected String infoboxIdentifier;
-
- protected List cardChannelScript;
-
@Override
- public String getInfoboxIdentifier() {
- return infoboxIdentifier;
+ protected String getInfoboxIdentifier(InfoboxUpdateRequestType request) {
+ return request.getInfoboxIdentifier();
}
-
+
@Override
- public void init(SLCommandContext ctx, Object request)
- throws SLCommandException {
+ public void init(SLCommandContext ctx, Object request) throws SLCommandException {
super.init(ctx, request);
InfoboxUpdateRequestType req = getRequestValue();
- infoboxIdentifier = req.getInfoboxIdentifier();
+ if (req.getAssocArrayParameters() != null &&
+ !(infobox instanceof AssocArrayInfobox)) {
+ log.info("Got AssocArrayParameters but Infobox type is not AssocArray.");
+ throw new SLCommandException(4010);
+ }
- if (INFOBOX_IDENTIFIER_CARD_CHANNEL.equals(infoboxIdentifier)) {
-
- if (req.getAssocArrayParameters() != null) {
- log.info("Got AssocArrayParameters but Infobox type is BinaryFile.");
- throw new SLCommandException(4010);
- }
-
- Base64XMLContentType binaryFileParameters = req.getBinaryFileParameters();
- if (binaryFileParameters == null) {
- log.info("Got no BinaryFileParameters but Infobox type is BinaryFile.");
- throw new SLCommandException(4010);
- }
-
- if (binaryFileParameters.getBase64Content() == null) {
- log.info("Got Base64Content but ContentIsXMLEntity is true.");
- throw new SLCommandException(4010);
- }
-
- List content = binaryFileParameters.getXMLContent().getContent();
- if (content.isEmpty()) {
- log.info("Got no XMLContent but ContentIsXMLEntity is true.");
- throw new SLCommandException(4010);
- }
-
- for (Object element : content) {
- if (!(element instanceof ScriptType)) {
- log.info("Infobox identifier is '" + infoboxIdentifier + "' but XMLContent does not contain 'Script'.");
- throw new SLCommandException(4010);
- }
-
- setCardChannelScript(((ScriptType) element).getResetOrCommandAPDUOrVerifyAPDU());
- }
-
- if (getCardChannelScript() == null) {
- log.info("Infobox identifier is '" + infoboxIdentifier + "' but XMLContent does not contain 'Script'.");
- throw new SLCommandException(4010);
- }
-
- } else {
- throw new SLCommandException(4002,
- SLExceptionMessages.EC4002_INFOBOX_UNKNOWN,
- new Object[] { infoboxIdentifier });
+ if (req.getBinaryFileParameters() != null &&
+ !(infobox instanceof BinaryFileInfobox)) {
+ log.info("Got BinaryFileParameters but Infobox type is not BinaryFile.");
+ throw new SLCommandException(4010);
}
}
- public List getCardChannelScript() {
- return cardChannelScript;
- }
-
- public void setCardChannelScript(List cardChannelScript) {
- this.cardChannelScript = cardChannelScript;
- }
-
@Override
public SLResult execute() {
try {
- if (INFOBOX_IDENTIFIER_CARD_CHANNEL.equals(getInfoboxIdentifier())) {
-
- executeCardChannelScript();
- return new InfoboxUpdateResultImpl();
-
- } else {
- throw new SLCommandException(4002,
- SLExceptionMessages.EC4002_INFOBOX_UNKNOWN,
- new Object[] { infoboxIdentifier });
- }
+ return infobox.update(getRequestValue(), getCmdCtx());
} catch (SLCommandException e) {
- return new ErrorResultImpl(e, cmdCtx.getLocale());
+ return new ErrorResultImpl(e, getCmdCtx().getLocale());
}
}
-
- protected void executeCardChannelScript() throws SLCommandException {
-
- if (cardChannelScript != null) {
-
- for (Object element : cardChannelScript) {
- if (element instanceof ResetType) {
-
- } else if (element instanceof CommandAPDUType) {
-
- } else if (element instanceof VerifyAPDUType) {
-
- }
- }
-
- }
-
- }
-
- @Override
- public String getName() {
- return "InfoboxUpdateRequest";
- }
}
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 80bbdca8..99a3b119 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,7 @@
*/
package at.gv.egiz.bku.slcommands.impl;
+import java.io.UnsupportedEncodingException;
import java.util.Locale;
import javax.xml.bind.JAXBContext;
@@ -32,6 +33,7 @@ import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,6 +47,8 @@ import at.gv.egiz.bku.slexceptions.SLBindingException;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.DebugOutputStream;
+import at.gv.egiz.bku.utils.DebugWriter;
/**
* This class serves as an abstract base class for the implementation of a
@@ -128,6 +132,20 @@ public abstract class SLResultImpl implements SLResult {
* @param templates
*/
protected void writeTo(JAXBElement> response, Result result, Templates templates) {
+
+ DebugWriter dw = null;
+ DebugOutputStream ds = null;
+ if (log.isTraceEnabled() && result instanceof StreamResult) {
+ StreamResult streamResult = (StreamResult) result;
+ if (streamResult.getOutputStream() != null) {
+ ds = new DebugOutputStream(streamResult.getOutputStream());
+ streamResult.setOutputStream(ds);
+ }
+ if (streamResult.getWriter() != null) {
+ dw = new DebugWriter(streamResult.getWriter());
+ streamResult.setWriter(dw);
+ }
+ }
TransformerHandler transformerHandler = null;
if (templates != null) {
@@ -151,10 +169,36 @@ public abstract class SLResultImpl implements SLResult {
writeErrorTo(commandException, result, templates);
}
+ if (ds != null) {
+ try {
+ log.trace("Marshalled result:\n" + new String(ds.getBufferedBytes(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ log.trace(e.getMessage());
+ }
+ }
+
+ if (dw != null) {
+ log.trace("Marshalled result:\n" + dw.getBufferedString());
+ }
+
}
protected void writeTo(Node node, Result result, Templates templates) {
+ DebugWriter dw = null;
+ DebugOutputStream ds = null;
+ if (log.isTraceEnabled() && result instanceof StreamResult) {
+ StreamResult streamResult = (StreamResult) result;
+ if (streamResult.getOutputStream() != null) {
+ ds = new DebugOutputStream(streamResult.getOutputStream());
+ streamResult.setOutputStream(ds);
+ }
+ if (streamResult.getWriter() != null) {
+ dw = new DebugWriter(streamResult.getWriter());
+ streamResult.setWriter(dw);
+ }
+ }
+
if (templates == null) {
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
@@ -179,7 +223,19 @@ public abstract class SLResultImpl implements SLResult {
writeErrorTo(new SLException(2008), result, templates);
}
}
+
+ if (ds != null) {
+ try {
+ log.trace("Marshalled result:\n" + new String(ds.getBufferedBytes(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ log.trace(e.getMessage());
+ }
+ }
+ if (dw != null) {
+ log.trace("Marshalled result:\n" + dw.getBufferedString());
+ }
+
}
protected void writeErrorTo(SLException slException, Result result, Templates templates) {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java
index 969288c1..0c7ce3f5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java
@@ -85,7 +85,7 @@ public class STALHelper {
* @param stalRequests
* @throws SLCommandException
*/
- public void transmitSTALRequest(List stalRequests) throws SLCommandException {
+ public void transmitSTALRequest(List extends STALRequest> stalRequests) throws SLCommandException {
List responses = stal.handleRequest(stalRequests);
if (responses == null) {
Log log = LogFactory.getLog(this.getClass());
diff --git a/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java b/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java
index 2ea0bae0..dd8b8c8f 100644
--- a/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java
+++ b/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java
@@ -71,7 +71,7 @@ public class DummySTAL implements STAL {
}
@Override
- public List handleRequest(List requestList) {
+ public List handleRequest(List extends STALRequest> requestList) {
List responses = new ArrayList();
for (STALRequest request : requestList) {
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java
index b828e8cd..e34c4899 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java
@@ -36,6 +36,7 @@ import javax.smartcardio.ATR;
import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
+import javax.smartcardio.CardTerminal;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
@@ -53,7 +54,12 @@ public abstract class AbstractSignatureCard implements SignatureCard {
int ifs_ = 254;
- Card card_;
+ private Card card_;
+
+ /**
+ * The card terminal that connects the {@link #card_}.
+ */
+ private CardTerminal cardTerminal;
protected AbstractSignatureCard(String resourceBundleName) {
this.resourceBundleName = resourceBundleName;
@@ -331,8 +337,9 @@ public abstract class AbstractSignatureCard implements SignatureCard {
}
- public void init(Card card) {
+ public void init(Card card, CardTerminal cardTerminal) {
card_ = card;
+ this.cardTerminal = cardTerminal;
ATR atr = card.getATR();
byte[] atrBytes = atr.getBytes();
if (atrBytes.length >= 6) {
@@ -340,6 +347,11 @@ public abstract class AbstractSignatureCard implements SignatureCard {
log.trace("Setting IFS (information field size) to " + ifs_);
}
}
+
+ @Override
+ public Card getCard() {
+ return card_;
+ }
protected CardChannel getCardChannel() {
return card_.getBasicChannel();
@@ -372,4 +384,18 @@ public abstract class AbstractSignatureCard implements SignatureCard {
}
}
+ @Override
+ public void reset() throws SignatureCardException {
+ try {
+ log.debug("Disconnect and reset smart card.");
+ card_.disconnect(true);
+ log.debug("Reconnect smart card.");
+ if (cardTerminal != null) {
+ card_ = cardTerminal.connect("*");
+ }
+ } catch (CardException e) {
+ throw new SignatureCardException("Failed to reset card.", e);
+ }
+ }
+
}
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java
index 42943541..439be034 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java
@@ -40,6 +40,7 @@ import java.util.Enumeration;
import java.util.Locale;
import javax.smartcardio.Card;
+import javax.smartcardio.CardTerminal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -102,7 +103,12 @@ public class SWCard implements SignatureCard {
SWCard.swCardDir = swCardDir;
}
- public void init(Card card) {
+ public void init(Card card, CardTerminal cardTerminal) {
+ }
+
+ @Override
+ public Card getCard() {
+ return null;
}
private String getFileName(String fileName) {
@@ -379,4 +385,8 @@ public class SWCard implements SignatureCard {
public void disconnect(boolean reset) {
}
+ @Override
+ public void reset() throws SignatureCardException {
+ }
+
}
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java
index b6a453df..d7e76dd8 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java
@@ -31,6 +31,7 @@ package at.gv.egiz.smcc;
import java.util.Locale;
import javax.smartcardio.Card;
+import javax.smartcardio.CardTerminal;
public interface SignatureCard {
@@ -75,12 +76,21 @@ public interface SignatureCard {
}
- public void init(Card card);
+ public void init(Card card, CardTerminal cardTerminal);
+
+ public Card getCard();
public byte[] getCertificate(KeyboxName keyboxName)
throws SignatureCardException, InterruptedException;
public void disconnect(boolean reset);
+
+ /**
+ * Performs a reset of the card.
+ *
+ * @throws SignatureCardException if reset fails.
+ */
+ public void reset() throws SignatureCardException;
/**
*
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java
index 777299d9..ab66e9a1 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java
@@ -34,6 +34,7 @@ import java.util.List;
import javax.smartcardio.ATR;
import javax.smartcardio.Card;
+import javax.smartcardio.CardTerminal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -204,6 +205,7 @@ public class SignatureCardFactory {
* @param card
* the smart card, or null if a software card should be
* created
+ * @param cardTerminal TODO
*
* @return a SignatureCard instance
*
@@ -211,12 +213,12 @@ public class SignatureCardFactory {
* if no implementation of the given card could be
* found
*/
- public SignatureCard createSignatureCard(Card card)
+ public SignatureCard createSignatureCard(Card card, CardTerminal cardTerminal)
throws CardNotSupportedException {
if(card == null) {
SignatureCard sCard = new SWCard();
- sCard.init(card);
+ sCard.init(card, cardTerminal);
return sCard;
}
@@ -231,7 +233,7 @@ public class SignatureCardFactory {
try {
Class> scClass = cl.loadClass(supportedCard.getImplementationClassName());
sc = (SignatureCard) scClass.newInstance();
- sc.init(card);
+ sc.init(card, cardTerminal);
return sc;
} catch (ClassNotFoundException e) {
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java b/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java
index 4dae7975..f7d3bab7 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java
@@ -57,7 +57,7 @@ public class SMCCHelper {
SignatureCardFactory factory = SignatureCardFactory.getInstance();
if (useSWCard) {
try {
- signatureCard = factory.createSignatureCard(null);
+ signatureCard = factory.createSignatureCard(null, null);
resultCode = CARD_FOUND;
} catch (CardNotSupportedException e) {
resultCode = CARD_NOT_SUPPORTED;
@@ -83,7 +83,7 @@ public class SMCCHelper {
if (c == null) {
throw new CardNotSupportedException();
}
- signatureCard = factory.createSignatureCard(c);
+ signatureCard = factory.createSignatureCard(c, cardTerminal);
ATR atr = newCards.get(cardTerminal).getATR();
log.trace("Found supported card (" + signatureCard.toString() + ") "
+ "in terminal '" + cardTerminal.getName() + "', ATR = "
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java b/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java
index b70b44a7..b1866894 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java
@@ -16,6 +16,7 @@
*/
package at.gv.egiz.smcc.util;
+import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -54,7 +55,13 @@ public class SmartCardIO {
CardTerminals cardTerminals_;
private void updateTerminalFactory() {
- TerminalFactory terminalFactory = TerminalFactory.getDefault();
+ TerminalFactory terminalFactory;
+ try {
+ terminalFactory = TerminalFactory.getInstance("PC/SC", null);
+ } catch (NoSuchAlgorithmException e) {
+ log.info("Failed to get TerminalFactory of type 'PC/SC'.", e);
+ terminalFactory = TerminalFactory.getDefault();
+ }
log.debug("TerminalFactory : " + terminalFactory);
if ("PC/SC".equals(terminalFactory.getType())) {
terminalFactory_ = terminalFactory;
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
index 55f51b22..6f08a135 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
@@ -121,7 +121,7 @@ public abstract class AbstractSMCCSTAL implements STAL {
}
@Override
- public List handleRequest(List requestList) {
+ public List handleRequest(List extends STALRequest> requestList) {
log.debug("Got request list containing " + requestList.size()
+ " STAL requests");
List responseList = new ArrayList(requestList
diff --git a/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java b/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java
index 59ea141c..77997217 100644
--- a/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java
+++ b/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java
@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Locale;
import javax.smartcardio.Card;
+import javax.smartcardio.CardTerminal;
import org.junit.Assert;
import org.junit.Before;
@@ -61,7 +62,7 @@ public class AbstractSMCCSTALTest extends AbstractSMCCSTAL implements
}
@Override
- public void init(Card card) {
+ public void init(Card card, CardTerminal cardTerminal) {
// TODO Auto-generated method stub
}
@@ -71,6 +72,18 @@ public class AbstractSMCCSTALTest extends AbstractSMCCSTAL implements
// TODO Auto-generated method stub
}
+
+ @Override
+ public Card getCard() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void reset() throws SignatureCardException {
+ // TODO Auto-generated method stub
+
+ }
};
return false;
diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/DebugOutputStream.java b/utils/src/main/java/at/gv/egiz/bku/utils/DebugOutputStream.java
new file mode 100644
index 00000000..8516b76c
--- /dev/null
+++ b/utils/src/main/java/at/gv/egiz/bku/utils/DebugOutputStream.java
@@ -0,0 +1,48 @@
+/*
+* 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.bku.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class DebugOutputStream extends FilterOutputStream {
+
+ private ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+
+ public DebugOutputStream(OutputStream out) {
+ super(out);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ buffer.write(b, off, len);
+ super.write(b, off, len);
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ buffer.write(b);
+ super.write(b);
+ }
+
+ public byte[] getBufferedBytes() {
+ return buffer.toByteArray();
+ }
+
+}
diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/DebugReader.java b/utils/src/main/java/at/gv/egiz/bku/utils/DebugReader.java
new file mode 100644
index 00000000..cafe4a72
--- /dev/null
+++ b/utils/src/main/java/at/gv/egiz/bku/utils/DebugReader.java
@@ -0,0 +1,58 @@
+/*
+* 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.bku.utils;
+
+import java.io.FilterReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringWriter;
+
+public class DebugReader extends FilterReader {
+
+ private StringWriter buffer = new StringWriter();
+
+ public DebugReader(Reader in) {
+ super(in);
+ }
+
+ public DebugReader(Reader in, String start) {
+ super(in);
+ buffer.write(start);
+ }
+
+ @Override
+ public int read() throws IOException {
+ int c = super.read();
+ if (c != -1)
+ buffer.write(c);
+ return c;
+ }
+
+ @Override
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ int l = super.read(cbuf, off, len);
+ if (l != -1 ) {
+ buffer.write(cbuf, off, l);
+ }
+ return l;
+ }
+
+ public String getCachedString() {
+ return buffer.toString();
+ }
+
+}
diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/DebugWriter.java b/utils/src/main/java/at/gv/egiz/bku/utils/DebugWriter.java
new file mode 100644
index 00000000..5566f927
--- /dev/null
+++ b/utils/src/main/java/at/gv/egiz/bku/utils/DebugWriter.java
@@ -0,0 +1,55 @@
+/*
+* 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.bku.utils;
+
+import java.io.FilterWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+public class DebugWriter extends FilterWriter {
+
+ private Writer buffer = new StringWriter();
+
+ public DebugWriter(Writer out) {
+ super(out);
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ buffer.write(cbuf, off, len);
+ super.write(cbuf, off, len);
+ }
+
+ @Override
+ public void write(String str, int off, int len) throws IOException {
+ buffer.write(str, off, len);
+ super.write(str, off, len);
+ }
+
+ @Override
+ public void write(int c) throws IOException {
+ buffer.write(c);
+ super.write(c);
+ }
+
+ public String getBufferedString() {
+ return buffer.toString();
+ }
+
+
+}
--
cgit v1.2.3
From 5d72bc4d896f4326dfe89e556dcc2b4de7806f4a Mon Sep 17 00:00:00 2001
From: wbauer
Date: Tue, 9 Dec 2008 10:16:38 +0000
Subject: changed method visibility to use this class outside the package
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@240 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
index 78e2e7fa..98c2432f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -56,7 +56,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
/**
* The XML document containing the infobox content.
*/
- Document xmlDocument;
+ protected Document xmlDocument;
/**
* Creates the response document from the given binaryContent.
@@ -112,7 +112,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
/**
* @return an XMLResult for marshalling the infobox to
*/
- Result getXmlResult(boolean preserveSpace) {
+ public Result getXmlResult(boolean preserveSpace) {
xmlDocument = createResponseDocument(null, preserveSpace);
@@ -127,7 +127,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
*
* @param resultBytes
*/
- void setResultBytes(byte[] resultBytes) {
+ public void setResultBytes(byte[] resultBytes) {
xmlDocument = createResponseDocument(resultBytes, false);
--
cgit v1.2.3
From e918d250c1dda9f8b7fccfc6f611b626f65e7a5c Mon Sep 17 00:00:00 2001
From: mcentner
Date: Tue, 9 Dec 2008 10:59:08 +0000
Subject: Added method for setting a document as result of
InfoboxReadResultFileImpl.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@241 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../slcommands/impl/InfoboxReadResultFileImpl.java | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
index 98c2432f..e43d99c6 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -29,6 +29,7 @@ import javax.xml.transform.dom.DOMResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
@@ -119,8 +120,25 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
return new DOMResult(nodeList.item(0));
- }
-
+ }
+
+ /**
+ * Creates a new InfoboxReadResponse document and appends
+ * the given node as child node of the XMLContent element.
+ *
+ * @param node the node to be appended as child node of the XMLContnet element
+ * @param preserveSpace if true the value of the XMLContent's space
+ * attribute is set to preserve.
+ */
+ public void setResultXMLContent(Node node, boolean preserveSpace) {
+
+ xmlDocument = createResponseDocument(null, preserveSpace);
+
+ NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
+ nodeList.item(0).appendChild(node);
+
+ }
+
/**
* Creates a new result document for this InfoboxReadResult
* and sets the given resultBytes as content.
--
cgit v1.2.3
From dbfd110e2e502b561241e7578a7028dce48f961c Mon Sep 17 00:00:00 2001
From: mcentner
Date: Tue, 9 Dec 2008 15:50:02 +0000
Subject: Updated InfoboxReadResultFileImpl to cope with nodes from different
documents.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@243 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
index e43d99c6..c26bcd0b 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -135,6 +135,10 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
xmlDocument = createResponseDocument(null, preserveSpace);
NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
+ if (node.getOwnerDocument() != xmlDocument.getOwnerDocument()) {
+ Document doc = xmlDocument.getOwnerDocument();
+ node = doc.importNode(node, true);
+ }
nodeList.item(0).appendChild(node);
}
--
cgit v1.2.3
From 6f34b1722aa7e6c4a726a7376499a17fd2691f47 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Tue, 9 Dec 2008 15:57:42 +0000
Subject: Updated InfoboxReadResultFileImpl to cope with nodes from different
documents.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@244 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
index c26bcd0b..d8295227 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -135,9 +135,8 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
xmlDocument = createResponseDocument(null, preserveSpace);
NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
- if (node.getOwnerDocument() != xmlDocument.getOwnerDocument()) {
- Document doc = xmlDocument.getOwnerDocument();
- node = doc.importNode(node, true);
+ if (node.getOwnerDocument() != xmlDocument) {
+ node = xmlDocument.importNode(node, true);
}
nodeList.item(0).appendChild(node);
--
cgit v1.2.3
From 401c481eed1f1e30928f7310d35832f8411d7e1b Mon Sep 17 00:00:00 2001
From: mcentner
Date: Thu, 11 Dec 2008 14:42:17 +0000
Subject: XSecProvider delegation provider registration.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@246 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../main/java/at/gv/egiz/bku/conf/Configurator.java | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
index e37d107f..733b47dc 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
@@ -14,6 +14,7 @@ import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
+import java.security.Provider.Service;
import java.security.cert.CertStore;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
@@ -24,6 +25,7 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@@ -150,9 +152,21 @@ public abstract class Configurator {
log.debug("Registering security providers");
Security.insertProviderAt(new IAIK(), 1);
Security.insertProviderAt(new ECCProvider(false), 2);
- Security.addProvider(new STALProvider());
- XSecProvider.addAsProvider(false);
+
+ // registering STALProvider as delegation provider for XSECT
+ STALProvider stalProvider = new STALProvider();
+ Set services = stalProvider.getServices();
StringBuilder sb = new StringBuilder();
+ for (Service service : services) {
+ String algorithm = service.getType() + "." + service.getAlgorithm();
+ XSecProvider.setDelegationProvider(algorithm, stalProvider.getName());
+ sb.append("\n" + algorithm);
+ }
+ log.debug("Registered STALProvider as XSecProvider delegation provider for the following services : " + sb.toString());
+
+ Security.addProvider(stalProvider);
+ XSecProvider.addAsProvider(false);
+ sb = new StringBuilder();
sb.append("Registered providers: ");
int i = 1;
for (Provider prov : Security.getProviders()) {
--
cgit v1.2.3
From 887f6727479f3ae3d89a08ba619f9382b450e4c1 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Fri, 12 Dec 2008 11:48:47 +0000
Subject: Updated SMCC to support non-blocking PIN entry. Added
SV-Personendaten infobox implementation.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@248 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../src/main/webapp/WEB-INF/applicationContext.xml | 3 +
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 1 +
.../bku/binding/LegacyDataUrlConnectionImpl.java | 3 +
.../slcommands/impl/AbstractAssocArrayInfobox.java | 96 +++--
.../impl/SVPersonendatenInfoboxImpl.java | 323 +++++++++++++++++
.../impl/SVPersonendatenInfoboxImplTest.java | 147 ++++++++
smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java | 320 +++++++++--------
.../at/gv/egiz/smcc/AbstractSignatureCard.java | 214 +++++++-----
.../src/main/java/at/gv/egiz/smcc/STARCOSCard.java | 386 +++++++++++++--------
.../smcc/SecurityStatusNotSatisfiedException.java | 38 ++
.../gv/egiz/smcc/VerificationFailedException.java | 65 ++++
.../test/java/at/gv/egiz/smcc/STARCOSCardTest.java | 40 ++-
.../bku/smccstal/InfoBoxReadRequestHandler.java | 3 +
13 files changed, 1219 insertions(+), 420 deletions(-)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImpl.java
create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/SecurityStatusNotSatisfiedException.java
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/VerificationFailedException.java
(limited to 'bkucommon/src/main')
diff --git a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
index eb7d5b7a..2ddd46a1 100644
--- a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
@@ -82,6 +82,9 @@
+
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
index 408330cc..57d89c89 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -100,6 +100,7 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
}
if (hostnameVerifier != null) {
log.debug("Setting custom hostname verifier");
+ https.setHostnameVerifier(hostnameVerifier);
}
} else {
log.trace("No secure connection with: "+url+ " class="+connection.getClass());
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
index ef8034aa..452c45e5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
@@ -80,6 +80,7 @@ public class LegacyDataUrlConnectionImpl implements DataUrlConnectionSPI {
}
if (hostnameVerifier != null) {
log.debug("Setting custom hostname verifier");
+ https.setHostnameVerifier(hostnameVerifier);
}
}
connection.setDoOutput(true);
@@ -229,6 +230,8 @@ public class LegacyDataUrlConnectionImpl implements DataUrlConnectionSPI {
public DataUrlConnectionSPI newInstance() {
DataUrlConnectionSPI uc = new LegacyDataUrlConnectionImpl();
uc.setConfiguration(config);
+ uc.setSSLSocketFactory(sslSocketFactory);
+ uc.setHostnameVerifier(hostnameVerifier);
return uc;
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
index e49ed6c0..e7f96c06 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
@@ -16,12 +16,17 @@
*/
package at.gv.egiz.bku.slcommands.impl;
+import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,6 +41,7 @@ import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayTy
import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadValue;
import at.gv.egiz.bku.slcommands.InfoboxReadResult;
import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
import at.gv.egiz.bku.slexceptions.SLCommandException;
/**
@@ -54,7 +60,7 @@ public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
/**
* The search string pattern.
*/
- public static final String SEARCH_STRING_PATTERN = ".&&[^/](/.&&[^/])*";
+ public static final String SEARCH_STRING_PATTERN = "(.&&[^/])+(/.&&[^/])*";
/**
* @return the keys available in this infobox.
@@ -93,6 +99,11 @@ public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
return Arrays.asList(getKeys());
}
+ if (!searchString.contains("*")) {
+ Arrays.asList(getKeys()).contains(searchString);
+ return Collections.singletonList(searchString);
+ }
+
if (Pattern.matches(SEARCH_STRING_PATTERN, searchString)) {
// for (int i = 0; i < searchString.length(); i++) {
@@ -160,15 +171,10 @@ public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
protected InfoboxReadResult readPairs(ReadPairs readPairs, SLCommandContext cmdCtx) throws SLCommandException {
if (readPairs.isValuesAreXMLEntities() && !isValuesAreXMLEntities()) {
- log.info("Got valuesAreXMLEntities=" + readPairs + " but infobox type is binary.");
+ log.info("Got valuesAreXMLEntities=" + readPairs.isValuesAreXMLEntities() + " but infobox type is binary.");
throw new SLCommandException(4010);
}
- if (!readPairs.isValuesAreXMLEntities() && isValuesAreXMLEntities()) {
- log.info("Got valuesAreXMLEntities=" + readPairs + " but infobox type is XML.");
- throw new SLCommandException(4010);
- }
-
List selectedKeys = selectKeys(readPairs.getSearchString());
if (readPairs.isUserMakesUnique() && selectedKeys.size() > 1) {
@@ -177,26 +183,10 @@ public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
throw new SLCommandException(4010);
}
- ObjectFactory objectFactory = new ObjectFactory();
-
- InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory.createInfoboxReadDataAssocArrayType();
-
- Map values = getValues(selectedKeys, cmdCtx);
- for (String key : selectedKeys) {
- InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType();
- infoboxAssocArrayPairType.setKey(key);
- Object value = values.get(key);
- if (value instanceof byte[]) {
- infoboxAssocArrayPairType.setBase64Content((byte[]) value);
- } else {
- infoboxAssocArrayPairType.setXMLContent((XMLContentType) value);
- }
- infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType);
- }
-
- return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType);
+ return new InfoboxReadResultImpl(marshallPairs(selectedKeys, getValues(
+ selectedKeys, cmdCtx), readPairs.isValuesAreXMLEntities()));
}
-
+
/**
* Read the value specified by readPairs.
*
@@ -213,12 +203,7 @@ public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
protected InfoboxReadResult readValue(ReadValue readValue, SLCommandContext cmdCtx) throws SLCommandException {
if (readValue.isValueIsXMLEntity() && !isValuesAreXMLEntities()) {
- log.info("Got valuesAreXMLEntities=" + readValue + " but infobox type is binary.");
- throw new SLCommandException(4010);
- }
-
- if (!readValue.isValueIsXMLEntity() && isValuesAreXMLEntities()) {
- log.info("Got valuesAreXMLEntities=" + readValue + " but infobox type is XML.");
+ log.info("Got valuesAreXMLEntities=" + readValue.isValueIsXMLEntity() + " but infobox type is binary.");
throw new SLCommandException(4010);
}
@@ -230,24 +215,59 @@ public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
selectedKeys = Collections.emptyList();
}
+ return new InfoboxReadResultImpl(marshallPairs(selectedKeys, getValues(
+ selectedKeys, cmdCtx), readValue.isValueIsXMLEntity()));
+
+ }
+
+ protected InfoboxReadDataAssocArrayType marshallPairs(List selectedKeys, Map values, boolean areXMLEntities) throws SLCommandException {
+
ObjectFactory objectFactory = new ObjectFactory();
-
+
InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory.createInfoboxReadDataAssocArrayType();
- Map values = getValues(selectedKeys, cmdCtx);
for (String key : selectedKeys) {
InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType();
infoboxAssocArrayPairType.setKey(key);
+
Object value = values.get(key);
- if (value instanceof byte[]) {
- infoboxAssocArrayPairType.setBase64Content((byte[]) value);
+ if (areXMLEntities) {
+ if (value instanceof byte[]) {
+ log.info("Got valuesAreXMLEntities=" + areXMLEntities + " but infobox type is binary.");
+ throw new SLCommandException(4122);
+ } else {
+ XMLContentType contentType = objectFactory.createXMLContentType();
+ contentType.getContent().add(value);
+ infoboxAssocArrayPairType.setXMLContent(contentType);
+ }
} else {
- infoboxAssocArrayPairType.setXMLContent((XMLContentType) value);
+ infoboxAssocArrayPairType.setBase64Content((value instanceof byte[]) ? (byte[]) value : marshallValue(value));
}
+
infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType);
}
+
+ return infoboxReadDataAssocArrayType;
- return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType);
+ }
+
+ protected byte[] marshallValue(Object jaxbElement) throws SLCommandException {
+ SLCommandFactory commandFactory = SLCommandFactory.getInstance();
+ JAXBContext jaxbContext = commandFactory.getJaxbContext();
+
+ ByteArrayOutputStream result;
+ try {
+ Marshaller marshaller = jaxbContext.createMarshaller();
+
+ result = new ByteArrayOutputStream();
+ marshaller.marshal(jaxbElement, result);
+ } catch (JAXBException e) {
+ log.info("Failed to marshall infobox content.", e);
+ throw new SLCommandException(4122);
+ }
+
+ return result.toByteArray();
+
}
@Override
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImpl.java
new file mode 100644
index 00000000..7e204632
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImpl.java
@@ -0,0 +1,323 @@
+/*
+* 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.bku.slcommands.impl;
+
+import iaik.asn1.ASN;
+import iaik.asn1.ASN1Object;
+import iaik.asn1.CodingException;
+import iaik.asn1.DerCoder;
+import iaik.asn1.NumericString;
+import iaik.asn1.OCTET_STRING;
+import iaik.asn1.ObjectID;
+import iaik.asn1.SEQUENCE;
+import iaik.asn1.SET;
+import iaik.asn1.UNKNOWN;
+import iaik.asn1.structures.ChoiceOfTime;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.nio.charset.Charset;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.buergerkarte.namespaces.cardchannel.AttributeList;
+import at.buergerkarte.namespaces.cardchannel.AttributeType;
+import at.buergerkarte.namespaces.cardchannel.ObjectFactory;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.InfoboxReadResponse;
+import at.gv.egiz.stal.STALRequest;
+
+/**
+ * An implementation of the {@link Infobox} Certificates as
+ * specified in Security Layer 1.2.
+ *
+ * @author mcentner
+ */
+public class SVPersonendatenInfoboxImpl extends AbstractAssocArrayInfobox {
+
+ /**
+ * Logging facility.
+ */
+ private static Log log = LogFactory.getLog(SVPersonendatenInfoboxImpl.class);
+
+ public static final String EHIC = "EHIC";
+
+ public static final String GRUNDDATEN = "Grunddaten";
+
+ public static final String STATUS = "Status";
+
+ public static final String SV_PERSONENBINDUNG = "SV-Personenbindung";
+
+ /**
+ * The valid keys.
+ */
+ public static final String[] KEYS = new String[] {
+ GRUNDDATEN, EHIC, STATUS, SV_PERSONENBINDUNG
+ };
+
+ @Override
+ public String getIdentifier() {
+ return "SV-Personendaten";
+ }
+
+ @Override
+ public String[] getKeys() {
+ return KEYS;
+ }
+
+ @Override
+ public boolean isValuesAreXMLEntities() {
+ return true;
+ }
+
+ @Override
+ public Map getValues(List keys, SLCommandContext cmdCtx) throws SLCommandException {
+
+ STALHelper stalHelper = new STALHelper(cmdCtx.getSTAL());
+
+ if (keys != null && !keys.isEmpty()) {
+
+ List stalRequests = new ArrayList();
+
+ // get values
+ InfoboxReadRequest infoboxReadRequest;
+ for (int i = 0; i < keys.size(); i++) {
+ infoboxReadRequest = new InfoboxReadRequest();
+ infoboxReadRequest.setInfoboxIdentifier(keys.get(i));
+ stalRequests.add(infoboxReadRequest);
+ }
+
+ stalHelper.transmitSTALRequest(stalRequests);
+
+ Map values = new HashMap();
+
+ try {
+ for (int i = 0; i < keys.size(); i++) {
+
+ String key = keys.get(i);
+ InfoboxReadResponse nextResponse = (InfoboxReadResponse) stalHelper.nextResponse(InfoboxReadResponse.class);
+
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ if (EHIC.equals(key)) {
+ AttributeList attributeList = createAttributeList(nextResponse.getInfoboxValue());
+ values.put(key, objectFactory.createEHIC(attributeList));
+ } else if (GRUNDDATEN.equals(key)) {
+ AttributeList attributeList = createAttributeList(nextResponse.getInfoboxValue());
+ values.put(key, objectFactory.createGrunddaten(attributeList));
+ } else if (SV_PERSONENBINDUNG.equals(key)) {
+ values.put(key, objectFactory.createSVPersonenbindung(nextResponse.getInfoboxValue()));
+ } else if (STATUS.equals(key)) {
+ AttributeList attributeList = createAttributeListFromRecords(nextResponse.getInfoboxValue());
+ values.put(key, objectFactory.createStatus(attributeList));
+ }
+
+ }
+ } catch (CodingException e) {
+ log.info("Failed to decode '" + getIdentifier() + "' infobox.", e);
+ throw new SLCommandException(4000,
+ SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID,
+ new Object[] { "IdentityLink" });
+
+ }
+
+ return values;
+
+ } else {
+
+ return new HashMap();
+
+ }
+
+
+ }
+
+ public static AttributeList createAttributeList(byte[] infoboxValue) throws CodingException {
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ ASN1Object asn1 = DerCoder.decode(infoboxValue);
+
+ AttributeList attributeList = objectFactory.createAttributeList();
+ List attributes = attributeList.getAttribute();
+
+ if (asn1.isA(ASN.SEQUENCE)) {
+ for (int i = 0; i < ((SEQUENCE) asn1).countComponents(); i++) {
+
+ AttributeType attributeType = objectFactory.createAttributeType();
+
+ if (asn1.getComponentAt(i).isA(ASN.SEQUENCE)) {
+ SEQUENCE attribute = (SEQUENCE) asn1.getComponentAt(i);
+ if (attribute.getComponentAt(0).isA(ASN.ObjectID)) {
+ ObjectID objectId = (ObjectID) attribute.getComponentAt(0);
+ attributeType.setOid("urn:oid:" + objectId.getID());
+ }
+ if (attribute.getComponentAt(1).isA(ASN.SET)) {
+ SET values = (SET) attribute.getComponentAt(1);
+ for (int j = 0; j < values.countComponents(); j++) {
+ setAttributeValue(attributeType, values.getComponentAt(j));
+ }
+ }
+ }
+
+ attributes.add(attributeType);
+
+ }
+
+ }
+
+ return attributeList;
+
+ }
+
+ public static AttributeList createAttributeListFromRecords(byte[] infoboxValue) throws CodingException {
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ AttributeList attributeList = objectFactory.createAttributeList();
+ List attributes = attributeList.getAttribute();
+
+ byte[] records = infoboxValue;
+
+ while (records != null && records.length > 0) {
+
+ int length;
+
+ if (records[0] != 0x00) {
+
+ ASN1Object asn1 = DerCoder.decode(records);
+
+ AttributeType attributeType = objectFactory.createAttributeType();
+
+ if (asn1.isA(ASN.SEQUENCE)) {
+ SEQUENCE attribute = (SEQUENCE) asn1;
+ if (attribute.getComponentAt(0).isA(ASN.ObjectID)) {
+ ObjectID objectId = (ObjectID) attribute.getComponentAt(0);
+ attributeType.setOid("urn:oid:" + objectId.getID());
+ }
+ if (attribute.getComponentAt(1).isA(ASN.SET)) {
+ SET values = (SET) attribute.getComponentAt(1);
+ for (int j = 0; j < values.countComponents(); j++) {
+ setAttributeValue(attributeType, values.getComponentAt(j));
+ }
+ }
+ }
+
+ attributes.add(attributeType);
+
+ length = DerCoder.encode(asn1).length;
+
+ } else {
+ length = 1;
+ }
+
+ if (length < records.length) {
+ records = Arrays.copyOfRange(records, length + 1, records.length);
+ } else {
+ records = null;
+ }
+
+ }
+
+ return attributeList;
+
+ }
+
+ private static void setAttributeValue(AttributeType attributeType, ASN1Object value) {
+
+ if (value.isA(ASN.OCTET_STRING)) {
+
+ try {
+ byte[] octets = ((OCTET_STRING) value).getWholeValue();
+ attributeType.setLatin1String(new String(octets, Charset.forName("ISO-8859-1")));
+ } catch (IOException e) {
+ log.info("Failed to set Latin1String.", e);
+ }
+
+ } else if (value.isA(ASN.NumericString)) {
+
+ attributeType.setNumericString((String) ((NumericString) value).getValue());
+
+ } else if (value.isA(ASN.GeneralizedTime)) {
+
+ try {
+ ChoiceOfTime choiceOfTime = new ChoiceOfTime(value);
+
+ GregorianCalendar gregorianCalendar = new GregorianCalendar();
+ gregorianCalendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ gregorianCalendar.setTime(choiceOfTime.getDate());
+
+ DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
+ XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
+ xmlGregorianCalendar.setTimezone(0);
+
+ attributeType.setGeneralizedTime(xmlGregorianCalendar);
+ } catch (Exception e) {
+ log.info("Failed to set GeneralizedTime.", e);
+ }
+
+ } else if (value.isA(ASN.INTEGER)) {
+
+ attributeType.setInteger((BigInteger) value.getValue());
+
+ } else if (value.isA(ASN.UTF8String)) {
+
+ attributeType.setUTF8String((String) value.getValue());
+
+ } else if (value.isA(ASN.PrintableString)) {
+
+ attributeType.setPrintableString((String) value.getValue());
+
+ } else if (value.isA(ASN.UNKNOWN)) {
+
+ byte[] bytes = (byte[]) ((UNKNOWN) value).getValue();
+
+ try {
+ BigInteger bigInteger = new BigInteger(bytes);
+ String string = bigInteger.toString(16);
+
+ Date date = new SimpleDateFormat("yyyyMMdd").parse(string);
+ attributeType.setDate(new SimpleDateFormat("yyyy-MM-dd").format(date));
+ } catch (Exception e) {
+ log.info("Failed to set Date.", e);
+ }
+ }
+
+ }
+
+
+
+
+
+}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java
new file mode 100644
index 00000000..f9c60b86
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java
@@ -0,0 +1,147 @@
+/*
+* 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.bku.slcommands.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import iaik.asn1.CodingException;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import at.buergerkarte.namespaces.cardchannel.AttributeList;
+import at.buergerkarte.namespaces.cardchannel.ObjectFactory;
+import at.gv.egiz.bku.slcommands.ErrorResult;
+import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLRequestException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.dummy.DummySTAL;
+
+//@Ignore
+public class SVPersonendatenInfoboxImplTest {
+
+ private byte[] EHIC = new byte[] {
+ (byte) 0x30, (byte) 0x6b, (byte) 0x30, (byte) 0x12, (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28,
+ (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x14, (byte) 0x31, (byte) 0x06,
+ (byte) 0x04, (byte) 0x04, (byte) 0x42, (byte) 0x47, (byte) 0x4b, (byte) 0x4b, (byte) 0x30, (byte) 0x12,
+ (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28, (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04,
+ (byte) 0x01, (byte) 0x15, (byte) 0x31, (byte) 0x06, (byte) 0x12, (byte) 0x04, (byte) 0x31, (byte) 0x33,
+ (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x22, (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28,
+ (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x16, (byte) 0x31, (byte) 0x16,
+ (byte) 0x12, (byte) 0x14, (byte) 0x38, (byte) 0x30, (byte) 0x30, (byte) 0x34, (byte) 0x30, (byte) 0x30,
+ (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x32, (byte) 0x33, (byte) 0x30, (byte) 0x30,
+ (byte) 0x34, (byte) 0x37, (byte) 0x30, (byte) 0x37, (byte) 0x35, (byte) 0x39, (byte) 0x30, (byte) 0x1d,
+ (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28, (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04,
+ (byte) 0x01, (byte) 0x17, (byte) 0x31, (byte) 0x11, (byte) 0x18, (byte) 0x0f, (byte) 0x32, (byte) 0x30,
+ (byte) 0x30, (byte) 0x35, (byte) 0x30, (byte) 0x37, (byte) 0x30, (byte) 0x31, (byte) 0x31, (byte) 0x32,
+ (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x5a
+ };
+
+ private static ApplicationContext appCtx;
+
+ private SLCommandFactory factory;
+
+ private STAL stal;
+
+// @BeforeClass
+ public static void setUpClass() {
+ appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml");
+ }
+
+// @Before
+ public void setUp() {
+ factory = SLCommandFactory.getInstance();
+ stal = new DummySTAL();
+ }
+
+ @Test
+ public void testEHIC() throws SLCommandException, JAXBException, CodingException, IOException {
+
+ AttributeList attributeList = SVPersonendatenInfoboxImpl.createAttributeList(EHIC);
+
+ JAXBElement ehic = new ObjectFactory().createEHIC(attributeList);
+
+ JAXBContext jaxbContext = SLCommandFactory.getInstance().getJaxbContext();
+
+ Marshaller marshaller = jaxbContext.createMarshaller();
+
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+
+ marshaller.marshal(ehic, System.out);
+
+ }
+
+ @Ignore
+ @Test
+ public void testInfboxReadRequest() throws SLCommandException, SLRuntimeException, SLRequestException {
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.xml");
+ assertNotNull(inputStream);
+
+ SLCommandContext context = new SLCommandContext();
+ context.setSTAL(stal);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ assertTrue(command instanceof InfoboxReadCommand);
+
+ SLResult result = command.execute();
+ result.writeTo(new StreamResult(System.out));
+ }
+
+ @Ignore
+ @Test(expected=SLCommandException.class)
+ public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException {
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
+ assertNotNull(inputStream);
+
+ SLCommandContext context = new SLCommandContext();
+ context.setSTAL(stal);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ assertTrue(command instanceof InfoboxReadCommand);
+ }
+
+ @Ignore
+ public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException {
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
+ assertNotNull(inputStream);
+
+ SLCommandContext context = new SLCommandContext();
+ context.setSTAL(stal);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ assertTrue(command instanceof InfoboxReadCommand);
+
+ SLResult result = command.execute();
+ assertTrue(result instanceof ErrorResult);
+ }
+
+}
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java
index 2baff834..6d96599c 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java
@@ -30,7 +30,6 @@ package at.gv.egiz.smcc;
import java.nio.charset.Charset;
-import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
import javax.smartcardio.CommandAPDU;
@@ -110,41 +109,47 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
public byte[] getCertificate(KeyboxName keyboxName)
throws SignatureCardException, InterruptedException {
- byte[] aid;
- byte[] efc;
- int maxsize;
- if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) {
- aid = AID_SIG;
- efc = EF_C_CH_DS;
- maxsize = EF_C_CH_DS_MAX_SIZE;
- } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) {
- aid = AID_DEC;
- efc = EF_C_CH_EKEY;
- maxsize = EF_C_CH_EKEY_MAX_SIZE;
- } else {
- throw new IllegalArgumentException("Keybox " + keyboxName
- + " not supported.");
- }
-
- log.debug("Get certificate for keybox '" + keyboxName.getKeyboxName() + "'" +
- " (AID=" + toString(aid) + " EF=" + toString(efc) + ").");
-
try {
- Card card = getCardChannel().getCard();
- try {
- card.beginExclusive();
- return readTLVFile(aid, efc, maxsize + 15000);
- } catch (FileNotFoundException e) {
- // if certificate is not present,
- // the citizen card application has not been activated
- throw new NotActivatedException();
- } finally {
- card.endExclusive();
+
+ if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) {
+
+ try {
+ getCard().beginExclusive();
+ byte[] certificate = readTLVFile(AID_SIG, EF_C_CH_DS, EF_C_CH_DS_MAX_SIZE);
+ if (certificate == null) {
+ throw new NotActivatedException();
+ }
+ return certificate;
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } finally {
+ getCard().endExclusive();
+ }
+
+ } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) {
+
+ try {
+ getCard().beginExclusive();
+ byte[] certificate = readTLVFile(AID_DEC, EF_C_CH_EKEY, EF_C_CH_EKEY_MAX_SIZE);
+ if (certificate == null) {
+ throw new NotActivatedException();
+ }
+ return certificate;
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } finally {
+ getCard().endExclusive();
+ }
+
+ } else {
+ throw new IllegalArgumentException("Keybox " + keyboxName
+ + " not supported.");
}
+
} catch (CardException e) {
- throw new SignatureCardException("Failed to get exclusive card access.");
+ log.warn(e);
+ throw new SignatureCardException("Failed to access card.", e);
}
-
}
@@ -155,30 +160,47 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
public byte[] getInfobox(String infobox, PINProvider provider, String domainId)
throws SignatureCardException, InterruptedException {
- if ("IdentityLink".equals(infobox)) {
-
- PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("inf.pin.name"));
-
- try {
- Card card = getCardChannel().getCard();
- try {
- card.beginExclusive();
- return readTLVFilePIN(AID_DEC, EF_INFOBOX, KID_PIN_INF, provider,
- spec, EF_INFOBOX_MAX_SIZE);
- } catch (FileNotFoundException e) {
- // if certificate is not present,
- // the citizen card application has not been activated
- throw new NotActivatedException();
- } finally {
- card.endExclusive();
- }
- } catch (CardException e) {
- throw new SignatureCardException("Failed to get exclusive card access.");
+ try {
+ if ("IdentityLink".equals(infobox)) {
+
+ PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("inf.pin.name"));
+
+ int retries = -1;
+ String pin = null;
+ boolean pinRequiered = false;
+
+ do {
+ if (pinRequiered) {
+ pin = provider.providePIN(spec, retries);
+ if (pin == null) {
+ throw new CancelledException();
+ }
+ }
+ try {
+ getCard().beginExclusive();
+ return readTLVFile(AID_DEC, EF_INFOBOX, pin, KID_PIN_INF, EF_INFOBOX_MAX_SIZE);
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } catch (SecurityStatusNotSatisfiedException e) {
+ pinRequiered = true;
+ } catch (VerificationFailedException e) {
+ pinRequiered = true;
+ retries = e.getRetries();
+ } finally {
+ getCard().endExclusive();
+ }
+ } while (retries != 0);
+
+ throw new LockedException();
+
+ } else {
+ throw new IllegalArgumentException("Infobox '" + infobox
+ + "' not supported.");
}
-
- } else {
- throw new IllegalArgumentException("Infobox '" + infobox
- + "' not supported.");
+
+ } catch (CardException e) {
+ log.warn(e);
+ throw new SignatureCardException("Failed to access card.", e);
}
}
@@ -192,68 +214,103 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
}
try {
- Card card = getCardChannel().getCard();
- try {
- card.beginExclusive();
-
- if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) {
-
- // SELECT DF
- selectFileFID(DF_SIG);
- // VERIFY
- verifyPIN(provider, new PINSpec(6, 10, "[0-9]", getResourceBundle()
- .getString("sig.pin.name")), KID_PIN_SIG);
- // MSE: SET DST
- mseSetDST(0x81, 0xb6, DST_SIG);
- // PSO: HASH
- psoHash(hash);
- // PSO: COMPUTE DIGITAL SIGNATURE
- return psoComputDigitalSiganture();
- } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) {
-
- // SELECT DF
- selectFileFID(DF_DEC);
- // VERIFY
- verifyPIN(provider, new PINSpec(4, 4, "[0-9]", getResourceBundle()
- .getString("dec.pin.name")), KID_PIN_DEC);
- // MSE: SET DST
- mseSetDST(0x41, 0xa4, DST_DEC);
- // INTERNAL AUTHENTICATE
- return internalAuthenticate(hash);
-
-
- // 00 88 10 00 23 30 21 30 09 06 05 2B 0E 03 02 1A 05 00 04 14 54 26 F0 EA AF EA F0 4E D4 A1 AD BF 66 D4 A5 9B 45 6F AF 79 00
- // 00 88 10 00 23 30 21 30 09 06 05 2B 0E 03 02 1A 05 00 04 14 DF 8C AB 8F E2 AD AC 7B 5A AF BE E9 44 5E 95 99 FA AF 2F 48 00
-
- } else {
- throw new IllegalArgumentException("KeyboxName '" + keyboxName
- + "' not supported.");
- }
+ if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) {
+
+ PINSpec spec = new PINSpec(6, 10, "[0-9]", getResourceBundle().getString("sig.pin.name"));
+
+ int retries = -1;
+ String pin = null;
+
+ do {
+ pin = provider.providePIN(spec, retries);
+ if (pin == null) {
+ throw new CancelledException();
+ }
+ try {
+ getCard().beginExclusive();
+
+ // SELECT DF
+ selectFileFID(DF_SIG);
+ // VERIFY
+ retries = verifyPIN(pin, KID_PIN_SIG);
+ if (retries != -1) {
+ throw new VerificationFailedException(retries);
+ }
+ // MSE: SET DST
+ mseSetDST(0x81, 0xb6, DST_SIG);
+ // PSO: HASH
+ psoHash(hash);
+ // PSO: COMPUTE DIGITAL SIGNATURE
+ return psoComputDigitalSiganture();
+
+ } catch (SecurityStatusNotSatisfiedException e) {
+ retries = verifyPIN(null, KID_PIN_SIG);
+ } catch (VerificationFailedException e) {
+ retries = e.getRetries();
+ } finally {
+ getCard().endExclusive();
+ }
+ } while (retries != 0);
+
+ throw new LockedException();
+
+
+ } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) {
- } catch (FileNotFoundException e) {
- // if certificate is not present,
- // the citizen card application has not been activated
- throw new NotActivatedException();
- } finally {
- card.endExclusive();
+ PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("dec.pin.name"));
+
+ int retries = -1;
+ String pin = null;
+ boolean pinRequiered = false;
+
+ do {
+ if (pinRequiered) {
+ pin = provider.providePIN(spec, retries);
+ if (pin == null) {
+ throw new CancelledException();
+ }
+ }
+ try {
+ getCard().beginExclusive();
+
+ // SELECT DF
+ selectFileFID(DF_DEC);
+ // VERIFY
+ retries = verifyPIN(pin, KID_PIN_DEC);
+ if (retries != -1) {
+ throw new VerificationFailedException(retries);
+ }
+ // MSE: SET DST
+ mseSetDST(0x41, 0xa4, DST_DEC);
+ // INTERNAL AUTHENTICATE
+ return internalAuthenticate(hash);
+
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } catch (SecurityStatusNotSatisfiedException e) {
+ pinRequiered = true;
+ retries = verifyPIN(null, KID_PIN_DEC);
+ } catch (VerificationFailedException e) {
+ pinRequiered = true;
+ retries = e.getRetries();
+ } finally {
+ getCard().endExclusive();
+ }
+ } while (retries != 0);
+
+ throw new LockedException();
+
+ } else {
+ throw new IllegalArgumentException("KeyboxName '" + keyboxName
+ + "' not supported.");
}
+
} catch (CardException e) {
- throw new SignatureCardException("Failed to get exclusive card access.");
- }
-
- }
-
- protected byte[] selectFileAID(byte[] fid) throws CardException, SignatureCardException {
- CardChannel channel = getCardChannel();
- ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x04,
- 0x00, fid, 256));
- if (resp.getSW() != 0x9000) {
- throw new SignatureCardException("Failed to select file (AID="
- + toString(fid) + "): SW=" + Integer.toHexString(resp.getSW()) + ".");
- } else {
- return resp.getBytes();
- }
+ log.warn(e);
+ throw new SignatureCardException("Failed to access card.", e);
+ }
+
}
protected ResponseAPDU selectFileFID(byte[] fid) throws CardException, SignatureCardException {
@@ -262,6 +319,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
0x00, fid, 256));
}
+ @Override
protected int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException {
CardChannel channel = getCardChannel();
@@ -290,35 +348,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
}
- /**
- *
- * @param pinProvider
- * @param spec
- * the PIN spec to be given to the pinProvider
- * @param kid
- * the KID (key identifier) of the PIN to be verified
- * @throws CancelledException
- * if the user canceld the operation
- * @throws javax.smartcardio.CardException
- * @throws at.gv.egiz.smcc.SignatureCardException
- */
- @Override
- protected void verifyPIN(PINProvider pinProvider, PINSpec spec, byte kid)
- throws CardException, CancelledException, SignatureCardException, InterruptedException {
-
- int retries = -1;
- do {
- String pin = pinProvider.providePIN(spec, retries);
- if (pin == null) {
- // user canceled operation
- throw new CancelledException("User canceled operation");
- }
- retries = verifyPIN(pin, kid);
- } while (retries > 0);
-
- }
-
- void mseSetDST(int p1, int p2, byte[] dst) throws CardException, SignatureCardException {
+ private void mseSetDST(int p1, int p2, byte[] dst) throws CardException, SignatureCardException {
CardChannel channel = getCardChannel();
ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x22, p1,
p2, dst));
@@ -328,7 +358,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
}
}
- void psoHash(byte[] hash) throws CardException, SignatureCardException {
+ private void psoHash(byte[] hash) throws CardException, SignatureCardException {
CardChannel channel = getCardChannel();
ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x2A, 0x90,
0x81, hash));
@@ -338,7 +368,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
}
}
- byte[] psoComputDigitalSiganture() throws CardException,
+ private byte[] psoComputDigitalSiganture() throws CardException,
SignatureCardException {
CardChannel channel = getCardChannel();
ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x2A, 0x9E,
@@ -352,7 +382,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard {
}
}
- byte[] internalAuthenticate(byte[] hash) throws CardException, SignatureCardException {
+ private byte[] internalAuthenticate(byte[] hash) throws CardException, SignatureCardException {
byte[] digestInfo = new byte[] {
(byte) 0x30, (byte) 0x21, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x05, (byte) 0x2B, (byte) 0x0E,
(byte) 0x03, (byte) 0x02, (byte) 0x1A, (byte) 0x05, (byte) 0x00, (byte) 0x04
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java
index e34c4899..633cc90d 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java
@@ -28,6 +28,8 @@
//
package at.gv.egiz.smcc;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -79,45 +81,56 @@ public abstract class AbstractSignatureCard implements SignatureCard {
return sb.toString();
}
- protected abstract byte[] selectFileAID(byte[] fid) throws CardException,
- SignatureCardException;
-
- protected abstract ResponseAPDU selectFileFID(byte[] fid) throws CardException,
- SignatureCardException;
-
/**
- * VERIFY PIN
+ * Select an application using AID as DF name according to ISO/IEC 7816-4
+ * section 8.2.2.2.
*
- *
- * Implementations of this method should call
- * {@link PINProvider#providePIN(PINSpec, int)} to retrieve the PIN entered by
- * the user and VERIFY PIN on the smart card until the PIN has been
- * successfully verified.
- *
+ * @param dfName
+ * AID of the application to be selected
*
- * @param pinProvider
- * the PINProvider
- * @param spec
- * the PINSpec
- * @param kid
- * the key ID (KID) of the PIN to verify
+ * @return the response data of the response APDU if SW=0x9000
*
* @throws CardException
- * if smart card communication fails
- *
- * @throws CancelledException
- * if the PINProvider indicated that the user canceled the PIN entry
- * @throws NotActivatedException
- * if the card application has not been activated
- * @throws LockedException
- * if the card application is locked
+ * if card communication fails
*
* @throws SignatureCardException
- * if VERIFY PIN fails
+ * if application selection fails (e.g. an application with the
+ * given AID is not present on the card)
*/
- protected abstract void verifyPIN(PINProvider pinProvider, PINSpec spec,
- byte kid) throws CardException, SignatureCardException, InterruptedException;
+ protected byte[] selectFileAID(byte[] dfName) throws CardException, SignatureCardException {
+ CardChannel channel = getCardChannel();
+ ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x04,
+ 0x00, dfName, 256));
+ if (resp.getSW() != 0x9000) {
+ throw new SignatureCardException("Failed to select application AID="
+ + toString(dfName) + ": SW=" + Integer.toHexString(resp.getSW()) + ".");
+ } else {
+ return resp.getBytes();
+ }
+ }
+
+ protected abstract ResponseAPDU selectFileFID(byte[] fid) throws CardException,
+ SignatureCardException;
+ protected abstract int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException;
+
+
+ protected byte[] readRecord(int recordNumber) throws SignatureCardException, CardException {
+ return readRecord(getCardChannel(), recordNumber);
+ }
+
+ protected byte[] readRecord(CardChannel channel, int recordNumber) throws SignatureCardException, CardException {
+
+ ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xB2,
+ recordNumber, 0x04, 256));
+ if (resp.getSW() == 0x9000) {
+ return resp.getData();
+ } else {
+ throw new SignatureCardException("Failed to read records. SW=" + Integer.toHexString(resp.getSW()));
+ }
+
+ }
+
protected byte[] readBinary(CardChannel channel, int offset, int len)
throws CardException, SignatureCardException {
@@ -125,6 +138,8 @@ public abstract class AbstractSignatureCard implements SignatureCard {
0x7F & (offset >> 8), offset & 0xFF, len));
if (resp.getSW() == 0x9000) {
return resp.getData();
+ } else if (resp.getSW() == 0x6982) {
+ throw new SecurityStatusNotSatisfiedException();
} else {
throw new SignatureCardException("Failed to read bytes (" + offset + "+"
+ len + "): SW=" + Integer.toHexString(resp.getSW()));
@@ -188,43 +203,10 @@ public abstract class AbstractSignatureCard implements SignatureCard {
}
- /**
- * Read the content of a TLV file.
- *
- * @param aid the application ID (AID)
- * @param ef the elementary file (EF)
- * @param maxLength the maximum length of the file
- *
- * @return the content of the file
- *
- * @throws SignatureCardException
- */
- protected byte[] readTLVFile(byte[] aid, byte[] ef, int maxLength)
- throws SignatureCardException, InterruptedException {
- return readTLVFilePIN(aid, ef, (byte) 0, null, null, maxLength);
- }
-
-
- /**
- * Read the content of a TLV file wich may require a PIN.
- *
- * @param aid the application ID (AID)
- * @param ef the elementary file (EF)
- * @param kid the key ID (KID) of the corresponding PIN
- * @param provider the PINProvider
- * @param spec the PINSpec
- * @param maxLength the maximum length of the file
- *
- * @return the content of the file
- *
- * @throws SignatureCardException
- */
- protected byte[] readTLVFilePIN(byte[] aid, byte[] ef, byte kid,
- PINProvider provider, PINSpec spec, int maxLength)
- throws SignatureCardException, InterruptedException {
-
+ protected byte[] readRecords(byte[] aid, byte[] ef, int start, int end) throws SignatureCardException, InterruptedException {
+
try {
-
+
// SELECT FILE (AID)
byte[] rb = selectFileAID(aid);
if (rb[rb.length - 2] != (byte) 0x90 || rb[rb.length - 1] != (byte) 0x00) {
@@ -256,37 +238,89 @@ public abstract class AbstractSignatureCard implements SignatureCard {
+ Integer.toHexString(resp.getSW()) + ").");
}
-
- // try to READ BINARY
- byte[] b = new byte[1];
- int sw = readBinary(0, 1, b);
- if (provider != null && sw == 0x6982) {
-
- // VERIFY
- verifyPIN(provider, spec, kid);
-
- } else if (sw == 0x9000) {
- // not expected type
- if (b[0] != 0x30) {
- throw new NotActivatedException();
- }
- } else {
- throw new SignatureCardException("READ BINARY failed (SW="
- + Integer.toHexString(sw) + ").");
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+
+ for (int i = start; i <= end; i++) {
+ bytes.write(readRecord(i));
}
-
- // READ BINARY
- byte[] data = readBinaryTLV(maxLength, (byte) 0x30);
-
- return data;
-
+
+ return bytes.toByteArray();
+
} catch (CardException e) {
throw new SignatureCardException("Failed to acces card.", e);
+ } catch (IOException e) {
+ throw new SignatureCardException("Failed to read records.", e);
}
-
+
+ }
+
+ /**
+ * Read the content of a TLV file.
+ *
+ * @param aid the application ID (AID)
+ * @param ef the elementary file (EF)
+ * @param maxLength the maximum length of the file
+ *
+ * @return the content of the file
+ *
+ * @throws SignatureCardException
+ * @throws CardException
+ */
+ protected byte[] readTLVFile(byte[] aid, byte[] ef, int maxLength)
+ throws SignatureCardException, InterruptedException, CardException {
+ return readTLVFile(aid, ef, null, (byte) 0, maxLength);
}
+ /**
+ * Read the content of a TLV file wich may require a PIN.
+ *
+ * @param aid the application ID (AID)
+ * @param ef the elementary file (EF)
+ * @param kid the key ID (KID) of the corresponding PIN
+ * @param provider the PINProvider
+ * @param spec the PINSpec
+ * @param maxLength the maximum length of the file
+ *
+ * @return the content of the file
+ *
+ * @throws SignatureCardException
+ * @throws CardException
+ */
+ protected byte[] readTLVFile(byte[] aid, byte[] ef, String pin, byte kid, int maxLength)
+ throws SignatureCardException, InterruptedException, CardException {
+
+
+ // SELECT FILE (AID)
+ selectFileAID(aid);
+
+ // SELECT FILE (EF)
+ ResponseAPDU resp = selectFileFID(ef);
+ if (resp.getSW() == 0x6a82) {
+ // EF not found
+ throw new FileNotFoundException("EF " + toString(ef) + " not found.");
+ } else if (resp.getSW() != 0x9000) {
+ throw new SignatureCardException("SELECT FILE with "
+ + "FID="
+ + toString(ef)
+ + " failed ("
+ + "SW="
+ + Integer.toHexString(resp.getSW()) + ").");
+ }
+
+ // VERIFY
+ if (pin != null) {
+ int retries = verifyPIN(pin, kid);
+ if (retries != -1) {
+ throw new VerificationFailedException(retries);
+ }
+ }
+
+ return readBinaryTLV(maxLength, (byte) 0x30);
+
+
+ }
+
/**
* Transmit the given command APDU using the given card channel.
*
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java
index d6d02475..2a6e90bf 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java
@@ -31,7 +31,6 @@ package at.gv.egiz.smcc;
import java.math.BigInteger;
import java.util.Arrays;
-import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
import javax.smartcardio.CommandAPDU;
@@ -49,6 +48,42 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
public static final byte[] MF = new byte[] { (byte) 0x3F, (byte) 0x00 };
+ /**
+ * Application ID SV-Personendaten.
+ */
+ public static final byte[] AID_SV_PERSONENDATEN = new byte[] {
+ (byte) 0xD0, (byte) 0x40, (byte) 0x00, (byte) 0x00,
+ (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
+ };
+
+ /**
+ * File ID Grunddaten ({@link #AID_SV_PERSONENDATEN}).
+ */
+ public static final byte[] FID_GRUNDDATEN = new byte[] {
+ (byte) 0xEF, (byte) 0x01
+ };
+
+ /**
+ * File ID EHIC ({@link #AID_SV_PERSONENDATEN}).
+ */
+ public static final byte[] FID_EHIC = new byte[] {
+ (byte) 0xEF, (byte) 0x02
+ };
+
+ /**
+ * File ID Status ({@link #AID_SV_PERSONENDATEN}).
+ */
+ public static final byte[] FID_SV_PERSONENBINDUNG = new byte[] {
+ (byte) 0xEF, (byte) 0x03
+ };
+
+ /**
+ * File ID Status ({@link #AID_SV_PERSONENDATEN}).
+ */
+ public static final byte[] FID_STATUS = new byte[] {
+ (byte) 0xEF, (byte) 0x04
+ };
+
public static final byte[] AID_INFOBOX = new byte[] { (byte) 0xd0,
(byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00,
(byte) 0x18, (byte) 0x01 };
@@ -126,85 +161,134 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
super("at/gv/egiz/smcc/STARCOSCard");
}
- /* (non-Javadoc)
- * @see at.gv.egiz.smcc.SignatureCard#getCertificate(at.gv.egiz.smcc.SignatureCard.KeyboxName)
- */
@Override
public byte[] getCertificate(KeyboxName keyboxName)
throws SignatureCardException, InterruptedException {
- byte[] aid;
- byte[] efc;
- if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) {
- aid = AID_DF_SS;
- efc = EF_C_X509_CH_DS;
- } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) {
- aid = AID_DF_GS;
- efc = EF_C_X509_CH_AUT;
- } else {
- throw new IllegalArgumentException("Keybox " + keyboxName
- + " not supported.");
- }
+ try {
+
+ if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) {
+
+ try {
+ getCard().beginExclusive();
+ return readTLVFile(AID_DF_SS, EF_C_X509_CH_DS, 2000);
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } finally {
+ getCard().endExclusive();
+ }
+
+ } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) {
- log.debug("Get certificate for keybox '" + keyboxName.getKeyboxName() + "'" +
- " (AID=" + toString(aid) + " EF=" + toString(efc) + ").");
+ try {
+ getCard().beginExclusive();
+ return readTLVFile(AID_DF_GS, EF_C_X509_CH_AUT, 2000);
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } finally {
+ getCard().endExclusive();
+ }
- try {
- Card card = getCardChannel().getCard();
- try {
- card.beginExclusive();
- return readTLVFile(aid, efc, 2000);
- } catch (FileNotFoundException e) {
- // if certificate is not present,
- // the citizen card application has not been activated
- throw new NotActivatedException();
- } finally {
- card.endExclusive();
+ } else {
+ throw new IllegalArgumentException("Keybox " + keyboxName
+ + " not supported.");
}
+
} catch (CardException e) {
- throw new SignatureCardException("Failed to get exclusive card access.");
+ log.warn(e);
+ throw new SignatureCardException("Failed to access card.", e);
}
-
- }
- /* (non-Javadoc)
- * @see at.gv.egiz.smcc.SignatureCard#getInfobox(java.lang.String, at.gv.egiz.smcc.PINProvider, java.lang.String)
- */
+ }
+
@Override
public byte[] getInfobox(String infobox, PINProvider provider, String domainId)
throws SignatureCardException, InterruptedException {
- if ("IdentityLink".equals(infobox)) {
-
- PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name"));
-
- try {
- Card card = getCardChannel().getCard();
+ try {
+ if ("IdentityLink".equals(infobox)) {
+
+ PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name"));
+
+ int retries = -1;
+ String pin = null;
+ boolean pinRequiered = false;
+
+ do {
+ if (pinRequiered) {
+ pin = provider.providePIN(spec, retries);
+ if (pin == null) {
+ throw new CancelledException();
+ }
+ }
+ try {
+ getCard().beginExclusive();
+ return readTLVFile(AID_INFOBOX, EF_INFOBOX, pin, KID_PIN_CARD, 2000);
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } catch (SecurityStatusNotSatisfiedException e) {
+ pinRequiered = true;
+ retries = verifyPIN(null, KID_PIN_CARD);
+ } catch (VerificationFailedException e) {
+ pinRequiered = true;
+ retries = e.getRetries();
+ } finally {
+ getCard().endExclusive();
+ }
+ } while (retries != 0);
+
+ throw new LockedException();
+
+
+ } else if ("EHIC".equals(infobox)) {
+
try {
- card.beginExclusive();
- return readTLVFilePIN(AID_INFOBOX, EF_INFOBOX, KID_PIN_CARD,
- provider, spec, 2000);
- } catch (FileNotFoundException e) {
- // if certificate is not present,
- // the citizen card application has not been activated
- throw new NotActivatedException();
+ getCard().beginExclusive();
+ return readTLVFile(AID_SV_PERSONENDATEN, FID_EHIC, 126);
} finally {
- card.endExclusive();
+ getCard().endExclusive();
}
- } catch (CardException e) {
- throw new SignatureCardException("Failed to get exclusive card access.");
+
+ } else if ("Grunddaten".equals(infobox)) {
+
+ try {
+ getCard().beginExclusive();
+ return readTLVFile(AID_SV_PERSONENDATEN, FID_GRUNDDATEN, 550);
+ } finally {
+ getCard().endExclusive();
+ }
+
+ } else if ("SV-Personenbindung".equals(infobox)) {
+
+ try {
+ getCard().beginExclusive();
+ return readTLVFile(AID_SV_PERSONENDATEN, FID_SV_PERSONENBINDUNG, 500);
+ } finally {
+ getCard().endExclusive();
+ }
+
+ } else if ("Status".equals(infobox)) {
+
+ try {
+ getCard().beginExclusive();
+ return readRecords(AID_SV_PERSONENDATEN, FID_STATUS, 1, 5);
+ } finally {
+ getCard().endExclusive();
+ }
+
+ } else {
+ throw new IllegalArgumentException("Infobox '" + infobox
+ + "' not supported.");
}
- } else {
- throw new IllegalArgumentException("Infobox '" + infobox
- + "' not supported.");
+ } catch (CardException e) {
+ log.warn(e);
+ throw new SignatureCardException("Failed to access card.", e);
}
}
- /* (non-Javadoc)
- * @see at.gv.egiz.smcc.SignatureCard#createSignature(byte[], at.gv.egiz.smcc.SignatureCard.KeyboxName, at.gv.egiz.smcc.PINProvider)
- */
+ @Override
public byte[] createSignature(byte[] hash, KeyboxName keyboxName,
PINProvider provider) throws SignatureCardException, InterruptedException {
@@ -212,72 +296,115 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
throw new IllegalArgumentException("Hash value must be of length 20.");
}
- byte[] aid;
- byte kid;
- byte[] dst;
- PINSpec spec;
- if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) {
- aid = AID_DF_SS;
- kid = KID_PIN_SS;
- dst = DST_SS;
- spec = new PINSpec(6, 10, "[0-9]", getResourceBundle().getString("sig.pin.name"));
-
- } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) {
- aid = AID_DF_GS;
- kid = KID_PIN_CARD;
- dst = DST_GS;
- spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name"));
-
- } else {
- throw new IllegalArgumentException("KeyboxName '" + keyboxName
- + "' not supported.");
- }
-
try {
- Card card = getCardChannel().getCard();
- try {
- card.beginExclusive();
-
- // SELECT MF
- selectMF();
- // SELECT DF
- selectFileAID(aid);
- // VERIFY
- verifyPIN(provider, spec, kid);
- // MSE: SET DST
- mseSetDST(dst);
- // PSO: HASH
- psoHash(hash);
- // PSO: COMPUTE DIGITAL SIGNATURE
- return psoComputDigitalSiganture();
-
-
- } catch (FileNotFoundException e) {
- // if certificate is not present,
- // the citizen card application has not been activated
- throw new NotActivatedException();
- } finally {
- card.endExclusive();
+
+ if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) {
+
+ PINSpec spec = new PINSpec(6, 10, "[0-9]", getResourceBundle().getString("sig.pin.name"));
+
+ int retries = -1;
+ String pin = null;
+
+ do {
+ try {
+ getCard().beginExclusive();
+ selectFileAID(AID_DF_SS);
+ retries = verifyPIN(null, KID_PIN_SS);
+ } finally {
+ getCard().endExclusive();
+ }
+ pin = provider.providePIN(spec, retries);
+ if (pin == null) {
+ throw new CancelledException();
+ }
+ try {
+ getCard().beginExclusive();
+ return createSignature(hash, AID_DF_SS, pin, KID_PIN_SS, DST_SS);
+ } catch (VerificationFailedException e) {
+ retries = e.getRetries();
+ } finally {
+ getCard().endExclusive();
+ }
+ } while (retries != 0);
+
+ throw new LockedException();
+
+
+ } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) {
+
+ PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name"));
+
+ int retries = -1;
+ String pin = null;
+ boolean pinRequiered = false;
+
+ do {
+ if (pinRequiered) {
+ pin = provider.providePIN(spec, retries);
+ if (pin == null) {
+ throw new CancelledException();
+ }
+ }
+ try {
+ getCard().beginExclusive();
+ return createSignature(hash, AID_DF_GS, pin, KID_PIN_CARD, DST_GS);
+ } catch (FileNotFoundException e) {
+ throw new NotActivatedException();
+ } catch (SecurityStatusNotSatisfiedException e) {
+ pinRequiered = true;
+ retries = verifyPIN(null, KID_PIN_CARD);
+ } catch (VerificationFailedException e) {
+ pinRequiered = true;
+ retries = e.getRetries();
+ } finally {
+ getCard().endExclusive();
+ }
+ } while (retries != 0);
+
+ throw new LockedException();
+
+ } else {
+ throw new IllegalArgumentException("KeyboxName '" + keyboxName
+ + "' not supported.");
}
+
} catch (CardException e) {
- throw new SignatureCardException("Failed to get exclusive card access.");
+ log.warn(e);
+ throw new SignatureCardException("Failed to access card.", e);
}
}
- protected byte[] selectFileAID(byte[] fid) throws CardException, SignatureCardException {
+ protected ResponseAPDU selectFileFID(byte[] fid) throws CardException, SignatureCardException {
CardChannel channel = getCardChannel();
- ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x04,
+ return transmit(channel, new CommandAPDU(0x00, 0xA4, 0x02,
0x04, fid, 256));
- if (resp.getSW() != 0x9000) {
- throw new SignatureCardException("Failed to select file (AID="
- + toString(fid) + "): SW=" + Integer.toHexString(resp.getSW()) + ".");
- } else {
- return resp.getBytes();
+ }
+
+ private byte[] createSignature(byte[] hash, byte[] aid, String pin, byte kid,
+ byte[] dst) throws CardException, SignatureCardException {
+
+ // SELECT MF
+ selectMF();
+ // SELECT DF
+ selectFileAID(aid);
+ // VERIFY
+ int retries = verifyPIN(pin, kid);
+ if (retries != -1) {
+ throw new VerificationFailedException(retries);
}
+ // MSE: SET DST
+ mseSetDST(dst);
+ // PSO: HASH
+ psoHash(hash);
+ // PSO: COMPUTE DIGITAL SIGNATURE
+ return psoComputDigitalSiganture();
+
+
}
- void selectMF() throws CardException, SignatureCardException {
+
+ private void selectMF() throws CardException, SignatureCardException {
CardChannel channel = getCardChannel();
ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x00,
0x0C));
@@ -287,13 +414,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
}
}
- protected ResponseAPDU selectFileFID(byte[] fid) throws CardException, SignatureCardException {
- CardChannel channel = getCardChannel();
- return transmit(channel, new CommandAPDU(0x00, 0xA4, 0x02,
- 0x04, fid, 256));
- }
-
- void mseSetDST(byte[] dst) throws CardException, SignatureCardException {
+ private void mseSetDST(byte[] dst) throws CardException, SignatureCardException {
CardChannel channel = getCardChannel();
ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x22, 0x41,
0xB6, dst));
@@ -303,7 +424,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
}
}
- void psoHash(byte[] hash) throws CardException, SignatureCardException {
+ private void psoHash(byte[] hash) throws CardException, SignatureCardException {
byte[] data = new byte[hash.length + 2];
data[0] = (byte) 0x90; // tag
data[1] = (byte) (hash.length); // length
@@ -318,7 +439,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
}
}
- byte[] psoComputDigitalSiganture() throws CardException,
+ private byte[] psoComputDigitalSiganture() throws CardException,
SignatureCardException {
CardChannel channel = getCardChannel();
ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x2A, 0x9E,
@@ -353,7 +474,8 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
* @throws SignatureCardException
* if VERIFY PIN fails
*/
- private int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException {
+ @Override
+ protected int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException {
CardChannel channel = getCardChannel();
@@ -385,6 +507,8 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
} else if (resp.getSW1() == 0x63 && resp.getSW2() >> 4 == 0xc) {
// return number of possible retries
return resp.getSW2() & 0x0f;
+ } else if (resp.getSW() == 0x6983) {
+ throw new LockedException();
} else if (resp.getSW() == 0x6984) {
// PIN LCS = "Initialized" (-> not activated)
throw new NotActivatedException("PIN not set.");
@@ -397,26 +521,8 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard
}
- /* (non-Javadoc)
- * @see at.gv.egiz.smcc.AbstractSignatureCard#verifyPIN(at.gv.egiz.smcc.PINProvider, at.gv.egiz.smcc.PINSpec, byte, int)
- */
- protected void verifyPIN(PINProvider pinProvider, PINSpec spec, byte kid)
- throws CardException, SignatureCardException, InterruptedException {
-
- int retries = verifyPIN(null, kid);
- do {
- String pin = pinProvider.providePIN(spec, retries);
- if (pin == null) {
- // user canceled operation
- throw new CancelledException("User canceld operation.");
- }
- retries = verifyPIN(pin, kid);
- } while (retries > 0);
-
- }
-
public String toString() {
- return "eCard";
+ return "e-card";
}
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SecurityStatusNotSatisfiedException.java b/smcc/src/main/java/at/gv/egiz/smcc/SecurityStatusNotSatisfiedException.java
new file mode 100644
index 00000000..bf0af76c
--- /dev/null
+++ b/smcc/src/main/java/at/gv/egiz/smcc/SecurityStatusNotSatisfiedException.java
@@ -0,0 +1,38 @@
+/*
+* 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;
+
+public class SecurityStatusNotSatisfiedException extends SignatureCardException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SecurityStatusNotSatisfiedException() {
+ }
+
+ public SecurityStatusNotSatisfiedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SecurityStatusNotSatisfiedException(String message) {
+ super(message);
+ }
+
+ public SecurityStatusNotSatisfiedException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/VerificationFailedException.java b/smcc/src/main/java/at/gv/egiz/smcc/VerificationFailedException.java
new file mode 100644
index 00000000..fa066ff9
--- /dev/null
+++ b/smcc/src/main/java/at/gv/egiz/smcc/VerificationFailedException.java
@@ -0,0 +1,65 @@
+/*
+* 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;
+
+public class VerificationFailedException extends SignatureCardException {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final int UNKNOWN = -1;
+
+ private int retries = UNKNOWN;
+
+ public VerificationFailedException() {
+ }
+
+ public VerificationFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public VerificationFailedException(String message) {
+ super(message);
+ }
+
+ public VerificationFailedException(Throwable cause) {
+ super(cause);
+ }
+
+ public VerificationFailedException(int retries) {
+ this.retries = retries;
+ }
+
+ public VerificationFailedException(int retries, String message, Throwable cause) {
+ super(message, cause);
+ this.retries = retries;
+ }
+
+ public VerificationFailedException(int retries, String message) {
+ super(message);
+ this.retries = retries;
+ }
+
+ public VerificationFailedException(int retries, Throwable cause) {
+ super(cause);
+ this.retries = retries;
+ }
+
+ public int getRetries() {
+ return retries;
+ }
+
+}
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
index 13210540..090e1181 100644
--- a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
+++ b/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
@@ -19,6 +19,8 @@ package at.gv.egiz.smcc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintWriter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
@@ -27,6 +29,8 @@ import javax.smartcardio.CardException;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
+import sun.misc.HexDumpEncoder;
+
import at.gv.egiz.smcc.SignatureCard.KeyboxName;
import at.gv.egiz.smcc.util.SMCCHelper;
@@ -34,10 +38,9 @@ public class STARCOSCardTest {
/**
* @param args
- * @throws CardException
- * @throws NoSuchAlgorithmException
+ * @throws Exception
*/
- public static void main(String[] args) throws CardException, NoSuchAlgorithmException, InterruptedException {
+ public static void main(String[] args) throws Exception {
SMCCHelper helper = new SMCCHelper();
while (helper.getResultCode() != SMCCHelper.CARD_FOUND) {
@@ -55,18 +58,41 @@ public class STARCOSCardTest {
System.out.println("Found '" + signatureCard + "'.");
try {
-// signatureCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR);
-// signatureCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR);
-// signatureCard.getInfobox("IdentityLink", new CommandLinePINProvider(), null);
+// printJavaByteArray(
+// signatureCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR), System.out);
+// printJavaByteArray(
+// signatureCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR), System.out);
+// System.out. println(new String(signatureCard.getInfobox("IdentityLink", new CommandLinePINProvider(), null)));
+// byte[] infobox = signatureCard.getInfobox("Status", new CommandLinePINProvider(), null);
+// printJavaByteArray(infobox, System.out);
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
byte[] digest = messageDigest.digest("test".getBytes());
- signatureCard.createSignature(digest, KeyboxName.CERITIFIED_KEYPAIR, new CommandLinePINProvider());
+ byte[] signature = signatureCard.createSignature(digest, KeyboxName.SECURE_SIGNATURE_KEYPAIR, new CommandLinePINProvider());
+ printJavaByteArray(signature, System.out);
} catch (SignatureCardException e) {
e.printStackTrace();
}
}
+ public static void printJavaByteArray(byte[] bytes, OutputStream os) {
+
+ PrintWriter w = new PrintWriter(os);
+
+ w.write("new byte[] {");
+ for (int i = 0; i < bytes.length;) {
+ if (i % 8 == 0) {
+ w.write("\n ");
+ }
+ w.write("(byte) 0x" + Integer.toHexString(0x0F & (bytes[i] >> 4)) + Integer.toHexString(0x0F & bytes[i]));
+ if (++i < bytes.length) {
+ w.write(", ");
+ }
+ }
+ w.write("\n};");
+ w.flush();
+ }
+
private static class CommandLinePINProvider implements PINProvider {
@Override
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
index 04f179e7..5a54e97f 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
@@ -103,6 +103,9 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements
stalResp.setInfoboxValue(resp);
return stalResp;
}
+ } catch (IllegalArgumentException e) {
+ log.info("Infobox " + infoBox.getInfoboxIdentifier() + " not supported.");
+ return new ErrorResponse(4002);
} catch (NotActivatedException e) {
log.info("Citizen card not activated.", e);
gui.showErrorDialog(BKUGUIFacade.ERR_CARD_NOTACTIVATED, null, this, null);
--
cgit v1.2.3
From 77a19e106e4128c21dd2d1270fdc8d930e415247 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Thu, 18 Dec 2008 08:58:39 +0000
Subject: Fixed BUG #366, changed applet name in BKUOnline to have no version
number
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@253 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../gv/egiz/bku/online/applet/AppletBKUWorker.java | 59 ++++--
.../online/applet/InternalSSLSocketFactory.java | 235 +++++++++++----------
.../conf/certs/CACerts/A-CERT GLOBALTRUST.cer | Bin 0 -> 1561 bytes
.../local/conf/certs/certStore/A-CERT ADVANCED.cer | Bin 0 -> 1751 bytes
.../conf/certs/certStore/A-CERT GLOBALTRUST.cer | Bin 0 -> 1561 bytes
.../conf/certs/certStore/A-Trust-Qual-01a.cer | Bin 0 -> 1111 bytes
.../conf/certs/certStore/A-Trust-Qual-02a.cer | Bin 0 -> 975 bytes
.../conf/certs/certStore/A-Trust-Qual-03a.cer | Bin 0 -> 975 bytes
.../conf/certs/certStore/A-Trust-nQual-01a.cer | Bin 0 -> 865 bytes
.../conf/certs/certStore/A-Trust-nQual-03.cer | Bin 0 -> 979 bytes
BKUOnline/pom.xml | 1 +
.../egiz/bku/online/webapp/BKURequestHandler.java | 60 ++++--
.../webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar | Bin 182140 -> 0 bytes
BKUOnline/src/main/webapp/appletPage.jsp | 2 +-
.../accesscontroller/AuthenticationClassifier.java | 3 +-
.../test/java/at/gv/egiz/smcc/SMCCApplication.java | 49 -----
.../test/java/at/gv/egiz/smcc/STARCOSCardTest.java | 121 -----------
smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java | 66 ------
18 files changed, 197 insertions(+), 399 deletions(-)
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/CACerts/A-CERT GLOBALTRUST.cer
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT ADVANCED.cer
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT GLOBALTRUST.cer
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-01a.cer
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-02a.cer
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-03a.cer
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-01a.cer
create mode 100644 BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-03.cer
delete mode 100644 BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar
delete mode 100644 smcc/src/test/java/at/gv/egiz/smcc/SMCCApplication.java
delete mode 100644 smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
delete mode 100644 smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java
(limited to 'bkucommon/src/main')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
index 03e4b7c9..9fc21df8 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
@@ -38,7 +38,7 @@ import java.util.List;
import javax.xml.namespace.QName;
/**
- *
+ *
* @author Clemens Orthacker
*/
public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
@@ -48,7 +48,8 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
protected String sessionId;
protected STALPortType stalPort;
- public AppletBKUWorker(BKUGUIFacade gui, AppletContext ctx, AppletParameterProvider paramProvider) {
+ public AppletBKUWorker(BKUGUIFacade gui, AppletContext ctx,
+ AppletParameterProvider paramProvider) {
super(gui);
if (ctx == null) {
throw new NullPointerException("Applet context not provided");
@@ -76,7 +77,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
actionCommandList.clear();
actionCommandList.add("ok");
gui.showErrorDialog(BKUGUIFacade.ERR_SERVICE_UNREACHABLE,
- new Object[]{e.getMessage()});
+ new Object[] { e.getMessage() });
try {
waitForAction();
} catch (InterruptedException e1) {
@@ -92,8 +93,10 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
GetNextRequestResponseType nextRequestResp = stalPort.connect(sessionId);
do {
- List requests = nextRequestResp.getInfoboxReadRequestOrSignRequestOrQuitRequest();
- List stalRequests = STALTranslator.translateRequests(requests);
+ List requests = nextRequestResp
+ .getInfoboxReadRequestOrSignRequestOrQuitRequest();
+ List stalRequests = STALTranslator
+ .translateRequests(requests);
if (log.isInfoEnabled()) {
StringBuilder sb = new StringBuilder("Received ");
@@ -142,64 +145,76 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
}
if (!finished) {
- log.info("Not finished yet (BKUWorker: " + this + "), sending responses");
+ log.info("Not finished yet (BKUWorker: " + this
+ + "), sending responses");
GetNextRequestType nextRequest = of.createGetNextRequestType();
nextRequest.setSessionId(sessionId);
- nextRequest.getInfoboxReadResponseOrSignResponseOrErrorResponse().addAll(responses);
+ nextRequest.getInfoboxReadResponseOrSignResponseOrErrorResponse()
+ .addAll(responses);
nextRequestResp = stalPort.getNextRequest(nextRequest);
}
} while (!finished);
log.info("Done " + Thread.currentThread().getName());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
- gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[]{ex.getMessage()});
+ gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[] { ex
+ .getMessage() });
try {
waitForAction();
} catch (InterruptedException e) {
log.error(e);
}
- }
- if (signatureCard != null) {
- signatureCard.disconnect(false);
+ if (signatureCard != null) {
+ signatureCard.disconnect(false);
+ }
}
sendRedirect();
}
protected void sendRedirect() {
try {
- URL redirectURL = params.getURLParameter(BKUApplet.REDIRECT_URL, sessionId);
- String redirectTarget = params.getAppletParameter(BKUApplet.REDIRECT_TARGET);
+ URL redirectURL = params.getURLParameter(BKUApplet.REDIRECT_URL,
+ sessionId);
+ String redirectTarget = params
+ .getAppletParameter(BKUApplet.REDIRECT_TARGET);
if (redirectTarget == null) {
log.info("Done. Redirecting to " + redirectURL + " ...");
ctx.showDocument(redirectURL);
} else {
- log.info("Done. Redirecting to " + redirectURL + " (target=" + redirectTarget + ") ...");
+ log.info("Done. Redirecting to " + redirectURL + " (target="
+ + redirectTarget + ") ...");
ctx.showDocument(redirectURL, redirectTarget);
}
} catch (MalformedURLException ex) {
log.warn("Failed to redirect: " + ex.getMessage(), ex);
- // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ // gui.showErrorDialog(errorMsg, okListener, actionCommand)
}
}
private STALPortType getSTALPort() throws MalformedURLException {
URL wsdlURL = params.getURLParameter(BKUApplet.WSDL_URL);
log.debug("STAL WSDL at " + wsdlURL);
- QName endpointName = new QName(BKUApplet.STAL_WSDL_NS, BKUApplet.STAL_SERVICE);
+ QName endpointName = new QName(BKUApplet.STAL_WSDL_NS,
+ BKUApplet.STAL_SERVICE);
STALService stal = new STALService(wsdlURL, endpointName);
return stal.getSTALPort();
}
private void registerSignRequestHandler() throws MalformedURLException {
- String hashDataDisplayStyle = params.getAppletParameter(BKUApplet.HASHDATA_DISPLAY);
+ String hashDataDisplayStyle = params
+ .getAppletParameter(BKUApplet.HASHDATA_DISPLAY);
if (BKUApplet.HASHDATA_DISPLAY_BROWSER.equals(hashDataDisplayStyle)) {
- URL hashDataURL = params.getURLParameter(BKUApplet.HASHDATA_URL, sessionId);
+ URL hashDataURL = params.getURLParameter(BKUApplet.HASHDATA_URL,
+ sessionId);
log.debug("register SignRequestHandler for HashDataURL " + hashDataURL);
- addRequestHandler(SignRequest.class, new BrowserHashDataDisplay(ctx, hashDataURL));
+ addRequestHandler(SignRequest.class, new BrowserHashDataDisplay(ctx,
+ hashDataURL));
} else {
- //BKUApplet.HASHDATA_DISPLAY_FRAME
- log.debug("register SignRequestHandler for STAL port " + BKUApplet.WSDL_URL);
- AppletHashDataDisplay handler = new AppletHashDataDisplay(stalPort, sessionId);
+ // BKUApplet.HASHDATA_DISPLAY_FRAME
+ log.debug("register SignRequestHandler for STAL port "
+ + BKUApplet.WSDL_URL);
+ AppletHashDataDisplay handler = new AppletHashDataDisplay(stalPort,
+ sessionId);
addRequestHandler(SignRequest.class, handler);
}
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
index c3417d63..a02e56eb 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
@@ -36,121 +36,122 @@ import org.apache.commons.logging.LogFactory;
public class InternalSSLSocketFactory extends SSLSocketFactory {
- private final static String GOV_DOMAIN = ".gv.at";
-
- private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory();
-
- private final static Log log = LogFactory
- .getLog(InternalSSLSocketFactory.class);
-
- private SSLSocket sslSocket;
-
- private SSLSocketFactory proxy;
-
- private InternalSSLSocketFactory() {
- proxy = HttpsURLConnection.getDefaultSSLSocketFactory();
- }
-
- public static InternalSSLSocketFactory getInstance() {
- return instance;
- }
-
- @Override
- public Socket createSocket() throws IOException {
- sslSocket = (SSLSocket) proxy.createSocket();
- return sslSocket;
- }
-
- @Override
- public Socket createSocket(String arg0, int arg1) throws IOException,
- UnknownHostException {
- sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1);
-
- return sslSocket;
- }
-
- @Override
- public Socket createSocket(InetAddress arg0, int arg1) throws IOException {
- sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1);
- return sslSocket;
- }
-
- @Override
- public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3)
- throws IOException, UnknownHostException {
- sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
- return sslSocket;
- }
-
- @Override
- public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2,
- int arg3) throws IOException {
- sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
- return sslSocket;
- }
-
- @Override
- public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3)
- throws IOException {
- sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
- return sslSocket;
- }
-
- @Override
- public String[] getDefaultCipherSuites() {
- return proxy.getDefaultCipherSuites();
- }
-
- @Override
- public String[] getSupportedCipherSuites() {
- return proxy.getSupportedCipherSuites();
- }
-
- public boolean isEgovAgency() {
- log.info("Checking if server is egov agency");
- if (sslSocket != null) {
- try {
- X509Certificate cert = (X509Certificate) sslSocket.getSession()
- .getPeerCertificates()[0];
- log.info("Server cert: " + cert);
- return isGovAgency(cert);
- } catch (SSLPeerUnverifiedException e) {
- log.error(e);
- return false;
- }
- }
- log.info("Not a SSL connection");
- return false;
- }
-
- public static boolean isGovAgency(X509Certificate cert) {
- String[] rdns = (cert.getSubjectX500Principal().getName()).split(",");
- for (String rdn : rdns) {
- if (rdn.startsWith("CN=")) {
- String dns = rdn.split("=")[1];
- if (dns.endsWith(GOV_DOMAIN)) {
- return true;
- }
- }
- }
- try {
- Collection> sanList = cert.getSubjectAlternativeNames();
- if (sanList != null) {
- for (List> san : sanList) {
- if ((Integer) san.get(0) == 2) {
- String dns = (String) san.get(1);
- if (dns.endsWith(GOV_DOMAIN)) {
- return true;
- }
- }
- }
- }
- } catch (CertificateParsingException e) {
- log.error(e);
- }
- if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
- return true;
- }
- return false;
- }
+ private final static String GOV_DOMAIN = ".gv.at";
+
+ private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory();
+
+ private final static Log log = LogFactory
+ .getLog(InternalSSLSocketFactory.class);
+
+ private SSLSocket sslSocket;
+
+ private SSLSocketFactory proxy;
+
+ private InternalSSLSocketFactory() {
+ proxy = HttpsURLConnection.getDefaultSSLSocketFactory();
+ }
+
+ public static InternalSSLSocketFactory getInstance() {
+ return instance;
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket();
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(String arg0, int arg1) throws IOException,
+ UnknownHostException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1);
+
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress arg0, int arg1) throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1);
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3)
+ throws IOException, UnknownHostException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2,
+ int arg3) throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3)
+ throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
+ return sslSocket;
+ }
+
+ @Override
+ public String[] getDefaultCipherSuites() {
+ return proxy.getDefaultCipherSuites();
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ return proxy.getSupportedCipherSuites();
+ }
+
+ public boolean isEgovAgency() {
+ log.info("Checking if server is egov agency");
+ if (sslSocket != null) {
+ try {
+ X509Certificate cert = (X509Certificate) sslSocket.getSession()
+ .getPeerCertificates()[0];
+ log.info("Server cert: " + cert);
+ return isGovAgency(cert);
+ } catch (SSLPeerUnverifiedException e) {
+ log.error(e);
+ return false;
+ }
+ }
+ log.info("Not a SSL connection");
+ return false;
+ }
+
+ public static boolean isGovAgency(X509Certificate cert) {
+ String[] rdns = (cert.getSubjectX500Principal().getName()).split(",");
+ for (String rdn : rdns) {
+ if (rdn.startsWith("CN=")) {
+ String dns = rdn.split("=")[1];
+ if (dns.endsWith(GOV_DOMAIN)) {
+ return true;
+ }
+ }
+ }
+ try {
+ Collection> sanList = cert.getSubjectAlternativeNames();
+ if (sanList != null) {
+ for (List> san : sanList) {
+ if ((Integer) san.get(0) == 2) {
+ String dns = (String) san.get(1);
+ if (dns.endsWith(GOV_DOMAIN)) {
+ return true;
+ }
+ }
+ }
+ }
+ } catch (CertificateParsingException e) {
+ log.error(e);
+ }
+ if ((cert.getExtensionValue("1.2.40.0.10.1.1.1") != null)
+ || (cert.getExtensionValue("1.2.40.0.10.1.1.2") != null)) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/CACerts/A-CERT GLOBALTRUST.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/CACerts/A-CERT GLOBALTRUST.cer
new file mode 100644
index 00000000..9a25e57d
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/CACerts/A-CERT GLOBALTRUST.cer differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT ADVANCED.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT ADVANCED.cer
new file mode 100644
index 00000000..66ff251b
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT ADVANCED.cer differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT GLOBALTRUST.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT GLOBALTRUST.cer
new file mode 100644
index 00000000..9a25e57d
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT GLOBALTRUST.cer differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-01a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-01a.cer
new file mode 100644
index 00000000..f9fef65f
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-01a.cer differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-02a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-02a.cer
new file mode 100644
index 00000000..36a442b8
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-02a.cer differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-03a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-03a.cer
new file mode 100644
index 00000000..ab9e0cd7
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-03a.cer differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-01a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-01a.cer
new file mode 100644
index 00000000..efa28178
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-01a.cer differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-03.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-03.cer
new file mode 100644
index 00000000..33e77636
Binary files /dev/null and b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-03.cer differ
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml
index 1ea2c1a1..5e6ac8ad 100644
--- a/BKUOnline/pom.xml
+++ b/BKUOnline/pom.xml
@@ -121,6 +121,7 @@
-->
at.gv.egizBKUApplet
+ truetrue
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
index 3aa6bc19..12166a5a 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -32,12 +33,12 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import at.gv.egiz.bku.binding.BindingProcessor;
import at.gv.egiz.bku.binding.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.HttpUtil;
import at.gv.egiz.bku.binding.IdFactory;
import at.gv.egiz.bku.utils.StreamUtil;
import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
-import javax.servlet.RequestDispatcher;
/**
* Handles SL requests and instantiates BindingProcessors
@@ -52,7 +53,8 @@ public class BKURequestHandler extends SpringBKUServlet {
protected Log log = LogFactory.getLog(BKURequestHandler.class);
- private static String getStringFromStream(InputStream is, String encoding) throws IOException {
+ private static String getStringFromStream(InputStream is, String encoding)
+ throws IOException {
if (is == null) {
return null;
}
@@ -63,8 +65,7 @@ public class BKURequestHandler extends SpringBKUServlet {
StreamUtil.copyStream(is, os);
return new String(os.toByteArray(), encoding);
}
-
-
+
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, java.io.IOException {
log.debug("Got new request");
@@ -75,21 +76,28 @@ public class BKURequestHandler extends SpringBKUServlet {
HttpSession session = req.getSession(false);
if (session != null) {
log.warn("Already a session with id: " + session.getId()
- + " active, continuing");
- RequestDispatcher dispatcher = getServletContext().getNamedDispatcher(BKU_APPLET_JSP);
- log.debug("forward to applet");
- dispatcher.forward(req, resp);
- return;
+ + " active, trying to get Bindingprocessor");
+ BindingProcessor bp = getBindingProcessorManager().getBindingProcessor(
+ IdFactory.getInstance().createId(session.getId()));
+ if (bp != null) {
+ log.debug("Found binding processor, using this one");
+ RequestDispatcher dispatcher = getServletContext().getNamedDispatcher(
+ BKU_APPLET_JSP);
+ log.debug("forward to applet");
+ dispatcher.forward(req, resp);
+ return;
+ }
+ log.debug("Did not find a binding processor, creating new ...");
}
session = req.getSession(true);
if (log.isDebugEnabled()) {
log.debug("Using session id: " + session.getId());
}
-
- HTTPBindingProcessor bindingProcessor;
+ HTTPBindingProcessor bindingProcessor;
bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
- .createBindingProcessor(req.getRequestURL().toString(), session.getId(), locale);
+ .createBindingProcessor(req.getRequestURL().toString(),
+ session.getId(), locale);
Map headerMap = new HashMap();
for (Enumeration headerName = req.getHeaderNames(); headerName
@@ -109,14 +117,20 @@ public class BKURequestHandler extends SpringBKUServlet {
bindingProcessor.consumeRequestStream(req.getInputStream());
req.getInputStream().close();
getBindingProcessorManager().process(bindingProcessor);
-
+
log.trace("Trying to find applet parameters in request");
- String width = getStringFromStream(bindingProcessor.getFormData("appletWidth"), charset);
- String height = getStringFromStream(bindingProcessor.getFormData("appletHeight"), charset);
- String background = getStringFromStream(bindingProcessor.getFormData("appletBackground"), charset);
- String guiStyle = getStringFromStream(bindingProcessor.getFormData("appletGuiStyle"), charset);
- String hashDataDisplay = getStringFromStream(bindingProcessor.getFormData("appletHashDataDisplay"), charset);
- String localeFormParam = getStringFromStream(bindingProcessor.getFormData("locale"), charset);
+ String width = getStringFromStream(bindingProcessor
+ .getFormData("appletWidth"), charset);
+ String height = getStringFromStream(bindingProcessor
+ .getFormData("appletHeight"), charset);
+ String background = getStringFromStream(bindingProcessor
+ .getFormData("appletBackground"), charset);
+ String guiStyle = getStringFromStream(bindingProcessor
+ .getFormData("appletGuiStyle"), charset);
+ String hashDataDisplay = getStringFromStream(bindingProcessor
+ .getFormData("appletHashDataDisplay"), charset);
+ String localeFormParam = getStringFromStream(bindingProcessor
+ .getFormData("locale"), charset);
if (width != null) {
try {
log.trace("Found applet width parameter: " + width);
@@ -148,7 +162,8 @@ public class BKURequestHandler extends SpringBKUServlet {
session.setAttribute("appletHashDataDisplay", hashDataDisplay);
}
if (localeFormParam != null) {
- log.debug("overrule accept-language locale " + locale + " with form param " + localeFormParam);
+ log.debug("overrule accept-language locale " + locale
+ + " with form param " + localeFormParam);
locale = new Locale(localeFormParam);
}
if (locale != null) {
@@ -156,8 +171,9 @@ public class BKURequestHandler extends SpringBKUServlet {
session.setAttribute("locale", locale.toString());
}
- //TODO error if no dispatcher found
- RequestDispatcher dispatcher = getServletContext().getNamedDispatcher(BKU_APPLET_JSP);
+ // TODO error if no dispatcher found
+ RequestDispatcher dispatcher = getServletContext().getNamedDispatcher(
+ BKU_APPLET_JSP);
log.debug("forward to applet");
dispatcher.forward(req, resp);
}
diff --git a/BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar b/BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar
deleted file mode 100644
index 74f00509..00000000
Binary files a/BKUOnline/src/main/webapp/applet/BKUApplet-1.0.2-SNAPSHOT.jar and /dev/null differ
diff --git a/BKUOnline/src/main/webapp/appletPage.jsp b/BKUOnline/src/main/webapp/appletPage.jsp
index ee5f429c..b73ed2f4 100644
--- a/BKUOnline/src/main/webapp/appletPage.jsp
+++ b/BKUOnline/src/main/webapp/appletPage.jsp
@@ -47,7 +47,7 @@
var attributes = {
codebase :'applet',
code :'at.gv.egiz.bku.online.applet.BKUApplet.class',
- archive :'BKUApplet-1.0.2-SNAPSHOT.jar, commons-logging-1.1.1.jar, iaik_jce_me4se-3.04.jar',
+ archive :'BKUApplet.jar, commons-logging-1.1.1.jar, iaik_jce_me4se-3.04.jar',
width : <%=width%>,
height :<%=height%>
};
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
index ed4b9bda..61d3d7a5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
@@ -65,7 +65,8 @@ public class AuthenticationClassifier {
} catch (CertificateParsingException e) {
log.error(e);
}
- if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
+ if ((cert.getExtensionValue("1.2.40.0.10.1.1.1") != null)
+ || (cert.getExtensionValue("1.2.40.0.10.1.1.2") != null)) {
return true;
}
return false;
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/SMCCApplication.java b/smcc/src/test/java/at/gv/egiz/smcc/SMCCApplication.java
deleted file mode 100644
index 4835865f..00000000
--- a/smcc/src/test/java/at/gv/egiz/smcc/SMCCApplication.java
+++ /dev/null
@@ -1,49 +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;
-
-import java.util.Locale;
-
-import org.junit.Ignore;
-
-import at.gv.egiz.smcc.util.SMCCHelper;
-
-@Ignore
-public class SMCCApplication {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- SignatureCard sc = null;
- SMCCHelper smccHelper = new SMCCHelper();
- while (smccHelper.getResultCode() != SMCCHelper.CARD_FOUND) {
- System.out.println("Did not get a signature card ... "+smccHelper.getResultCode());
- smccHelper.update();
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- sc = smccHelper.getSignatureCard(Locale.getDefault());
- System.out.println("Found supported siganture card: "+sc);
- }
-
-}
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
deleted file mode 100644
index 7f421474..00000000
--- a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
+++ /dev/null
@@ -1,121 +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;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Locale;
-
-import javax.smartcardio.CardException;
-import javax.smartcardio.CommandAPDU;
-import javax.smartcardio.ResponseAPDU;
-
-import org.junit.Ignore;
-
-import sun.misc.HexDumpEncoder;
-
-import at.gv.egiz.smcc.SignatureCard.KeyboxName;
-import at.gv.egiz.smcc.util.SMCCHelper;
-
-@Ignore
-public class STARCOSCardTest {
-
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
-
- SMCCHelper helper = new SMCCHelper();
- while (helper.getResultCode() != SMCCHelper.CARD_FOUND) {
- System.out.println("Did not get a signature card ... " + helper.getResultCode());
- helper.update();
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- SignatureCard signatureCard = helper.getSignatureCard(Locale.getDefault());
-
- System.out.println("Found '" + signatureCard + "'.");
-
- try {
-// printJavaByteArray(
-// signatureCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR), System.out);
-// printJavaByteArray(
-// signatureCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR), System.out);
-// System.out. println(new String(signatureCard.getInfobox("IdentityLink", new CommandLinePINProvider(), null)));
-// byte[] infobox = signatureCard.getInfobox("Status", new CommandLinePINProvider(), null);
-// printJavaByteArray(infobox, System.out);
- MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
- byte[] digest = messageDigest.digest("test".getBytes());
- byte[] signature = signatureCard.createSignature(digest, KeyboxName.SECURE_SIGNATURE_KEYPAIR, new CommandLinePINProvider());
- printJavaByteArray(signature, System.out);
- } catch (SignatureCardException e) {
- e.printStackTrace();
- }
-
- }
-
- public static void printJavaByteArray(byte[] bytes, OutputStream os) {
-
- PrintWriter w = new PrintWriter(os);
-
- w.write("new byte[] {");
- for (int i = 0; i < bytes.length;) {
- if (i % 8 == 0) {
- w.write("\n ");
- }
- w.write("(byte) 0x" + Integer.toHexString(0x0F & (bytes[i] >> 4)) + Integer.toHexString(0x0F & bytes[i]));
- if (++i < bytes.length) {
- w.write(", ");
- }
- }
- w.write("\n};");
- w.flush();
- }
-
- private static class CommandLinePINProvider implements PINProvider {
-
- @Override
- public String providePIN(PINSpec spec, int retries) {
-
- InputStreamReader inputStreamReader = new InputStreamReader(System.in);
- BufferedReader in = new BufferedReader(inputStreamReader);
-
- System.out.print("Enter " + spec.getLocalizedName() + " ["
- + spec.getMinLength() + "-" + spec.getMaxLength() + "] (" + retries
- + " retries):");
-
- try {
- return in.readLine();
- } catch (IOException e) {
- return null;
- }
-
- }
-
- }
-
-}
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java
deleted file mode 100644
index 115edc16..00000000
--- a/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java
+++ /dev/null
@@ -1,66 +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;
-
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import org.junit.Ignore;
-
-import at.gv.egiz.smcc.SignatureCard.KeyboxName;
-
-@Ignore
-public class SWCardTest implements PINProvider {
-
- SWCard swCard = new SWCard();
-
- public static void main(String[] args) throws Exception {
-
- SWCardTest swCardTest = new SWCardTest();
- swCardTest.test();
-
- }
-
- public void test() throws SignatureCardException, NoSuchAlgorithmException, InterruptedException {
-
- swCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR);
- swCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR);
-
- BigInteger t = BigInteger.valueOf(System.currentTimeMillis());
-
- MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
- byte[] hash = messageDigest.digest(t.toByteArray());
-
- byte[] signature;
- signature = swCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR, this);
- System.out.println(SignatureCardFactory.toString(signature));
-
- signature = swCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR, this);
- System.out.println(SignatureCardFactory.toString(signature));
-
- byte[] infobox = swCard.getInfobox("IdentityLink", this, null);
- System.out.println(SignatureCardFactory.toString(infobox));
-
- }
-
- @Override
- public String providePIN(PINSpec spec, int retries) {
- return "buerger";
- }
-
-}
--
cgit v1.2.3
From 3d0112fcd64ea80ad698861ce5d16e6de93c0bd5 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Wed, 21 Jan 2009 11:22:03 +0000
Subject: Fixed Bug #371
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@278 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../java/at/gv/egiz/bku/conf/Configurator.java | 8 +
.../bku/slcommands/impl/xsect/SignatureTest.java | 14 ++
.../HTTPURLProtocolHandlerImpl.java | 182 ++++++++++++---------
.../bku/utils/urldereferencer/URLDereferencer.java | 20 ++-
.../utils/urldereferencer/URLProtocolHandler.java | 9 +-
5 files changed, 156 insertions(+), 77 deletions(-)
(limited to 'bkucommon/src/main')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
index 733b47dc..7f180ad0 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
@@ -43,6 +43,7 @@ import at.gv.egiz.bku.binding.DataUrlConnection;
import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
public abstract class Configurator {
private Log log = LogFactory.getLog(Configurator.class);
@@ -270,6 +271,7 @@ public abstract class Configurator {
sslCtx.init(km, new TrustManager[] { pkixTM }, null);
}
DataUrl.setSSLSocketFactory(sslCtx.getSocketFactory());
+ URLDereferencer.getInstance().setSSLSocketFactory(sslCtx.getSocketFactory());
} catch (Exception e) {
log.error("Cannot configure SSL", e);
}
@@ -283,6 +285,12 @@ public abstract class Configurator {
return true;
}
});
+ URLDereferencer.getInstance().setHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
}
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java
index 9e34d9ae..78172dcb 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java
@@ -33,6 +33,8 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.List;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSocketFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
@@ -191,6 +193,18 @@ public class SignatureTest {
}
+ }
+
+ @Override
+ public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setSSLSocketFactory(SSLSocketFactory socketFactory) {
+ // TODO Auto-generated method stub
+
}
});
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 8d01fad1..99f804b7 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
@@ -1,78 +1,112 @@
/*
-* 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.bku.utils.urldereferencer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.security.InvalidParameterException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class HTTPURLProtocolHandlerImpl implements URLProtocolHandler {
-
- private static Log log = LogFactory.getLog(HTTPURLProtocolHandlerImpl.class);
-
- public final static String HTTP = "http";
- public final static String HTTPS = "https";
- public final static String FORMDATA = "formdata";
- public final static String[] PROTOCOLS = { HTTP, HTTPS, FORMDATA };
-
- public StreamData dereference(String aUrl, URLDereferencerContext aContext)
- throws IOException {
- String urlString = aUrl.toLowerCase().trim();
- if (urlString.startsWith(FORMDATA)) {
- log.debug("Requested to dereference a formdata url");
- return dereferenceFormData(aUrl, aContext);
- }
-
- URL url = new URL(aUrl);
- if ((!HTTP.equalsIgnoreCase(url.getProtocol()) && (!HTTPS
- .equalsIgnoreCase(url.getProtocol())))) {
- throw new InvalidParameterException("Url " + aUrl + " not supported");
- }
- return dereferenceHTTP(url);
- }
-
+ * 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.bku.utils.urldereferencer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.security.InvalidParameterException;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class HTTPURLProtocolHandlerImpl implements URLProtocolHandler {
+
+ private static Log log = LogFactory.getLog(HTTPURLProtocolHandlerImpl.class);
+
+ public final static String HTTP = "http";
+ public final static String HTTPS = "https";
+ public final static String FORMDATA = "formdata";
+ public final static String[] PROTOCOLS = { HTTP, HTTPS, FORMDATA };
+
+ private HostnameVerifier hostnameVerifier;
+ private SSLSocketFactory sslSocketFactory;
+
+ public StreamData dereference(String aUrl, URLDereferencerContext aContext)
+ throws IOException {
+ String urlString = aUrl.toLowerCase().trim();
+ if (urlString.startsWith(FORMDATA)) {
+ log.debug("Requested to dereference a formdata url");
+ return dereferenceFormData(aUrl, aContext);
+ }
+
+ URL url = new URL(aUrl);
+ if ((!HTTP.equalsIgnoreCase(url.getProtocol()) && (!HTTPS
+ .equalsIgnoreCase(url.getProtocol())))) {
+ throw new InvalidParameterException("Url " + aUrl + " not supported");
+ }
+ return dereferenceHTTP(url);
+ }
+
protected StreamData dereferenceHTTP(URL url) throws IOException {
- log.debug("Dereferencing url: "+url);
+ log.debug("Dereferencing url: " + url);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
- log.trace("Successfully opened connection");
- return new StreamData(url.toString(), httpConn.getContentType(), httpConn
- .getInputStream());
- }
-
- protected StreamData dereferenceFormData(String aUrl,
- URLDereferencerContext aContext) throws IOException {
- log.debug("Dereferencing formdata url: " + aUrl);
- String[] parts = aUrl.split(":", 2);
- FormDataURLSupplier supplier = (FormDataURLSupplier) aContext
- .getProperty(FormDataURLSupplier.PROPERTY_KEY_NAME);
- if (supplier == null) {
- throw new NullPointerException(
- "No FormdataUrlSupplier found in provided context");
- }
- String contentType = supplier.getFormDataContentType(parts[1]);
- InputStream is = supplier.getFormData(parts[1]);
- if (is != null) {
- return new StreamData(aUrl, contentType, is);
- }
- return null;
- }
+ if (httpConn instanceof HttpsURLConnection) {
+ log.trace("Detected ssl connection");
+ HttpsURLConnection https = (HttpsURLConnection) httpConn;
+ if (sslSocketFactory != null) {
+ log.debug("Setting custom ssl socket factory for ssl connection");
+ https.setSSLSocketFactory(sslSocketFactory);
+ } else {
+ log.trace("No custom socket factory set");
+ }
+ if (hostnameVerifier != null) {
+ log.debug("Setting custom hostname verifier");
+ https.setHostnameVerifier(hostnameVerifier);
+ }
+ } else {
+ log.trace("No secure connection with: "+url+ " class="+httpConn.getClass());
+ }
+ log.trace("Successfully opened connection");
+ return new StreamData(url.toString(), httpConn.getContentType(), httpConn
+ .getInputStream());
+ }
+
+ protected StreamData dereferenceFormData(String aUrl,
+ URLDereferencerContext aContext) throws IOException {
+ log.debug("Dereferencing formdata url: " + aUrl);
+ String[] parts = aUrl.split(":", 2);
+ FormDataURLSupplier supplier = (FormDataURLSupplier) aContext
+ .getProperty(FormDataURLSupplier.PROPERTY_KEY_NAME);
+ if (supplier == null) {
+ throw new NullPointerException(
+ "No FormdataUrlSupplier found in provided context");
+ }
+ String contentType = supplier.getFormDataContentType(parts[1]);
+ InputStream is = supplier.getFormData(parts[1]);
+ if (is != null) {
+ return new StreamData(aUrl, contentType, is);
+ }
+ return null;
+ }
+
+ @Override
+ public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
+ this.hostnameVerifier = hostnameVerifier;
+ }
+
+ @Override
+ public void setSSLSocketFactory(SSLSocketFactory socketFactory) {
+ this.sslSocketFactory = socketFactory;
+ }
+
}
\ No newline at end of file
diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLDereferencer.java b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLDereferencer.java
index d747753f..8853a9c1 100644
--- a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLDereferencer.java
+++ b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLDereferencer.java
@@ -20,6 +20,9 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSocketFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -37,7 +40,10 @@ public class URLDereferencer {
private static URLDereferencer instance = new URLDereferencer();
private Map handlerMap = new HashMap();
-
+
+ private HostnameVerifier hostnameVerifier;
+ private SSLSocketFactory sslSocketFactory;
+
private URLDereferencer() {
registerHandlers();
}
@@ -62,7 +68,9 @@ public class URLDereferencer {
if (handler == null) {
throw new MalformedURLException("No handler for protocol: " + protocol
+ " found");
- }
+ }
+ handler.setHostnameVerifier(hostnameVerifier);
+ handler.setSSLSocketFactory(sslSocketFactory);
return handler.dereference(aUrl, aContext);
}
@@ -86,5 +94,13 @@ public class URLDereferencer {
for (String proto : HTTPURLProtocolHandlerImpl.PROTOCOLS) {
handlerMap.put(proto, handler);
}
+ }
+
+ public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
+ this.hostnameVerifier = hostnameVerifier;
+ }
+
+ public void setSSLSocketFactory(SSLSocketFactory socketFactory) {
+ this.sslSocketFactory = socketFactory;
}
}
\ No newline at end of file
diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLProtocolHandler.java b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLProtocolHandler.java
index f584f450..f886bd4e 100644
--- a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLProtocolHandler.java
+++ b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/URLProtocolHandler.java
@@ -18,6 +18,9 @@ package at.gv.egiz.bku.utils.urldereferencer;
import java.io.IOException;
import java.net.MalformedURLException;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSocketFactory;
public interface URLProtocolHandler {
@@ -28,5 +31,9 @@ public interface URLProtocolHandler {
* @return the streamdata of this url or null if the url cannot be resolved.
* @throws IOException
*/
- public StreamData dereference(String aUrl, URLDereferencerContext aContext) throws IOException;
+ public StreamData dereference(String aUrl, URLDereferencerContext aContext) throws IOException;
+
+ public void setSSLSocketFactory(SSLSocketFactory socketFactory);
+
+ public void setHostnameVerifier(HostnameVerifier hostnameVerifier);
}
\ No newline at end of file
--
cgit v1.2.3
From 54aa4703e3d66c5b1a63b8d925fd4c9c1766687c Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 28 Jan 2009 19:40:11 +0000
Subject: activation
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@291 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUApplet/pom.xml | 74 +-
.../gv/egiz/bku/online/applet/AppletBKUWorker.java | 74 +-
.../bku/online/applet/AppletParameterProvider.java | 57 --
.../at/gv/egiz/bku/online/applet/BKUApplet.java | 106 ++-
BKUApplet/src/test/resources/appletTest.html | 2 +-
BKULocal/pom.xml | 2 +-
.../at/gv/egiz/bku/local/stal/LocalBKUWorker.java | 1 -
BKULocalApp/pom.xml | 6 +-
BKUOnline/pom.xml | 108 ++-
.../egiz/bku/online/webapp/BKURequestHandler.java | 3 +
.../stal/service/impl/STALRequestBrokerImpl.java | 8 +-
.../gv/egiz/stal/service/impl/STALServiceImpl.java | 18 +-
.../stal/service/impl/STALXJAXBContextFactory.java | 10 +-
BKUOnline/src/main/webapp/applet.jsp | 14 +-
BKUOnline/src/main/webapp/slRequestForm.html | 3 +-
STALExt/pom.xml | 2 +-
.../java/at/gv/egiz/stal/service/STALPortType.java | 2 +-
.../stal/service/translator/STALTranslator.java | 5 +-
STALXService/pom.xml | 25 +
.../namespaces/cardchannel/service/ATRType.java | 100 +++
.../cardchannel/service/AttributeList.java | 71 ++
.../cardchannel/service/AttributeType.java | 264 +++++++
.../cardchannel/service/CommandAPDUType.java | 154 ++++
.../cardchannel/service/ObjectFactory.java | 172 +++++
.../namespaces/cardchannel/service/ResetType.java | 64 ++
.../cardchannel/service/ResponseAPDUType.java | 161 +++++
.../cardchannel/service/ResponseType.java | 82 +++
.../namespaces/cardchannel/service/ScriptType.java | 85 +++
.../cardchannel/service/VerifyAPDUType.java | 266 +++++++
.../cardchannel/service/package-info.java | 2 +
.../at/gv/egiz/stalx/service/STALPortType.java | 45 ++
.../java/at/gv/egiz/stalx/service/STALService.java | 73 ++
.../translator/STALXTranslationHandler.java | 217 ++++++
.../src/main/resources/wsdl/CardChannel.xsd | 148 ++++
STALXService/src/main/resources/wsdl/stal.xsd | 162 +++++
STALXService/src/main/resources/wsdl/stalx.wsdl | 123 ++++
.../stalx/service/ClientJAXBContextFactory.java | 52 ++
.../at/gv/egiz/stalx/service/STALServiceTest.java | 112 +++
bkucommon/pom.xml | 7 +-
.../slcommands/impl/AbstractAssocArrayInfobox.java | 6 +-
.../impl/CreateXMLSignatureResultImpl.java | 145 ++--
.../slcommands/impl/InfoboxReadResultFileImpl.java | 197 ++---
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 6 +-
pom.xml | 7 +
.../at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java | 5 +-
utils/pom.xml | 5 +
.../egiz/idlink/CompressedIdentityLinkFactory.java | 800 ++++++++++-----------
.../at/gv/egiz/idlink/IdentityLinkFactory.java | 6 +-
.../java/at/gv/egiz/marshal/MarshallerFactory.java | 52 ++
.../gv/egiz/marshal/NamespacePrefixMapperImpl.java | 86 +++
.../gv/egiz/xades/QualifyingPropertiesFactory.java | 418 +++++------
51 files changed, 3519 insertions(+), 1094 deletions(-)
delete mode 100644 BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletParameterProvider.java
create mode 100644 STALXService/pom.xml
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/ATRType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/AttributeList.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/AttributeType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/CommandAPDUType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/ObjectFactory.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/ResetType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/ResponseAPDUType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/ResponseType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/ScriptType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/VerifyAPDUType.java
create mode 100644 STALXService/src/main/java/at/buergerkarte/namespaces/cardchannel/service/package-info.java
create mode 100644 STALXService/src/main/java/at/gv/egiz/stalx/service/STALPortType.java
create mode 100644 STALXService/src/main/java/at/gv/egiz/stalx/service/STALService.java
create mode 100644 STALXService/src/main/java/at/gv/egiz/stalx/service/translator/STALXTranslationHandler.java
create mode 100644 STALXService/src/main/resources/wsdl/CardChannel.xsd
create mode 100644 STALXService/src/main/resources/wsdl/stal.xsd
create mode 100644 STALXService/src/main/resources/wsdl/stalx.wsdl
create mode 100644 STALXService/src/test/java/at/gv/egiz/stalx/service/ClientJAXBContextFactory.java
create mode 100644 STALXService/src/test/java/at/gv/egiz/stalx/service/STALServiceTest.java
create mode 100644 utils/src/main/java/at/gv/egiz/marshal/MarshallerFactory.java
create mode 100644 utils/src/main/java/at/gv/egiz/marshal/NamespacePrefixMapperImpl.java
(limited to 'bkucommon/src/main')
diff --git a/BKUApplet/pom.xml b/BKUApplet/pom.xml
index 3b115399..da5dbc6f 100644
--- a/BKUApplet/pom.xml
+++ b/BKUApplet/pom.xml
@@ -23,35 +23,23 @@
at.gv.egiztrue${project.build.outputDirectory}
- META-INF\/
+ META-INF\/
+
+
+
+
+ copy_testapplet
+
+ copy-dependencies
+
+
+ ${project.build.directory}/test-classes
+ at.gv.egiz,commons-logging,iaik
+ commons-logging,iaik_jce_me4se
+ true
+
@@ -80,30 +68,6 @@
true
-
- maven-dependency-plugin
-
-
- copytestlibs
-
- copy
-
-
-
-
- commons-logging
- commons-logging
-
-
- iaik
- iaik_jce_me4se
-
-
- ${project.build.directory}/test-libs
-
-
-
-
@@ -132,9 +96,5 @@
BKUCommonGUI1.0.5-SNAPSHOT
-
- commons-logging
- commons-logging
-
\ No newline at end of file
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
index 6ac892ec..388f045f 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
@@ -22,7 +22,6 @@ import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
import at.gv.egiz.stal.service.STALPortType;
-import at.gv.egiz.stal.service.STALService;
import at.gv.egiz.stal.service.translator.STALTranslator;
import at.gv.egiz.stal.service.translator.TranslationException;
import at.gv.egiz.stal.service.types.ErrorResponseType;
@@ -31,13 +30,10 @@ import at.gv.egiz.stal.service.types.GetNextRequestType;
import at.gv.egiz.stal.service.types.ObjectFactory;
import at.gv.egiz.stal.service.types.RequestType;
import at.gv.egiz.stal.service.types.ResponseType;
-import java.applet.AppletContext;
import java.net.MalformedURLException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceException;
/**
@@ -46,29 +42,19 @@ import javax.xml.ws.WebServiceException;
*/
public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
- protected AppletContext ctx;
- protected AppletParameterProvider params;
+ protected BKUApplet applet;
protected String sessionId;
- protected STALPortType stalPort;
+
private ObjectFactory stalObjFactory = new ObjectFactory();
- private STALTranslator translator = new STALTranslator();
- public AppletBKUWorker(BKUGUIFacade gui, AppletContext ctx,
- AppletParameterProvider paramProvider) {
+ public AppletBKUWorker(BKUApplet applet, BKUGUIFacade gui) {
super(gui);
- if (ctx == null) {
- throw new NullPointerException("Applet context not provided");
- }
- if (paramProvider == null) {
- throw new NullPointerException("No applet parameters provided");
- }
- this.ctx = ctx;
- this.params = paramProvider;
-
- sessionId = params.getAppletParameter(BKUApplet.SESSION_ID);
+ this.applet = applet;
+
+ sessionId = applet.getParameter(BKUApplet.SESSION_ID);
if (sessionId == null) {
sessionId = "TestSession";
- log.info("using dummy sessionId " + sessionId);
+ log.warn("using dummy sessionId " + sessionId);
}
}
@@ -77,9 +63,11 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
gui.showWelcomeDialog();
try {
- stalPort = getSTALPort();
+ STALPortType stalPort = applet.getSTALPort();
+ STALTranslator stalTranslator = applet.getSTALTranslator();
- registerSignRequestHandler(stalPort, sessionId);
+ addRequestHandler(SignRequest.class,
+ new AppletHashDataDisplay(stalPort, sessionId));
GetNextRequestResponseType nextRequestResp = stalPort.connect(sessionId);
@@ -111,7 +99,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
List stalRequests = new ArrayList();
for (JAXBElement extends RequestType> req : requests) {
try {
- stalRequests.add(translator.translate(req));
+ stalRequests.add(stalTranslator.translate(req));
} catch (TranslationException ex) {
log.error("Received unknown request from server STAL: " + ex.getMessage());
throw new RuntimeException(ex);
@@ -123,7 +111,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
List stalResponses = handleRequest(stalRequests);
for (STALResponse stalResponse : stalResponses) {
try {
- responses.add(translator.translate(stalResponse));
+ responses.add(stalTranslator.translate(stalResponse));
} catch (TranslationException ex) {
log.error("Received unknown response from STAL: " + ex.getMessage());
throw new RuntimeException(ex);
@@ -184,7 +172,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
}
}
- sendRedirect();
+ applet.sendRedirect(sessionId);
}
/**
@@ -218,38 +206,4 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
log.error(e);
}
}
-
- protected void sendRedirect() {
- try {
- URL redirectURL = params.getURLParameter(BKUApplet.REDIRECT_URL,
- sessionId);
- String redirectTarget = params.getAppletParameter(BKUApplet.REDIRECT_TARGET);
- if (redirectTarget == null) {
- log.info("Done. Redirecting to " + redirectURL + " ...");
- ctx.showDocument(redirectURL);
- } else {
- log.info("Done. Redirecting to " + redirectURL + " (target=" + redirectTarget + ") ...");
- ctx.showDocument(redirectURL, redirectTarget);
- }
- } catch (MalformedURLException ex) {
- log.warn("Failed to redirect: " + ex.getMessage(), ex);
- // gui.showErrorDialog(errorMsg, okListener, actionCommand)
- }
- }
-
- private STALPortType getSTALPort() throws MalformedURLException {
- URL wsdlURL = params.getURLParameter(BKUApplet.WSDL_URL);
- log.debug("STAL WSDL at " + wsdlURL);
- QName endpointName = new QName(BKUApplet.STAL_WSDL_NS,
- BKUApplet.STAL_SERVICE);
- STALService stal = new STALService(wsdlURL, endpointName);
- return stal.getSTALPort();
- }
-
- private void registerSignRequestHandler(STALPortType stalPort, String sessionId) {
- log.debug("register SignRequestHandler (resolve hashdata via STAL Webservice)");
- AppletHashDataDisplay handler = new AppletHashDataDisplay(stalPort,
- sessionId);
- addRequestHandler(SignRequest.class, handler);
- }
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletParameterProvider.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletParameterProvider.java
deleted file mode 100644
index 42e2d6ff..00000000
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletParameterProvider.java
+++ /dev/null
@@ -1,57 +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.bku.online.applet;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- *
- * @author Clemens Orthacker
- */
-public interface AppletParameterProvider {
-
- /**
- * Applet configuration parameters
- *
- * @param paramKey
- * @return null if no parameter is provided for the given key
- */
- String getAppletParameter(String paramKey);
-
- /**
- * Get applet configuration parameter as (absolute) URL
- *
- * @param paramKey
- * @return a URL
- * @throws MalformedURLException if configured URL is invalid
- * or no parameter is provided for the given key
- */
- URL getURLParameter(String paramKey) throws MalformedURLException;
-
- /**
- * Get applet configuration parameter as (absolute) URL
- *
- * @param paramKey
- * @param sessionId adds the jsessionid to the URL
- * @return a URL
- * @throws MalformedURLException if configured URL is invalid
- * or no parameter is provided for the given key
- */
- URL getURLParameter(String paramKey, String sessionId) throws MalformedURLException;
-}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
index 5e60ed3e..d4b2018d 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
@@ -16,8 +16,10 @@
*/
package at.gv.egiz.bku.online.applet;
+import at.gv.egiz.bku.gui.BKUGUIFacade.Style;
import at.gv.egiz.bku.gui.DefaultHelpListener;
import at.gv.egiz.bku.gui.AbstractHelpListener;
+import at.gv.egiz.stal.service.translator.STALTranslator;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
@@ -30,15 +32,18 @@ import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.BKUGUIFactory;
+import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.service.STALService;
+import java.awt.Container;
+import javax.xml.namespace.QName;
/**
* Note: all swing code is executed by the event dispatch thread (see
* BKUGUIFacade)
*/
-public class BKUApplet extends JApplet implements AppletParameterProvider {
+public class BKUApplet extends JApplet {
private static Log log = LogFactory.getLog(BKUApplet.class);
-
/**
* Applet parameter keys
*/
@@ -55,18 +60,15 @@ public class BKUApplet extends JApplet implements AppletParameterProvider {
// public static final String HASHDATA_DISPLAY_INTERNAL = "internal";
// public static final String HASHDATA_DISPLAY_BROWSER = "browser";
public static final String HASHDATA_DISPLAY_FRAME = "frame";
-
/**
* STAL WSDL namespace and service name
*/
public static final String STAL_WSDL_NS = "http://www.egiz.gv.at/wsdl/stal";
public static final String STAL_SERVICE = "STALService";
-
/**
* Dummy session id, used if no sessionId parameter is provided
*/
protected static final String TEST_SESSION_ID = "TestSession";
-
/**
* STAL
*/
@@ -81,17 +83,17 @@ public class BKUApplet extends JApplet implements AppletParameterProvider {
public void init() {
log.info("Welcome to MOCCA");
log.debug("Called init()");
-
+
HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
- String locale = getAppletParameter(LOCALE);
+ String locale = getParameter(LOCALE);
if (locale != null) {
this.setLocale(new Locale(locale));
}
- log.debug("setting locale to " + getLocale());
+ log.debug("setting locale: " + getLocale());
BKUGUIFacade.Style guiStyle;
- String guiStyleParam = getAppletParameter(GUI_STYLE);
+ String guiStyleParam = getParameter(GUI_STYLE);
if ("advanced".equals(guiStyleParam)) {
guiStyle = BKUGUIFacade.Style.advanced;
} else if ("tiny".equals(guiStyleParam)) {
@@ -99,30 +101,33 @@ public class BKUApplet extends JApplet implements AppletParameterProvider {
} else {
guiStyle = BKUGUIFacade.Style.simple;
}
-
+ log.debug("setting gui-style: " + guiStyle);
+
URL backgroundImgURL = null;
try {
- backgroundImgURL = getURLParameter(BACKGROUND_IMG);
+ backgroundImgURL = getURLParameter(BACKGROUND_IMG, null);
+ log.debug("setting background: " + backgroundImgURL);
} catch (MalformedURLException ex) {
log.warn("failed to load applet background image: " + ex.getMessage() + ", using default");
}
-
+
AbstractHelpListener helpListener = null;
try {
- URL helpURL = getURLParameter(HELP_URL);
-// helpListener = new BrowserHelpListener(getAppletContext(), helpURL, getLocale());
- helpListener = new DefaultHelpListener(getAppletContext(), helpURL, getLocale());
+ helpListener = new DefaultHelpListener(getAppletContext(),
+ getURLParameter(HELP_URL, null), getLocale());
+ if (log.isDebugEnabled()) {
+ log.debug("setting helpURL: " + getURLParameter(HELP_URL, null));
+ }
} catch (MalformedURLException ex) {
log.warn("failed to load help URL: " + ex.getMessage() + ", disabling help");
}
-
- BKUGUIFacade gui = BKUGUIFactory.createGUI(getContentPane(),
- getLocale(),
- guiStyle,
- backgroundImgURL,
+
+ BKUGUIFacade gui = createGUI(getContentPane(), getLocale(),
+ guiStyle,
+ backgroundImgURL,
helpListener);
- worker = new AppletBKUWorker(gui, getAppletContext(), this);
+ worker = new AppletBKUWorker(this, gui);
}
@Override
@@ -145,15 +150,7 @@ public class BKUApplet extends JApplet implements AppletParameterProvider {
log.debug("Called destroy()");
}
- @Override
- public String getAppletParameter(String paramKey) {
- String param = getParameter(paramKey);
- log.info("applet parameter: " + paramKey + ": " + param);
- return param;
- }
-
- @Override
- public URL getURLParameter(String paramKey, String sessionId) throws MalformedURLException {
+ protected URL getURLParameter(String paramKey, String sessionId) throws MalformedURLException {
String urlParam = getParameter(paramKey);
if (urlParam != null) {
URL codebase = getCodeBase();
@@ -173,15 +170,54 @@ public class BKUApplet extends JApplet implements AppletParameterProvider {
} catch (MalformedURLException ex) {
log.error("applet paremeter " + urlParam + " is not a valid URL: " + ex.getMessage());
throw ex;
- }
+ }
} else {
log.error("applet paremeter " + urlParam + " not set");
throw new MalformedURLException(urlParam + " not set");
}
}
-
- @Override
- public URL getURLParameter(String paramKey) throws MalformedURLException {
- return getURLParameter(paramKey, null);
+
+ /**
+ * provides a means to for subclasses to inject a different GUI
+ */
+ protected BKUGUIFacade createGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ AbstractHelpListener helpListener) {
+ return BKUGUIFactory.createGUI(contentPane,
+ locale,
+ guiStyle,
+ backgroundImgURL,
+ helpListener);
+ }
+
+ protected STALPortType getSTALPort() throws MalformedURLException {
+ URL wsdlURL = getURLParameter(WSDL_URL, null);
+ log.debug("setting STAL WSDL: " + wsdlURL);
+ QName endpointName = new QName(STAL_WSDL_NS, STAL_SERVICE);
+ STALService stal = new STALService(wsdlURL, endpointName);
+ return stal.getSTALPort();
+ }
+
+ protected STALTranslator getSTALTranslator() {
+ return new STALTranslator();
+ }
+
+ protected void sendRedirect(String sessionId) {
+ try {
+ URL redirectURL = getURLParameter(REDIRECT_URL, sessionId);
+ String redirectTarget = getParameter(REDIRECT_TARGET);
+ if (redirectTarget == null) {
+ log.info("Done. Redirecting to " + redirectURL + " ...");
+ getAppletContext().showDocument(redirectURL);
+ } else {
+ log.info("Done. Redirecting to " + redirectURL + " (target=" + redirectTarget + ") ...");
+ getAppletContext().showDocument(redirectURL, redirectTarget);
+ }
+ } catch (MalformedURLException ex) {
+ log.warn("Failed to redirect: " + ex.getMessage(), ex);
+ // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ }
}
}
diff --git a/BKUApplet/src/test/resources/appletTest.html b/BKUApplet/src/test/resources/appletTest.html
index c8bd99d3..4a768f91 100644
--- a/BKUApplet/src/test/resources/appletTest.html
+++ b/BKUApplet/src/test/resources/appletTest.html
@@ -18,7 +18,7 @@