summaryrefslogtreecommitdiff
path: root/pdf-over-signator/src/main/java
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:53:55 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:53:55 +0000
commitfd63db00a873ba082029848041fe28392e496316 (patch)
tree221ce88a89c7264c8082e382b41a5ec7dd5bb93c /pdf-over-signator/src/main/java
parent23ae1caefcf0cc99c2b90327afaff6376ecc552a (diff)
downloadpdf-over-fd63db00a873ba082029848041fe28392e496316.tar.gz
pdf-over-fd63db00a873ba082029848041fe28392e496316.tar.bz2
pdf-over-fd63db00a873ba082029848041fe28392e496316.zip
Changed SLRequest interface
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@27 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-signator/src/main/java')
-rw-r--r--pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java84
1 files changed, 73 insertions, 11 deletions
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java
index abc0ff30..c4be9dae 100644
--- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java
+++ b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java
@@ -15,28 +15,90 @@
*/
package at.asit.pdfover.signator;
+import org.apache.commons.codec.binary.Base64;
+
/**
* Security Layer Request
*/
-public interface SLRequest {
-
+public class SLRequest {
+
/**
- * The String Konstant to replace the SL DATAOBJECT
+ * The String constant to replace the SL DATAOBJECT
*/
public static final String DATAOBJECT_STRING = "##DATAOBJECT##";
-
+
+ /**
+ * The security layer request
+ */
+ private String request;
+
+ /**
+ * The document to be signed
+ */
+ private DocumentSource signatureData;
+
+ /**
+ * Set the SL request
+ * @param request the request to set
+ */
+ protected void setRequest(String request) {
+ this.request = request;
+ }
+
/**
- * The SL Request String
+ * The SL request String with the document encoded in base64
*
- * In this string the DATAOBJECT_STRING has to be replaced by the reference of the Signature Data
- * Examples are sl:Base64Content, sl:LocRefContent
- * @return
+ * This SL Request is always a detached signature request which contains a
+ * reference to the data object in base64 encoding.
+ *
+ * @return SL request String
+ */
+ public String getBase64Request() {
+ byte[] b64content = Base64.encodeBase64(getSignatureData().getByteArray());
+
+ String b64request = this.request.replace(
+ DATAOBJECT_STRING,
+ "<sl:Base64Content>" + b64content //$NON-NLS-1$
+ + "</sl:Base64Content>"); //$NON-NLS-1$
+
+ return b64request;
+ }
+
+ /**
+ * The SL request String with the document referenced as an URI
+ *
+ * This SL Request is always a detached signature request which contains a
+ * reference to the data object as an URI
+ * The URI has to be provided and should be a valid reference to
+ * the document provided by getSignatureData().
+ *
+ * @param uri The URI pointing to the signature data
+ * @return SL request String
*/
- public String getRequest();
-
+ public String getURIRequest(String uri) {
+ String urirequest = this.request.replace(
+ DATAOBJECT_STRING,
+ "<sl:LocRefContent>" + uri //$NON-NLS-1$
+ + "</sl:LocRefContent>"); //$NON-NLS-1$
+
+ return urirequest;
+ }
+
+ /**
+ * Set the signature data (document to be signed)
+ * @param signatureData the signatureData to set
+ */
+ protected void setSignatureData(DocumentSource signatureData) {
+ this.signatureData = signatureData;
+ }
+
/**
* Gets the signature data for this request
+ *
* @return The document source
*/
- public DocumentSource getSignatureData();
+ public DocumentSource getSignatureData()
+ {
+ return this.signatureData;
+ }
}