clean up module info

This commit is contained in:
Jörg Prante 2022-11-02 22:01:27 +01:00
parent cdc4639347
commit 3049d51e96
7 changed files with 46 additions and 50 deletions

View file

@ -22,10 +22,11 @@ jar {
} }
tasks.withType(JavaCompile) { 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') options.addStringOption('Xdoclint:none', '-quiet')
} }

View file

@ -2,7 +2,7 @@ import org.xbib.net.security.CertificateProvider;
import org.xbib.net.bouncycastle.BouncyCastleCertificateProvider; import org.xbib.net.bouncycastle.BouncyCastleCertificateProvider;
module org.xbib.net.bouncycastle { module org.xbib.net.bouncycastle {
requires org.xbib.net.security; requires transitive org.xbib.net.security;
requires org.bouncycastle.pkix; requires org.bouncycastle.pkix;
requires org.bouncycastle.provider; requires org.bouncycastle.provider;
exports org.xbib.net.bouncycastle; exports org.xbib.net.bouncycastle;

View file

@ -5,7 +5,6 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.PEMKeyPair; import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.bouncycastle.operator.OperatorCreationException;
import org.xbib.net.security.CertificateProvider; import org.xbib.net.security.CertificateProvider;
import java.io.IOException; import java.io.IOException;
@ -13,8 +12,6 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.KeyPair; import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.Provider; import java.security.Provider;
import java.security.SecureRandom; import java.security.SecureRandom;
@ -55,12 +52,8 @@ public class BouncyCastleCertificateProvider implements CertificateProvider {
@Override @Override
public Map.Entry<PrivateKey, Collection<? extends X509Certificate>> provideSelfSigned(String fullQualifiedDomainName) throws CertificateException, IOException { public Map.Entry<PrivateKey, Collection<? extends X509Certificate>> provideSelfSigned(String fullQualifiedDomainName) throws CertificateException, IOException {
try {
SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate(); SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate();
selfSignedCertificate.generate(fullQualifiedDomainName, secureRandom, 2048); selfSignedCertificate.generate(fullQualifiedDomainName, secureRandom, 2048);
return Map.entry(selfSignedCertificate.getPrivateKey(), List.of(selfSignedCertificate.getCertificate())); return Map.entry(selfSignedCertificate.getPrivateKey(), List.of(selfSignedCertificate.getCertificate()));
} catch (NoSuchProviderException | NoSuchAlgorithmException | OperatorCreationException e) {
throw new IOException(e);
}
} }
} }

View file

@ -70,13 +70,11 @@ public final class SelfSignedCertificate {
* @param fqdn a fully qualified domain name * @param fqdn a fully qualified domain name
* @param random the {@link SecureRandom} to use * @param random the {@link SecureRandom} to use
* @param bits the number of bits of the generated private key * @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 * @throws IOException if generation fails
*/ */
public void generate(String fqdn, SecureRandom random, int bits) public void generate(String fqdn, SecureRandom random, int bits)
throws IOException, NoSuchProviderException, NoSuchAlgorithmException, OperatorCreationException { throws IOException {
try {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC"); KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC");
keyGen.initialize(bits, random); keyGen.initialize(bits, random);
KeyPair keypair = keyGen.generateKeyPair(); KeyPair keypair = keyGen.generateKeyPair();
@ -108,6 +106,9 @@ public final class SelfSignedCertificate {
outputStream.write(END_CERT.getBytes(StandardCharsets.US_ASCII)); outputStream.write(END_CERT.getBytes(StandardCharsets.US_ASCII));
outputStream.write('\n'); outputStream.write('\n');
this.certBytes = outputStream.toByteArray(); this.certBytes = outputStream.toByteArray();
} catch (NoSuchProviderException | NoSuchAlgorithmException | OperatorCreationException e) {
throw new IOException(e);
}
} }
/** /**

View file

@ -11,5 +11,6 @@ module org.xbib.net.security {
exports org.xbib.net.security.eddsa.spec; exports org.xbib.net.security.eddsa.spec;
exports org.xbib.net.security.signatures; exports org.xbib.net.security.signatures;
exports org.xbib.net.security.ssl; exports org.xbib.net.security.ssl;
exports org.xbib.net.security.ssl.trustmanager;
exports org.xbib.net.security.util; exports org.xbib.net.security.util;
} }

View file

@ -1,6 +1,6 @@
module org.xbib.net.socket { module org.xbib.net.socket {
requires java.logging; requires java.logging;
requires com.sun.jna; requires transitive com.sun.jna;
exports org.xbib.net.socket; exports org.xbib.net.socket;
exports org.xbib.net.socket.v4; exports org.xbib.net.socket.v4;
exports org.xbib.net.socket.v4.bsd; exports org.xbib.net.socket.v4.bsd;

View file

@ -15,7 +15,7 @@ module org.xbib.net {
exports org.xbib.net.util; exports org.xbib.net.util;
requires transitive org.xbib.datastructures.common; requires transitive org.xbib.datastructures.common;
requires java.management; requires java.management;
requires java.logging; requires transitive java.logging;
uses DataBufferFactory; uses DataBufferFactory;
provides DataBufferFactory with DefaultDataBufferFactory; provides DataBufferFactory with DefaultDataBufferFactory;
} }