diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-08-19 11:07:20 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-08-19 11:07:20 +0200 |
commit | e1b810ee9221f6247c575c669bff2ba98552c65e (patch) | |
tree | 32ddf763ccffe68e03d1a89f3b0c67f24417cab1 | |
parent | 5b455cba0b88255f58d1f9e00ab41770678b8828 (diff) | |
download | pdf-as-4-e1b810ee9221f6247c575c669bff2ba98552c65e.tar.gz pdf-as-4-e1b810ee9221f6247c575c669bff2ba98552c65e.tar.bz2 pdf-as-4-e1b810ee9221f6247c575c669bff2ba98552c65e.zip |
Web config changes
8 files changed, 114 insertions, 39 deletions
diff --git a/doc/PDFAS4_WebDokumentation.docx b/doc/PDFAS4_WebDokumentation.docx Binary files differindex 20699bc5..2be45f60 100644 --- a/doc/PDFAS4_WebDokumentation.docx +++ b/doc/PDFAS4_WebDokumentation.docx diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java index 96c31348..4b3eefb2 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java @@ -45,6 +45,8 @@ public interface IConfigurationConstants { public static final String PLACEHOLDER_SEARCH_ENABLED = "enable_placeholder_search"; public static final String DEFAULT_SIGNATURE_PROFILE = SIG_OBJECT + SEPERATOR + TYPE + SEPERATOR + DEFAULT; + public static final String CONFIG_BKU_URL = "bku.sign.url"; + /** * Signature object Prefix */ @@ -66,6 +68,8 @@ public interface IConfigurationConstants { */ public static final String MOA_TRUSTPROFILE_ID = "moa.verify.TrustProfileID"; + public static final String MOA_SIGN_KEY_ID = MOA_SS_KEY_IDENTIFIER; + public static final String MOA_SIGN_CERTIFICATE = MOA_SS_KEY_CERTIFICATE; /** * MOA Verify URL configuration Key @@ -78,4 +82,7 @@ public interface IConfigurationConstants { */ public static final String MOA_SIGN_URL = "moa.sign.url"; + public static final String MOC_SIGN_URL = "moc.sign.url"; + public static final String MOBILE_SIGN_URL = "mobile.sign.url"; + } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java index c8c4eeb4..af32aaa5 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java @@ -42,6 +42,8 @@ import org.apache.pdfbox.pdmodel.PDDocumentCatalog; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageNode; import org.apache.pdfbox.pdmodel.PDResources; +import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement; +import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot; import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent; import org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceCharacteristicsDictionary; @@ -73,6 +75,7 @@ import at.gv.egiz.pdfas.lib.impl.stamping.TableFactory; import at.gv.egiz.pdfas.lib.impl.stamping.ValueResolver; import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PDFAsVisualSignatureProperties; import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PdfBoxVisualObject; +import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.tagging.PDFBoxTaggingUtils; import at.gv.egiz.pdfas.lib.impl.status.PDFObject; import at.gv.egiz.pdfas.lib.impl.status.RequestedSignature; import at.gv.egiz.pdfas.lib.util.SignatureUtils; @@ -137,7 +140,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { signer.setPDSignature(signature); SignatureOptions options = new SignatureOptions(); - + // Is visible Signature if (requestedSignature.isVisual()) { logger.info("Creating visual siganture block"); @@ -231,14 +234,14 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { position.setWidth(visualObject.getWidth()); requestedSignature.setSignaturePosition(position); - + PDFAsVisualSignatureProperties properties = new PDFAsVisualSignatureProperties( pdfObject.getStatus().getSettings(), pdfObject, (PdfBoxVisualObject) visualObject, positioningInstruction); properties.buildSignature(); - + /* * ByteArrayOutputStream sigbos = new ByteArrayOutputStream(); * sigbos.write(StreamUtils.inputStreamToByteArray(properties @@ -314,36 +317,37 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { } } - /* - * if(signatureProfileSettings.isPDFA()) { // Check for PDF-UA - * PDDocumentCatalog root = doc.getDocumentCatalog(); - * PDStructureTreeRoot treeRoot = root.getStructureTreeRoot(); - * if(treeRoot != null) { // Handle as PDF-UA - * logger.info("Tree Root: {}", treeRoot.toString()); - * PDStructureElement docElement = - * PDFBoxTaggingUtils.getDocumentElement(treeRoot); - * PDStructureElement sigBlock = new PDStructureElement("Table", - * docElement); root.getCOSObject().setNeedToBeUpdate(true); - * docElement.getCOSObject().setNeedToBeUpdate(true); - * treeRoot.getCOSObject().setNeedToBeUpdate(true); - * sigBlock.setTitle("Signature Table"); } } - */ +// if (signatureProfileSettings.isPDFA()) { // Check for PDF-UA +// PDDocumentCatalog root = doc.getDocumentCatalog(); +// PDStructureTreeRoot treeRoot = root.getStructureTreeRoot(); +// if (treeRoot != null) { // Handle as PDF-UA +// logger.info("Tree Root: {}", treeRoot.toString()); +// PDStructureElement docElement = PDFBoxTaggingUtils +// .getDocumentElement(treeRoot); +// PDStructureElement sigBlock = new PDStructureElement( +// "Table", docElement); +// root.getCOSObject().setNeedToBeUpdate(true); +// docElement.getCOSObject().setNeedToBeUpdate(true); +// treeRoot.getCOSObject().setNeedToBeUpdate(true); +// sigBlock.setTitle("Signature Table"); +// } +// } options.setPreferedSignatureSize(0x1000); options.setPage(positioningInstruction.getPage()); options.setVisualSignature(properties.getVisibleSignature()); } - + doc.addSignature(signature, signer, options); - + String sigFieldName = signatureProfileSettings.getSignFieldValue(); if (sigFieldName == null) { sigFieldName = "PDF-AS Signatur"; } - + int count = SignatureUtils.countSignatures(doc, sigFieldName); - + sigFieldName = sigFieldName + count; PDAcroForm acroFormm = doc.getDocumentCatalog().getAcroForm(); @@ -372,7 +376,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { } else { logger.warn("Failed to name Signature Field! [Cannot find acroForm!]"); } - + if (requestedSignature.isVisual()) { // if(requestedSignature.getSignaturePosition().) diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java index 204fd727..bffb2974 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java @@ -57,8 +57,6 @@ public class BKUSLConnector extends BaseSLConnector { private static final Logger logger = LoggerFactory .getLogger(BKUSLConnector.class); - public static final String CONFIG_BKU_URL = "bku.sign.url"; - private String bkuUrl; public BKUSLConnector(Configuration config) { diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java index 99cdb9f8..a5036005 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java @@ -30,14 +30,11 @@ import org.slf4j.LoggerFactory; import at.gv.egiz.pdfas.common.exceptions.PDFIOException; 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.Base64OptRefContentType; -import at.gv.egiz.sl.schema.Base64XMLLocRefContentType; -import at.gv.egiz.sl.schema.Base64XMLLocRefOptRefContentType; -import at.gv.egiz.sl.schema.CMSDataObjectOptionalMetaType; import at.gv.egiz.sl.schema.CMSDataObjectRequiredMetaType; import at.gv.egiz.sl.schema.CreateCMSSignatureRequestType; -import at.gv.egiz.sl.schema.DataObjectInfoType; import at.gv.egiz.sl.schema.ExcludedByteRangeType; import at.gv.egiz.sl.schema.InfoboxReadParamsAssocArrayType; import at.gv.egiz.sl.schema.InfoboxReadParamsAssocArrayType.ReadValue; @@ -45,7 +42,7 @@ import at.gv.egiz.sl.schema.InfoboxReadRequestType; import at.gv.egiz.sl.schema.MetaInfoType; import at.gv.egiz.sl.schema.ObjectFactory; -public abstract class BaseSLConnector implements ISLConnector { +public abstract class BaseSLConnector implements ISLConnector, IConfigurationConstants { private static final Logger logger = LoggerFactory .getLogger(BaseSLConnector.class); diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java index 70b40876..7970b567 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java @@ -60,22 +60,19 @@ import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException; import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.common.utils.StreamUtils; import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.IConfigurationConstants; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; import at.gv.egiz.pdfas.lib.api.verify.VerifyResult; import at.gv.egiz.pdfas.lib.impl.status.RequestedSignature; import at.gv.egiz.pdfas.lib.util.SignatureUtils; -public class MOAConnector implements ISignatureConnector { +public class MOAConnector implements ISignatureConnector, IConfigurationConstants { private static final Logger logger = LoggerFactory .getLogger(MOAConnector.class); private static final Logger moalogger = LoggerFactory.getLogger("at.knowcenter.wag.egov.egiz.sig.connectors.MOASSRepsonseLogger"); - public static final String MOA_SIGN_URL = "moa.sign.url"; - public static final String MOA_SIGN_KEY_ID = "moa.sign.KeyIdentifier"; - public static final String MOA_SIGN_CERTIFICATE = "moa.sign.Certificate"; - public static final String KEY_ID_PATTERN = "##KEYID##"; public static final String CONTENT_PATTERN = "##CONTENT##"; diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java index 3a64c422..6306852e 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java @@ -33,9 +33,15 @@ import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class WebConfiguration { +import at.gv.egiz.pdfas.lib.api.IConfigurationConstants; +import at.gv.egiz.pdfas.web.helper.PdfAsHelper; + +public class WebConfiguration implements IConfigurationConstants { public static final String PUBLIC_URL = "public.url"; + public static final String LOCAL_BKU_ENABLED = "bku.sign.enabled"; + public static final String ONLINE_BKU_ENABLED = "moc.sign.enabled"; + public static final String MOBILE_BKU_ENABLED = "mobile.sign.enabled"; public static final String LOCAL_BKU_URL = "bku.local.url"; public static final String ONLINE_BKU_URL = "bku.online.url"; public static final String MOBILE_BKU_URL = "bku.mobile.url"; @@ -151,15 +157,45 @@ public class WebConfiguration { } public static String getLocalBKUURL() { - return properties.getProperty(LOCAL_BKU_URL); + if(!getLocalBKUEnabled()) { + String overwrite = properties.getProperty(CONFIG_BKU_URL); + if(overwrite == null) { + overwrite = properties.getProperty(LOCAL_BKU_URL); + if(overwrite == null) { + overwrite = PdfAsHelper.getPdfAsConfig().getValue(CONFIG_BKU_URL); + } + } + return overwrite; + } + return null; } public static String getOnlineBKUURL() { - return properties.getProperty(ONLINE_BKU_URL); + if(!getOnlineBKUEnabled()) { + String overwrite = properties.getProperty(MOC_SIGN_URL); + if(overwrite == null) { + overwrite = properties.getProperty(ONLINE_BKU_URL); + if(overwrite == null) { + overwrite = PdfAsHelper.getPdfAsConfig().getValue(MOC_SIGN_URL); + } + } + return overwrite; + } + return null; } public static String getHandyBKUURL() { - return properties.getProperty(MOBILE_BKU_URL); + if(!getMobileBKUEnabled()) { + String overwrite = properties.getProperty(MOBILE_SIGN_URL); + if(overwrite == null) { + overwrite = properties.getProperty(MOBILE_BKU_URL); + if(overwrite == null) { + overwrite = PdfAsHelper.getPdfAsConfig().getValue(MOBILE_SIGN_URL); + } + } + return overwrite; + } + return null; } public static String getPdfASDir() { @@ -206,6 +242,36 @@ public class WebConfiguration { return false; } + public static boolean getLocalBKUEnabled() { + String value = properties.getProperty(LOCAL_BKU_ENABLED); + if (value != null) { + if (value.equals("true")) { + return true; + } + } + return false; + } + + public static boolean getOnlineBKUEnabled() { + String value = properties.getProperty(ONLINE_BKU_ENABLED); + if (value != null) { + if (value.equals("true")) { + return true; + } + } + return false; + } + + public static boolean getMobileBKUEnabled() { + String value = properties.getProperty(MOBILE_BKU_ENABLED); + if (value != null) { + if (value.equals("true")) { + return true; + } + } + return false; + } + public static boolean getSoapSignEnabled() { String value = properties.getProperty(SOAP_SIGN_ENABLED); if (value != null) { diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java index 6b63255f..83dd2610 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java @@ -118,7 +118,8 @@ public class PdfAsHelper { private static PdfAs pdfAs; private static ObjectFactory of = new ObjectFactory(); - + private static Configuration pdfAsConfig; + static { reloadConfig(); } @@ -131,9 +132,14 @@ public class PdfAsHelper { logger.info("Creating PDF-AS"); pdfAs = PdfAsFactory.createPdfAs(new File(WebConfiguration .getPdfASDir())); + pdfAsConfig = pdfAs.getConfiguration(); logger.info("Creating PDF-AS done"); } + public static Configuration getPdfAsConfig() { + return pdfAsConfig; + } + private static void validatePdfSize(HttpServletRequest request, HttpServletResponse response, byte[] pdfData) throws PdfAsWebException { |