summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2016-11-12 23:01:13 -0800
committerShawn Pearce <spearce@spearce.org>2016-11-13 12:17:20 -0400
commit92eab1867dd10e3d1acd6eb2fffa04473c2df5ce (patch)
tree2a23579269bcb241623e529dfb2626244e89f5e7
parent8adbfe4da6723768febbb86c22ac118e233c2154 (diff)
downloadjgit-92eab1867dd10e3d1acd6eb2fffa04473c2df5ce.tar.gz
jgit-92eab1867dd10e3d1acd6eb2fffa04473c2df5ce.zip
WalkEncryption: Cleanup Java 8 support
Java 8 is now the minimum for JGit, so Java 7 only paths are not necessary. Change-Id: I0151625fed4d0da95321ebed5cca648b8c29d5f1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java38
1 files changed, 3 insertions, 35 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java
index fe03bdc867..d14e2f2668 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java
@@ -143,35 +143,6 @@ abstract class WalkEncryption {
}
}
- // PBEParameterSpec factory for Java (version <= 7).
- // Does not support AlgorithmParameterSpec.
- static PBEParameterSpec java7PBEParameterSpec(byte[] salt,
- int iterationCount) {
- return new PBEParameterSpec(salt, iterationCount);
- }
-
- // PBEParameterSpec factory for Java (version >= 8).
- // Adds support for AlgorithmParameterSpec.
- static PBEParameterSpec java8PBEParameterSpec(byte[] salt,
- int iterationCount, AlgorithmParameterSpec paramSpec) {
- try {
- @SuppressWarnings("boxing")
- PBEParameterSpec instance = PBEParameterSpec.class
- .getConstructor(byte[].class, int.class,
- AlgorithmParameterSpec.class)
- .newInstance(salt, iterationCount, paramSpec);
- return instance;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- // Current runtime version.
- // https://docs.oracle.com/javase/7/docs/technotes/guides/versioning/spec/versioning2.html
- static double javaVersion() {
- return Double.parseDouble(System.getProperty("java.specification.version")); //$NON-NLS-1$
- }
-
/**
* JetS3t compatibility reference: <a href=
* "https://bitbucket.org/jmurty/jets3t/src/156c00eb160598c2e9937fd6873f00d3190e28ca/src/org/jets3t/service/security/EncryptionUtil.java">
@@ -233,9 +204,7 @@ abstract class WalkEncryption {
boolean useIV = cryptoName.contains("AES"); //$NON-NLS-1$
// PBEParameterSpec algorithm parameters are supported from Java 8.
- boolean isJava8 = javaVersion() >= 1.8;
-
- if (useIV && isJava8) {
+ if (useIV) {
// Support IV where possible:
// * since JCE provider uses random IV for PBE/AES
// * and there is no place to store dynamic IV in JetS3t V2
@@ -245,16 +214,15 @@ abstract class WalkEncryption {
// https://bitbucket.org/jmurty/jets3t/raw/156c00eb160598c2e9937fd6873f00d3190e28ca/src/org/jets3t/service/security/EncryptionUtil.java
// http://cr.openjdk.java.net/~mullan/webrevs/ascarpin/webrev.00/raw_files/new/src/share/classes/com/sun/crypto/provider/PBES2Core.java
IvParameterSpec paramIV = new IvParameterSpec(ZERO_AES_IV);
- paramSpec = java8PBEParameterSpec(SALT, ITERATIONS, paramIV);
+ paramSpec = new PBEParameterSpec(SALT, ITERATIONS, paramIV);
} else {
// Strict legacy JetS3t V2 compatibility, with no IV support.
- paramSpec = java7PBEParameterSpec(SALT, ITERATIONS);
+ paramSpec = new PBEParameterSpec(SALT, ITERATIONS);
}
// Verify if cipher + key are allowed by policy.
cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec);
cipher.doFinal();
-
}
@Override