diff options
Diffstat (limited to 'pdf-as-lib/src/main')
2 files changed, 15 insertions, 2 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java index 07e9ccd..83bf046 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java @@ -259,7 +259,7 @@ public class DetachedLocRefMOAConnector implements Connector // byte[] data_value = data.getData();
// byte[] data_value_hash = CodingHelper.buildDigest(data_value);
byte[] data_value_hash = CodingHelper.buildDigest(data.getDataSource(), algSuite.getDataDigestMethod());
- String object_data_hash = CodingHelper.encodeBase64(data_value_hash);
+ String object_data_hash = CodingHelper.encodeBase64PEM(data_value_hash);
verify_xml = verify_xml.replaceFirst(TemplateReplaces.DIGEST_VALUE_SIGNED_DATA_REPLACE, object_data_hash);
}
@@ -301,7 +301,7 @@ public class DetachedLocRefMOAConnector implements Connector final byte[] bytes_to_be_hashed = string_to_be_hashed.getBytes("UTF-8"); //$NON-NLS-1$
byte[] sig_prop_code = CodingHelper.buildDigest(bytes_to_be_hashed, algSuite.getPropertiesDigestMethod());
- String sig_prop_hash = CodingHelper.encodeBase64(sig_prop_code);
+ String sig_prop_hash = CodingHelper.encodeBase64PEM(sig_prop_code);
verify_xml = verify_xml.replaceFirst(TemplateReplaces.DIGEST_VALUE_SIGNED_PROPERTIES_REPLACE, sig_prop_hash);
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java index eebe127..1e22838 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java @@ -203,6 +203,19 @@ public class CodingHelper }
}
+ public static String encodeBase64PEM(byte[] plainString) {
+ String base64String = encodeBase64(plainString);
+ StringBuilder sb = new StringBuilder();
+ while(base64String.length() > 64) {
+ String part = base64String.substring(0, 64);
+ sb.append(part);
+ sb.append("\n");
+ base64String = base64String.substring(64);
+ }
+ sb.append(base64String);
+ return sb.toString();
+ }
+
// dferbas
/**
* This method builds an hash value of a given byte array.
|