diff --git a/Jenkinsfile b/Jenkinsfile
index 3b19af3..efd463b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -109,7 +109,7 @@ def getSha1() {
def mvn(args) {
withMaven(
- maven: 'maven-3.6.1',
+ maven: 'maven-3.9.4',
globalMavenSettingsConfig: 'locusworks-settings'
) {
@@ -183,4 +183,4 @@ def SetVersion( v ) {
}
}
-return this
\ No newline at end of file
+return this
diff --git a/pom.xml b/pom.xml
index 5f563f8..6faff9a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,11 +18,11 @@
- 2.14.1
- 1.7.32
- 2.12.5
- 1.8
- 1.8
+ 2.20.0
+ 2.0.9
+ 2.15.2
+ 17
+ 17
https://nexus.locusworks.net
@@ -31,28 +31,27 @@
org.apache.maven.plugins
maven-surefire-plugin
- 3.0.0-M5
-
- always
-
+ 3.1.2
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.1
+ 3.11.0
${maven.compiler.source}
${maven.compiler.target}
true
-
- -Xlint:all
-
+
+ -Xlint:all
+ --add-exports
+ java.base/sun.security.jca=ALL-UNNAMED
+
org.owasp
dependency-check-maven
- 6.3.1
+ 8.4.0
@@ -61,20 +60,77 @@
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.10
+
+
+
+ prepare-agent
+
+
+
+ report
+ prepare-package
+
+ report
+
+
+
+ jacoco-check
+
+ check
+
+
+
+
+ PACKAGE
+
+
+ LINE
+ COVEREDRATIO
+ 1.00
+
+
+ BRANCH
+ COVEREDRATIO
+ 1.00
+
+
+
+
+
+
+
+
- junit
- junit
- 4.13.2
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.10.0
test
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.10.0
+ test
+
+
+ org.mockito
+ mockito-core
+ 5.5.0
+ test
+
+
org.flywaydb
flyway-core
- 7.15.0
+ 9.22.1
org.apache.logging.log4j
@@ -103,14 +159,14 @@
- org.apache.httpcomponents
- httpclient
- 4.5.13
+ org.apache.httpcomponents.client5
+ httpclient5
+ 5.2.1
org.apache.httpcomponents
httpmime
- 4.5.13
+ 4.5.14
@@ -133,7 +189,7 @@
com.google.code.gson
gson
- 2.8.8
+ 2.10.1
@@ -176,4 +232,4 @@
-
\ No newline at end of file
+
diff --git a/src/main/java/net/locusworks/common/configuration/PropertiesManager.java b/src/main/java/net/locusworks/common/configuration/PropertiesManager.java
index c99a16d..a9b8a0b 100644
--- a/src/main/java/net/locusworks/common/configuration/PropertiesManager.java
+++ b/src/main/java/net/locusworks/common/configuration/PropertiesManager.java
@@ -15,11 +15,13 @@ import java.util.Properties;
import java.util.stream.Collectors;
import net.locusworks.common.immutables.Pair;
+import net.locusworks.common.immutables.Unit;
+
/**
* Properties manager class to help load and read properties
* @author Isaac Parenteau
- * @version 1.0.0
- * @date 02/15/2018
+ * @version 2.0.0
+ * @date 09/17/2023
*/
public class PropertiesManager {
/**
@@ -88,7 +90,8 @@ public class PropertiesManager {
* @return a map containing the results of the values added
*/
public static Map addConfiguration(Properties to, Properties from) {
- Map results = from.entrySet()
+
+ return from.entrySet()
.stream()
.filter(entry -> !to.containsKey(entry.getKey()))
.map(entry -> {
@@ -97,9 +100,7 @@ public class PropertiesManager {
to.put(key, value);
return new Pair(key, value);
})
- .collect(Collectors.toMap(key -> key.getValue1(), value -> value.getValue2()));
-
- return results;
+ .collect(Collectors.toMap(Unit::getValue1, Pair::getValue2));
}
/**
@@ -109,19 +110,17 @@ public class PropertiesManager {
* @return a map containing the results of the values removed
*/
public static Map removeConfiguration(Properties from, Properties comparedTo) {
- Map results = from.keySet()
+
+ return from.keySet()
.stream()
.filter(key -> !comparedTo.containsKey(key)) //only get the items that are not in the comparedTo properties
.map(key -> new Pair(String.valueOf(key), String.valueOf(from.get(key))))
- .collect(Collectors.toList()) //Create a list of paired items (key value) of the items that were filtered
+ .toList() //Create a list of paired items (key value) of the items that were filtered
.stream()
- .map(pair -> { //remove those pairs from the from properties
+ .peek(pair -> { //remove those pairs from the from properties
from.remove(pair.getValue1());
- return pair;
})
- .collect(Collectors.toMap(key -> key.getValue1(), value -> value.getValue2())); //create a map of what was removed
-
- return results;
+ .collect(Collectors.toMap(Unit::getValue1, Pair::getValue2));
}
/**
diff --git a/src/main/java/net/locusworks/common/crypto/AES.java b/src/main/java/net/locusworks/common/crypto/AES.java
index 9c67983..b44355a 100644
--- a/src/main/java/net/locusworks/common/crypto/AES.java
+++ b/src/main/java/net/locusworks/common/crypto/AES.java
@@ -7,10 +7,7 @@ import javax.crypto.KeyGenerator;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
+import java.security.*;
import java.util.Base64;
import net.locusworks.common.utils.RandomString;
@@ -21,7 +18,7 @@ import static net.locusworks.common.Charsets.UTF_8;
/**
* AES encryption/decryption class
* This class will encrypt/decrypt data. The encryption key is never known.
- * Instead it is is generated by the provided seed. As long as the seed stays the same
+ * Instead, it is generated by the provided seed. As long as the seed stays the same
* the key will remain the same and the encryption/decryption will work. This
* provides and added security.
* @author Isaac Parenteau
@@ -62,7 +59,6 @@ public class AES {
* @param seed Seed to initialize SecureRandom with
* @return SecureRandom object
* @throws NoSuchAlgorithmException thrown when algorithm can't be used
- * @throws NoSuchProviderException thrown when the provider cant be found
*/
private static SecureRandom getSecureRandom(String seed) throws NoSuchAlgorithmException {
SecureRandom sr = SecureRandom.getInstance(ALGORITHM);
@@ -73,7 +69,7 @@ public class AES {
/**
* Initialize the aes engine
* @param key secret key to use
- * @param sr
+ * @param sr the secure random class
*/
private void init(final byte[] key, SecureRandom sr) {
try {
@@ -81,8 +77,7 @@ public class AES {
this.secretKeySpec = new SecretKeySpec(key, ENCRYPTION_TYPE);
this.ivParamSpec = new IvParameterSpec(RandomString.getBytes(16, sr));
} catch (Exception ex) {
- System.err.println(ex);
- throw new IllegalArgumentException("Unable to initalize encryption:", ex);
+ throw new IllegalArgumentException("Unable to initialize encryption:", ex);
}
}
@@ -122,7 +117,7 @@ public class AES {
}
}
- public AES setSeed(String seed) {
+ public AES withSeed(String seed) {
if (this.seed == null || !this.seed.equals(seed)) {
initSecureKey(seed);
}
@@ -144,9 +139,7 @@ public class AES {
}
public static AES createInstance(String seed) {
- AES aes = new AES();
- aes.setSeed(seed);
- return aes;
+ return new AES().withSeed(seed);
}
public static void main(String[] args) throws NoSuchAlgorithmException {
diff --git a/src/main/java/net/locusworks/common/crypto/AESKey.java b/src/main/java/net/locusworks/common/crypto/AESKey.java
index b64d6b8..3bec359 100644
--- a/src/main/java/net/locusworks/common/crypto/AESKey.java
+++ b/src/main/java/net/locusworks/common/crypto/AESKey.java
@@ -1,13 +1,14 @@
package net.locusworks.common.crypto;
+import java.io.Serial;
import java.security.PrivateKey;
import net.locusworks.common.Charsets;
public class AESKey implements PrivateKey {
- private static final long serialVersionUID = -8452357427706386362L;
- private String seed;
+ @Serial private static final long serialVersionUID = -8452357427706386362L;
+ private final String seed;
public AESKey(String seed) {
this.seed = seed;
diff --git a/src/main/java/net/locusworks/common/crypto/KeyFile.java b/src/main/java/net/locusworks/common/crypto/KeyFile.java
index 9b71ce3..0ebffec 100644
--- a/src/main/java/net/locusworks/common/crypto/KeyFile.java
+++ b/src/main/java/net/locusworks/common/crypto/KeyFile.java
@@ -114,7 +114,7 @@ public class KeyFile implements AutoCloseable {
dosh.writeInt(item.length);
dosh.write(item);
}));
- data = String.format("ssh-rsa", dosh.base64Encoded(), this.description);
+ data = String.format("ssh-rsa %s %s", dosh.base64Encoded(), this.description);
IOUtils.writeStringToFile(fileName, data);
}
break;
@@ -186,9 +186,9 @@ public class KeyFile implements AutoCloseable {
}
private static class KeySpecHelper {
- private KeySpec keySpec;
- private boolean isPrivate;
- private EncryptionType encryptionType;
+ private final KeySpec keySpec;
+ private final boolean isPrivate;
+ private final EncryptionType encryptionType;
public KeySpecHelper(KeySpec keySpec, boolean isPrivate, EncryptionType encryptionType) {
super();
diff --git a/src/main/java/net/locusworks/common/crypto/SSHEncodedKeySpec.java b/src/main/java/net/locusworks/common/crypto/SSHEncodedKeySpec.java
index 0572364..94a33a2 100644
--- a/src/main/java/net/locusworks/common/crypto/SSHEncodedKeySpec.java
+++ b/src/main/java/net/locusworks/common/crypto/SSHEncodedKeySpec.java
@@ -37,8 +37,7 @@ public class SSHEncodedKeySpec extends EncodedKeySpec {
checkArguments(SSH_MARKER.equals(marker), "Looking for marker %s but received %s", SSH_MARKER, marker);
BigInteger publicExponent = new BigInteger(readLengthFirst(stream));
BigInteger modulus = new BigInteger(readLengthFirst(stream));
- RSAPublicKeySpec keySpec = new RSAPublicKeySpec(modulus, publicExponent);
- return keySpec;
+ return new RSAPublicKeySpec(modulus, publicExponent);
} catch (Exception ex) {
throw new InvalidKeySpecException(ex);
}
diff --git a/src/main/java/net/locusworks/common/exceptions/ApplicationException.java b/src/main/java/net/locusworks/common/exceptions/ApplicationException.java
index 0ade43a..40cb230 100644
--- a/src/main/java/net/locusworks/common/exceptions/ApplicationException.java
+++ b/src/main/java/net/locusworks/common/exceptions/ApplicationException.java
@@ -1,5 +1,7 @@
package net.locusworks.common.exceptions;
+import java.io.Serial;
+
/***
* Custom exception class for the patch repository
* @author Isaac Parenteau
@@ -8,7 +10,7 @@ package net.locusworks.common.exceptions;
public class ApplicationException extends Exception {
private final Integer code;
boolean success = false;
- private static final long serialVersionUID = 1L;
+ @Serial private static final long serialVersionUID = 1L;
public static ApplicationException egregiousServer() {
return new ApplicationException(9001, "Something went wrong. Please see logs for details");
diff --git a/src/main/java/net/locusworks/common/immutables/Triplet.java b/src/main/java/net/locusworks/common/immutables/Triplet.java
index 5ff5c83..065b7e2 100644
--- a/src/main/java/net/locusworks/common/immutables/Triplet.java
+++ b/src/main/java/net/locusworks/common/immutables/Triplet.java
@@ -48,10 +48,8 @@ public class Triplet extends Pair {
@Override
public boolean equals(Object other) {
- if (!(other instanceof Triplet)) return false;
-
- Triplet, ?, ?> otherTriplet = (Triplet, ?, ?>)other;
-
+ if (!(other instanceof Triplet, ?, ?> otherTriplet)) return false;
+
return super.equals(otherTriplet) && this.getValue3().equals(otherTriplet.getValue3());
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/locusworks/common/interfaces/AutoCloseableIterator.java b/src/main/java/net/locusworks/common/interfaces/AutoCloseableIterator.java
index d494fcb..bc02ab1 100644
--- a/src/main/java/net/locusworks/common/interfaces/AutoCloseableIterator.java
+++ b/src/main/java/net/locusworks/common/interfaces/AutoCloseableIterator.java
@@ -5,6 +5,6 @@ import java.util.Iterator;
public interface AutoCloseableIterator extends Iterator, AutoCloseable {
@Override
- public void close();
+ void close();
}
diff --git a/src/main/java/net/locusworks/common/io/IOUtils.java b/src/main/java/net/locusworks/common/io/IOUtils.java
index 7ce89f1..71c3bf4 100644
--- a/src/main/java/net/locusworks/common/io/IOUtils.java
+++ b/src/main/java/net/locusworks/common/io/IOUtils.java
@@ -172,7 +172,7 @@ public class IOUtils {
*/
public static void copy(final InputStream input, final Writer output, final Charset inputEncoding)
throws IOException {
- final InputStreamReader in = new InputStreamReader(input, inputEncoding.toString());
+ final InputStreamReader in = new InputStreamReader(input, inputEncoding);
copy(in, output);
}
diff --git a/src/main/java/net/locusworks/common/objectmapper/ObjectMapperHelper.java b/src/main/java/net/locusworks/common/objectmapper/ObjectMapperHelper.java
index 9ce2050..0fa5993 100644
--- a/src/main/java/net/locusworks/common/objectmapper/ObjectMapperHelper.java
+++ b/src/main/java/net/locusworks/common/objectmapper/ObjectMapperHelper.java
@@ -20,7 +20,7 @@ import com.google.gson.GsonBuilder;
*/
public class ObjectMapperHelper {
- private static ObjectMapper mapper;
+ private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
@@ -145,4 +145,4 @@ public class ObjectMapperHelper {
return new ObjectMapperListResults<>(ex);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/locusworks/common/properties/ImmutableProperties.java b/src/main/java/net/locusworks/common/properties/ImmutableProperties.java
index 0884479..05a1eef 100644
--- a/src/main/java/net/locusworks/common/properties/ImmutableProperties.java
+++ b/src/main/java/net/locusworks/common/properties/ImmutableProperties.java
@@ -1,10 +1,11 @@
package net.locusworks.common.properties;
+import java.io.Serial;
import java.util.Properties;
public class ImmutableProperties extends Properties {
- private static final long serialVersionUID = 65942088008978137L;
+ @Serial private static final long serialVersionUID = 65942088008978137L;
public ImmutableProperties() {
super();
@@ -13,8 +14,8 @@ public class ImmutableProperties extends Properties {
public ImmutableProperties(Properties props) {
super();
if (props == null || props.isEmpty()) return;
-
- props.entrySet().forEach(item -> this.put(item.getKey(), item.getValue()));
+
+ this.putAll(props);
}
@Override
diff --git a/src/main/java/net/locusworks/common/properties/OrderedProperties.java b/src/main/java/net/locusworks/common/properties/OrderedProperties.java
index dcefa70..410d7c9 100644
--- a/src/main/java/net/locusworks/common/properties/OrderedProperties.java
+++ b/src/main/java/net/locusworks/common/properties/OrderedProperties.java
@@ -24,15 +24,7 @@ package net.locusworks.common.properties;
*
*
*/
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.io.OutputStreamWriter;
-import java.io.BufferedWriter;
+import java.io.*;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
@@ -123,7 +115,7 @@ public class OrderedProperties extends LinkedHashMap