You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fs...@apache.org on 2020/02/09 14:22:34 UTC
[tomcat-jakartaee-migration] 02/02: Add warnings in the log for
each removed signature
This is an automated email from the ASF dual-hosted git repository.
fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
commit 1418dfd906bb4bbe405a1ce835617231e8ac1177
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 9 15:19:15 2020 +0100
Add warnings in the log for each removed signature
---
README.md | 5 +++++
src/main/java/org/apache/tomcat/jakartaee/Migration.java | 10 +++++++---
.../org/apache/tomcat/jakartaee/LocalStrings.properties | 3 ++-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 637c529..990718e 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,11 @@ Migrate your Servlet application with:
The source should be a path to a compressed archive, a folder or an individual file. The destination will be created at the specified path as a resource of the same type as the source.
+> **INFO**
+> This tool will remove cryptographic signatures from JAR files contained in the *source*, as the changed resources would not match them anymore.
+>
+> A warning will be logged for each JAR file where the signature has been removed.
+
## Differences between Java EE 8 and Jakarta EE 9
Jakarta EE 9 is still under development and there are some details that remain to be worked out.
diff --git a/src/main/java/org/apache/tomcat/jakartaee/Migration.java b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
index f2eed3f..1140f26 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/Migration.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
@@ -139,7 +139,9 @@ public class Migration {
// Otherwise messing with signatures will fail
manifest = new Manifest(manifest);
updateVersion(manifest);
- removeSignatures(manifest);
+ if (removeSignatures(manifest)) {
+ logger.log(Level.WARNING, sm.getString("migration.warnSignatureRemoval"));
+ }
JarEntry manifestEntry = new JarEntry(JarFile.MANIFEST_NAME);
jarOs.putNextEntry(manifestEntry);
manifest.write(jarOs);
@@ -185,8 +187,8 @@ public class Migration {
}
- private void removeSignatures(Manifest manifest) {
- manifest.getMainAttributes().remove(Attributes.Name.SIGNATURE_VERSION);
+ private boolean removeSignatures(Manifest manifest) {
+ boolean removedSignatures = manifest.getMainAttributes().remove(Attributes.Name.SIGNATURE_VERSION) != null;
List<String> signatureEntries = new ArrayList<>();
Map<String, Attributes> manifestAttributeEntries = manifest.getEntries();
for (Entry<String, Attributes> entry : manifestAttributeEntries.entrySet()) {
@@ -194,10 +196,12 @@ public class Migration {
String entryName = entry.getKey();
signatureEntries.add(entryName);
logger.log(Level.FINE, sm.getString("migration.removeSignature", entryName));
+ removedSignatures = true;
}
}
signatureEntries.stream()
.forEach(manifestAttributeEntries::remove);
+ return removedSignatures;
}
diff --git a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
index 2f9560d..d13091f 100644
--- a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
+++ b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
@@ -23,4 +23,5 @@ migration.mkdirError=Error creating destination directory [{0}]
migration.removeSignature=Remove cryptographic signature for [{0}]
migration.skipSignatureFile=Drop cryptographic signature file [{0}]
migration.stream=Migrating stream [{0}]
-migration.usage=Usage: Migration <source> <destination>
\ No newline at end of file
+migration.usage=Usage: Migration <source> <destination>
+migration.warnSignatureRemoval=Removed cryptographic signature from JAR file
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org