aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/sl
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/sl')
-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
3 files changed, 104 insertions, 13 deletions
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;
+ }
}