diff --git a/gradle/compile/java.gradle b/gradle/compile/java.gradle index b011802..8d7f2e5 100644 --- a/gradle/compile/java.gradle +++ b/gradle/compile/java.gradle @@ -22,10 +22,11 @@ jar { } tasks.withType(JavaCompile) { - options.compilerArgs.add('-Xlint:all,-exports') + options.compilerArgs.add('-Xlint:all') + options.encoding = 'UTF-8' } -javadoc { +tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') } diff --git a/net-bouncycastle/src/main/java/module-info.java b/net-bouncycastle/src/main/java/module-info.java index 2d6a788..690a6c5 100644 --- a/net-bouncycastle/src/main/java/module-info.java +++ b/net-bouncycastle/src/main/java/module-info.java @@ -2,7 +2,7 @@ import org.xbib.net.security.CertificateProvider; import org.xbib.net.bouncycastle.BouncyCastleCertificateProvider; module org.xbib.net.bouncycastle { - requires org.xbib.net.security; + requires transitive org.xbib.net.security; requires org.bouncycastle.pkix; requires org.bouncycastle.provider; exports org.xbib.net.bouncycastle; diff --git a/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/BouncyCastleCertificateProvider.java b/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/BouncyCastleCertificateProvider.java index a57ef1e..b86f5ff 100644 --- a/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/BouncyCastleCertificateProvider.java +++ b/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/BouncyCastleCertificateProvider.java @@ -5,7 +5,6 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.openssl.PEMKeyPair; import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; -import org.bouncycastle.operator.OperatorCreationException; import org.xbib.net.security.CertificateProvider; import java.io.IOException; @@ -13,8 +12,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.security.KeyPair; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.Provider; import java.security.SecureRandom; @@ -55,12 +52,8 @@ public class BouncyCastleCertificateProvider implements CertificateProvider { @Override public Map.Entry> provideSelfSigned(String fullQualifiedDomainName) throws CertificateException, IOException { - try { - SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate(); - selfSignedCertificate.generate(fullQualifiedDomainName, secureRandom, 2048); - return Map.entry(selfSignedCertificate.getPrivateKey(), List.of(selfSignedCertificate.getCertificate())); - } catch (NoSuchProviderException | NoSuchAlgorithmException | OperatorCreationException e) { - throw new IOException(e); - } + SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate(); + selfSignedCertificate.generate(fullQualifiedDomainName, secureRandom, 2048); + return Map.entry(selfSignedCertificate.getPrivateKey(), List.of(selfSignedCertificate.getCertificate())); } } diff --git a/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/SelfSignedCertificate.java b/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/SelfSignedCertificate.java index 52c6953..eb8ecf0 100644 --- a/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/SelfSignedCertificate.java +++ b/net-bouncycastle/src/main/java/org/xbib/net/bouncycastle/SelfSignedCertificate.java @@ -70,44 +70,45 @@ public final class SelfSignedCertificate { * @param fqdn a fully qualified domain name * @param random the {@link SecureRandom} to use * @param bits the number of bits of the generated private key - * @throws NoSuchAlgorithmException if algorithm does not exist - * @throws NoSuchProviderException if provider does not exist - * @throws OperatorCreationException if provider does not exist * @throws IOException if generation fails */ public void generate(String fqdn, SecureRandom random, int bits) - throws IOException, NoSuchProviderException, NoSuchAlgorithmException, OperatorCreationException { - KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC"); - keyGen.initialize(bits, random); - KeyPair keypair = keyGen.generateKeyPair(); - this.key = keypair.getPrivate(); - X500Name name = new X500Name("CN=" + fqdn); - SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(keypair.getPublic().getEncoded()); - X509v3CertificateBuilder certificateBuilder = - new X509v3CertificateBuilder(name, BigInteger.valueOf(System.currentTimeMillis()), - DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER, name, subjectPublicKeyInfo); - AlgorithmIdentifier sigAlgId = - new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256WithRSAEncryption"); - AlgorithmIdentifier digestAlgId = - new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId); - AsymmetricKeyParameter caPrivateKeyParameters = PrivateKeyFactory.createKey(key.getEncoded()); - ContentSigner contentSigner = new BcRSAContentSignerBuilder(sigAlgId, digestAlgId) - .build(caPrivateKeyParameters); - this.cert = certificateBuilder.build(contentSigner); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - outputStream.write(BEGIN_KEY.getBytes(StandardCharsets.US_ASCII)); - outputStream.write('\n'); - writeEncoded(key.getEncoded(), outputStream); - outputStream.write(END_KEY.getBytes(StandardCharsets.US_ASCII)); - outputStream.write('\n'); - this.keyBytes = outputStream.toByteArray(); - outputStream = new ByteArrayOutputStream(); - outputStream.write(BEGIN_CERT.getBytes(StandardCharsets.US_ASCII)); - outputStream.write('\n'); - writeEncoded(cert.getEncoded(), outputStream); - outputStream.write(END_CERT.getBytes(StandardCharsets.US_ASCII)); - outputStream.write('\n'); - this.certBytes = outputStream.toByteArray(); + throws IOException { + try { + KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC"); + keyGen.initialize(bits, random); + KeyPair keypair = keyGen.generateKeyPair(); + this.key = keypair.getPrivate(); + X500Name name = new X500Name("CN=" + fqdn); + SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(keypair.getPublic().getEncoded()); + X509v3CertificateBuilder certificateBuilder = + new X509v3CertificateBuilder(name, BigInteger.valueOf(System.currentTimeMillis()), + DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER, name, subjectPublicKeyInfo); + AlgorithmIdentifier sigAlgId = + new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256WithRSAEncryption"); + AlgorithmIdentifier digestAlgId = + new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId); + AsymmetricKeyParameter caPrivateKeyParameters = PrivateKeyFactory.createKey(key.getEncoded()); + ContentSigner contentSigner = new BcRSAContentSignerBuilder(sigAlgId, digestAlgId) + .build(caPrivateKeyParameters); + this.cert = certificateBuilder.build(contentSigner); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + outputStream.write(BEGIN_KEY.getBytes(StandardCharsets.US_ASCII)); + outputStream.write('\n'); + writeEncoded(key.getEncoded(), outputStream); + outputStream.write(END_KEY.getBytes(StandardCharsets.US_ASCII)); + outputStream.write('\n'); + this.keyBytes = outputStream.toByteArray(); + outputStream = new ByteArrayOutputStream(); + outputStream.write(BEGIN_CERT.getBytes(StandardCharsets.US_ASCII)); + outputStream.write('\n'); + writeEncoded(cert.getEncoded(), outputStream); + outputStream.write(END_CERT.getBytes(StandardCharsets.US_ASCII)); + outputStream.write('\n'); + this.certBytes = outputStream.toByteArray(); + } catch (NoSuchProviderException | NoSuchAlgorithmException | OperatorCreationException e) { + throw new IOException(e); + } } /** diff --git a/net-security/src/main/java/module-info.java b/net-security/src/main/java/module-info.java index cee7b1e..1a8e45e 100644 --- a/net-security/src/main/java/module-info.java +++ b/net-security/src/main/java/module-info.java @@ -11,5 +11,6 @@ module org.xbib.net.security { exports org.xbib.net.security.eddsa.spec; exports org.xbib.net.security.signatures; exports org.xbib.net.security.ssl; + exports org.xbib.net.security.ssl.trustmanager; exports org.xbib.net.security.util; } diff --git a/net-socket/src/main/java/module-info.java b/net-socket/src/main/java/module-info.java index 9507bd4..cba6f25 100644 --- a/net-socket/src/main/java/module-info.java +++ b/net-socket/src/main/java/module-info.java @@ -1,6 +1,6 @@ module org.xbib.net.socket { requires java.logging; - requires com.sun.jna; + requires transitive com.sun.jna; exports org.xbib.net.socket; exports org.xbib.net.socket.v4; exports org.xbib.net.socket.v4.bsd; diff --git a/net/src/main/java/module-info.java b/net/src/main/java/module-info.java index 1562019..f4ae050 100644 --- a/net/src/main/java/module-info.java +++ b/net/src/main/java/module-info.java @@ -15,7 +15,7 @@ module org.xbib.net { exports org.xbib.net.util; requires transitive org.xbib.datastructures.common; requires java.management; - requires java.logging; + requires transitive java.logging; uses DataBufferFactory; provides DataBufferFactory with DefaultDataBufferFactory; }