diff options
Diffstat (limited to 'pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner')
7 files changed, 0 insertions, 399 deletions
diff --git a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/ByteArrayPdfAsDataSource.java b/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/ByteArrayPdfAsDataSource.java deleted file mode 100644 index 874a08e9..00000000 --- a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/ByteArrayPdfAsDataSource.java +++ /dev/null @@ -1,36 +0,0 @@ -package at.asit.pdfover.pdfsigner.pdfas; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import at.gv.egiz.pdfas.api.io.DataSource; - -public class ByteArrayPdfAsDataSource implements DataSource { - - private byte[] data; - - public ByteArrayPdfAsDataSource(byte[] data) { - this.data = data; - } - - public InputStream createInputStream() { - return new ByteArrayInputStream(this.data); - } - - public int getLength() { - return this.data.length; - } - - public byte[] getAsByteArray() { - return this.data; - } - - public String getMimeType() { - return "application/pdf"; - } - - public String getCharacterEncoding() { - return null; - } - -}
\ No newline at end of file diff --git a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASHelper.java b/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASHelper.java deleted file mode 100644 index 1e14fc39..00000000 --- a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASHelper.java +++ /dev/null @@ -1,73 +0,0 @@ -package at.asit.pdfover.pdfsigner.pdfas; - -import at.asit.pdfover.pdfsigner.PDFSignatureException; -import at.gv.egiz.pdfas.api.PdfAs; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; -import at.gv.egiz.pdfas.api.internal.PdfAsInternal; - -/** - * Encapsulates PDF AS API Object to need just one initialization - * @author afitzek - */ -public class PDFASHelper { - - /** - * PDF AS Object - */ - private static PdfAs pdf_as_instance = null; - - /** - * Internal Pdf AS Object - */ - private static PdfAsInternal pdf_as_internal = null; - - /** - * Creates PDF AS Object - * @return - * @throws PdfAsException - */ - private static PdfAs CreatePdfAs() throws PdfAsException { - return new at.gv.egiz.pdfas.impl.api.PdfAsObject(); - } - - /** - * Creates a PDF AS Internal object - * @return - * @throws PdfAsException - */ - private static PdfAsInternal CreatePdfAsInternal() throws PdfAsException { - return new at.gv.egiz.pdfas.impl.api.internal.PdfAsInternalObject(); - } - - /** - * Gets PDF AS Object - * @return - * @throws PDFSignatureException - */ - public static synchronized PdfAs GetPdfAs() throws PDFSignatureException { - if(pdf_as_instance == null) { - try { - pdf_as_instance = CreatePdfAs(); - } catch(PdfAsException e) { - throw new PDFSignatureException(e); - } - } - return pdf_as_instance; - } - - /** - * Gets PDF AS Internal object - * @return - * @throws PDFSignatureException - */ - public static synchronized PdfAsInternal GetPdfAsInternal() throws PDFSignatureException { - if(pdf_as_internal == null) { - try { - pdf_as_internal = CreatePdfAsInternal(); - } catch(PdfAsException e) { - throw new PDFSignatureException(e); - } - } - return pdf_as_internal; - } -} diff --git a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSLRequest.java b/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSLRequest.java deleted file mode 100644 index a4b55c94..00000000 --- a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSLRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package at.asit.pdfover.pdfsigner.pdfas; - -import at.asit.pdfover.pdfsigner.DocumentSource; -import at.asit.pdfover.pdfsigner.SLRequest; - -public class PDFASSLRequest implements SLRequest { - - public PDFASSLRequest(String slRequest) { - /// Analyse Request ... - } - - @Override - public DocumentSource GetSignatureData() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSignatureParameter.java b/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSignatureParameter.java deleted file mode 100644 index 518f54b7..00000000 --- a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSignatureParameter.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.asit.pdfover.pdfsigner.pdfas; - -import at.asit.pdfover.pdfsigner.SignatureDimension; -import at.asit.pdfover.pdfsigner.SignatureParameter; -import at.gv.egiz.pdfas.api.sign.pos.SignaturePositioning; -import at.gv.egiz.pdfas.api.io.DataSource; - -public class PDFASSignatureParameter extends SignatureParameter { - - @Override - public SignatureDimension GetPlaceholderDimension() { - // TODO Auto-generated method stub - return null; - } - - public SignaturePositioning GetPDFASPositioning() { - // TODO: implement Signature creation - return new SignaturePositioning(); - } - - public DataSource GetPDFASDataSource() { - // TODO: implement Signature creation - return new ByteArrayPdfAsDataSource(null); - } -} diff --git a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSigner.java b/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSigner.java deleted file mode 100644 index 0cbaef1b..00000000 --- a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSigner.java +++ /dev/null @@ -1,147 +0,0 @@ -package at.asit.pdfover.pdfsigner.pdfas; - -import at.asit.pdfover.pdfsigner.ByteArrayDocumentSource; -import at.asit.pdfover.pdfsigner.PDFSignatureException; -import at.asit.pdfover.pdfsigner.PDFSignerInterface; -import at.asit.pdfover.pdfsigner.SignResult; -import at.asit.pdfover.pdfsigner.SignResultImpl; -import at.asit.pdfover.pdfsigner.SignatureParameter; -import at.asit.pdfover.pdfsigner.SignaturePosition; -import at.asit.pdfover.pdfsigner.SigningState; -import at.gv.egiz.pdfas.api.PdfAs; -import at.gv.egiz.pdfas.api.sign.SignParameters; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; -import at.gv.egiz.pdfas.io.ByteArrayDataSink; -import at.gv.egiz.pdfas.api.commons.Constants; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; -import at.gv.egiz.pdfas.api.internal.LocalBKUParams; -import at.gv.egiz.pdfas.api.internal.PdfAsInternal; - -/** - * PDF AS Signer Implementation - * - * @author afitzek - */ -public class PDFASSigner implements PDFSignerInterface { - - protected static final String PROFILE_ID = "SIGNATURBLOCK_DE"; - - protected static final String URL_TEMPLATE = "http://pdfover.4.gv.at/template"; - - @Override - public SigningState Prepare(SignatureParameter parameter) - throws PDFSignatureException { - try { - PDFASSignatureParameter sign_para = null; - - if (PDFASSignatureParameter.class.isInstance(parameter)) { - sign_para = PDFASSignatureParameter.class.cast(parameter); - } - - if (sign_para == null) { - throw new PDFSignatureException("Incorrect SignatureParameter!"); - } - - PdfAs pdfas = PDFASHelper.GetPdfAs(); - - PDFASSigningState state = new PDFASSigningState(); - - SignParameters params = new SignParameters(); - params.setSignaturePositioning(sign_para.GetPDFASPositioning()); - params.setSignatureDevice(Constants.SIGNATURE_DEVICE_BKU); - params.setSignatureType(Constants.SIGNATURE_TYPE_BINARY); - params.setSignatureProfileId(PROFILE_ID); - - if(parameter.GetCollimatingMark() != null) { - params.setProfileOverrideValue("SIG_LABEL", parameter.GetCollimatingMark().GetFileName()); - } - - params.setDocument(sign_para.GetPDFASDataSource()); - - state.setSignParameters(params); - - PdfAsInternal pdfasInternal = PDFASHelper.GetPdfAsInternal(); - - // Prepares the document - SignatureDetailInformation sdi = pdfas.prepareSign(params); - - state.setSignatureDetailInformation(sdi); - - // Retrieve the SL Request - String slRequest = pdfasInternal.prepareLocalSignRequest(params, - false, URL_TEMPLATE, sdi); - - PDFASSLRequest request = new PDFASSLRequest(slRequest); - - state.SetSLSignatureRequest(request); - - return state; - } catch (PdfAsException e) { - throw new PDFSignatureException(e); - } - } - - @Override - public SignResult Sign(SigningState state) throws PDFSignatureException { - try { - PDFASSigningState sstate = null; - - if (PDFASSigningState.class.isInstance(state)) { - sstate = PDFASSigningState.class.cast(state); - } - - if (sstate == null) { - throw new PDFSignatureException("Incorrect SigningState!"); - } - - // Retrieve objects - PdfAs pdfas = PDFASHelper.GetPdfAs(); - - PdfAsInternal pdfasInternal = PDFASHelper.GetPdfAsInternal(); - - SignParameters params = sstate.getSignParameters(); - - // Prepare Output sink - ByteArrayDataSink data = new ByteArrayDataSink(); - params.setOutput(data); - - SignatureDetailInformation sdi = sstate - .getSignatureDetailInformation(); - - LocalBKUParams bkuParams = new LocalBKUParams(null, null, null); - - // Perform signature - at.gv.egiz.pdfas.api.sign.SignResult signResult = pdfasInternal - .finishLocalSign(pdfas, params, sdi, bkuParams, false, - sstate.GetSLSignatureResponse().GetSLRespone()); - - // Preparing Result Response - SignResultImpl result = new SignResultImpl(); - - // Set Signer Certificate - result.SetSignerCertificate(signResult.getSignerCertificate()); - at.gv.egiz.pdfas.api.sign.pos.SignaturePosition pdfasPos = signResult - .getSignaturePosition(); - - // Set Signature position - SignaturePosition pos = new SignaturePosition(pdfasPos.getX(), - pdfasPos.getY(), pdfasPos.getPage()); - pos.SetAuto(sstate.getPDFAsSignatureParameter() - .GetSignaturePosition().GetAuto()); - result.SetSignaturePosition(pos); - - // Set signed Document - result.SetSignedDocument(new ByteArrayDocumentSource(data.getData())); - - return result; - } catch (PdfAsException e) { - throw new PDFSignatureException(e); - } - } - - @Override - public SignatureParameter GetParameter() { - return new PDFASSignatureParameter(); - } - -} diff --git a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSignerFactory.java b/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSignerFactory.java deleted file mode 100644 index 2545578b..00000000 --- a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSignerFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -package at.asit.pdfover.pdfsigner.pdfas; - -import at.asit.pdfover.pdfsigner.PDFSigner; -import at.asit.pdfover.pdfsigner.PDFSignerFactory; -import at.asit.pdfover.pdfsigner.PDFSignerInterface; - -public class PDFASSignerFactory extends PDFSignerFactory { - - @Override - public PDFSignerInterface CreatePDFSigner() { - return new PDFASSigner(); - } - - @Override - public PDFSigner GetPDFSignerType() { - return PDFSigner.PDFAS; - } - -} diff --git a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSigningState.java b/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSigningState.java deleted file mode 100644 index 9500f981..00000000 --- a/pdf-over/pdf-signer-pdf-as/src/main/java/at/asit/pdfover/pdfsigner/pdfas/PDFASSigningState.java +++ /dev/null @@ -1,81 +0,0 @@ -package at.asit.pdfover.pdfsigner.pdfas; - -import at.asit.pdfover.pdfsigner.SLRequest; -import at.asit.pdfover.pdfsigner.SLResponse; -import at.asit.pdfover.pdfsigner.SigningState; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; - -/** - * Signing State for PDFAS Wrapper - * @author afitzek - */ -public class PDFASSigningState implements SigningState { - - protected SLRequest slrequest; - - protected SLResponse slresponse; - - @Override - public SLRequest GetSLSignatureRequest() { - return slrequest; - } - - @Override - public void SetSLSignatureResponse(SLResponse value) { - this.slresponse = value; - } - - /** - * Sets the SL Request - * @param request The SL Request - */ - public void SetSLSignatureRequest(SLRequest request) { - this.slrequest = request; - } - - /** - * Gets the SL Response - * @return The SL Repsonse object - */ - public SLResponse GetSLSignatureResponse() { - return this.slresponse; - } - - - // ---------------------------------------- - // PDF AS Specific stuff - // ---------------------------------------- - - protected SignatureDetailInformation SignatureDetailInformation; - - protected at.gv.egiz.pdfas.api.sign.SignParameters SignParameters; - - protected PDFASSignatureParameter PDFAsSignatureParameter; - - public PDFASSignatureParameter getPDFAsSignatureParameter() { - return PDFAsSignatureParameter; - } - - public void setPDFAsSignatureParameter( - PDFASSignatureParameter pDFAsSignatureParameter) { - PDFAsSignatureParameter = pDFAsSignatureParameter; - } - - public at.gv.egiz.pdfas.api.sign.SignParameters getSignParameters() { - return SignParameters; - } - - public void setSignParameters( - at.gv.egiz.pdfas.api.sign.SignParameters signParameters) { - SignParameters = signParameters; - } - - public SignatureDetailInformation getSignatureDetailInformation() { - return SignatureDetailInformation; - } - - public void setSignatureDetailInformation( - SignatureDetailInformation signatureDetailInformation) { - SignatureDetailInformation = signatureDetailInformation; - } -} |