summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-24 18:48:00 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-24 18:48:00 +0000
commit5af9b75dccc1b52d1382fe0f2df30affd509f5b9 (patch)
tree8640f3e4f0446e85cbe34f2d87916e187f5b40ad
parent650732adaff82503b19a41b6c53d4299be9a1533 (diff)
downloadmocca-5af9b75dccc1b52d1382fe0f2df30affd509f5b9.tar.gz
mocca-5af9b75dccc1b52d1382fe0f2df30affd509f5b9.tar.bz2
mocca-5af9b75dccc1b52d1382fe0f2df30affd509f5b9.zip
Filenames derived from reference URI
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@553 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java3
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java10
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java56
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java53
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java5
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java9
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties3
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties1
-rw-r--r--BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java12
-rw-r--r--BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java6
-rw-r--r--BKUOnline/pom.xml2
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java1
-rw-r--r--BKUOnline/src/main/webapp/META-INF/context.xml2
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd1
-rw-r--r--BKUOnline/src/main/wsdl/stal-service.xsd1
-rw-r--r--BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java21
-rw-r--r--STAL/src/main/java/at/gv/egiz/stal/HashDataInput.java2
-rw-r--r--STALService/src/main/java/at/gv/egiz/stal/service/types/GetHashDataInputResponseType.java28
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java1
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java6
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java88
-rw-r--r--bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java50
-rw-r--r--bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_Detached_LocRefContent.xml13
-rw-r--r--bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_LocRefContent_2.xml2
-rw-r--r--utils/src/main/java/at/gv/egiz/slbinding/RedirectEventFilter.java3
-rw-r--r--utils/src/main/java/at/gv/egiz/slbinding/impl/TransformsInfoType.java8
-rw-r--r--utils/src/main/java/at/gv/egiz/slbinding/impl/XMLContentType.java9
27 files changed, 313 insertions, 83 deletions
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java
index 2e0cb331..c67699af 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java
@@ -180,6 +180,7 @@ public class AppletSecureViewer implements SecureViewer {
byte[] hdi = hashDataInput.getValue();
String mimeType = hashDataInput.getMimeType();
String encoding = hashDataInput.getEncoding();
+ String filename = hashDataInput.getFilename();
if (hdi == null) {
throw new Exception("No hashdata input for reference " + signedRefId + " provided by service");
@@ -199,7 +200,7 @@ public class AppletSecureViewer implements SecureViewer {
throw new DigestException("Bad digest value for reference " + signedRefId);
}
- verifiedHashDataInputs.add(new ByteArrayHashDataInput(hdi, signedRefId, mimeType, encoding));
+ verifiedHashDataInputs.add(new ByteArrayHashDataInput(hdi, signedRefId, mimeType, encoding, filename));
}
}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java
index 16024fcc..6af22815 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java
@@ -39,10 +39,14 @@ public class HyperlinkRenderer extends DefaultTableCellRenderer {
@Override
protected void setValue(Object value) {
String hrefText;
- if (renderReferenceId) {
- hrefText = ((HashDataInput) value).getReferenceId();
+ if (((HashDataInput) value).getFilename() != null) {
+ hrefText = ((HashDataInput) value).getFilename();
} else {
- hrefText = ((HashDataInput) value).getMimeType();
+ if (renderReferenceId) {
+ hrefText = ((HashDataInput) value).getReferenceId();
+ } else {
+ hrefText = ((HashDataInput) value).getMimeType();
+ }
}
super.setText("<html><u>" + hrefText + "</u></html>");
setForeground(BKUGUIFacade.HYPERLINK_COLOR);
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java
index c0385dce..5d64eb4f 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java
@@ -26,14 +26,6 @@ import javax.swing.filechooser.FileFilter;
*/
class MimeFilter extends FileFilter {
- private static final String MIMETYPE_DESC_XML = "mimetype.desc.xml";
- private static final String MIMETYPE_DESC_HTML = "mimetype.desc.html";
- private static final String MIMETYPE_DESC_XHTML = "mimetype.desc.xhtml";
- private static final String MIMETYPE_DESC_TXT = "mimetype.desc.txt";
- private static final String MIMETYPE_DESC_PDF = "mimetype.desc.pdf";
- private static final String MIMETYPE_DESC_BIN = "mimetype.desc.bin";
- private static final String MIMETYPE_DESC_UNKNOWN = "mimetype.desc.unknown";
-
protected String mimeType;
protected ResourceBundle messages;
@@ -48,21 +40,7 @@ class MimeFilter extends FileFilter {
if (f.isDirectory()) {
return true;
}
-
- String ext = getExtension(f);
- if ("text/xml".equals(mimeType)) {
- return "xml".equalsIgnoreCase(ext);
- } else if ("text/html".equals(mimeType)) {
- return "html".equalsIgnoreCase(ext) || "htm".equalsIgnoreCase(ext);
- } else if ("application/xhtml+xml".equals(mimeType)) {
- return "xhtml".equalsIgnoreCase(ext);
- } else if ("text/plain".equals(mimeType)) {
- return "txt".equalsIgnoreCase(ext);
- } else if ("application/pdf".equals(mimeType)) {
- return "pdf".equalsIgnoreCase(ext);
- } else {
- return true;
- }
+ return MimeTypes.getExtension(mimeType).equalsIgnoreCase(getExtension(f));
}
private String getExtension(File f) {
@@ -78,38 +56,10 @@ class MimeFilter extends FileFilter {
@Override
public String getDescription() {
- if ("text/xml".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_XML);
- } else if ("text/html".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_HTML);
- } else if ("application/xhtml+xml".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_XHTML);
- } else if ("text/plain".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_TXT);
- } else if ("application/pdf".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_PDF);
- } else if ("application/octet-stream".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_BIN);
- } else {
- return messages.getString(MIMETYPE_DESC_UNKNOWN);
- }
+ return messages.getString(MimeTypes.getDescriptionKey(mimeType));
}
public static String getExtension(String mimeType) {
- if ("text/xml".equals(mimeType)) {
- return ".xml";
- } else if ("text/html".equals(mimeType)) {
- return ".html";
- } else if ("application/xhtml+xml".equals(mimeType)) {
- return ".xhtml";
- } else if ("text/plain".equals(mimeType)) {
- return ".txt";
- } else if ("application/pdf".equals(mimeType)) {
- return ".pdf";
- } else if ("application/octet-stream".equals(mimeType)) {
- return ".bin";
- } else {
- return "";
- }
+ return MimeTypes.getExtension(mimeType);
}
} \ No newline at end of file
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java
new file mode 100644
index 00000000..4500fa71
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java
@@ -0,0 +1,53 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.gui.viewer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author clemens
+ */
+public class MimeTypes {
+
+ private static final Map<String , String> FILE_EXTENSIONS = new HashMap<String, String>() {{
+ put("application/msword", ".doc");
+ put("application/octet-stream", ".bin");
+ put("application/pdf", ".pdf");
+ put("application/xhtml+xml", ".xhtml");
+ put("text/html", ".html");
+ put("text/plain", ".txt");
+ put("text/xml", ".xml");
+ }};
+
+ private static final Map<String , String> DESCRIPTIONS = new HashMap<String, String>() {{
+ put("application/msword", "mimetype.desc.doc");
+ put("application/octet-stream", "mimetype.desc.bin");
+ put("application/pdf", "mimetype.desc.pdf");
+ put("application/xhtml+xml", "mimetype.desc.xhtml");
+ put("text/html", "mimetype.desc.html");
+ put("text/plain", "mimetype.desc.txt");
+ put("text/xml", "mimetype.desc.xml");
+ }};
+
+ public static String getExtension(String mimetype) {
+ if (FILE_EXTENSIONS.containsKey(mimetype)) {
+ return FILE_EXTENSIONS.get(mimetype);
+ }
+ return "";
+ }
+
+ /**
+ * @return bundle key to be resolved in message resource bundle
+ */
+ public static String getDescriptionKey(String mimetype) {
+ if (DESCRIPTIONS.containsKey(mimetype)) {
+ return DESCRIPTIONS.get(mimetype);
+ }
+ return "mimetype.desc.unknown";
+ }
+}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java
index 40133f95..3303d4ef 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java
@@ -52,8 +52,9 @@ public class SecureViewerSaveDialog {
String mimeType = hashDataInput.getMimeType();
MimeFilter mimeFilter = new MimeFilter(mimeType, messages);
fileDialog.setFileFilter(mimeFilter);
- String filename = messages
- .getString(BKUGUIFacade.SAVE_HASHDATAINPUT_PREFIX)
+ String filename = (hashDataInput.getFilename() != null) ?
+ hashDataInput.getFilename() :
+ messages.getString(BKUGUIFacade.SAVE_HASHDATAINPUT_PREFIX)
+ MimeFilter.getExtension(mimeType);
fileDialog.setSelectedFile(new File(userHome, filename));
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java b/BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
index 6ca9a0b2..b9416845 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
@@ -36,8 +36,9 @@ public class ByteArrayHashDataInput implements HashDataInput {
protected String id;
protected String mimeType;
protected String encoding;
+ protected String filename;
- public ByteArrayHashDataInput(byte[] hashData, String id, String mimeType, String encoding) {
+ public ByteArrayHashDataInput(byte[] hashData, String id, String mimeType, String encoding, String filename) {
if (hashData == null) {
throw new NullPointerException("HashDataInput not provided.");
}
@@ -45,6 +46,7 @@ public class ByteArrayHashDataInput implements HashDataInput {
this.id = id;
this.mimeType = mimeType;
this.encoding = encoding;
+ this.filename = filename;
}
/**
@@ -96,5 +98,10 @@ public class ByteArrayHashDataInput implements HashDataInput {
return encoding;
}
+ @Override
+ public String getFilename() {
+ return filename;
+ }
+
}
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
index 7135b561..3e483fc8 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
@@ -48,7 +48,7 @@ hashdatalink.tiny.focus=<html><a href=\"anzeige\">[Signaturdaten]</a></html>
#verwenden sie bitte die von ihrem System zur Verf\u00FCgung gestellte {0} Anwendung.
hashdatalist=<html>{0} Signaturdaten:</html>
hashdata.viewer=<html>Signaturdaten werden im Betrachter angezeigt
-unsupported.mimetype=<html>Signaturdaten können nicht angezeigt werden
+unsupported.mimetype=<html>Signaturdaten k\u00F6nnen nicht angezeigt werden
retries.last=<html>Letzter Versuch!</html>
retries=<html>Noch {0} Versuche</html>
retries.pinpad.last=<html>Eingabe wiederholen, letzter Versuch!</html>
@@ -71,6 +71,7 @@ mimetype.desc.xhtml=XHTML-Dateien (.xhtml)
mimetype.desc.txt=Textdateien (.txt)
mimetype.desc.pdf=Adobe PDF-Dateien (.pdf)
mimetype.desc.bin=Bin\u00E4rdateien (.bin)
+mimetype.desc.doc=Microsoft Word-Dateien (.doc)
mimetype.desc.unknown=Alle Dateien (.*)
save.hashdatainput.prefix=Signaturdaten
alt.help=Hilfe
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
index 6e89510e..c553bcb5 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
@@ -69,6 +69,7 @@ mimetype.desc.xhtml=XHTML-files (.xhtml)
mimetype.desc.txt=Textfiles (.txt)
mimetype.desc.pdf=Adobe PDF-files (.pdf)
mimetype.desc.bin=Binary files (.bin)
+mimetype.desc.doc=Microsoft Word-files (.doc)
mimetype.desc.unknown=All files (.*)
save.hashdatainput.prefix=signaturedata
alt.help=help
diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
index 20654141..6e345ee3 100644
--- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
+++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
@@ -85,25 +85,29 @@ public class BKUGUIWorker implements Runnable {
"Ich bin ein einfacher Text mit Umlauten: öäüßéç@€\n123\n456\n\tHello, world!\n\nlkjsd\nnksdjf".getBytes(),
"ref-id-0000000000000000000000001",
"text/plain",
- "UTF-8");
+ "UTF-8",
+ "file.txt");
HashDataInput signedRef2 = new ByteArrayHashDataInput(
"<xml>HashDataInput_002</xml>".getBytes(),
"ref-id-000000002",
"application/xhtml+xml",
- "UTF-8");
+ "UTF-8",
+ "file.xhtml");
HashDataInput signedRef3 = new ByteArrayHashDataInput(
"<xml>HashDataInput_003</xml>".getBytes(),
"ref-id-000000003",
"application/xhtml+xml",
- "UTF-8");
+ "UTF-8",
+ "file2.xhtml");
HashDataInput signedRef4 = new ByteArrayHashDataInput(
"<xml>HashDataInput_004</xml>".getBytes(),
"ref-id-000000004",
"text/xml",
- "UTF-8");
+ "UTF-8",
+ "file.xml");
//
List<HashDataInput> signedRefs = new ArrayList();
diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java
index 131a344f..9bbc1b1a 100644
--- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java
+++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java
@@ -66,7 +66,7 @@ public class SecureViewerDialogTest {
String s = new String(bytes, "iso-8859-1");
System.out.println("read iso-8859-1 bytes " + s);
- secureViewer.setContent(new ByteArrayHashDataInput(s.getBytes("UTF-8"), "id-1", "text/plain", "iso-8859-1"));
+ secureViewer.setContent(new ByteArrayHashDataInput(s.getBytes("UTF-8"), "id-1", "text/plain", "iso-8859-1", "file.txt"));
}
@@ -87,7 +87,7 @@ public class SecureViewerDialogTest {
}
System.out.println(data.toString());
- secureViewer.setContent(new ByteArrayHashDataInput(data.toString().getBytes("UTF-8"), "id-1", "text/plain", "UTF-8"));
+ secureViewer.setContent(new ByteArrayHashDataInput(data.toString().getBytes("UTF-8"), "id-1", "text/plain", "UTF-8", "file.txt"));
}
@@ -146,7 +146,7 @@ public class SecureViewerDialogTest {
// byte[] bytes2 = data.getBytes("cp1252");
// System.out.println(data + "\t" + SMCCHelper.toString(bytes2));
- secureViewer.setContent(new ByteArrayHashDataInput(data.toString().getBytes("UTF-8"), "id-1", "text/plain", "UTF-8"));
+ secureViewer.setContent(new ByteArrayHashDataInput(data.toString().getBytes("UTF-8"), "id-1", "text/plain", "UTF-8", "file.txt"));
System.out.println("\n\n=============================\n");
//
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml
index ed7f228c..c7c40982 100644
--- a/BKUOnline/pom.xml
+++ b/BKUOnline/pom.xml
@@ -263,7 +263,7 @@
<bindingFile>staltypes-custom.xml</bindingFile>
<bindingFile>cardchannel-custom.xml</bindingFile>
</bindingFiles>
- <wsdlDirectory>${basedir}/src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
+ <!-- wsdlDirectory>${basedir}/src/main/webapp/WEB-INF/wsdl</wsdlDirectory-->
<wsdlDirectory>${basedir}/src/main/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>stal-service.wsdl</wsdlFile>
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 eab9bed5..c8ab280f 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
@@ -267,6 +267,7 @@ public class STALServiceImpl implements STALPortType {
ref.setID(reqRefId);
ref.setMimeType(reqHdi.getMimeType());
ref.setEncoding(reqHdi.getEncoding());
+ ref.setFilename(reqHdi.getFilename());
ref.setValue(baos.toByteArray());
response.getReference().add(ref);
} catch (IOException ex) {
diff --git a/BKUOnline/src/main/webapp/META-INF/context.xml b/BKUOnline/src/main/webapp/META-INF/context.xml
index f38215a1..2a2da79e 100644
--- a/BKUOnline/src/main/webapp/META-INF/context.xml
+++ b/BKUOnline/src/main/webapp/META-INF/context.xml
@@ -16,4 +16,4 @@
limitations under the License.
-->
<!--Context path="/bkuonline"/-->
-<Context path=""/>
+<Context path="/bkuonline"/>
diff --git a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd
index 2389e043..a420035f 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd
+++ b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd
@@ -151,6 +151,7 @@
<attribute name="ID" type="string"/>
<attribute name="MimeType" type="string" use="optional"/>
<attribute name="Encoding" type="string" use="optional"/>
+ <attribute name="Filename" type="string" use="optional"/>
</extension>
</simpleContent>
</complexType>
diff --git a/BKUOnline/src/main/wsdl/stal-service.xsd b/BKUOnline/src/main/wsdl/stal-service.xsd
index 870e2db6..177b9e7f 100644
--- a/BKUOnline/src/main/wsdl/stal-service.xsd
+++ b/BKUOnline/src/main/wsdl/stal-service.xsd
@@ -166,6 +166,7 @@
<attribute name="ID" type="string"/>
<attribute name="MimeType" type="string" use="optional"/>
<attribute name="Encoding" type="string" use="optional"/>
+ <attribute name="Filename" type="string" use="optional"/>
</extension>
</simpleContent>
</complexType>
diff --git a/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java
index a1f3864e..741974eb 100644
--- a/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java
+++ b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java
@@ -126,6 +126,12 @@ public class STALRequestBrokerTest {
public String getEncoding() {
return "UTF-8";
}
+
+
+ @Override
+ public String getFilename() {
+ return "file.txt";
+ }
};
r1.setHashDataInput(Collections.singletonList(hdi));
requests.add(r1);
@@ -172,6 +178,11 @@ public class STALRequestBrokerTest {
public String getEncoding() {
return "UTF-8";
}
+
+ @Override
+ public String getFilename() {
+ return "file.txt";
+ }
};
r1.setHashDataInput(Collections.singletonList(hdi));
requests.add(r1);
@@ -231,6 +242,11 @@ public class STALRequestBrokerTest {
public String getEncoding() {
return "UTF-8";
}
+
+ @Override
+ public String getFilename() {
+ return "file.txt";
+ }
};
r1.setHashDataInput(Collections.singletonList(hdi));
requests.add(r1);
@@ -259,6 +275,11 @@ public class STALRequestBrokerTest {
public String getEncoding() {
return "UTF-8";
}
+
+ @Override
+ public String getFilename() {
+ return "file.xml";
+ }
};
r2.setHashDataInput(Collections.singletonList(hdi2));
requests2.add(r2);
diff --git a/STAL/src/main/java/at/gv/egiz/stal/HashDataInput.java b/STAL/src/main/java/at/gv/egiz/stal/HashDataInput.java
index 62c25fc4..7092470c 100644
--- a/STAL/src/main/java/at/gv/egiz/stal/HashDataInput.java
+++ b/STAL/src/main/java/at/gv/egiz/stal/HashDataInput.java
@@ -31,6 +31,8 @@ public interface HashDataInput {
public String getEncoding();
+ public String getFilename();
+
public InputStream getHashDataInput();
}
diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/GetHashDataInputResponseType.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/GetHashDataInputResponseType.java
index 7536d936..ad029757 100644
--- a/STALService/src/main/java/at/gv/egiz/stal/service/types/GetHashDataInputResponseType.java
+++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/GetHashDataInputResponseType.java
@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlValue;
* &lt;attribute name="ID" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="MimeType" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="Encoding" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * &lt;attribute name="Filename" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
@@ -118,6 +119,7 @@ public class GetHashDataInputResponseType {
* &lt;attribute name="ID" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="MimeType" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="Encoding" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * &lt;attribute name="Filename" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
@@ -139,6 +141,8 @@ public class GetHashDataInputResponseType {
protected String mimeType;
@XmlAttribute(name = "Encoding")
protected String encoding;
+ @XmlAttribute(name = "Filename")
+ protected String filename;
/**
* Gets the value of the value property.
@@ -234,6 +238,30 @@ public class GetHashDataInputResponseType {
this.encoding = value;
}
+ /**
+ * Gets the value of the filename property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getFilename() {
+ return filename;
+ }
+
+ /**
+ * Sets the value of the filename property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setFilename(String value) {
+ this.filename = value;
+ }
+
}
}
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 b1906666..e39addb5 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
@@ -339,6 +339,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
// process headers and request
setHTTPHeaders(dataUrlResponse.getResponseHeaders());
consumeRequestStream(dataUrlResponse.getStream());
+ //TODO check for bindingProcessorError
closeDataUrlConnection();
srcContex.setSourceCertificate(conn.getServerCertificate());
srcContex.setSourceIsDataURL(true);
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 1a9b56fb..57358ba0 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
@@ -50,4 +50,10 @@ public class DataObjectHashDataInput implements HashDataInput {
return HttpUtil.getCharset(dataObject.getMimeType(), false);
}
+ @Override
+ public String getFilename() {
+ //TODO obtain filename from dataObject, if not set return null or get filename (extension!) from mimetype
+ return dataObject.getFilename();
+ }
+
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java
index 89124d16..6e84081e 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java
@@ -49,8 +49,6 @@ import javax.xml.crypto.dsig.spec.XPathType;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.w3._2000._09.xmldsig_.TransformType;
-import org.w3._2000._09.xmldsig_.TransformsType;
import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
@@ -71,6 +69,7 @@ import at.buergerkarte.namespaces.securitylayer._1.DataObjectInfoType;
import at.buergerkarte.namespaces.securitylayer._1.MetaInfoType;
import at.buergerkarte.namespaces.securitylayer._1.TransformsInfoType;
import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.gui.viewer.MimeTypes;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
@@ -81,11 +80,11 @@ import at.gv.egiz.bku.viewer.ValidationException;
import at.gv.egiz.bku.viewer.Validator;
import at.gv.egiz.bku.viewer.ValidatorFactory;
import at.gv.egiz.dom.DOMUtils;
-import at.gv.egiz.marshal.NamespacePrefixMapperImpl;
import at.gv.egiz.slbinding.impl.XMLContentType;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
/**
* This class represents a <code>DataObject</code> of an XML-Signature
@@ -184,7 +183,9 @@ public class DataObject {
* An optional description of the digest input.
*/
private String description;
-
+
+ private String filename;
+
/**
* Creates a new instance.
*
@@ -230,6 +231,10 @@ public class DataObject {
return mimeType;
}
+ public String getFilename() {
+ return filename;
+ }
+
/**
* @return the description
*/
@@ -336,7 +341,74 @@ public class DataObject {
}
// other values are not allowed by the schema and are therefore ignored
-
+
+ this.filename = deriveFilename();
+ }
+
+ /**
+ * Extract filename from reference URI
+ * or propose reference Id with an apropriate (mime-type) file extension
+ *
+ * @return if neither reference nor id can be extracted return null (or data.extension?)
+ */
+ private String deriveFilename() {
+
+ String filename = null;
+
+ if (reference != null) {
+ if (reference.getURI() != null && !"".equals(reference.getURI())) {
+ try {
+ log.info("deriving filename from reference URI " + reference.getURI());
+ URI refURI = new URI(reference.getURI());
+
+ if (refURI.isOpaque()) {
+ // could check scheme component, but also allow other schemes (e.g. testlocal)
+ log.trace("opaque reference URI, use scheme-specific part as filename");
+ filename = refURI.getSchemeSpecificPart();
+ if (!hasExtension(filename)) {
+ filename += MimeTypes.getExtension(mimeType);
+ }
+ // else hierarchical URI:
+ // for shorthand xpointer use fragment as filename,
+ // for any other xpointer use reference Id and
+ // for any other hierarchical (absolute or relative) use filename (ignore fragment, see xmldsig section 4.3.3.2: fragments not recommendet)
+ } else if ("".equals(refURI.getPath()) &&
+ refURI.getFragment() != null &&
+ refURI.getFragment().indexOf('(') < 0) { // exclude (schemebased) xpointer expressions
+ log.trace("fragment (shorthand xpointer) URI, use fragment as filename");
+ filename = refURI.getFragment();
+ if(!hasExtension(filename)) {
+ filename += MimeTypes.getExtension(mimeType);
+ }
+ } else if (!"".equals(refURI.getPath())) {
+ log.trace("hierarchical URI with path component, use path as filename");
+ File refFile = new File(refURI.getPath());
+ filename = refFile.getName();
+ if(!hasExtension(filename)) {
+ filename += MimeTypes.getExtension(mimeType);
+ }
+ } else {
+ log.info("failed to derive filename from URI '" + refURI + "', derive filename from reference ID");
+ filename = reference.getId() + MimeTypes.getExtension(mimeType);
+ }
+ } catch (URISyntaxException ex) {
+ log.error("failed to derive filename from invalid URI " + ex.getMessage());
+ filename = reference.getId() + MimeTypes.getExtension(mimeType);
+ }
+ } else {
+ log.info("same-document URI, derive filename from reference ID");
+ filename = reference.getId() + MimeTypes.getExtension(mimeType);
+ }
+ } else {
+ log.error("failed to derive filename, no reference created");
+ }
+ log.debug("derived filename for reference " + reference.getId() + ": " + filename);
+ return filename;
+ }
+
+ private static boolean hasExtension(String filename) {
+ int extDelimiterInd = filename.lastIndexOf('.');
+ return extDelimiterInd >= 0 && extDelimiterInd >= filename.length() - 4;
}
private byte[] getTransformsBytes(at.gv.egiz.slbinding.impl.TransformsInfoType ti) {
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 7ce7b42d..ccd29e85 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
@@ -443,8 +443,11 @@ public class SignatureTest {
@SuppressWarnings("unchecked")
@Test
+
public void testDataObject_XMLContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+ System.out.println("\n ****************** testDataObject_XMLContent_1 \n");
+
List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_XMLContent_1.xml");
Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
@@ -485,6 +488,8 @@ public class SignatureTest {
@Test
public void testDataObject_XMLContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+ System.out.println("\n ****************** testDataObject_XMLContent_2 \n");
+
List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_XMLContent_2.xml");
Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
@@ -526,6 +531,8 @@ public class SignatureTest {
@Test
public void testDataObject_LocRefContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+ System.out.println("\n ****************** testDataObject_LocRefContent_1 \n");
+
List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_LocRefContent_1.xml");
Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
@@ -535,7 +542,7 @@ public class SignatureTest {
}
signature.buildXMLSignature();
-
+
signAndMarshalSignature(signature);
List<Reference> references = signature.getReferences();
@@ -564,6 +571,8 @@ public class SignatureTest {
@Test
public void testDataObject_LocRefContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+ System.out.println("\n ****************** testDataObject_LocRefContent_2 \n");
+
List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_LocRefContent_2.xml");
Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
@@ -602,6 +611,8 @@ public class SignatureTest {
@Test
public void testDataObject_Reference_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+ System.out.println("\n ****************** testDataObject_Reference_1 \n");
+
List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Reference_1.xml");
Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
@@ -640,6 +651,8 @@ public class SignatureTest {
@Test
public void testDataObject_Detached_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+ System.out.println("\n ****************** testDataObject_Detached_1 \n");
+
List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_1.xml");
Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
@@ -671,6 +684,8 @@ public class SignatureTest {
@Test
public void testDataObject_Detached_Base64Content() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+ System.out.println("\n ****************** testDataObject_Detached_Base64Content \n");
+
List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_Base64Content.xml");
Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
@@ -698,6 +713,39 @@ public class SignatureTest {
}
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testDataObject_Detached_LocRefContent() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException {
+
+ System.out.println("\n ****************** testDataObject_Detached_LocRefContent \n");
+
+ List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_LocRefContent.xml");
+
+ Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl());
+
+ for (DataObjectInfoType dataObjectInfo : dataObjectInfos) {
+ signature.addDataObject(dataObjectInfo);
+ }
+
+ signature.buildXMLSignature();
+
+ signAndMarshalSignature(signature);
+
+ List<Reference> references = signature.getReferences();
+ assertTrue(references.size() == 2);
+
+ Reference reference = references.get(0);
+ assertNotNull(reference.getId());
+
+ List<Transform> transforms = reference.getTransforms();
+ assertTrue(transforms.size() == 0);
+
+ List<XMLObject> objects = signature.getXMLObjects();
+ assertNotNull(objects);
+ assertTrue(objects.size() == 1);
+
+ }
+
//
//
// TransformsInfo
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_Detached_LocRefContent.xml b/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_Detached_LocRefContent.xml
new file mode 100644
index 00000000..75f45ff0
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_Detached_LocRefContent.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sl:CreateXMLSignatureRequest xmlns:sl="http://www.buergerkarte.at/namespaces/securitylayer/1.2#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+ <sl:DataObjectInfo Structure="detached">
+ <sl:DataObject Reference="http://example.com/path/filenameNoExt#fragmentNoExt">
+ <sl:LocRefContent>testlocal:DataObject1.bin</sl:LocRefContent>
+ </sl:DataObject>
+ <sl:TransformsInfo>
+ <sl:FinalDataMetaInfo>
+ <sl:MimeType>application/octet-stream</sl:MimeType>
+ </sl:FinalDataMetaInfo>
+ </sl:TransformsInfo>
+ </sl:DataObjectInfo>
+</sl:CreateXMLSignatureRequest> \ No newline at end of file
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_LocRefContent_2.xml b/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_LocRefContent_2.xml
index 852c115f..a94f51b6 100644
--- a/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_LocRefContent_2.xml
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/impl/DataObjectInfo_LocRefContent_2.xml
@@ -6,7 +6,7 @@
</sl:DataObject>
<sl:TransformsInfo>
<sl:FinalDataMetaInfo>
- <sl:MimeType>application/octetstream</sl:MimeType>
+ <sl:MimeType>application/octet-stream</sl:MimeType>
</sl:FinalDataMetaInfo>
</sl:TransformsInfo>
</sl:DataObjectInfo>
diff --git a/utils/src/main/java/at/gv/egiz/slbinding/RedirectEventFilter.java b/utils/src/main/java/at/gv/egiz/slbinding/RedirectEventFilter.java
index 14c5ba48..5fe84aae 100644
--- a/utils/src/main/java/at/gv/egiz/slbinding/RedirectEventFilter.java
+++ b/utils/src/main/java/at/gv/egiz/slbinding/RedirectEventFilter.java
@@ -153,9 +153,6 @@ public class RedirectEventFilter implements EventFilter {
private void redirectEvent(XMLEvent event) {
try {
- if (log.isTraceEnabled()) {
- log.trace("redirecting StAX event " + event);
- }
redirectWriter.add(event);
} catch (XMLStreamException ex) {
ex.printStackTrace();
diff --git a/utils/src/main/java/at/gv/egiz/slbinding/impl/TransformsInfoType.java b/utils/src/main/java/at/gv/egiz/slbinding/impl/TransformsInfoType.java
index 1180e9fa..b1de9406 100644
--- a/utils/src/main/java/at/gv/egiz/slbinding/impl/TransformsInfoType.java
+++ b/utils/src/main/java/at/gv/egiz/slbinding/impl/TransformsInfoType.java
@@ -22,6 +22,7 @@ package at.gv.egiz.slbinding.impl;
import at.gv.egiz.slbinding.*;
import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
import java.util.HashSet;
import java.util.Set;
import javax.xml.bind.annotation.XmlTransient;
@@ -62,6 +63,13 @@ public class TransformsInfoType extends at.buergerkarte.namespaces.securitylayer
log.debug("disabling event redirection for TransformsInfoType");
filter.flushRedirectStream();
filter.setRedirectStream(null);
+ if (log.isDebugEnabled()) {
+ try {
+ log.debug("redirected events (UTF-8): " + redirectOS.toString("UTF-8"));
+ } catch (UnsupportedEncodingException ex) {
+ log.debug("failed to log redirected events", ex);
+ }
+ }
}
@Override
diff --git a/utils/src/main/java/at/gv/egiz/slbinding/impl/XMLContentType.java b/utils/src/main/java/at/gv/egiz/slbinding/impl/XMLContentType.java
index eb147f88..fd52e378 100644
--- a/utils/src/main/java/at/gv/egiz/slbinding/impl/XMLContentType.java
+++ b/utils/src/main/java/at/gv/egiz/slbinding/impl/XMLContentType.java
@@ -23,6 +23,8 @@ package at.gv.egiz.slbinding.impl;
import at.gv.egiz.slbinding.RedirectCallback;
import at.gv.egiz.slbinding.RedirectEventFilter;
import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.stream.XMLStreamException;
import org.apache.commons.logging.Log;
@@ -51,6 +53,13 @@ public class XMLContentType extends at.buergerkarte.namespaces.securitylayer._1.
log.debug("disabling event redirection for XMLContentType");
filter.flushRedirectStream();
filter.setRedirectStream(null);
+ if (log.isDebugEnabled()) {
+ try {
+ log.debug("redirected events (UTF-8): " + redirectOS.toString("UTF-8"));
+ } catch (UnsupportedEncodingException ex) {
+ log.debug("failed to log redirected events", ex);
+ }
+ }
}
@Override