aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib
diff options
context:
space:
mode:
authorbschnalzer <bianca.schnalzer@egiz.gv.at>2017-08-09 13:56:12 +0200
committerbschnalzer <bianca.schnalzer@egiz.gv.at>2017-08-09 13:56:14 +0200
commit7fe464cc98d714179b907c142bdd2fabfd009aa3 (patch)
tree328c53a9b60dfa1106c6b9d930d75ab127dce33f /pdf-as-lib
parent17be060a4d2d79ee75036a2f785d4a4913f7935f (diff)
downloadpdf-as-4-7fe464cc98d714179b907c142bdd2fabfd009aa3.tar.gz
pdf-as-4-7fe464cc98d714179b907c142bdd2fabfd009aa3.tar.bz2
pdf-as-4-7fe464cc98d714179b907c142bdd2fabfd009aa3.zip
Fixed problem with PAdES Signatures, removed some attributes from CAdES signatures which are not required, minor bug fixes, implemented new style (lineCenter)4.1.1-RC
Diffstat (limited to 'pdf-as-lib')
-rw-r--r--pdf-as-lib/libs/iaik_jce_full.jarbin1129729 -> 1283803 bytes
-rw-r--r--pdf-as-lib/src/configuration/cfg/config.properties7
-rw-r--r--pdf-as-lib/src/configuration/cfg/profiles/BASE_NORMAL.properties4
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java16
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java42
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java34
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/settings/Settings.java1
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/schema/CreateCMSSignatureRequestType.java37
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java9
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java71
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java13
-rw-r--r--pdf-as-lib/src/main/resources/config/config.zipbin1276538 -> 1276506 bytes
12 files changed, 198 insertions, 36 deletions
diff --git a/pdf-as-lib/libs/iaik_jce_full.jar b/pdf-as-lib/libs/iaik_jce_full.jar
index 18cb0a0b..ec92882e 100644
--- a/pdf-as-lib/libs/iaik_jce_full.jar
+++ b/pdf-as-lib/libs/iaik_jce_full.jar
Binary files differ
diff --git a/pdf-as-lib/src/configuration/cfg/config.properties b/pdf-as-lib/src/configuration/cfg/config.properties
index a5275aff..f9eaeb98 100644
--- a/pdf-as-lib/src/configuration/cfg/config.properties
+++ b/pdf-as-lib/src/configuration/cfg/config.properties
@@ -26,10 +26,6 @@ bku.sign.url=http://127.0.0.1:3495/http-security-layer-request
# Verifikation
bku.verify.url=http://127.0.0.1:3495/http-security-layer-request
-##
-# Online BKU (MOCCA)
-# Signatur
-moc.sign.url=http://127.0.0.1:8080/bkuonline/http-security-layer-request
##
# Handy-Signatur
@@ -104,4 +100,5 @@ include.01 = profiles/*.properties
#include.22 = profiles/justizsignatur.properties
# Legt das Standard-Signaturprofil fest
-sig_obj.type.default=SIGNATURBLOCK_SMALL_DE
+sig_obj.type.default=SIGNATURBLOCK_SMALL_DE_NOTE
+
diff --git a/pdf-as-lib/src/configuration/cfg/profiles/BASE_NORMAL.properties b/pdf-as-lib/src/configuration/cfg/profiles/BASE_NORMAL.properties
index b85fc381..36304b66 100644
--- a/pdf-as-lib/src/configuration/cfg/profiles/BASE_NORMAL.properties
+++ b/pdf-as-lib/src/configuration/cfg/profiles/BASE_NORMAL.properties
@@ -82,9 +82,9 @@ sig_obj.BASE_NORMAL.table.main.Style.border=0.1
## Horizontale Ausrichtung der Eintraege im Signaturblock.
#
# sig_obj.PROFILE.table.TABLE_NAME.Style.halign=[left|center|right]
-# sig_obj.PROFILE.table.TABLE_NAME.Style.valuehalign=[left|center|right]
+# sig_obj.PROFILE.table.TABLE_NAME.Style.valuehalign=[left|lineCenter|center|right]
# sig_obj.PROFILE.table.TABLE_NAME.Style.imagehalign=[left|center|right]
-sig_obj.BASE_NORMAL.table.main.Style.halign=center
+sig_obj.BASE_NORMAL.table.main.Style.halign=right
## Vertikale Ausrichtung der Eintraege im Signaturblock.
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 14aca130..364acb44 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
@@ -50,15 +50,10 @@ 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
- */
- public static final String SIG_OBJECT_PREFIX = "sig_obj.";
-
- /**
* MOA SS Signing Key Identifier
*/
public static final String MOA_SS_KEY_IDENTIFIER = "moa.sign.KeyIdentifier";
@@ -103,10 +98,17 @@ public interface IConfigurationConstants {
* Signature object Prefix
*/
public static final String SIG_RESERVED_SIZE = "signatureSize";
-
+
/**
* Visual Signature placement
*/
public static final String BG_COLOR_DETECTION = "sigblock.placement.bgcolor.detection.enabled";
public static final String SIG_PLACEMENT_DEBUG_OUTPUT = "sigblock.placement.debug.file";
+
+
+ /**
+ * PADES Constants
+ */
+ public static final String SIG_PADES_FORCE_FLAG= SIG_OBJECT + SEPERATOR+"PAdESCompatibility";
+ public static final String SIG_PADES_INTELL_FLAG = SIG_OBJECT + SEPERATOR+"CheckPAdESCompatibility";
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java
index ec030388..6e91e808 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java
@@ -24,7 +24,23 @@
package at.gv.egiz.pdfas.lib.impl.configuration;
import at.gv.egiz.pdfas.common.settings.ISettings;
+import at.gv.egiz.pdfas.common.settings.Profiles;
+import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
+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.impl.PdfAsImpl;
+import at.gv.egiz.pdfas.lib.impl.PdfAsParameterImpl;
+import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
+import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
+import at.gv.egiz.pdfas.lib.settings.Settings;
+import at.gv.egiz.pdfas.lib.util.SignatureUtils;
+import at.gv.egiz.pdfas.lib.api.PdfAs;
+import com.sun.corba.se.spi.orb.Operation;
+
+import java.security.Signature;
+import java.util.Properties;
+
public class PlaceholderConfiguration extends SpecificBaseConfiguration
implements IConfigurationConstants {
@@ -34,13 +50,33 @@ public class PlaceholderConfiguration extends SpecificBaseConfiguration
}
public boolean isGlobalPlaceholderEnabled() {
- if(configuration.hasValue(PLACEHOLDER_SEARCH_ENABLED)) {
+ if (configuration.hasValue(PLACEHOLDER_SEARCH_ENABLED)) {
String value = configuration.getValue(PLACEHOLDER_SEARCH_ENABLED);
- if(value.equalsIgnoreCase(TRUE)) {
+ if (value.equalsIgnoreCase(TRUE)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * Match selected Profile for Placeholder
+ * Enables to activate placeholder search/match for different profiles
+ * @return
+ */
+ public boolean isProfileConfigurationEnabled(String selectedProfileID)
+ {
+ String profileMatch = SIG_OBJECT+SEPERATOR+selectedProfileID+SEPERATOR+PLACEHOLDER_SEARCH_ENABLED;
+ if (configuration.hasValue(profileMatch)) {
+ String value = configuration.getValue(profileMatch);
+ if (value.equalsIgnoreCase(TRUE)) {
return true;
}
}
return false;
}
-
}
+
+
+
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
index 19ea496d..9906fd6a 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
@@ -63,7 +63,35 @@ public class PlaceholderFilter implements IConfigurationConstants,
.extract(status.getPdfObject(), placeholderID, placeholderMode);
return signaturePlaceholderData;
- }
+ } else
+ //filter for local placeholder in selected profiles
+ if (status.getPlaceholderConfiguration().isProfileConfigurationEnabled(status.getRequestedSignature().getSignatureProfileID())) {
+ PlaceholderExtractor extractor = status.getBackend()
+ .getPlaceholderExtractor();
+ String placeholderID = settings.getValue(PLACEHOLDER_ID);
+ String placeholderModeString = settings.getValue(PLACEHOLDER_MODE);
+ int placeholderMode = PLACEHOLDER_MATCH_MODE_MODERATE;
+ if (placeholderModeString != null) {
+ try {
+ placeholderMode = Integer.parseInt(placeholderModeString);
+
+ if (placeholderMode < PLACEHOLDER_MODE_MIN
+ || placeholderMode > PLACEHOLDER_MODE_MAX) {
+ throw new PdfAsErrorCarrier(new PDFASError(
+ PDFASError.ERROR_INVALID_PLACEHOLDER_MODE));
+ }
+ } catch (NumberFormatException e) {
+ throw new PdfAsErrorCarrier(new PDFASError(
+ PDFASError.ERROR_INVALID_PLACEHOLDER_MODE, e));
+ }
+ }
+ SignaturePlaceholderData signaturePlaceholderData = extractor
+ .extract(status.getPdfObject(), placeholderID, placeholderMode);
+
+ return signaturePlaceholderData;
+
+
+
+ }
return null;
- }
-}
+ }} \ No newline at end of file
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/settings/Settings.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/settings/Settings.java
index c5879783..c5b6dc57 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/settings/Settings.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/settings/Settings.java
@@ -399,6 +399,7 @@ public class Settings implements ISettings, IProfileConstants {
while (keyIterator.hasNext()) {
String key = keyIterator.next().toString();
+
if (key.startsWith(prefix)) {
valueMap.put(key, props.getProperty(key));
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/schema/CreateCMSSignatureRequestType.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/schema/CreateCMSSignatureRequestType.java
index cbfb1f53..5d565d9d 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/schema/CreateCMSSignatureRequestType.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/schema/CreateCMSSignatureRequestType.java
@@ -31,6 +31,8 @@
package at.gv.egiz.sl.schema;
+import com.sun.org.apache.xpath.internal.operations.Bool;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@@ -82,14 +84,17 @@ public class CreateCMSSignatureRequestType {
protected CMSDataObjectRequiredMetaType dataObject;
@XmlAttribute(name = "Structure", required = true)
protected String structure;
+ //PAdES Signatures
+ @XmlAttribute(name = "PAdESCompatibility", required = false)
+ private Boolean PAdESFlag;
/**
* Gets the value of the keyboxIdentifier property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getKeyboxIdentifier() {
return keyboxIdentifier;
@@ -97,11 +102,11 @@ public class CreateCMSSignatureRequestType {
/**
* Sets the value of the keyboxIdentifier property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setKeyboxIdentifier(String value) {
this.keyboxIdentifier = value;
@@ -109,11 +114,11 @@ public class CreateCMSSignatureRequestType {
/**
* Gets the value of the dataObject property.
- *
+ *
* @return
* possible object is
* {@link CMSDataObjectRequiredMetaType }
- *
+ *
*/
public CMSDataObjectRequiredMetaType getDataObject() {
return dataObject;
@@ -121,11 +126,11 @@ public class CreateCMSSignatureRequestType {
/**
* Sets the value of the dataObject property.
- *
+ *
* @param value
* allowed object is
* {@link CMSDataObjectRequiredMetaType }
- *
+ *
*/
public void setDataObject(CMSDataObjectRequiredMetaType value) {
this.dataObject = value;
@@ -133,11 +138,11 @@ public class CreateCMSSignatureRequestType {
/**
* Gets the value of the structure property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getStructure() {
return structure;
@@ -145,14 +150,22 @@ public class CreateCMSSignatureRequestType {
/**
* Sets the value of the structure property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setStructure(String value) {
this.structure = value;
}
+
+ public Boolean getPAdESFlag() {
+ return PAdESFlag;
+ }
+
+ public void setPAdESFlag(Boolean PAdESFlag) {
+ this.PAdESFlag = PAdESFlag;
+ }
}
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 6383b89b..4a32390b 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
@@ -164,14 +164,23 @@ public class BKUSLConnector extends BaseSLConnector {
BKUHeader hdr = new BKUHeader(headers[i].getName(),
headers[i].getValue());
logger.debug("Response Header : {}", hdr.toString());
+ if (hdr.toString().contains("Server"))
+ {
+ BaseSLConnector.responseHeader=hdr.toString();
+ }
+
holder.getProcessInfo().add(hdr);
+
}
+
}
BKUHeader hdr = new BKUHeader(
ErrorConstants.STATUS_INFO_SIGDEVICE, SIGNATURE_DEVICE);
logger.debug("Response Header : {}", hdr.toString());
+
holder.getProcessInfo().add(hdr);
+
}
BufferedReader rd = new BufferedReader(new InputStreamReader(
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 d6c21672..46857249 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
@@ -24,6 +24,9 @@
package at.gv.egiz.sl.util;
import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,6 +61,11 @@ public abstract class BaseSLConnector implements ISLConnector,
public static final String XMLREQUEST = "XMLRequest";
+ public static final String WHITELIST_VERSION_ENABLED = "whitelistVersion.enabled";
+ public static final String WHITELIST_VALUE_PRE = "whiteListVersions";
+ private static List<String> whiteListregEx = new ArrayList<String>();
+ public static String responseHeader;
+
protected ObjectFactory of = new ObjectFactory();
public InfoboxReadRequestType createInfoboxReadRequest(
@@ -92,7 +100,6 @@ public abstract class BaseSLConnector implements ISLConnector,
logger.info("Exclude Byte Range: " + exclude_range[0] + " "
+ exclude_range[1]);
- // == MetaInfoType
MetaInfoType metaInfoType = new MetaInfoType();
metaInfoType.setMimeType(PDF_MIME_TYPE);
@@ -122,12 +129,74 @@ public abstract class BaseSLConnector implements ISLConnector,
}
// == CreateCMSSignatureRequestType
+
CreateCMSSignatureRequestType request = new CreateCMSSignatureRequestType();
request.setKeyboxIdentifier(SecureSignatureKeypair);
request.setDataObject(cmsDataObjectRequiredMetaType);
request.setStructure(DETACHED);
+
+
+ //whiteListregEx.add("1.2 MOCCA");
+ if (parameter.getConfiguration().hasValue(IConfigurationConstants.SIG_PADES_FORCE_FLAG))
+ {
+ if (IConfigurationConstants.TRUE.equalsIgnoreCase(parameter.getConfiguration().getValue(IConfigurationConstants.SIG_PADES_FORCE_FLAG)))
+ {
+ request.setPAdESFlag(true);
+ }
+ }
+ else
+ if (parameter.getConfiguration().hasValue(IConfigurationConstants.SIG_PADES_INTELL_FLAG)){
+ if (IConfigurationConstants.TRUE.equalsIgnoreCase(parameter.getConfiguration().getValue(IConfigurationConstants.SIG_PADES_INTELL_FLAG)))
+ {
+ boolean intellFlag=isProvidePdfVersionInWhitelist(responseHeader, parameter);
+
+ if (intellFlag)
+ {
+ request.setPAdESFlag(true);
+ }
+ }}
+
pack.setRequestType(request);
return pack;
}
+
+
+ public static boolean isWhiteListEnabled(SignParameter parameter) {
+
+ boolean whiteListConfig = parameter.getConfiguration().hasValue(WHITELIST_VERSION_ENABLED);
+ if (whiteListConfig)
+ {
+ String value = parameter.getConfiguration().getValue(WHITELIST_VERSION_ENABLED);
+
+ if (value != null) {
+ if (value.equals("true")) {
+ whiteListregEx.add(parameter.getConfiguration().getValue(WHITELIST_VALUE_PRE));
+ return true;
+ }
+ }}
+ return false;
+
+ }
+
+ public static synchronized boolean isProvidePdfVersionInWhitelist(String bkuVersionInformation, SignParameter parameter) {
+ if (isWhiteListEnabled(parameter)) {
+
+ Iterator<String> patterns = whiteListregEx.iterator();
+ while (patterns.hasNext()) {
+ String pattern = patterns.next();
+ try {
+ if (bkuVersionInformation.contains(pattern)) {
+ return true;
+ }
+ //TODO: extend with BlackList
+
+ } catch (Throwable e) {
+ logger.warn("Error in matching regex: " + pattern, e);
+ }
+ }
+ return false;
+ }
+ return true;
+ }
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java
index 2dded8ae..a3af957d 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/table/Style.java
@@ -74,7 +74,12 @@ public class Style implements Serializable {
* SVUID.
*/
private static final long serialVersionUID = 5855722896712428387L;
-
+
+ /**
+ * New Style to set each line centered
+ */
+ public final static String LINECENTER = "lineCenter";
+
/**
* valign statement key top
*/
@@ -275,6 +280,7 @@ public class Style implements Serializable {
}
}
}
+
if (HALIGN.equals(id)) {
if (LEFT.equals(value) || CENTER.equals(value) || RIGHT.equals(value)) {
hAlign_ = value;
@@ -285,8 +291,9 @@ public class Style implements Serializable {
vAlign_ = value;
}
}
+ //Set new align for horziontal valign of lineCenter
if (VALUEHALIGN.equals(id)) {
- if (LEFT.equals(value) || CENTER.equals(value) || RIGHT.equals(value)) {
+ if (LEFT.equals(value) || CENTER.equals(value) || RIGHT.equals(value)||LINECENTER.equals(value)) {
valueHAlign_ = value;
}
}
@@ -509,7 +516,7 @@ public class Style implements Serializable {
* The toString method, used for tests or debugging.
*/
public String toString() {
- return "bgcolor:" + getBgColor() + " halign:" + getHAlign() + " valign:" + getVAlign() + " padding:" + getPadding() + " border:" + getBorder() + " font:" + getFont() + " valuefont:" + getValueFont() + " imageScaleToFit:" + getImageScaleToFit();
+ return "bgcolor:" + getBgColor() + " halign:" + getHAlign() + " valueAlign:" + getValueHAlign()+ " valign:" + getVAlign() + " padding:" + getPadding() + " border:" + getBorder() + " font:" + getFont() + " valuefont:" + getValueFont() + " imageScaleToFit:" + getImageScaleToFit();
}
/**
diff --git a/pdf-as-lib/src/main/resources/config/config.zip b/pdf-as-lib/src/main/resources/config/config.zip
index 3a750a26..2b699d54 100644
--- a/pdf-as-lib/src/main/resources/config/config.zip
+++ b/pdf-as-lib/src/main/resources/config/config.zip
Binary files differ