diff --git a/CHANGELOG.md b/CHANGELOG.md index 52e0719..1618ff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ See also +## 6.3.5 +- Release date: 2024/mm/dd + ## 6.3.4 - Release date: 2024/01/01 - Features: diff --git a/README.md b/README.md index 8811f68..da89db8 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,5 @@ Just [create issue](https://github.com/xipki/commons/issues). For bug-report please upload the test data and log files, describe the version of XiPKI Commons, OS and -JRE/JDK, and the steps to reproduce the bug. \ No newline at end of file +JRE/JDK, and the steps to reproduce the bug. + diff --git a/audit-extra/pom.xml b/audit-extra/pom.xml index cb0bff2..b0c0a9d 100644 --- a/audit-extra/pom.xml +++ b/audit-extra/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT bundle audit-extra diff --git a/audit/pom.xml b/audit/pom.xml index d3a60fc..cb57a78 100644 --- a/audit/pom.xml +++ b/audit/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT bundle audit diff --git a/datasource/pom.xml b/datasource/pom.xml index 32f587a..8105f86 100644 --- a/datasource/pom.xml +++ b/datasource/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT bundle datasource diff --git a/password/pom.xml b/password/pom.xml index 0ba286d..4bebd19 100644 --- a/password/pom.xml +++ b/password/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT bundle password diff --git a/pom.xml b/pom.xml index 5641ab7..e213a0c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.xipki.commons xipki-commons-parent pom - 6.3.4 + 6.3.5-SNAPSHOT XiPKI :: ${project.artifactId} XiPKI Parent http://xipki.org @@ -29,12 +29,12 @@ UTF-8 - 1.77 + 1.78.1 1.7.36 - 1.0.8 + 1.0.9 4.0.3 2.16.1 - 4.4.4 + 4.4.6 4.13.1 @@ -49,8 +49,7 @@ shell-base security-shell xipki-tomcat-password - servlet3-common - servlet5-common + servlet-common scm:git:git@github.com:xipki/commons.git diff --git a/security-shell/pom.xml b/security-shell/pom.xml index c086fdc..c82dfbd 100644 --- a/security-shell/pom.xml +++ b/security-shell/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT security-shell bundle diff --git a/security-shell/src/main/java/org/xipki/security/shell/JceActions.java b/security-shell/src/main/java/org/xipki/security/shell/JceActions.java index 07ec241..d16eaa0 100644 --- a/security-shell/src/main/java/org/xipki/security/shell/JceActions.java +++ b/security-shell/src/main/java/org/xipki/security/shell/JceActions.java @@ -23,7 +23,7 @@ public class JceActions { @Command(scope = "xi", name = "csr-jce", description = "generate CSR request with JCE device") @Service - public static class CsrJce extends Actions.BaseCsrGenAction { + public static class CsrJce extends SecurityActions.BaseCsrGenAction { @Option(name = "--type", required = true, description = "JCE signer type") private String type; diff --git a/security-shell/src/main/java/org/xipki/security/shell/P11Actions.java b/security-shell/src/main/java/org/xipki/security/shell/P11Actions.java index c4bf624..b078fb4 100644 --- a/security-shell/src/main/java/org/xipki/security/shell/P11Actions.java +++ b/security-shell/src/main/java/org/xipki/security/shell/P11Actions.java @@ -28,8 +28,8 @@ import org.xipki.security.pkcs11.P11Slot; import org.xipki.security.pkcs11.P11Slot.P11NewKeyControl; import org.xipki.security.pkcs11.P11SlotId; -import org.xipki.security.shell.Actions.CsrGenAction; -import org.xipki.security.shell.Actions.SecurityAction; +import org.xipki.security.shell.SecurityActions.CsrGenAction; +import org.xipki.security.shell.SecurityActions.SecurityAction; import org.xipki.security.util.AlgorithmUtil; import org.xipki.security.util.KeyUtil; import org.xipki.shell.Completers; @@ -384,7 +384,7 @@ public static class RsaP11 extends P11KeyGenAction { private Integer keysize = 2048; @Option(name = "-e", description = "public exponent") - private String publicExponent = Actions.TEXT_F4; + private String publicExponent = SecurityActions.TEXT_F4; @Override protected Object execute0() throws Exception { diff --git a/security-shell/src/main/java/org/xipki/security/shell/P12Actions.java b/security-shell/src/main/java/org/xipki/security/shell/P12Actions.java index 54ebcb8..457ae42 100644 --- a/security-shell/src/main/java/org/xipki/security/shell/P12Actions.java +++ b/security-shell/src/main/java/org/xipki/security/shell/P12Actions.java @@ -21,8 +21,8 @@ import org.xipki.security.pkcs12.KeypairWithCert; import org.xipki.security.pkcs12.KeystoreGenerationParameters; import org.xipki.security.pkcs12.P12KeyGenerator; -import org.xipki.security.shell.Actions.CsrGenAction; -import org.xipki.security.shell.Actions.SecurityAction; +import org.xipki.security.shell.SecurityActions.CsrGenAction; +import org.xipki.security.shell.SecurityActions.SecurityAction; import org.xipki.security.util.AlgorithmUtil; import org.xipki.security.util.KeyUtil; import org.xipki.security.util.X509Util; @@ -387,7 +387,7 @@ public static class RsaP12 extends P12KeyGenAction { private Integer keysize = 2048; @Option(name = "-e", description = "public exponent") - private String publicExponent = Actions.TEXT_F4; + private String publicExponent = SecurityActions.TEXT_F4; @Override protected Object execute0() throws Exception { diff --git a/security-shell/src/main/java/org/xipki/security/shell/PasswordActions.java b/security-shell/src/main/java/org/xipki/security/shell/PasswordActions.java index b38ff88..0065418 100644 --- a/security-shell/src/main/java/org/xipki/security/shell/PasswordActions.java +++ b/security-shell/src/main/java/org/xipki/security/shell/PasswordActions.java @@ -11,7 +11,7 @@ import org.xipki.password.OBFPasswordService; import org.xipki.password.PBEPasswordService; import org.xipki.password.Passwords; -import org.xipki.security.shell.Actions.SecurityAction; +import org.xipki.security.shell.SecurityActions.SecurityAction; import org.xipki.shell.IllegalCmdParamException; import org.xipki.util.Args; import org.xipki.util.IoUtil; diff --git a/security-shell/src/main/java/org/xipki/security/shell/QaSecurityActions.java b/security-shell/src/main/java/org/xipki/security/shell/QaSecurityActions.java index 86e2a7d..b502e30 100644 --- a/security-shell/src/main/java/org/xipki/security/shell/QaSecurityActions.java +++ b/security-shell/src/main/java/org/xipki/security/shell/QaSecurityActions.java @@ -545,7 +545,7 @@ public static class SpeedRsaGenP11 extends SpeedP11ActionQa { private Integer keysize = 2048; @Option(name = "--exponent", aliases = "-e", description = "public exponent") - private String publicExponent = Actions.TEXT_F4; + private String publicExponent = SecurityActions.TEXT_F4; @Override protected BenchmarkExecutor getTester() throws Exception { @@ -568,7 +568,7 @@ public static class SpeedRsaSignP11 extends SpeedP11SignActionQa { private Integer keysize = 2048; @Option(name = "-e", description = "public exponent") - private String publicExponent = Actions.TEXT_F4; + private String publicExponent = SecurityActions.TEXT_F4; @Option(name = "--sig-algo", required = true, description = "signature algorithm") @Completion(QaCompleters.RSASigAlgCompleter.class) @@ -892,7 +892,7 @@ public static class SpeedRsaGenP12 extends SingleSpeedActionQa { private Integer keysize = 2048; @Option(name = "-e", description = "public exponent") - private String publicExponent = Actions.TEXT_F4; + private String publicExponent = SecurityActions.TEXT_F4; @Override protected BenchmarkExecutor getTester() throws Exception { @@ -910,7 +910,7 @@ public static class SpeedRsaSignP12 extends SpeedP12SignActionQa { private Integer keysize = 2048; @Option(name = "-e", description = "public exponent") - private String publicExponent = Actions.TEXT_F4; + private String publicExponent = SecurityActions.TEXT_F4; @Option(name = "--sig-algo", required = true, description = "signature algorithm") @Completion(QaCompleters.RSASigAlgCompleter.class) diff --git a/security-shell/src/main/java/org/xipki/security/shell/Actions.java b/security-shell/src/main/java/org/xipki/security/shell/SecurityActions.java similarity index 99% rename from security-shell/src/main/java/org/xipki/security/shell/Actions.java rename to security-shell/src/main/java/org/xipki/security/shell/SecurityActions.java index 4ab9d79..0cf03fc 100644 --- a/security-shell/src/main/java/org/xipki/security/shell/Actions.java +++ b/security-shell/src/main/java/org/xipki/security/shell/SecurityActions.java @@ -74,7 +74,6 @@ import org.xipki.util.Base64; import org.xipki.util.CollectionUtil; import org.xipki.util.CompareUtil; -import org.xipki.util.ConcurrentBag; import org.xipki.util.DateUtil; import org.xipki.util.Hex; import org.xipki.util.IoUtil; @@ -119,7 +118,7 @@ * @author Lijun Liao (xipki) */ -public class Actions { +public class SecurityActions { public static final String TEXT_F4 = "0x10001"; @@ -875,7 +874,7 @@ private PKCS10CertificationRequest generateRequest( } } - ConcurrentBag.BagEntry signer0; + XiContentSigner signer0; try { signer0 = signer.borrowSigner(); } catch (NoIdleSignerException ex) { @@ -883,7 +882,7 @@ private PKCS10CertificationRequest generateRequest( } try { - return csrBuilder.build(signer0.value()); + return csrBuilder.build(signer0); } finally { signer.requiteSigner(signer0); } diff --git a/security/pom.xml b/security/pom.xml index c14345c..c9b46bc 100644 --- a/security/pom.xml +++ b/security/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT security bundle diff --git a/security/src/main/java/org/xipki/security/ConcurrentContentSigner.java b/security/src/main/java/org/xipki/security/ConcurrentContentSigner.java index 96f8ce8..baac18f 100644 --- a/security/src/main/java/org/xipki/security/ConcurrentContentSigner.java +++ b/security/src/main/java/org/xipki/security/ConcurrentContentSigner.java @@ -4,7 +4,6 @@ package org.xipki.security; import org.bouncycastle.operator.ContentSigner; -import org.xipki.util.ConcurrentBag.BagEntry; import java.io.Closeable; import java.security.Key; @@ -98,7 +97,7 @@ public interface ConcurrentContentSigner extends Closeable { * @throws NoIdleSignerException * If no idle signer is available */ - BagEntry borrowSigner() throws NoIdleSignerException; + XiContentSigner borrowSigner() throws NoIdleSignerException; /** * Borrows a signer with the given {@code soTimeout}. @@ -107,9 +106,9 @@ public interface ConcurrentContentSigner extends Closeable { * @throws NoIdleSignerException * If no idle signer is available */ - BagEntry borrowSigner(int soTimeout) throws NoIdleSignerException; + XiContentSigner borrowSigner(int soTimeout) throws NoIdleSignerException; - void requiteSigner(BagEntry signer); + void requiteSigner(XiContentSigner signer); boolean isHealthy(); diff --git a/security/src/main/java/org/xipki/security/DfltConcurrentContentSigner.java b/security/src/main/java/org/xipki/security/DfltConcurrentContentSigner.java index f6baa9b..048f454 100644 --- a/security/src/main/java/org/xipki/security/DfltConcurrentContentSigner.java +++ b/security/src/main/java/org/xipki/security/DfltConcurrentContentSigner.java @@ -7,8 +7,6 @@ import org.slf4j.LoggerFactory; import org.xipki.util.Args; import org.xipki.util.CollectionUtil; -import org.xipki.util.ConcurrentBag; -import org.xipki.util.ConcurrentBag.BagEntry; import org.xipki.util.LogUtil; import java.io.IOException; @@ -20,6 +18,7 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -38,7 +37,7 @@ public class DfltConcurrentContentSigner implements ConcurrentContentSigner { private static int defaultSignServiceTimeout = 10000; // 10 seconds - private final ConcurrentBag signers = new ConcurrentBag<>(); + private final ArrayBlockingQueue signers; private final String name; @@ -80,10 +79,8 @@ public DfltConcurrentContentSigner(boolean mac, List signers, K this.mac = mac; this.algorithm = SignAlgo.getInstance(signers.get(0).getAlgorithmIdentifier()); - - for (XiContentSigner signer : signers) { - this.signers.add(new BagEntry<>(signer)); - } + this.signers = new ArrayBlockingQueue<>(signers.size()); + this.signers.addAll(signers); this.signingKey = signingKey; this.name = "defaultSigner-" + NAME_INDEX.getAndIncrement(); @@ -120,7 +117,7 @@ public SignAlgo getAlgorithm() { } @Override - public BagEntry borrowSigner() throws NoIdleSignerException { + public XiContentSigner borrowSigner() throws NoIdleSignerException { return borrowSigner(defaultSignServiceTimeout); } @@ -130,10 +127,10 @@ public BagEntry borrowSigner() throws NoIdleSignerException { * @param soTimeout timeout in milliseconds, 0 for infinitely. */ @Override - public BagEntry borrowSigner(int soTimeout) throws NoIdleSignerException { - BagEntry signer = null; + public XiContentSigner borrowSigner(int soTimeout) throws NoIdleSignerException { + XiContentSigner signer = null; try { - signer = signers.borrow(soTimeout, TimeUnit.MILLISECONDS); + signer = signers.poll(soTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException ex) { } @@ -142,8 +139,8 @@ public BagEntry borrowSigner(int soTimeout) throws NoIdleSigner } @Override - public void requiteSigner(BagEntry signer) { - signers.requite(signer); + public void requiteSigner(XiContentSigner signer) { + signers.add(signer); } @Override @@ -188,12 +185,12 @@ public X509Cert[] getCertificateChain() { @Override public boolean isHealthy() { - BagEntry signer = null; + XiContentSigner signer = null; try { signer = borrowSigner(); - OutputStream stream = signer.value().getOutputStream(); + OutputStream stream = signer.getOutputStream(); stream.write(new byte[]{1, 2, 3, 4}); - byte[] signature = signer.value().getSignature(); + byte[] signature = signer.getSignature(); return signature != null && signature.length > 0; } catch (Exception ex) { LogUtil.error(LOG, ex); @@ -211,15 +208,15 @@ public void close() { @Override public byte[] sign(byte[] data) throws NoIdleSignerException, SignatureException { - BagEntry signer = borrowSigner(); + XiContentSigner signer = borrowSigner(); try { - OutputStream signatureStream = signer.value().getOutputStream(); + OutputStream signatureStream = signer.getOutputStream(); try { signatureStream.write(data); } catch (IOException ex) { throw new SignatureException("could not write data to SignatureStream: " + ex.getMessage(), ex); } - return signer.value().getSignature(); + return signer.getSignature(); } finally { requiteSigner(signer); } @@ -228,19 +225,17 @@ public byte[] sign(byte[] data) throws NoIdleSignerException, SignatureException @Override public byte[][] sign(byte[][] data) throws NoIdleSignerException, SignatureException { byte[][] signatures = new byte[data.length][]; - BagEntry signer = borrowSigner(); + XiContentSigner signer = borrowSigner(); try { - XiContentSigner xiSigner = signer.value(); - for (int i = 0; i < data.length; i++) { - OutputStream signatureStream = xiSigner.getOutputStream(); + OutputStream signatureStream = signer.getOutputStream(); try { signatureStream.write(data[i]); } catch (IOException ex) { throw new SignatureException("could not write data to SignatureStream: " + ex.getMessage(), ex); } - signatures[i] = xiSigner.getSignature(); + signatures[i] = signer.getSignature(); } } finally { requiteSigner(signer); diff --git a/security/src/main/java/org/xipki/security/HashAlgo.java b/security/src/main/java/org/xipki/security/HashAlgo.java index 86e4630..78fa517 100644 --- a/security/src/main/java/org/xipki/security/HashAlgo.java +++ b/security/src/main/java/org/xipki/security/HashAlgo.java @@ -9,6 +9,7 @@ import org.bouncycastle.asn1.gm.GMObjectIdentifiers; import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers; import org.bouncycastle.asn1.x509.AlgorithmIdentifier; +import org.bouncycastle.crypto.Digest; import org.bouncycastle.crypto.ExtendedDigest; import org.bouncycastle.crypto.digests.SHA1Digest; import org.bouncycastle.crypto.digests.SHA224Digest; @@ -19,6 +20,8 @@ import org.bouncycastle.crypto.digests.SHAKEDigest; import org.bouncycastle.crypto.digests.SM3Digest; import org.xipki.util.Args; +import org.xipki.util.Base64; +import org.xipki.util.Hex; import java.io.IOException; import java.security.NoSuchAlgorithmException; @@ -226,27 +229,37 @@ public ExtendedDigest createDigest() { } public String hexHash(byte[]... datas) { - return HashCalculator.hexHash(this, datas); + return Hex.encode(hash(datas)); } public String hexHash(byte[] data, int offset, int len) { - return HashCalculator.hexHash(this, data, offset, len); + return Hex.encode(hash(data, offset, len)); } public String base64Hash(byte[]... datas) { - return HashCalculator.base64Hash(this, datas); + return Base64.encodeToString(hash(datas)); } public String base64Hash(byte[] data, int offset, int len) { - return HashCalculator.base64Hash(this, data, offset, len); + return Base64.encodeToString(hash(data, offset, len)); } public byte[] hash(byte[]... datas) { - return HashCalculator.hash(this, datas); + Digest digest = createDigest(); + for (byte[] data : datas) { + digest.update(data, 0, data.length); + } + byte[] rv = new byte[length]; + digest.doFinal(rv, 0); + return rv; } public byte[] hash(byte[] data, int offset, int len) { - return HashCalculator.hash(this, data, offset, len); + Digest digest = createDigest(); + digest.update(data, offset, len); + byte[] rv = new byte[length]; + digest.doFinal(rv, 0); + return rv; } public int getEncodedLength() { diff --git a/security/src/main/java/org/xipki/security/HashCalculator.java b/security/src/main/java/org/xipki/security/HashCalculator.java deleted file mode 100644 index 03ad35f..0000000 --- a/security/src/main/java/org/xipki/security/HashCalculator.java +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) 2013-2024 xipki. All rights reserved. -// License Apache License 2.0 - -package org.xipki.security; - -import org.bouncycastle.crypto.Digest; -import org.bouncycastle.operator.RuntimeOperatorException; -import org.xipki.util.Args; -import org.xipki.util.Base64; -import org.xipki.util.ConcurrentBag; -import org.xipki.util.ConcurrentBag.BagEntry; -import org.xipki.util.Hex; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -/** - * Utility class to calculate hash values. - * - * @author Lijun Liao (xipki) - * @since 2.0.0 - */ - -class HashCalculator { - - private static final int PARALLELISM = 50; - - private static final ConcurrentHashMap> - MDS_MAP = new ConcurrentHashMap<>(); - - static { - for (HashAlgo ha : HashAlgo.values()) { - MDS_MAP.put(ha, getMessageDigests(ha)); - } - } - - private HashCalculator() { - } - - private static ConcurrentBag getMessageDigests(HashAlgo hashAlgo) { - ConcurrentBag mds = new ConcurrentBag<>(); - for (int i = 0; i < PARALLELISM; i++) { - mds.add(new BagEntry<>(hashAlgo.createDigest())); - } - return mds; - } - - public static String base64Sha1(byte[]... datas) { - return Base64.encodeToString(hash(HashAlgo.SHA1, datas)); - } - - public static String base64Sha1(byte[] data, int offset, int len) { - return Base64.encodeToString(hash(HashAlgo.SHA1, data, offset, len)); - } - - public static String hexSha1(byte[]... datas) { - return Hex.encode(hash(HashAlgo.SHA1, datas)); - } - - public static String hexSha1(byte[] data, int offset, int len) { - return Hex.encode(hash(HashAlgo.SHA1, data, offset, len)); - } - - public static byte[] sha1(byte[]... datas) { - return hash(HashAlgo.SHA1, datas); - } - - public static byte[] sha1(byte[] data, int offset, int len) { - return hash(HashAlgo.SHA1, data, offset, len); - } - - public static String base64Sha256(byte[]... datas) { - return Base64.encodeToString(hash(HashAlgo.SHA256, datas)); - } - - public static String base64Sha256(byte[] data, int offset, int len) { - return Base64.encodeToString(hash(HashAlgo.SHA256, data, offset, len)); - } - - public static String hexSha256(byte[]... datas) { - return Hex.encode(hash(HashAlgo.SHA256, datas)); - } - - public static String hexSha256(byte[] data, int offset, int len) { - return Hex.encode(hash(HashAlgo.SHA256, data, offset, len)); - } - - public static byte[] sha256(byte[]... datas) { - return hash(HashAlgo.SHA256, datas); - } - - public static byte[] sha256(byte[] data, int offset, int len) { - return hash(HashAlgo.SHA256, data, offset, len); - } - - public static String hexHash(HashAlgo hashAlgo, byte[]... datas) { - return Hex.encode(hash(hashAlgo, datas)); - } - - public static String hexHash(HashAlgo hashAlgo, byte[] data, int offset, int len) { - return Hex.encode(hash(hashAlgo, data, offset, len)); - } - - public static String base64Hash(HashAlgo hashAlgo, byte[]... datas) { - return Base64.encodeToString(hash(hashAlgo, datas)); - } - - public static String base64Hash(HashAlgo hashAlgo, byte[] data, int offset, int len) { - return Base64.encodeToString(hash(hashAlgo, data, offset, len)); - } - - public static byte[] hash(HashAlgo hashAlgo, byte[]... datas) { - Args.notNull(datas, "datas"); - - if (!MDS_MAP.containsKey(Args.notNull(hashAlgo, "hashAlgo"))) { - throw new IllegalArgumentException("unknown hash algo " + hashAlgo); - } - - ConcurrentBag mds = MDS_MAP.get(hashAlgo); - - BagEntry md0 = null; - for (int i = 0; i < 3; i++) { - try { - md0 = mds.borrow(10, TimeUnit.SECONDS); - break; - } catch (InterruptedException ex) { - } - } - - if (md0 == null) { - throw new RuntimeOperatorException("could not get idle MessageDigest"); - } - - try { - Digest md = md0.value(); - md.reset(); - for (byte[] data : datas) { - if (data != null && data.length > 0) { - md.update(data, 0, data.length); - } - } - - byte[] bytes = new byte[md.getDigestSize()]; - md.doFinal(bytes, 0); - return bytes; - } finally { - mds.requite(md0); - } - } // method hash - - public static byte[] hash(HashAlgo hashAlgo, byte[] data, int offset, int len) { - Args.notNull(hashAlgo, "hashAlgo"); - - if (Args.notNull(data, "data").length - offset < len) { - throw new IndexOutOfBoundsException("data.length - offset < len"); - } - - if (!MDS_MAP.containsKey(hashAlgo)) { - throw new IllegalArgumentException("unknown hash algo " + hashAlgo); - } - - ConcurrentBag mds = MDS_MAP.get(hashAlgo); - - BagEntry md0 = null; - for (int i = 0; i < 3; i++) { - try { - md0 = mds.borrow(10, TimeUnit.SECONDS); - break; - } catch (InterruptedException ex) { - } - } - - if (md0 == null) { - throw new RuntimeOperatorException("could not get idle MessageDigest"); - } - - try { - Digest md = md0.value(); - md.reset(); - md.update(data, offset, len); - byte[] bytes = new byte[md.getDigestSize()]; - md.doFinal(bytes, 0); - return bytes; - } finally { - mds.requite(md0); - } - } // method hash - -} diff --git a/security/src/main/java/org/xipki/security/IssuerHash.java b/security/src/main/java/org/xipki/security/IssuerHash.java index d0e3725..7c376c5 100644 --- a/security/src/main/java/org/xipki/security/IssuerHash.java +++ b/security/src/main/java/org/xipki/security/IssuerHash.java @@ -36,8 +36,8 @@ public IssuerHash(HashAlgo hashAlgo, X509Cert issuerCert) throws IOException { this.hashAlgo = Args.notNull(hashAlgo, "hashAlgo"); byte[] encodedName = Args.notNull(issuerCert, "issuerCert").getSubject().getEncoded(); byte[] encodedKey = issuerCert.getSubjectPublicKeyInfo().getPublicKeyData().getBytes(); - this.issuerNameHash = HashCalculator.hash(hashAlgo, encodedName); - this.issuerKeyHash = HashCalculator.hash(hashAlgo, encodedKey); + this.issuerNameHash = hashAlgo.hash(encodedName); + this.issuerKeyHash = hashAlgo.hash(encodedKey); } public HashAlgo getHashAlgo() { diff --git a/security/src/main/java/org/xipki/security/ObjectIdentifiers.java b/security/src/main/java/org/xipki/security/ObjectIdentifiers.java index aeb7fce..691dd20 100644 --- a/security/src/main/java/org/xipki/security/ObjectIdentifiers.java +++ b/security/src/main/java/org/xipki/security/ObjectIdentifiers.java @@ -577,7 +577,7 @@ public static final class Extn { public static final ASN1ObjectIdentifier id_ccc_extn = id_ccc.branch("5"); public static final ASN1ObjectIdentifier id_ccc_Vehicle_Cert_K = id_ccc_extn.branch("1"); public static final ASN1ObjectIdentifier id_ccc_External_CA_Cert_F = id_ccc_extn.branch("2"); - public static final ASN1ObjectIdentifier id_ccc_Internal_CA_Cert_E = id_ccc_extn.branch("3"); + public static final ASN1ObjectIdentifier id_ccc_Instance_CA_Cert_E = id_ccc_extn.branch("3"); public static final ASN1ObjectIdentifier id_ccc_Endpoint_Cert_H = id_ccc_extn.branch("4"); public static final ASN1ObjectIdentifier id_ccc_VehicleOEM_Enc_Cert = id_ccc_extn.branch("5"); public static final ASN1ObjectIdentifier id_ccc_VehicleOEM_Sig_Cert = id_ccc_extn.branch("6"); @@ -654,7 +654,7 @@ private static class OidNameMap { // CCC oidNameMap.put(Extn.id_ccc_Vehicle_Cert_K, "CCC Vehicle Certificate [K]"); oidNameMap.put(Extn.id_ccc_External_CA_Cert_F, "CCC External CA Certificate [F]"); - oidNameMap.put(Extn.id_ccc_Internal_CA_Cert_E, "CCC External CA Certificate [E]"); + oidNameMap.put(Extn.id_ccc_Instance_CA_Cert_E, "CCC Instance CA Certificate [E]"); oidNameMap.put(Extn.id_ccc_Endpoint_Cert_H, "Endpoint Certificate [H]"); oidNameMap.put(Extn.id_ccc_VehicleOEM_Enc_Cert, "CCC VehicleOEM.Enc.Cert"); oidNameMap.put(Extn.id_ccc_VehicleOEM_Sig_Cert, "CCC VehicleOEM.Sig.Cert"); diff --git a/security/src/main/java/org/xipki/security/pkcs11/emulator/EmulatorP11Key.java b/security/src/main/java/org/xipki/security/pkcs11/emulator/EmulatorP11Key.java index 6c96b73..c5a19f7 100644 --- a/security/src/main/java/org/xipki/security/pkcs11/emulator/EmulatorP11Key.java +++ b/security/src/main/java/org/xipki/security/pkcs11/emulator/EmulatorP11Key.java @@ -28,8 +28,6 @@ import org.xipki.security.util.PKCS1Util; import org.xipki.security.util.SignerUtil; import org.xipki.util.Args; -import org.xipki.util.ConcurrentBag; -import org.xipki.util.ConcurrentBag.BagEntry; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -48,6 +46,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import static org.xipki.pkcs11.wrapper.PKCS11Constants.CKG_MGF1_SHA1; @@ -159,13 +159,13 @@ class EmulatorP11Key extends P11Key { private final Key signingKey; - private final ConcurrentBag rsaCiphers = new ConcurrentBag<>(); + private final ArrayBlockingQueue rsaCiphers; - private final ConcurrentBag dsaSignatures = new ConcurrentBag<>(); + private final ArrayBlockingQueue dsaSignatures; - private final ConcurrentBag eddsaSignatures = new ConcurrentBag<>(); + private final ArrayBlockingQueue eddsaSignatures; - private final ConcurrentBag sm2Signers = new ConcurrentBag<>(); + private final ArrayBlockingQueue sm2Signers; private final SecureRandom random; @@ -264,6 +264,10 @@ public EmulatorP11Key( this.signingKey = Args.notNull(signingKey, "signingKey"); this.random = Args.notNull(random, "random"); this.maxSessions = maxSessions; + this.dsaSignatures = new ArrayBlockingQueue<>(maxSessions); + this.eddsaSignatures = new ArrayBlockingQueue<>(maxSessions); + this.sm2Signers = new ArrayBlockingQueue<>(maxSessions); + this.rsaCiphers = new ArrayBlockingQueue<>(maxSessions); } // constructor public void setEcParams(ASN1ObjectIdentifier ecParams) { @@ -312,7 +316,7 @@ private synchronized void init() throws TokenException { } } rsaCipher.init(Cipher.ENCRYPT_MODE, signingKey); - rsaCiphers.add(new BagEntry<>(rsaCipher)); + rsaCiphers.add(rsaCipher); } } else { String algorithm; @@ -334,7 +338,7 @@ private synchronized void init() throws TokenException { for (int i = 0; i < maxSessions; i++) { Signature dsaSignature = Signature.getInstance(algorithm, "BC"); dsaSignature.initSign((PrivateKey) signingKey, random); - dsaSignatures.add(new BagEntry<>(dsaSignature)); + dsaSignatures.add(dsaSignature); } } else if (keyType == CKK_EC_EDWARDS) { algorithm = EdECConstants.getName(getEcParams()); @@ -344,7 +348,7 @@ private synchronized void init() throws TokenException { for (int i = 0; i < maxSessions; i++) { Signature signature = Signature.getInstance(algorithm, "BC"); signature.initSign((PrivateKey) signingKey); - eddsaSignatures.add(new BagEntry<>(signature)); + eddsaSignatures.add(signature); } } else if (keyType == CKK_EC_MONTGOMERY) { // do nothing. not suitable for sign. @@ -352,7 +356,7 @@ private synchronized void init() throws TokenException { for (int i = 0; i < maxSessions; i++) { EmulatorSM2Signer sm2signer = new EmulatorSM2Signer(ECUtil.generatePrivateKeyParameter((PrivateKey) signingKey)); - sm2Signers.add(new BagEntry<>(sm2signer)); + sm2Signers.add(sm2signer); } } } @@ -509,38 +513,37 @@ private byte[] rsaPkcsSign(byte[] contentToSign, HashAlgo hashAlgo) throws Token } // method rsaPkcsSign private byte[] rsaX509Sign(byte[] dataToSign) throws TokenException { - BagEntry cipher; + Cipher cipher; try { - cipher = Optional.ofNullable(rsaCiphers.borrow(5000, TimeUnit.MILLISECONDS)).orElseThrow( + cipher = Optional.ofNullable(rsaCiphers.poll(5000, TimeUnit.MILLISECONDS)).orElseThrow( () -> new TokenException("no idle RSA cipher available")); } catch (InterruptedException ex) { throw new TokenException("could not take any idle signer"); } try { - return cipher.value().doFinal(dataToSign); + return cipher.doFinal(dataToSign); } catch (BadPaddingException ex) { throw new TokenException("BadPaddingException: " + ex.getMessage(), ex); } catch (IllegalBlockSizeException ex) { throw new TokenException("IllegalBlockSizeException: " + ex.getMessage(), ex); } finally { - rsaCiphers.requite(cipher); + rsaCiphers.add(cipher); } } // method rsaX509Sign private byte[] dsaAndEcdsaSign(byte[] dataToSign, HashAlgo hashAlgo) throws TokenException { byte[] hash = (hashAlgo == null) ? dataToSign : hashAlgo.hash(dataToSign); - BagEntry sig0; + Signature sig; try { - sig0 = Optional.ofNullable(dsaSignatures.borrow(5000, TimeUnit.MILLISECONDS)) + sig = Optional.ofNullable(dsaSignatures.poll(5000, TimeUnit.MILLISECONDS)) .orElseThrow(() -> new TokenException("no idle DSA Signature available")); } catch (InterruptedException ex) { throw new TokenException("InterruptedException occurs while retrieving idle signature"); } try { - Signature sig = sig0.value(); sig.update(hash); byte[] x962Signature = sig.sign(); return SignerUtil.dsaSigX962ToPlain(x962Signature, dsaOrderBitLen); @@ -549,7 +552,7 @@ private byte[] dsaAndEcdsaSign(byte[] dataToSign, HashAlgo hashAlgo) throws Toke } catch (XiSecurityException ex) { throw new TokenException("XiSecurityException: " + ex.getMessage(), ex); } finally { - dsaSignatures.requite(sig0); + dsaSignatures.add(sig); } } // method dsaAndEcdsaSign @@ -558,43 +561,42 @@ private byte[] eddsaSign(byte[] dataToSign) throws TokenException { throw new TokenException("given signing key is not suitable for EdDSA sign"); } - BagEntry sig0; + Signature sig; try { - sig0 = Optional.ofNullable(eddsaSignatures.borrow(5000, TimeUnit.MILLISECONDS)) + sig = Optional.ofNullable(eddsaSignatures.poll(5000, TimeUnit.MILLISECONDS)) .orElseThrow(() -> new TokenException("no idle DSA Signature available")); } catch (InterruptedException ex) { throw new TokenException("InterruptedException occurs while retrieving idle signature"); } try { - Signature sig = sig0.value(); sig.update(dataToSign); return sig.sign(); } catch (SignatureException ex) { throw new TokenException("SignatureException: " + ex.getMessage(), ex); } finally { - eddsaSignatures.requite(sig0); + eddsaSignatures.add(sig); } } // method eddsaSign private byte[] sm2SignHash(byte[] hash) throws TokenException { - BagEntry sig; + EmulatorSM2Signer sig; try { - sig = Optional.ofNullable(sm2Signers.borrow(5000, TimeUnit.MILLISECONDS)).orElseThrow( + sig = Optional.ofNullable(sm2Signers.poll(5000, TimeUnit.MILLISECONDS)).orElseThrow( () -> new TokenException("no idle SM2 Signer available")); } catch (InterruptedException ex) { throw new TokenException("InterruptedException occurs while retrieving idle signature"); } try { - byte[] x962Signature = sig.value().generateSignatureForHash(hash); + byte[] x962Signature = sig.generateSignatureForHash(hash); return SignerUtil.dsaSigX962ToPlain(x962Signature, dsaOrderBitLen); } catch (CryptoException ex) { throw new TokenException("CryptoException: " + ex.getMessage(), ex); } catch (XiSecurityException ex) { throw new TokenException("XiSecurityException: " + ex.getMessage(), ex); } finally { - sm2Signers.requite(sig); + sm2Signers.add(sig); } } // method sm2SignHash @@ -610,23 +612,23 @@ private byte[] sm2Sign(P11Params params, byte[] dataToSign) throws TokenExceptio throw new TokenException("params must be instanceof P11ByteArrayParams"); } - BagEntry sig0; + EmulatorSM2Signer sig; try { - sig0 = Optional.ofNullable(sm2Signers.borrow(5000, TimeUnit.MILLISECONDS)).orElseThrow( + sig = Optional.ofNullable(sm2Signers.poll(5000, TimeUnit.MILLISECONDS)).orElseThrow( () -> new TokenException("no idle SM2 Signer available")); } catch (InterruptedException ex) { throw new TokenException("InterruptedException occurs while retrieving idle signature"); } try { - byte[] x962Signature = sig0.value().generateSignatureForMessage(userId, dataToSign); + byte[] x962Signature = sig.generateSignatureForMessage(userId, dataToSign); return SignerUtil.dsaSigX962ToPlain(x962Signature, dsaOrderBitLen); } catch (CryptoException ex) { throw new TokenException("CryptoException: " + ex.getMessage(), ex); } catch (XiSecurityException ex) { throw new TokenException("XiSecurityException: " + ex.getMessage(), ex); } finally { - sm2Signers.requite(sig0); + sm2Signers.add(sig); } } // method sm2Sign diff --git a/security/src/main/java/org/xipki/security/pkcs11/hsmproxy/HsmProxyP11Module.java b/security/src/main/java/org/xipki/security/pkcs11/hsmproxy/HsmProxyP11Module.java index be128f5..d1e7e09 100644 --- a/security/src/main/java/org/xipki/security/pkcs11/hsmproxy/HsmProxyP11Module.java +++ b/security/src/main/java/org/xipki/security/pkcs11/hsmproxy/HsmProxyP11Module.java @@ -27,7 +27,6 @@ import org.xipki.util.IoUtil; import org.xipki.util.LogUtil; import org.xipki.util.StringUtil; -import org.xipki.util.cbor.ByteArrayCborDecoder; import org.xipki.util.cbor.CborConstants; import org.xipki.util.cbor.CborDecoder; import org.xipki.util.cbor.CborType; @@ -336,7 +335,7 @@ public ProxyMessage send(ProxyAction action, byte[] request) throws TokenExcepti throw new TokenException(ex.getMessage(), ex); } - CborDecoder decoder = new ByteArrayCborDecoder(respBytes); + CborDecoder decoder = new CborDecoder(respBytes); ErrorResponse errorResp = null; try { diff --git a/security/src/main/java/org/xipki/security/pkcs12/P12KeyGenerator.java b/security/src/main/java/org/xipki/security/pkcs12/P12KeyGenerator.java index 301663f..cd57612 100644 --- a/security/src/main/java/org/xipki/security/pkcs12/P12KeyGenerator.java +++ b/security/src/main/java/org/xipki/security/pkcs12/P12KeyGenerator.java @@ -291,7 +291,7 @@ public static ContentSigner getContentSigner(PrivateKey key, PublicKey publicKey P12ContentSignerBuilder builder = new P12ContentSignerBuilder(key, publicKey); ConcurrentContentSigner csigner = builder.createSigner(algo, 1, null); - return csigner.borrowSigner().value(); + return csigner.borrowSigner(); } // method getContentSigner } diff --git a/security/src/main/java/org/xipki/security/qa/P12SignSpeed.java b/security/src/main/java/org/xipki/security/qa/P12SignSpeed.java index 8c30f44..07ff7a8 100644 --- a/security/src/main/java/org/xipki/security/qa/P12SignSpeed.java +++ b/security/src/main/java/org/xipki/security/qa/P12SignSpeed.java @@ -46,7 +46,7 @@ public AESGmac(SecurityFactory securityFactory, String signatureAlgorithm, int t private static byte[] generateKeystore(String signatureAlgorithm) throws Exception { int keysize = getKeysize(signatureAlgorithm); - KeyStoreWrapper identity = new P12KeyGenerator().generateSecretKey( + KeyStoreWrapper identity = P12KeyGenerator.generateSecretKey( "AES", keysize, new KeystoreGenerationParameters(PASSWORD.toCharArray())); return identity.keystore(); } @@ -86,7 +86,7 @@ private static byte[] generateKeystore(int plength, int qlength) throws Exceptio if (keystoreBytes == null) { KeystoreGenerationParameters params = new KeystoreGenerationParameters(PASSWORD.toCharArray()); params.setRandom(new SecureRandom()); - KeyStoreWrapper identity = new P12KeyGenerator().generateDSAKeypair(plength, qlength, params, null); + KeyStoreWrapper identity = P12KeyGenerator.generateDSAKeypair(plength, qlength, params, null); keystoreBytes = identity.keystore(); } return keystoreBytes; @@ -108,8 +108,8 @@ private static byte[] generateKeystore(ASN1ObjectIdentifier curveOid) throws Exc KeystoreGenerationParameters params = new KeystoreGenerationParameters(PASSWORD.toCharArray()); params.setRandom(new SecureRandom()); KeyStoreWrapper identity = EdECConstants.isEdwardsOrMontgomeryCurve(curveOid) - ? new P12KeyGenerator().generateEdECKeypair(curveOid, params, null) - : new P12KeyGenerator().generateECKeypair(curveOid, params, null); + ? P12KeyGenerator.generateEdECKeypair(curveOid, params, null) + : P12KeyGenerator.generateECKeypair(curveOid, params, null); keystoreBytes = identity.keystore(); } @@ -127,7 +127,7 @@ public HMAC(SecurityFactory securityFactory, String signatureAlgorithm, int thre private static byte[] generateKeystore(String signatureAlgorithm) throws Exception { int keysize = getKeysize(signatureAlgorithm); - KeyStoreWrapper identity = new P12KeyGenerator().generateSecretKey( + KeyStoreWrapper identity = P12KeyGenerator.generateSecretKey( "GENERIC", keysize, new KeystoreGenerationParameters(PASSWORD.toCharArray())); return identity.keystore(); } @@ -177,7 +177,7 @@ private static byte[] generateKeystore(int keysize, BigInteger publicExponent) t if (keystoreBytes == null) { KeystoreGenerationParameters params = new KeystoreGenerationParameters(PASSWORD.toCharArray()); params.setRandom(new SecureRandom()); - KeyStoreWrapper identity = new P12KeyGenerator().generateRSAKeypair(keysize, publicExponent, params, null); + KeyStoreWrapper identity = P12KeyGenerator.generateRSAKeypair(keysize, publicExponent, params, null); keystoreBytes = identity.keystore(); } return keystoreBytes; @@ -197,7 +197,7 @@ private static byte[] generateKeystore(ASN1ObjectIdentifier curveNOid) throws Ex if (keystoreBytes == null) { KeystoreGenerationParameters params = new KeystoreGenerationParameters(PASSWORD.toCharArray()); params.setRandom(new SecureRandom()); - KeyStoreWrapper identity = new P12KeyGenerator().generateECKeypair(curveNOid, params, null); + KeyStoreWrapper identity = P12KeyGenerator.generateECKeypair(curveNOid, params, null); keystoreBytes = identity.keystore(); } return keystoreBytes; diff --git a/security/src/main/java/org/xipki/security/util/PKCS1Util.java b/security/src/main/java/org/xipki/security/util/PKCS1Util.java index 26fa96b..4fbdfc3 100644 --- a/security/src/main/java/org/xipki/security/util/PKCS1Util.java +++ b/security/src/main/java/org/xipki/security/util/PKCS1Util.java @@ -142,7 +142,7 @@ public static byte[] EMSA_PSS_ENCODE(HashAlgo contentDigest, byte[] hashValue, H block[i] ^= dbMask[i]; } - block[0] &= (0xff >> ((block.length * 8) - emBits)); + block[0] &= (byte) (0xff >> ((block.length * 8) - emBits)); System.arraycopy(hv, 0, block, block.length - hLen - 1, hLen); @@ -211,7 +211,7 @@ public static boolean EMSA_PSS_DECODE(HashAlgo mgfDigest, byte[] mHash, byte[] E DB[i] = (byte)(DB[i] ^ dbMask[i]); } // 9. Set the leftmost 8.emLen ? emBits bits of DB to zero. - DB[0] &= (0xFF >>> (8*emLen - emBits)); + DB[0] &= (byte) (0xFF >>> (8*emLen - emBits)); // 10. If the emLen - hLen -sLen -2 leftmost octets of DB are not zero or // if the octet at position emLen -hLen -sLen -1 is not equal to 0x01, // output 'inconsistent' and stop. diff --git a/security/src/test/java/org/xipki/security/test/CrlTestVectorGenerateMain.java b/security/src/test/java/org/xipki/security/test/CrlTestVectorGenerateMain.java index 4a69d0b..86eeba5 100644 --- a/security/src/test/java/org/xipki/security/test/CrlTestVectorGenerateMain.java +++ b/security/src/test/java/org/xipki/security/test/CrlTestVectorGenerateMain.java @@ -14,7 +14,6 @@ import org.xipki.security.SignerConf; import org.xipki.security.X509Cert; import org.xipki.security.XiContentSigner; -import org.xipki.util.ConcurrentBag.BagEntry; import org.xipki.util.ConfPairs; import org.xipki.util.IoUtil; @@ -53,7 +52,7 @@ private static void genTestVectors() throws Exception { "PKCS12", sconf, (X509Cert) null); X509Cert caCert = csigner.getCertificate(); - BagEntry signer = csigner.borrowSigner(); + XiContentSigner signer = csigner.borrowSigner(); // no revoked certs X509v2CRLBuilder builder = getBuilder(caCert, true, true); buildCrl(builder, signer, "no-revoked-certs.crl"); @@ -87,9 +86,9 @@ private static void genTestVectors() throws Exception { } } - private static void buildCrl(X509v2CRLBuilder builder, BagEntry signer, String fn) + private static void buildCrl(X509v2CRLBuilder builder, XiContentSigner signer, String fn) throws Exception { - byte[] encoded = builder.build(signer.value()).getEncoded(); + byte[] encoded = builder.build(signer).getEncoded(); IoUtil.save("output/" + fn, encoded); } diff --git a/servlet5-common/pom.xml b/servlet-common/pom.xml similarity index 91% rename from servlet5-common/pom.xml rename to servlet-common/pom.xml index 340c57e..0298965 100644 --- a/servlet5-common/pom.xml +++ b/servlet-common/pom.xml @@ -6,9 +6,9 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT - servlet5-common + servlet-common XiPKI :: ${project.artifactId} bundle diff --git a/servlet5-common/src/main/java/org/xipki/servlet5/ServletFilter.java b/servlet-common/src/main/java/org/xipki/servlet/ServletFilter.java similarity index 98% rename from servlet5-common/src/main/java/org/xipki/servlet5/ServletFilter.java rename to servlet-common/src/main/java/org/xipki/servlet/ServletFilter.java index 3d465f5..2a6a088 100644 --- a/servlet5-common/src/main/java/org/xipki/servlet5/ServletFilter.java +++ b/servlet-common/src/main/java/org/xipki/servlet/ServletFilter.java @@ -1,7 +1,7 @@ // Copyright (c) 2013-2024 xipki. All rights reserved. // License Apache License 2.0 -package org.xipki.servlet5; +package org.xipki.servlet; import jakarta.servlet.Filter; import jakarta.servlet.FilterChain; diff --git a/servlet5-common/src/main/java/org/xipki/servlet5/XiHttpRequestImpl.java b/servlet-common/src/main/java/org/xipki/servlet/XiHttpRequestImpl.java similarity index 98% rename from servlet5-common/src/main/java/org/xipki/servlet5/XiHttpRequestImpl.java rename to servlet-common/src/main/java/org/xipki/servlet/XiHttpRequestImpl.java index c49c4a3..20e84ea 100644 --- a/servlet5-common/src/main/java/org/xipki/servlet5/XiHttpRequestImpl.java +++ b/servlet-common/src/main/java/org/xipki/servlet/XiHttpRequestImpl.java @@ -1,6 +1,6 @@ // Copyright (c) 2013-2024 xipki. All rights reserved. // License Apache License 2.0 -package org.xipki.servlet5; +package org.xipki.servlet; import jakarta.servlet.http.HttpServletRequest; import org.xipki.util.http.XiHttpRequest; diff --git a/servlet5-common/src/main/java/org/xipki/servlet5/XiHttpResponseImpl.java b/servlet-common/src/main/java/org/xipki/servlet/XiHttpResponseImpl.java similarity index 97% rename from servlet5-common/src/main/java/org/xipki/servlet5/XiHttpResponseImpl.java rename to servlet-common/src/main/java/org/xipki/servlet/XiHttpResponseImpl.java index c4e1934..f1e1a19 100644 --- a/servlet5-common/src/main/java/org/xipki/servlet5/XiHttpResponseImpl.java +++ b/servlet-common/src/main/java/org/xipki/servlet/XiHttpResponseImpl.java @@ -1,6 +1,6 @@ // Copyright (c) 2013-2024 xipki. All rights reserved. // License Apache License 2.0 -package org.xipki.servlet5; +package org.xipki.servlet; import jakarta.servlet.http.HttpServletResponse; import org.xipki.util.Args; diff --git a/servlet3-common/pom.xml b/servlet3-common/pom.xml deleted file mode 100644 index b69864c..0000000 --- a/servlet3-common/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - 4.0.0 - - org.xipki.commons - xipki-commons-parent - 6.3.4 - - servlet3-common - XiPKI :: ${project.artifactId} - bundle - - - ${project.groupId} - util - ${project.version} - - - javax.servlet - javax.servlet-api - 3.1.0 - - - diff --git a/servlet3-common/src/main/java/org/xipki/servlet3/ServletFilter.java b/servlet3-common/src/main/java/org/xipki/servlet3/ServletFilter.java deleted file mode 100644 index 95f10e0..0000000 --- a/servlet3-common/src/main/java/org/xipki/servlet3/ServletFilter.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2013-2024 xipki. All rights reserved. -// License Apache License 2.0 - -package org.xipki.servlet3; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xipki.util.http.XiHttpFilter; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Filter. - * - * @author Lijun Liao (xipki) - * @since 6.0.0 - */ -public abstract class ServletFilter implements Filter { - - private static final Logger LOG = LoggerFactory.getLogger(ServletFilter.class); - - private XiHttpFilter filter0; - - protected abstract XiHttpFilter initFilter(FilterConfig filterConfig) throws Exception; - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - try { - filter0 = initFilter(filterConfig); - } catch (Exception ex) { - LOG.error("error initializing ServletFiler", ex); - throw new ServletException(ex); - } - } - - @Override - public void destroy() { - if (filter0 != null) { - filter0.destroy(); - filter0 = null; - } - } - - @Override - public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - if (filter0 == null) { - throw new ServletException("filter is not initialized"); - } - - if (!(request instanceof HttpServletRequest & response instanceof HttpServletResponse)) { - throw new ServletException("Only HTTP request is supported"); - } - - try { - filter0.doFilter(new XiHttpRequestImpl((HttpServletRequest) request), - new XiHttpResponseImpl((HttpServletResponse) response)); - } catch (IOException ex) { - throw ex; - } catch (Exception ex) { - throw new ServletException(ex); - } - } - -} diff --git a/servlet3-common/src/main/java/org/xipki/servlet3/XiHttpRequestImpl.java b/servlet3-common/src/main/java/org/xipki/servlet3/XiHttpRequestImpl.java deleted file mode 100644 index 5eedfe9..0000000 --- a/servlet3-common/src/main/java/org/xipki/servlet3/XiHttpRequestImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2013-2024 xipki. All rights reserved. -// License Apache License 2.0 -package org.xipki.servlet3; - -import org.xipki.util.Args; -import org.xipki.util.http.XiHttpRequest; - -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; -import java.io.InputStream; -import java.security.cert.X509Certificate; - -/** - * HTTP request wrapper. - * - * @author Lijun Liao (xipki) - * @since 3.0.1 - */ - -public class XiHttpRequestImpl implements XiHttpRequest { - - private final HttpServletRequest req; - - public XiHttpRequestImpl(HttpServletRequest req) { - this.req = Args.notNull(req, "req"); - } - - @Override - public String getHeader(String headerName) { - return req.getHeader(headerName); - } - - @Override - public String getParameter(String paramName) { - return req.getParameter(paramName); - } - - @Override - public String getMethod() { - return req.getMethod(); - } - - @Override - public String getServletPath() { - return req.getServletPath(); - } - - @Override - public String getContentType() { - return req.getContentType(); - } - - @Override - public Object getAttribute(String name) { - return req.getAttribute(name); - } - - @Override - public String getRequestURI() { - return req.getRequestURI(); - } - - @Override - public String getContextPath() { - return req.getContextPath(); - } - - @Override - public X509Certificate[] getCertificateChain() { - return (X509Certificate[]) req.getAttribute("javax.servlet.request.X509Certificate"); - } - - @Override - public InputStream getInputStream() throws IOException { - return req.getInputStream(); - } - - @Override - public void setAttribute(String name, String value) { - req.setAttribute(name, value); - } - -} diff --git a/servlet3-common/src/main/java/org/xipki/servlet3/XiHttpResponseImpl.java b/servlet3-common/src/main/java/org/xipki/servlet3/XiHttpResponseImpl.java deleted file mode 100644 index bfed8a3..0000000 --- a/servlet3-common/src/main/java/org/xipki/servlet3/XiHttpResponseImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2013-2024 xipki. All rights reserved. -// License Apache License 2.0 -package org.xipki.servlet3; - -import org.xipki.util.Args; -import org.xipki.util.http.XiHttpResponse; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.OutputStream; - -/** - * HTTP response wrapper. - * - * @author Lijun Liao (xipki) - */ -public class XiHttpResponseImpl implements XiHttpResponse { - - private final HttpServletResponse resp; - - public XiHttpResponseImpl(HttpServletResponse resp) { - this.resp = Args.notNull(resp, "resp"); - } - - @Override - public void setStatus(int sc) { - resp.setStatus(sc); - } - - @Override - public void sendError(int sc) throws IOException { - resp.sendError(sc); - } - - @Override - public void setContentType(String type) { - resp.setContentType(type); - } - - @Override - public void addHeader(String name, String value) { - resp.addHeader(name, value); - } - - @Override - public void setHeader(String name, String value) { - resp.setHeader(name, value); - } - - @Override - public void setContentLength(int len) { - resp.setContentLength(len); - } - - @Override - public OutputStream getOutputStream() throws IOException { - return resp.getOutputStream(); - } -} diff --git a/shell-base/pom.xml b/shell-base/pom.xml index e98b954..7a870ef 100644 --- a/shell-base/pom.xml +++ b/shell-base/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT shell-base bundle diff --git a/util/pom.xml b/util/pom.xml index 3c56474..04241e4 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT bundle util diff --git a/util/src/main/java/org/xipki/util/ConcurrentBag.java b/util/src/main/java/org/xipki/util/ConcurrentBag.java deleted file mode 100644 index dafd500..0000000 --- a/util/src/main/java/org/xipki/util/ConcurrentBag.java +++ /dev/null @@ -1,553 +0,0 @@ -// #THIRDPARTY# HikariCP - -/* - * Copyright (C) 2013, 2014 Brett Wooldridge - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.xipki.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.ref.WeakReference; -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import java.util.RandomAccess; -import java.util.Spliterator; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.function.Consumer; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; - -import static java.util.concurrent.TimeUnit.MICROSECONDS; -import static java.util.concurrent.TimeUnit.NANOSECONDS; -import static java.util.concurrent.locks.LockSupport.parkNanos; - -/** - * This is a specialized concurrent bag that achieves superior performance - * to LinkedBlockingQueue and LinkedTransferQueue for the purposes of a - * connection pool. It uses ThreadLocal storage when possible to avoid - * locks, but resorts to scanning a common collection if there are no - * available items in the ThreadLocal list. Not-in-use items in the - * ThreadLocal lists can be "stolen" when the borrowing thread has none - * of its own. It is a "lock-less" implementation using a specialized - * AbstractQueuedLongSynchronizer to manage cross-thread signaling. - *

- * Note that items that are "borrowed" from the bag are not actually - * removed from any collection, so garbage collection will not occur - * even if the reference is abandoned. Thus care must be taken to - * "requite" borrowed objects otherwise a memory leak will result. Only - * the "remove" method can completely remove an object from the bag. - * - * @author Brett Wooldridge - * @author Lijun Liao (xipki) - * - * @param the templated type to store in the bag - */ -public class ConcurrentBag implements AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(ConcurrentBag.class); - - private final CopyOnWriteArrayList> sharedList; - private final boolean weakThreadLocals; - - private final ThreadLocal> threadList; - private final AtomicInteger waiters; - private volatile boolean closed; - - private final SynchronousQueue> handoffQueue; - - private static final int STATE_NOT_IN_USE = 0; - private static final int STATE_IN_USE = 1; - private static final int STATE_REMOVED = -1; - private static final int STATE_RESERVED = -2; - - /** - * Construct a ConcurrentBag with the specified listener. - */ - public ConcurrentBag() { - this.weakThreadLocals = useWeakThreadLocals(); - - this.handoffQueue = new SynchronousQueue<>(true); - this.waiters = new AtomicInteger(); - this.sharedList = new CopyOnWriteArrayList<>(); - if (weakThreadLocals) { - this.threadList = ThreadLocal.withInitial(() -> new ArrayList<>(16)); - } else { - this.threadList = ThreadLocal.withInitial(() -> new FastList<>(BagEntry.class, 16)); - } - } - - /** - * The method will borrow a BagEntry from the bag, blocking for the - * specified timeout if none are available. - * - * @param timeout how long to wait before giving up, in units of unit - * @param timeUnit a TimeUnit determining how to interpret the timeout parameter - * @return a borrowed instance from the bag or null if a timeout occurs - * @throws InterruptedException if interrupted while waiting - */ - public BagEntry borrow(long timeout, final TimeUnit timeUnit) throws InterruptedException { - // Try the thread-local list first - final List list = threadList.get(); - for (int i = list.size() - 1; i >= 0; i--) { - final Object entry = list.remove(i); - @SuppressWarnings("unchecked") - final BagEntry bagEntry = weakThreadLocals ? ((WeakReference>) entry).get() : (BagEntry) entry; - if (bagEntry != null && bagEntry.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) { - return bagEntry; - } - } - - try { - for (BagEntry bagEntry : sharedList) { - if (bagEntry.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) { - return bagEntry; - } - } - - timeout = timeUnit.toNanos(timeout); - do { - final long start = System.nanoTime(); - final BagEntry bagEntry = handoffQueue.poll(timeout, NANOSECONDS); - if (bagEntry == null || bagEntry.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) { - return bagEntry; - } - - timeout -= System.nanoTime() - start; - } while (timeout > 10_000); - - return null; - } finally { - waiters.decrementAndGet(); - } - } - - /** - * This method will return a borrowed object to the bag. Objects - * that are borrowed from the bag but never "requited" will result - * in a memory leak. - * - * @param bagEntry the value to return to the bag - * @throws NullPointerException if value is null - * @throws IllegalStateException if the bagEntry was not borrowed from the bag - */ - public void requite(final BagEntry bagEntry) { - bagEntry.setState(STATE_NOT_IN_USE); - - for (int i = 0; waiters.get() > 0; i++) { - if (bagEntry.getState() != STATE_NOT_IN_USE || handoffQueue.offer(bagEntry)) { - return; - } else if ((i & 0xff) == 0xff) { - parkNanos(MICROSECONDS.toNanos(10)); - } else { - Thread.yield(); - } - } - - final List threadLocalList = threadList.get(); - if (threadLocalList.size() < 50) { - threadLocalList.add(weakThreadLocals ? new WeakReference<>(bagEntry) : bagEntry); - } - } - - /** - * Add a new object to the bag for others to borrow. - * - * @param bagEntry an object to add to the bag - */ - public void add(final BagEntry bagEntry) { - if (closed) { - LOG.info("ConcurrentBag has been closed, ignoring add()"); - throw new IllegalStateException("ConcurrentBag has been closed, ignoring add()"); - } - - sharedList.add(bagEntry); - - // spin until a thread takes it or none are waiting - while (waiters.get() > 0 && bagEntry.getState() == STATE_NOT_IN_USE && !handoffQueue.offer(bagEntry)) { - Thread.yield(); - } - } - - /** - * Remove a value from the bag. This method should only be called - * with objects obtained by borrow(long, TimeUnit) or reserve(T) - * - * @param bagEntry the value to remove - * @return true if the entry was removed, false otherwise - * @throws IllegalStateException if an attempt is made to remove an object - * from the bag that was not borrowed or reserved first - */ - public boolean remove(final BagEntry bagEntry) { - if (!bagEntry.compareAndSet(STATE_IN_USE, STATE_REMOVED) - && !bagEntry.compareAndSet(STATE_RESERVED, STATE_REMOVED) && !closed) { - LOG.warn("Attempt to remove an object from the bag that was not borrowed or reserved: {}", bagEntry); - return false; - } - - final boolean removed = sharedList.remove(bagEntry); - if (!removed && !closed) { - LOG.warn("Attempt to remove an object from the bag that does not exist: {}", bagEntry); - } - - threadList.get().remove(bagEntry); - - return removed; - } - - /** - * Close the bag to further adds. - */ - @Override - public void close() { - closed = true; - } - - /** - * This method provides a "snapshot" in time of the bag items. It - * does not "lock" or reserve items in any way. Call reserve(T) - * on items in the list, or understand the concurrency implications of - * modifying items, before performing any action on them. - * - * @return a possibly empty list of (all) bag items - */ - @SuppressWarnings("unchecked") - public List> values() { - return (List>) sharedList.clone(); - } - - /** - * Get the total number of items in the bag. - * - * @return the number of items in the bag - */ - public int size() { - return sharedList.size(); - } - - /** - * Determine whether to use WeakReferences based on whether there is a - * custom ClassLoader implementation sitting between this class and the - * System ClassLoader. - * - * @return true if we should use WeakReferences in our ThreadLocals, false otherwise - */ - private boolean useWeakThreadLocals() { - try { - return getClass().getClassLoader() != ClassLoader.getSystemClassLoader(); - } catch (SecurityException se) { - return true; - } - } - - public static class BagEntry { - - @SuppressWarnings({ "unused" }) - private volatile int state = 0; // Don't delete me and add final declaration, will be used by the stateUpdater - - private static final AtomicIntegerFieldUpdater stateUpdater; - - private final T value; - - static { - stateUpdater = AtomicIntegerFieldUpdater.newUpdater(BagEntry.class, "state"); - } - - public BagEntry(T value) { - this.value = value; - } - - public T value() { - return value; - } - - public int getState() { - return stateUpdater.get(this); - } - - public boolean compareAndSet(int expect, int update) { - return stateUpdater.compareAndSet(this, expect, update); - } - - public void setState(int update) { - stateUpdater.set(this, update); - } - - } - - /** - * Fast list without range checking. - * - * @author Brett Wooldridge - */ - private static final class FastList implements List, RandomAccess { - - private final Class clazz; - private T[] elementData; - private int size; - - /** - * Construct a FastList with a specified size. - * @param clazz the Class stored in the collection - * @param capacity the initial size of the FastList - */ - @SuppressWarnings("unchecked") - public FastList(Class clazz, int capacity) { - this.elementData = (T[]) Array.newInstance(clazz, capacity); - this.clazz = clazz; - } - - /** - * Add an element to the tail of the FastList. - * - * @param element the element to add - */ - @Override - public boolean add(T element) { - if (size < elementData.length) { - elementData[size++] = element; - } else { - // overflow-conscious code - final int oldCapacity = elementData.length; - final int newCapacity = oldCapacity << 1; - @SuppressWarnings("unchecked") - final T[] newElementData = (T[]) Array.newInstance(clazz, newCapacity); - System.arraycopy(elementData, 0, newElementData, 0, oldCapacity); - newElementData[size++] = element; - elementData = newElementData; - } - - return true; - } - - /** - * Get the element at the specified index. - * - * @param index the index of the element to get - * @return the element, or ArrayIndexOutOfBounds is thrown if the index is invalid - */ - @Override - public T get(int index) { - return elementData[index]; - } - - /** - * This remove method is most efficient when the element being removed - * is the last element. Equality is identity based, not equals() based. - * Only the first matching element is removed. - * - * @param element the element to remove - */ - @Override - public boolean remove(Object element) { - for (int index = size - 1; index >= 0; index--) { - if (element == elementData[index]) { - final int numMoved = size - index - 1; - if (numMoved > 0) { - System.arraycopy(elementData, index + 1, elementData, index, numMoved); - } - elementData[--size] = null; - return true; - } - } - - return false; - } - - /** - * Clear the FastList. - */ - @Override - public void clear() { - for (int i = 0; i < size; i++) { - elementData[i] = null; - } - - size = 0; - } - - /** - * Get the current number of elements in the FastList. - * - * @return the number of current elements - */ - @Override - public int size() { - return size; - } - - @Override - public boolean isEmpty() { - return size == 0; - } - - @Override - public T set(int index, T element) { - T old = elementData[index]; - elementData[index] = element; - return old; - } - - @Override - public T remove(int index) { - if (size == 0) { - return null; - } - - final T old = elementData[index]; - - final int numMoved = size - index - 1; - if (numMoved > 0) { - System.arraycopy(elementData, index + 1, elementData, index, numMoved); - } - - elementData[--size] = null; - - return old; - } - - @Override - public boolean contains(Object o) { - throw new UnsupportedOperationException(); - } - - @Override - public Iterator iterator() { - return new Iterator<>() { - private int index; - - @Override - public boolean hasNext() { - return index < size; - } - - @Override - public T next() { - if (index < size) { - return elementData[index++]; - } - - throw new NoSuchElementException("No more elements in FastList"); - } - }; - } - - @Override - public Object[] toArray() { - throw new UnsupportedOperationException(); - } - - @Override - public E[] toArray(E[] a) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean containsAll(Collection c) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean addAll(int index, Collection c) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - - @Override - public void add(int index, T element) { - throw new UnsupportedOperationException(); - } - - @Override - public int indexOf(Object o) { - throw new UnsupportedOperationException(); - } - - @Override - public int lastIndexOf(Object o) { - throw new UnsupportedOperationException(); - } - - @Override - public ListIterator listIterator() { - throw new UnsupportedOperationException(); - } - - @Override - public ListIterator listIterator(int index) { - throw new UnsupportedOperationException(); - } - - @Override - public List subList(int fromIndex, int toIndex) { - throw new UnsupportedOperationException(); - } - - @Override - public Object clone() { - throw new UnsupportedOperationException(); - } - - @Override - public void forEach(Consumer action) { - throw new UnsupportedOperationException(); - } - - @Override - public Spliterator spliterator() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean removeIf(Predicate filter) { - throw new UnsupportedOperationException(); - } - - @Override - public void replaceAll(UnaryOperator operator) { - throw new UnsupportedOperationException(); - } - - @Override - public void sort(Comparator c) { - throw new UnsupportedOperationException(); - } - - } -} diff --git a/util/src/main/java/org/xipki/util/cbor/ByteArrayCborDecoder.java b/util/src/main/java/org/xipki/util/cbor/ByteArrayCborDecoder.java deleted file mode 100644 index 787ab49..0000000 --- a/util/src/main/java/org/xipki/util/cbor/ByteArrayCborDecoder.java +++ /dev/null @@ -1,44 +0,0 @@ -// #THIRDPARTY -/* - * JACOB - CBOR implementation in Java. - * - * (C) Copyright - 2013 - J.W. Janssen - * - * Licensed under Apache License v2.0. - */ -package org.xipki.util.cbor; - -import org.xipki.util.Args; - -import java.io.ByteArrayInputStream; - -public class ByteArrayCborDecoder extends CborDecoder { - - /** - * Creates a new {@link ByteArrayCborDecoder} instance. - * @param bytes the encoded cbor message. - */ - public ByteArrayCborDecoder(byte[] bytes) { - this(bytes, 0, bytes.length); - } - - /** - * Creates a new {@link ByteArrayCborDecoder} instance. - * @param bytes the encoded cbor message. - * @param offset offset of bytes. - */ - public ByteArrayCborDecoder(byte[] bytes, int offset) { - this(bytes, offset, bytes.length - offset); - } - - /** - * Creates a new {@link ByteArrayCborDecoder} instance. - * @param bytes the encoded cbor message. - * @param offset offset of bytes for the cbor message. - * @param len length of the bytes for the cbor message. - */ - public ByteArrayCborDecoder(byte[] bytes, int offset, int len) { - super(new ByteArrayInputStream(bytes, Args.min(offset, "offset", 0), Args.min(len, "len", 0))); - } - -} diff --git a/util/src/main/java/org/xipki/util/cbor/CborDecoder.java b/util/src/main/java/org/xipki/util/cbor/CborDecoder.java index 6d046ed..d1600f4 100644 --- a/util/src/main/java/org/xipki/util/cbor/CborDecoder.java +++ b/util/src/main/java/org/xipki/util/cbor/CborDecoder.java @@ -10,6 +10,7 @@ import org.xipki.util.DateUtil; import org.xipki.util.exception.DecodeException; +import java.io.ByteArrayInputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; @@ -27,6 +28,17 @@ public class CborDecoder implements AutoCloseable { protected final PushbackInputStream m_is; + + public CborDecoder(byte[] bytes) { + this(bytes, 0, bytes.length); + } + + public CborDecoder(byte[] bytes, int offset, int length) { + this(new ByteArrayInputStream(bytes, + Args.min(offset, "offset", 0), + Args.min(length, "length", 0))); + } + /** * Creates a new {@link CborDecoder} instance. * @@ -533,7 +545,7 @@ protected int readUInt16() throws IOException { */ protected long readUInt32() throws IOException { byte[] buf = readFully(new byte[4]); - return ((buf[0] & 0xFF) << 24 | (buf[1] & 0xFF) << 16 | (buf[2] & 0xFF) << 8 | (buf[3] & 0xFF)) & 0xffffffffL; + return ((buf[0] & 0xFFL) << 24 | (buf[1] & 0xFF) << 16 | (buf[2] & 0xFF) << 8 | (buf[3] & 0xFF)) & 0xffffffffL; } /** @@ -619,7 +631,7 @@ public Integer readNullOrArrayLength() throws IOException, DecodeException { } } - public Integer readNullOrArrayLength(Class clazz) throws DecodeException { + public Integer readNullOrArrayLength(Class clazz) throws DecodeException { try { return readNullOrArrayLength(); } catch (IOException ex) { @@ -777,7 +789,7 @@ public BigInteger[] readBigInts() throws IOException, DecodeException { } BigInteger[] ret = new BigInteger[arrayLen]; - for (int i = 0; i < arrayLen.intValue(); i++) { + for (int i = 0; i < arrayLen; i++) { ret[i] = readBigInt(); } diff --git a/xipki-tomcat-password/pom.xml b/xipki-tomcat-password/pom.xml index 7bce74c..8f0eb0a 100644 --- a/xipki-tomcat-password/pom.xml +++ b/xipki-tomcat-password/pom.xml @@ -6,7 +6,7 @@ org.xipki.commons xipki-commons-parent - 6.3.4 + 6.3.5-SNAPSHOT xipki-tomcat-password @@ -14,7 +14,7 @@ org.apache.tomcat tomcat-coyote - 9.0.73 + 10.1.31 ${project.groupId}