summaryrefslogtreecommitdiff
path: root/pdf-over-signer/pdf-over-sigpdfas4/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src/main')
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java150
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java76
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java47
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java230
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java164
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java31
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java192
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java34
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer19
9 files changed, 0 insertions, 943 deletions
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
deleted file mode 100644
index 124bf43d..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signer.pdfas;
-
-// Imports
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.signator.BkuSlConnector;
-import at.asit.pdfover.signator.SignatureException;
-import at.asit.pdfover.signer.pdfas.exceptions.PdfAs4SLRequestException;
-import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
-import at.gv.egiz.pdfas.common.utils.PDFUtils;
-import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
-import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
-import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType;
-import at.gv.egiz.sl.schema.ErrorResponseType;
-import at.gv.egiz.sl.schema.InfoboxReadRequestType;
-import at.gv.egiz.sl.schema.InfoboxReadResponseType;
-import at.gv.egiz.sl.util.BaseSLConnector;
-import at.gv.egiz.sl.util.RequestPackage;
-import at.gv.egiz.sl.util.SLMarschaller;
-
-/**
- *
- */
-public class PdfAs4BKUSLConnector extends BaseSLConnector {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory
- .getLogger(PdfAs4BKUSLConnector.class);
-
- private BkuSlConnector connector;
-
- /**
- * Constructor
- * @param connector the BKU SL Connector
- */
- public PdfAs4BKUSLConnector(BkuSlConnector connector) {
- this.connector = connector;
- }
-
-
- /* (non-Javadoc)
- * @see at.gv.egiz.sl.util.ISLConnector#sendInfoboxReadRequest(at.gv.egiz.sl.schema.InfoboxReadRequestType, at.gv.egiz.pdfas.lib.api.sign.SignParameter)
- */
- @Override
- public InfoboxReadResponseType sendInfoboxReadRequest(
- InfoboxReadRequestType request, SignParameter parameter)
- throws PdfAsException {
- JAXBElement<?> element = null;
- try {
- String slRequestString = SLMarschaller.marshalToString(this.of.createInfoboxReadRequest(request));
- //log.trace(slRequestString);
-
- PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, null);
- String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone();
-
- element = (JAXBElement<?>) SLMarschaller
- .unmarshalFromString(slResponse);
- } catch (JAXBException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (PdfAs4SLRequestException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (SignatureException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- }
-
- if (element == null) {
- throw new PDFIOException("error.pdf.io.04");
- }
-
- if (element.getValue() instanceof InfoboxReadResponseType) {
- InfoboxReadResponseType infoboxReadResponseType = (InfoboxReadResponseType) element
- .getValue();
- return infoboxReadResponseType;
- } else if (element.getValue() instanceof ErrorResponseType) {
- ErrorResponseType errorResponseType = (ErrorResponseType) element
- .getValue();
- throw new SLPdfAsException(errorResponseType.getErrorCode(),
- errorResponseType.getInfo());
- }
- throw new PdfAsException("error.pdf.io.03");
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.sl.util.ISLConnector#sendCMSRequest(at.gv.egiz.sl.util.RequestPackage, at.gv.egiz.pdfas.lib.api.sign.SignParameter)
- */
- @Override
- public CreateCMSSignatureResponseType sendCMSRequest(RequestPackage pack,
- SignParameter parameter) throws PdfAsException {
- JAXBElement<?> element = null;
- try {
- String slRequestString = SLMarschaller.marshalToString(this.of.createCreateCMSSignatureRequest(pack.getRequestType()));
- //log.trace(slRequestString);
-
- byte[] signatureData = pack.getSignatureData();
- if (IConfigurationConstants.SL_REQUEST_TYPE_UPLOAD.equals(parameter.getConfiguration().getValue(IConfigurationConstants.SL_REQUEST_TYPE)))
- signatureData = PDFUtils.blackOutSignature(signatureData, pack.getByteRange());
-
- PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, signatureData);
- String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone();
-
- element = (JAXBElement<?>) SLMarschaller
- .unmarshalFromString(slResponse);
- } catch (JAXBException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (PdfAs4SLRequestException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (SignatureException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- }
-
- if (element == null) {
- throw new PDFIOException("error.pdf.io.05");
- }
-
- if (element.getValue() instanceof CreateCMSSignatureResponseType) {
- CreateCMSSignatureResponseType createCMSSignatureResponseType = (CreateCMSSignatureResponseType) element
- .getValue();
- log.trace(createCMSSignatureResponseType.toString());
- return createCMSSignatureResponseType;
- } else if (element.getValue() instanceof ErrorResponseType) {
- ErrorResponseType errorResponseType = (ErrorResponseType) element
- .getValue();
- throw new SLPdfAsException(errorResponseType.getErrorCode(),
- errorResponseType.getInfo());
- }
- throw new PdfAsException("error.pdf.io.03");
- }
-}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java
deleted file mode 100644
index e523637f..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signer.pdfas;
-
-// Imports
-import java.io.File;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.signator.SignatureException;
-import at.gv.egiz.pdfas.lib.api.PdfAs;
-import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
-
-/**
- * PDF-AS 4 Helper
- */
-public class PdfAs4Helper {
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory
- .getLogger(PdfAs4Helper.class);
-
- /**
- * PDF-AS Object
- */
- private static PdfAs pdfAs = null;
-
- /**
- * Gets PDF-AS Object
- * @return the PDF-AS Object
- * @throws SignatureException
- */
- public static synchronized PdfAs getPdfAs() throws SignatureException {
- if (pdfAs == null) {
- try {
- pdfAs = createPdfAs();
- } catch(Exception e) {
- throw new SignatureException(e);
- }
- }
- return pdfAs;
- }
-
- /**
- * Creates PDF-AS Object
- * @return the PDF-AS Object
- * @throws PdfAsException
- */
- private static PdfAs createPdfAs() {
- return PdfAsFactory.createPdfAs(new File(getWorkDir()));
- }
-
- /**
- * Provides the working directory
- * @return the working directory
- */
- public static String getWorkDir() {
- return System.getProperty("user.home") + "/.pdf-over";
- }
-}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java
deleted file mode 100644
index 87b97ac9..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signer.pdfas;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.signator.ByteArrayDocumentSource;
-import at.asit.pdfover.signator.SLRequest;
-import at.asit.pdfover.signer.pdfas.exceptions.PdfAs4SLRequestException;
-
-/**
- * PDF - AS Security Layer Request implementation
- */
-public class PdfAs4SLRequest extends SLRequest {
-
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(PdfAs4SLRequest.class);
-
- /**
- * Default constructor
- * @param slRequest
- * @param signData
- * @throws PdfAs4SLRequestException
- */
- public PdfAs4SLRequest(String slRequest, byte[] signData) throws PdfAs4SLRequestException {
- setRequest(slRequest);
- setSignatureData(signData == null ? null : new ByteArrayDocumentSource(signData));
- }
-}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
deleted file mode 100644
index 032416cd..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signer.pdfas;
-
-//Imports
-
-import iaik.x509.X509Certificate;
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.util.HashMap;
-import java.util.Locale;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-import at.asit.pdfover.signator.SignatureDimension;
-import at.asit.pdfover.signator.SignatureParameter;
-import at.asit.pdfover.signator.SignaturePosition;
-import at.gv.egiz.pdfas.lib.api.Configuration;
-import at.gv.egiz.pdfas.lib.api.PdfAs;
-import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
-import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
-import at.asit.pdfover.commons.Profile;
-
-/**
- * Implementation of SignatureParameter for PDF-AS 4 Library
- */
-public class PdfAs4SignatureParameter extends SignatureParameter {
- /**
- * The profile ID extension for the German signature block
- */
- private static final String PROFILE_ID_LANG_DE = "_DE";
- /**
- * The profile ID extension for the English signature block
- */
- private static final String PROFILE_ID_LANG_EN = "_EN";
- /**
- * The profile ID extension for the signature note
- */
- private static final String PROFILE_ID_NOTE = "_NOTE";
- /**
- * The profile ID extension for PDF/A compatibility
- */
- private static final String PROFILE_ID_PDFA = "_PDFA";
-
- private static final String PROFILE_ID_RECOMMENDED = "_RECOMMENDED";
-
- /**
- * Visibility of signature block
- */
- public static boolean PROFILE_VISIBILITY = true;
-
- private HashMap<String, String> genericProperties = new HashMap<String, String>();
-
- /**
- * This parameters are defining the signature block size
- */
- private int sig_w = 229;
- private int sig_h = 77;
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory
- .getLogger(PdfAs4SignatureParameter.class);
- private String profile = Profile.getDefaultProfile();
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholderDimension()
- */
- @Override
- public SignatureDimension getPlaceholderDimension() {
- return new SignatureDimension(this.sig_w, this.sig_h);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholder()
- */
- @Override
- public Image getPlaceholder() {
- String sigProfile = getPdfAsSignatureProfileId();
-
- String sigEmblem = (getEmblem() == null ? null : getEmblem().getFileName());
- String sigNote = getProperty("SIG_NOTE");
-
- try {
- X509Certificate cert = new X509Certificate(PdfAs4SignatureParameter.class.getResourceAsStream("/qualified.cer"));
- PdfAs pdfas = PdfAs4Helper.getPdfAs();
- Configuration conf = pdfas.getConfiguration();
- if (sigEmblem != null && !sigEmblem.trim().equals("")) {
- conf.setValue("sig_obj." + sigProfile + ".value.SIG_LABEL", sigEmblem);
- }
- if (sigNote != null) {
- conf.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote);
- }
- SignParameter param = PdfAsFactory
- .createSignParameter(conf, null, null);
- param.setSignatureProfileId(sigProfile);
- Image img = pdfas.generateVisibleSignaturePreview(param, cert, 72 * 4);
- this.sig_w = img.getWidth(null) / 4;
- this.sig_h = img.getHeight(null) / 4;
-
- return img;
- } catch (Exception e) {
- log.error("Failed to get signature placeholder", e);
- return new BufferedImage(getPlaceholderDimension().getWidth(),
- getPlaceholderDimension().getHeight(),
- BufferedImage.TYPE_INT_RGB);
- }
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#setProperty(java.lang.String, java.lang.String)
- */
- @Override
- public void setProperty(String key, String value) {
- this.genericProperties.put(key, value);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#getProperty(java.lang.String)
- */
- @Override
- public String getProperty(String key) {
- return this.genericProperties.get(key);
- }
-
- /**
- * Gets the Signature Position String for PDF-AS
- *
- * @return Signature Position String
- */
- public String getPdfAsSignaturePosition() {
- SignaturePosition in_pos = getSignaturePosition();
- String out_pos;
-
- if (!in_pos.useAutoPositioning()) {
- if (in_pos.getPage() < 1) {
- out_pos = String.format(
- (Locale) null,
- "p:new;x:%f;y:%f", in_pos.getX(), in_pos.getY());
- } else {
- out_pos = String.format(
- (Locale) null,
- "p:%d;x:%f;y:%f", in_pos.getPage(), in_pos.getX(), in_pos.getY());
- }
- } else {
- out_pos = "p:auto;x:auto;y:auto";
- }
-
- return out_pos;
- }
-
- /**
- * Get the Signature Profile ID for this set of parameters
- *
- * @return the Signature Profile ID
- */
- public String getPdfAsSignatureProfileId() {
- String lang = getSignatureLanguage();
- boolean useNote = (getProperty("SIG_NOTE") != null);
- boolean usePdfACompat = (getSignaturePdfACompat());
-
- //Add Signature Param here//
- String profileId;
-
- if (!PROFILE_VISIBILITY) {
- log.debug("Profile visibility was set to false");
- return Profile.INVISIBLE.name();
- }
-
- Profile profile = Profile.getProfile(this.profile);
- switch (profile) {
- case BASE_LOGO:
- case INVISIBLE:
- return this.profile;
- case AMTSSIGNATURBLOCK:
- profileId = this.profile;
- profileId += getLangProfilePart(lang);
- profileId += PROFILE_ID_RECOMMENDED;
- return profileId;
- default:
- profileId = this.profile;
- profileId += getLangProfilePart(lang);
- break;
- }
-
- if (useNote)
- profileId += PROFILE_ID_NOTE;
-
- if (usePdfACompat)
- profileId += PROFILE_ID_PDFA;
-
- log.debug("Profile ID: {}", profileId);
- return profileId;
- }
-
- private String getLangProfilePart(String lang) {
- return (lang != null && lang.equals("en")) ? PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE;
- }
-
- @Override
- public void setSignatureProfile(String profile) {
- this.profile = profile;
- }
-
- @Override
- public String getSignatureProfile() {
- return this.profile;
- }
-
-}
-
-
-
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
deleted file mode 100644
index 9943ec0e..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package at.asit.pdfover.signer.pdfas;
-
-import java.io.ByteArrayOutputStream;
-import java.util.UUID;
-
-import javax.activation.DataSource;
-
-import at.asit.pdfover.commons.Profile;
-import at.asit.pdfover.signator.ByteArrayDocumentSource;
-import at.asit.pdfover.signator.SignResult;
-import at.asit.pdfover.signator.SignResultImpl;
-import at.asit.pdfover.signator.SignatureException;
-import at.asit.pdfover.signator.SignatureParameter;
-import at.asit.pdfover.signator.SignaturePosition;
-import at.asit.pdfover.signator.Signer;
-import at.asit.pdfover.signator.SigningState;
-import at.gv.egiz.pdfas.common.exceptions.PDFASError;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
-import at.gv.egiz.pdfas.lib.api.Configuration;
-import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
-import at.gv.egiz.pdfas.lib.api.PdfAs;
-import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
-import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner;
-import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
-import at.gv.egiz.pdfas.sigs.pades.PAdESSigner;
-import at.gv.egiz.sl.util.ISLConnector;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-
-/**
- * PDF AS Signer Implementation
- */
-public class PdfAs4Signer implements Signer {
-
-
-
-
- /**
- * The template URL
- */
- protected static final String URL_TEMPLATE = "http://pdfover.4.gv.at/template";
-
- /**
- * Location reference string
- */
- protected static final String LOC_REF = "<sl:LocRefContent>" + URL_TEMPLATE
- + "</sl:LocRefContent>";
-
- @Override
- public SigningState prepare(SignatureParameter parameter)
- throws SignatureException {
- PdfAs4SignatureParameter sign_para = null;
-
- if (PdfAs4SignatureParameter.class.isInstance(parameter)) {
- sign_para = PdfAs4SignatureParameter.class.cast(parameter);
- }
-
- if (sign_para == null) {
- throw new SignatureException("Incorrect SignatureParameter!");
- }
-
- String sigProfile = sign_para.getPdfAsSignatureProfileId();
- String sigEmblem = (sign_para.getEmblem() == null ? null : sign_para.getEmblem().getFileName());
- String sigNote = sign_para.getProperty("SIG_NOTE");
- String sigPos = null;
- if (sign_para.getSignaturePosition() != null) {
- sigPos = sign_para.getPdfAsSignaturePosition();
- }
- PdfAs pdfas = PdfAs4Helper.getPdfAs();
- Configuration config = pdfas.getConfiguration();
- if (sigEmblem != null && !sigEmblem.trim().isEmpty()) {
- config.setValue("sig_obj." + sigProfile + ".value.SIG_LABEL", sigEmblem);
- }
-
- if(sigNote != null) {
- config.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote);
- }
-
- PdfAs4SigningState state = new PdfAs4SigningState();
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- DataSource input = new ByteArrayDataSource(parameter.getInputDocument().getByteArray());
- SignParameter param = PdfAsFactory.createSignParameter(config, input, output);
- if (sigPos != null) {
- param.setSignaturePosition(sigPos);
- }
- param.setSignatureProfileId(sigProfile);
- String id = UUID.randomUUID().toString();
- param.setTransactionId(id);
-
- if (parameter.isSearchForPlaceholderSignatures()) {
- param.getConfiguration().setValue(IConfigurationConstants.PLACEHOLDER_MODE, "1");
- param.getConfiguration().setValue(IConfigurationConstants.PLACEHOLDER_SEARCH_ENABLED, IConfigurationConstants.TRUE);
- }
-
- state.setSignParameter(param);
- state.setOutput(output);
- return state;
- }
-
- @Override
- public SignResult sign(SigningState state) throws SignatureException {
- try {
- PdfAs4SigningState sstate = null;
-
- if (PdfAs4SigningState.class.isInstance(state)) {
- sstate = PdfAs4SigningState.class.cast(state);
- }
-
- if (sstate == null) {
- throw new SignatureException("Incorrect SigningState!");
- }
-
- // Retrieve objects
- PdfAs pdfas = PdfAs4Helper.getPdfAs();
-
- SignParameter param = sstate.getSignParameter();
-
- Configuration config = param.getConfiguration();
- config.setValue(IConfigurationConstants.SL_REQUEST_TYPE,
- sstate.getUseBase64Request() ?
- IConfigurationConstants.SL_REQUEST_TYPE_BASE64 :
- IConfigurationConstants.SL_REQUEST_TYPE_UPLOAD);
-
- IPlainSigner signer;
- if (sstate.hasBKUConnector()) {
- ISLConnector connector = new PdfAs4BKUSLConnector(sstate.getBKUConnector());
- signer = new PAdESSigner(connector);
- } else if (sstate.hasKSSigner()) {
- signer = sstate.getKSSigner();
- } else {
- throw new SignatureException("SigningState doesn't have a signer");
- }
- param.setPlainSigner(signer);
-
- pdfas.sign(param);
-
- SignResultImpl result = new SignResultImpl();
-
- if (param.getSignaturePosition() != null) {
- TablePos tp = new TablePos(param.getSignaturePosition());
- SignaturePosition sp;
- if (tp.isXauto() && tp.isYauto())
- sp = new SignaturePosition();
- else if (tp.isPauto())
- sp = new SignaturePosition(tp.getPosX(), tp.getPosY());
- else if (param.getSignatureProfileId().contains(Profile.AMTSSIGNATURBLOCK.name()))
- sp = new SignaturePosition();
- else
- sp = new SignaturePosition(tp.getPosX(), tp.getPosY(), tp.getPage());
- result.setSignaturePosition(sp);
- }
-
- result.setSignedDocument(new ByteArrayDocumentSource(sstate.getOutput().toByteArray()));
- return result;
- } catch (PdfAsException | PDFASError e) {
- throw new SignatureException(e);
- }
- }
-
- @Override
- public SignatureParameter newParameter() {
- return new PdfAs4SignatureParameter();
- }
-}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java
deleted file mode 100644
index 3fa7ce16..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signer.pdfas;
-
-//Imports
-import at.asit.pdfover.signator.Signer;
-import at.asit.pdfover.signator.SignerFactory;
-
-/**
- * Factory class for PDF-AS Signer
- */
-public class PdfAs4SignerFactory extends SignerFactory {
-
- @Override
- public Signer createSigner() {
- return new PdfAs4Signer();
- }
-}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java
deleted file mode 100644
index f0aff1c8..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signer.pdfas;
-
-//Imports
-import java.io.ByteArrayOutputStream;
-
-import at.asit.pdfover.signator.BkuSlConnector;
-import at.asit.pdfover.signator.SLRequest;
-import at.asit.pdfover.signator.SLResponse;
-import at.asit.pdfover.signator.SignatureException;
-import at.asit.pdfover.signator.SigningState;
-import at.gv.egiz.pdfas.common.exceptions.PDFASError;
-import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner;
-import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
-import at.gv.egiz.pdfas.sigs.pades.PAdESSignerKeystore;
-
-/**
- * Signing State for PDFAS Wrapper
- */
-public class PdfAs4SigningState implements SigningState {
-
- /**
- * The Signature Layer request
- */
- private SLRequest slrequest;
-
- /**
- * The Signature Layer response
- */
- private SLResponse slresponse;
-
- /**
- * The Sign Parameters
- */
- private SignParameter parameter;
-
- private ByteArrayOutputStream output;
-
- private BkuSlConnector bkuconnector = null;
-
- private IPlainSigner kssigner = null;
-
- private boolean useBase64Request;
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SigningState#getSignatureRequest()
- */
- @Override
- public SLRequest getSignatureRequest() {
- return this.slrequest;
- }
-
- /**
- * Sets the SL Request
- * @param request The SL Request
- */
- public void setSignatureRequest(SLRequest request) {
- this.slrequest = request;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SigningState#setUseBase64Request(boolean)
- */
- @Override
- public void setUseBase64Request(boolean useBase64Request) {
- this.useBase64Request = useBase64Request;
- }
-
- /**
- * Gets whether to use base64 (or FileUpload) for request data
- * @return whether to use base64 for request data
- */
- public boolean getUseBase64Request() {
- return this.useBase64Request;
- }
-
- /**
- * Gets the SL Response
- * @return The SL Response object
- */
- public SLResponse getSignatureResponse() {
- return this.slresponse;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SigningState#setSignatureResponse(at.asit.pdfover.signator.SLResponse)
- */
- @Override
- public void setSignatureResponse(SLResponse response) {
- this.slresponse = response;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SigningState#hasSignatureResponse()
- */
- @Override
- public boolean hasSignatureResponse() {
- return this.slresponse != null;
- }
-
- /**
- * @return the output
- */
- public ByteArrayOutputStream getOutput() {
- return this.output;
- }
-
- /**
- * @param output the output to set
- */
- public void setOutput(ByteArrayOutputStream output) {
- this.output = output;
- }
-
- /**
- * @return the parameter
- */
- public SignParameter getSignParameter() {
- return this.parameter;
- }
-
- /**
- * @param parameter the parameter to set
- */
- public void setSignParameter(SignParameter parameter) {
- this.parameter = parameter;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SigningState#setBKUConnector(at.asit.pdfover.signator.BkuSlConnector)
- */
- @Override
- public void setBKUConnector(BkuSlConnector connector) {
- this.bkuconnector = connector;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SigningState#setKSSigner(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public void setKSSigner(String file, String alias, String kspassword,
- String keypassword, String type) throws SignatureException {
- try {
- this.kssigner = new PAdESSignerKeystore(file, alias, kspassword, keypassword, type);
- } catch (PDFASError e) {
- throw new SignatureException(e);
- }
- }
-
- /**
- * @return whether a BKU connector was set
- */
- public boolean hasBKUConnector() {
- return this.bkuconnector != null;
- }
-
- /**
- * @return the BKU connector
- */
- public BkuSlConnector getBKUConnector() {
- return this.bkuconnector;
- }
-
- /**
- * @return whether a KS signer was set
- */
- public boolean hasKSSigner() {
- return this.kssigner != null;
- }
-
- /**
- * @return the KS signer
- */
- public IPlainSigner getKSSigner() {
- return this.kssigner;
- }
-
-}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java
deleted file mode 100644
index ab50e78b..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signer.pdfas.exceptions;
-
-/**
- *
- */
-public class PdfAs4SLRequestException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = 6855855001105199269L;
-
- /**
- * Constructor
- * @param msg
- */
- public PdfAs4SLRequestException(String msg) {
- super(msg);
- }
-}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer b/pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer
deleted file mode 100644
index e083c81e..00000000
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer
+++ /dev/null
@@ -1,19 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDJjCCAg4CCQDj2QcuXR0CJjANBgkqhkiG9w0BAQsFADBVMQswCQYDVQQGEwJB
-VDEPMA0GA1UECAwGU3R5cmlhMQ0wCwYDVQQHDARHcmF6MQ0wCwYDVQQKDARFR0la
-MRcwFQYDVQQDDA5NYXggTXVzdGVybWFubjAeFw0xNDExMDYwOTQyMTVaFw0yNDEx
-MDMwOTQyMTVaMFUxCzAJBgNVBAYTAkFUMQ8wDQYDVQQIDAZTdHlyaWExDTALBgNV
-BAcMBEdyYXoxDTALBgNVBAoMBEVHSVoxFzAVBgNVBAMMDk1heCBNdXN0ZXJtYW5u
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwKREoPZyoxmmXiULkXA/
-onwGn+J9pXX2f9AZ7ktHhoRmV3ZJgfv2rCcSO1gAwRUyJY2MFfaDMfQchooHS7e0
-+nOFKfHt5QtwkK6TYImWiFZRjoTgsDW8tTFrrR82k6LNUi5Upj3l6t7mxOdWdJBA
-U0cmqALW5QQTbnbeJFVlCrTiIRBgB+G+jXBu8C64/HS5rbUUccPXxU8Mi3OnUVVd
-R9AL5RothHeCIcw19rAXaU7+o/jNPeTm5mdJqG+3+mca7qBBszvOPCTnMj81fdmX
-R7NWCkkT8gAlB602IBhWUUx/Az8zVglsDoL61RNXn5EA2Ajq75qUkalN5zJNytie
-AQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBZuxsCprwxByxRab8S97HP1Qpb8dlM
-TVdqCYMRNCik4e7l04OAJdX62H1xtL3npoT0C+pM+fkUNk9E18UTvA3jyeQXJ6f+
-z1nzdTbHVE1HANveqvUgq+LqTCTfVLk09mFmEIZnkPVd97XarmxrfCJbCaiYljka
-b63ER+87QE9YiN38nZpIlocOcI9QQVpE8boRCjgyJF3i84lIbKgwM32nWs0Sz+p1
-ewWHeQw3oziie3MfH3Xkag341i/k+7VF0FxLuPn7DZB4M5pZmjy0DNA/bdhGNu96
-pOjb/TWp18KMqCMrMAGLz/cjgWqbC4KkzPUtYx6HmCdtVXHWwRV7Lgto
------END CERTIFICATE-----