diff options
Diffstat (limited to 'pdf-over/pdf-signer-interface/src/main/java/at/asit')
8 files changed, 136 insertions, 19 deletions
diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/ByteArrayDocumentSource.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/ByteArrayDocumentSource.java new file mode 100644 index 00000000..27e0c537 --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/ByteArrayDocumentSource.java @@ -0,0 +1,29 @@ +package at.asit.pdfover.pdfsigner; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +public class ByteArrayDocumentSource implements DocumentSource { + + protected byte[] data; + + public ByteArrayDocumentSource(byte[] data) { + this.data = data; + } + + @Override + public InputStream GetInputStream() { + return new ByteArrayInputStream(this.data); + } + + @Override + public int GetLength() { + return data.length; + } + + @Override + public byte[] GetByteArray() { + return data; + } + +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/DocumentSource.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/DocumentSource.java index af377c44..dafe9797 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/DocumentSource.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/DocumentSource.java @@ -1,9 +1,29 @@ package at.asit.pdfover.pdfsigner; +import java.io.InputStream; + /** * A Document Source + * * @author afitzek */ -public class DocumentSource { +public interface DocumentSource { + + /** + * Gets Document as INput Stream + * @return + */ + public InputStream GetInputStream(); + + /** + * Get Length of document + * @return + */ + public int GetLength(); + /** + * Get byte[] + * @return + */ + public byte[] GetByteArray(); } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignatureException.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignatureException.java index 19253af1..5a9a0073 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignatureException.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignatureException.java @@ -10,5 +10,12 @@ public class PDFSignatureException extends Exception { * */ private static final long serialVersionUID = 711578398780816710L; - + + public PDFSignatureException(Throwable e) { + super(e); + } + + public PDFSignatureException(String msg) { + super(msg); + } } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignerInterface.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignerInterface.java index 6c8aa83b..0d9592dc 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignerInterface.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignerInterface.java @@ -1,7 +1,5 @@ package at.asit.pdfover.pdfsigner; -import java.security.SignatureException; - /** * PDF Signator base Class * This class should be extended to support PDF-AS and PADES. @@ -17,7 +15,7 @@ public interface PDFSignerInterface { * @return The siging state (contains the prepared document and the signature request * @throws SignatureException */ - public SigningState Prepare(SignatureParameter parameter) throws SignatureException; + public SigningState Prepare(SignatureParameter parameter) throws PDFSignatureException; /** * Adds the signature to the document. @@ -26,7 +24,7 @@ public interface PDFSignerInterface { * @return The signature Result * @throws SignatureException */ - public SignResult Sign(SigningState state) throws SignatureException; + public SignResult Sign(SigningState state) throws PDFSignatureException; /** * Creates new signing profile diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SLResponse.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SLResponse.java index 4d2e594a..de98aa1a 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SLResponse.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SLResponse.java @@ -5,5 +5,14 @@ package at.asit.pdfover.pdfsigner; * @author afitzek */ public class SLResponse { - + + private String response; + + public SLResponse(String value) { + response = value; + } + + public String GetSLRespone() { + return this.response; + } } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResult.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResult.java index 6357fe11..8069da4e 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResult.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResult.java @@ -1,6 +1,6 @@ package at.asit.pdfover.pdfsigner; -import javax.security.cert.Certificate; +import java.security.cert.X509Certificate; /** * Signature Result containing the signed document as document source @@ -24,5 +24,5 @@ public interface SignResult { * Gets the signer certificate * @return The signer x509 certificate */ - public Certificate GetSignerCertificate(); + public X509Certificate GetSignerCertificate(); } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResultImpl.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResultImpl.java new file mode 100644 index 00000000..433ad093 --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResultImpl.java @@ -0,0 +1,37 @@ +package at.asit.pdfover.pdfsigner; + +import java.security.cert.X509Certificate; + +public class SignResultImpl implements SignResult { + + private SignaturePosition position; + private DocumentSource source; + private X509Certificate certificate; + + @Override + public SignaturePosition GetSignaturePosition() { + return position; + } + + @Override + public DocumentSource GetSignedDocument() { + return source; + } + + @Override + public X509Certificate GetSignerCertificate() { + return certificate; + } + + public void SetSignerCertificate(X509Certificate x509Certificate) { + this.certificate = x509Certificate; + } + + public void SetSignaturePosition(SignaturePosition postion) { + this.position = postion; + } + + public void SetSignedDocument(DocumentSource source) { + this.source = source; + } +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignaturePosition.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignaturePosition.java index f6d2aa81..82f37deb 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignaturePosition.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignaturePosition.java @@ -9,18 +9,20 @@ public class SignaturePosition { /** * The x value of the position */ - protected int x = 0; + protected float x = 0; /** * The y value of the position */ - protected int y = 0; + protected float y = 0; /** * The page value of the position */ protected int page = 1; + protected boolean auto = true; + /** * Default constructor */ @@ -32,7 +34,7 @@ public class SignaturePosition { * @param x The x value of the position * @param y The y value of the position */ - public SignaturePosition(int x, int y) { + public SignaturePosition(float x, float y) { this.x = x; this.y = y; } @@ -43,7 +45,7 @@ public class SignaturePosition { * @param y The y value of the position * @param page The page value of the position */ - public SignaturePosition(int x, int y, int page) { + public SignaturePosition(float x, float y, int page) { this.x = x; this.y = y; this.page = page; @@ -53,15 +55,15 @@ public class SignaturePosition { * Sets X value of position * @param value the new x value */ - public void SetX(int value) { + public void SetX(float value) { this.x = value; } /** * Gets the X value of the position - * @return int the x value of the position + * @return float the x value of the position */ - public int GetX() { + public float GetX() { return this.x; } @@ -69,15 +71,15 @@ public class SignaturePosition { * Sets Y value of position * @param value the new y value */ - public void SetY(int value) { + public void SetY(float value) { this.y = value; } /** * Gets the Y value of the position - * @return int the y value of the position + * @return float the y value of the position */ - public int GetY() { + public float GetY() { return this.y; } @@ -97,4 +99,19 @@ public class SignaturePosition { return this.page; } + /** + * Sets Page value of position + * @param value the new page value + */ + public void SetAuto(boolean value) { + this.auto = value; + } + + /** + * Gets the Page value of the position + * @return int the page value of the position + */ + public boolean GetAuto() { + return this.auto; + } } |