lift tests to module path

This commit is contained in:
Jörg Prante 2024-03-04 13:54:05 +01:00
parent 9e30dd2e1c
commit 96f47650b5
123 changed files with 522 additions and 214 deletions

View file

@ -0,0 +1,5 @@
module org.xbib.net.benchmark.jmh {
requires jmh.core;
requires org.xbib.net;
requires org.xbib.net.path;
}

View file

@ -1,18 +1,14 @@
plugins { plugins {
id "checkstyle"
id "pmd"
id 'maven-publish' id 'maven-publish'
id 'signing' id 'signing'
id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-1" id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-1"
id "com.github.spotbugs" version "6.0.0-beta.3"
id "org.cyclonedx.bom" version "1.7.4"
id "org.xbib.gradle.plugin.asciidoctor" version "3.0.0" id "org.xbib.gradle.plugin.asciidoctor" version "3.0.0"
} }
wrapper { wrapper {
gradleVersion = libs.versions.gradle.get() gradleVersion = libs.versions.gradle.get()
distributionType = Wrapper.DistributionType.ALL distributionType = Wrapper.DistributionType.BIN
} }
ext { ext {
@ -36,11 +32,7 @@ subprojects {
apply from: rootProject.file('gradle/compile/java.gradle') apply from: rootProject.file('gradle/compile/java.gradle')
apply from: rootProject.file('gradle/test/junit5.gradle') apply from: rootProject.file('gradle/test/junit5.gradle')
apply from: rootProject.file('gradle/documentation/asciidoc.gradle') apply from: rootProject.file('gradle/documentation/asciidoc.gradle')
apply from: rootProject.file('gradle/quality/checkstyle.gradle')
apply from: rootProject.file('gradle/quality/pmd.gradle')
//apply from: rootProject.file('gradle/quality/spotbugs.gradle')
apply from: rootProject.file('gradle/publish/maven.gradle') apply from: rootProject.file('gradle/publish/maven.gradle')
} }
apply from: rootProject.file('gradle/publish/sonatype.gradle') apply from: rootProject.file('gradle/publish/sonatype.gradle')
apply from: rootProject.file('gradle/publish/forgejo.gradle') apply from: rootProject.file('gradle/publish/forgejo.gradle')
apply from: rootProject.file('gradle/quality/cyclonedx.gradle')

View file

@ -1,3 +1,3 @@
group = org.xbib group = org.xbib
name = net name = net
version = 4.2.0 version = 4.3.0

View file

@ -17,13 +17,29 @@ jar {
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
doFirst {
options.fork = true options.fork = true
options.forkOptions.jvmArgs += ['-Duser.language=en','-Duser.country=US'] options.forkOptions.jvmArgs += ['-Duser.language=en','-Duser.country=US']
options.compilerArgs.add('-Xlint:all')
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
options.compilerArgs.add('-Xlint:all')
// enforce presence of module-info.java
options.compilerArgs.add("--module-path")
options.compilerArgs.add(classpath.asPath)
classpath = files()
}
} }
tasks.withType(Javadoc) { tasks.withType(Javadoc) {
doFirst {
options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }
}
tasks.withType(JavaExec) {
doFirst {
jvmArguments.add("--module-path")
jvmArguments.add(classpath.asPath)
classpath = files()
}
}

View file

@ -11,7 +11,6 @@ test {
jvmArgs '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED', jvmArgs '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED', '--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED',
'--add-exports=java.base/sun.nio.ch=ALL-UNNAMED', '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
'--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED', '--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED', '--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED',
'--add-opens=java.base/java.lang=ALL-UNNAMED', '--add-opens=java.base/java.lang=ALL-UNNAMED',

12
net-mime/build.gradle Normal file
View file

@ -0,0 +1,12 @@
def moduleName = 'org.xbib.net.mime.test'
def patchArgs = ['--patch-module', "$moduleName=" + files(sourceSets.test.resources.srcDirs).asPath ]
tasks.named('compileTestJava') {
options.compilerArgs += patchArgs
}
tasks.named('test') {
jvmArgs += patchArgs
}

View file

@ -0,0 +1,6 @@
module org.xbib.net.mime.test {
requires java.logging;
requires org.junit.jupiter.api;
requires org.xbib.net.mime;
exports org.xbib.net.mime.test;
}

View file

@ -17,7 +17,7 @@ public class MimeMultipartTest {
@Test @Test
public void multiPartTest() throws MimeException, IOException { public void multiPartTest() throws MimeException, IOException {
try (InputStream inputStream = getClass().getResourceAsStream("/org/xbib/net/mime/test/msg.txt")) { try (InputStream inputStream = getClass().getResourceAsStream("msg.txt")) {
Objects.requireNonNull(inputStream); Objects.requireNonNull(inputStream);
MimeMultipartParser parser = new MimeMultipartParser("multipart/mixed; boundary=\"----=_Part_4_910054940.1065629194743\"; charset=\"ISO-8859-1\""); MimeMultipartParser parser = new MimeMultipartParser("multipart/mixed; boundary=\"----=_Part_4_910054940.1065629194743\"; charset=\"ISO-8859-1\"");
parser.parse(ByteBuffer.wrap(inputStream.readAllBytes()), parser.parse(ByteBuffer.wrap(inputStream.readAllBytes()),

View file

@ -1,3 +1,14 @@
dependencies { dependencies {
api project(':net') api project(':net')
} }
def moduleName = 'org.xbib.net.path.test'
def patchArgs = ['--patch-module', "$moduleName=" + files(sourceSets.test.resources.srcDirs).asPath ]
tasks.named('compileTestJava') {
options.compilerArgs += patchArgs
}
tasks.named('test') {
jvmArgs += patchArgs
}

View file

@ -0,0 +1,13 @@
module org.xbib.net.path.test {
requires transitive org.junit.jupiter.api;
requires org.hamcrest;
requires org.xbib.net.path;
exports org.xbib.net.path.test;
exports org.xbib.net.path.test.simple;
exports org.xbib.net.path.test.spring;
exports org.xbib.net.path.test.structure;
opens org.xbib.net.path.test;
opens org.xbib.net.path.test.simple;
opens org.xbib.net.path.test.spring;
opens org.xbib.net.path.test.structure;
}

View file

@ -1,8 +1,9 @@
package org.xbib.net.path; package org.xbib.net.path.test;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.Parameter; import org.xbib.net.Parameter;
import org.xbib.net.URL; import org.xbib.net.URL;
import org.xbib.net.path.PathDecoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;

View file

@ -1,4 +1,4 @@
package org.xbib.net.path.simple; package org.xbib.net.path.test.simple;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View file

@ -1,8 +1,9 @@
package org.xbib.net.path.simple; package org.xbib.net.path.test.simple;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.Parameter; import org.xbib.net.Parameter;
import org.xbib.net.ParameterException; import org.xbib.net.ParameterException;
import org.xbib.net.path.simple.PathResolver;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;

View file

@ -1,6 +1,8 @@
package org.xbib.net.path.simple; package org.xbib.net.path.test.simple;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.path.simple.Path;
import org.xbib.net.path.simple.PathComparator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View file

@ -1,7 +1,8 @@
package org.xbib.net.path.spring; package org.xbib.net.path.test.spring;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.path.spring.PathPatternParser;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;

View file

@ -1,6 +1,7 @@
package org.xbib.net.path.structure; package org.xbib.net.path.test.structure;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.path.structure.PathMatcher;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;

View file

@ -1,9 +1,10 @@
package org.xbib.net.path.structure; package org.xbib.net.path.test.structure;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.Parameter; import org.xbib.net.Parameter;
import org.xbib.net.ParameterException; import org.xbib.net.ParameterException;
import org.xbib.net.path.structure.PathResolver;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;

View file

@ -1,6 +1,8 @@
package org.xbib.net.path.structure; package org.xbib.net.path.test.structure;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.path.structure.Path;
import org.xbib.net.path.structure.PathComparator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View file

@ -0,0 +1,4 @@
module org.xbib.net.resource.test {
requires org.junit.jupiter.api;
requires org.xbib.net.resource;
}

View file

@ -1,4 +1,4 @@
package org.xbib.net.resource; package org.xbib.net.resource.test;
/* /*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@ -26,6 +26,8 @@ package org.xbib.net.resource;
* @test * @test
*/ */
import org.xbib.net.resource.IRI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,4 +1,4 @@
package org.xbib.net.resource;/* package org.xbib.net.resource.test;/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -31,6 +31,8 @@ package org.xbib.net.resource;/*
* exception with new URL(IRI.toString()) and IRI.toURL() * exception with new URL(IRI.toString()) and IRI.toURL()
*/ */
import org.xbib.net.resource.IRI;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;

View file

@ -1,4 +1,4 @@
package org.xbib.net.resource; package org.xbib.net.resource.test;
/* /*
* Copyright (c) 2003, 2019 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@ -27,6 +27,8 @@ package org.xbib.net.resource;
* @summary URI.resolve escapes characters in parameter URI * @summary URI.resolve escapes characters in parameter URI
*/ */
import org.xbib.net.resource.IRI;
import java.io.File; import java.io.File;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Objects; import java.util.Objects;

View file

@ -1,4 +1,4 @@
package org.xbib.net.resource; package org.xbib.net.resource.test;
/* /*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@ -27,6 +27,8 @@ package org.xbib.net.resource;
* @bug 8019345 6345502 6363889 6345551 6348515 * @bug 8019345 6345502 6363889 6345551 6348515
*/ */
import org.xbib.net.resource.IRI;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -36,7 +38,6 @@ import java.io.PrintStream;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.MalformedURLException; import java.net.MalformedURLException;

View file

@ -2,3 +2,14 @@ dependencies {
api project(':net') api project(':net')
testImplementation project(':net-bouncycastle') testImplementation project(':net-bouncycastle')
} }
def moduleName = 'org.xbib.net.security.test'
def patchArgs = ['--patch-module', "$moduleName=" + files(sourceSets.test.resources.srcDirs).asPath ]
tasks.named('compileTestJava') {
options.compilerArgs += patchArgs
}
tasks.named('test') {
jvmArgs += patchArgs
}

View file

@ -12,5 +12,6 @@ module org.xbib.net.security {
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.ssl.trustmanager;
exports org.xbib.net.security.ssl.util;
exports org.xbib.net.security.util; exports org.xbib.net.security.util;
} }

View file

@ -22,41 +22,41 @@ public class GroupElement {
/** /**
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
final Curve curve; public final Curve curve;
/** /**
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
final Representation repr; public final Representation repr;
/** /**
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
final FieldElement X; public final FieldElement X;
/** /**
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
final FieldElement Y; public final FieldElement Y;
/** /**
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
final FieldElement Z; public final FieldElement Z;
/** /**
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
final FieldElement T; public final FieldElement T;
/** /**
* Precomputed table for {@link #scalarMultiply(byte[])}, * Precomputed table for {@link #scalarMultiply(byte[])},
* filled if necessary. * filled if necessary.
* <p> * <p>
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
GroupElement[][] precmp; public GroupElement[][] precmp;
/** /**
* Precomputed table for {@link #doubleScalarMultiplyVariableTime(GroupElement, byte[], byte[])}, * Precomputed table for {@link #doubleScalarMultiplyVariableTime(GroupElement, byte[], byte[])},
* filled if necessary. * filled if necessary.
* <p> * <p>
* Variable is package private only so that tests run. * Variable is package private only so that tests run.
*/ */
GroupElement[] dblPrecmp; public GroupElement[] dblPrecmp;
/** /**
* Creates a group element for a curve. * Creates a group element for a curve.
@ -243,7 +243,7 @@ public class GroupElement {
* @param a $= a[0]+256*a[1]+...+256^{31} a[31]$ * @param a $= a[0]+256*a[1]+...+256^{31} a[31]$
* @return 64 bytes, each between -8 and 7 * @return 64 bytes, each between -8 and 7
*/ */
static byte[] toRadix16(final byte[] a) { public static byte[] toRadix16(final byte[] a) {
final byte[] e = new byte[64]; final byte[] e = new byte[64];
int i; int i;
// Radix 16 notation // Radix 16 notation
@ -822,7 +822,7 @@ public class GroupElement {
* @param b in $\{0, 1\}$ * @param b in $\{0, 1\}$
* @return $u$ if $b == 1$; this if $b == 0$. Results undefined if $b$ is not in $\{0, 1\}$. * @return $u$ if $b == 1$; this if $b == 0$. Results undefined if $b$ is not in $\{0, 1\}$.
*/ */
GroupElement cmov(final GroupElement u, final int b) { public GroupElement cmov(final GroupElement u, final int b) {
return precomp(curve, X.cmov(u.X, b), Y.cmov(u.Y, b), Z.cmov(u.Z, b)); return precomp(curve, X.cmov(u.X, b), Y.cmov(u.Y, b), Z.cmov(u.Z, b));
} }
@ -840,7 +840,7 @@ public class GroupElement {
* @param b $= r_i$ * @param b $= r_i$
* @return the GroupElement * @return the GroupElement
*/ */
GroupElement select(final int pos, final int b) { public GroupElement select(final int pos, final int b) {
// Is r_i negative? // Is r_i negative?
final int bnegative = Utils.negative(b); final int bnegative = Utils.negative(b);
// |r_i| // |r_i|

View file

@ -12,7 +12,7 @@ public class BigIntegerFieldElement extends FieldElement {
/** /**
* Variable is package private for encoding. * Variable is package private for encoding.
*/ */
final BigInteger bi; public final BigInteger bi;
public BigIntegerFieldElement(Field f, BigInteger bi) { public BigIntegerFieldElement(Field f, BigInteger bi) {
super(f); super(f);

View file

@ -17,7 +17,7 @@ public class Ed25519FieldElement extends FieldElement {
/** /**
* Variable is package private for encoding. * Variable is package private for encoding.
*/ */
final int[] t; public final int[] t;
/** /**
* Creates a field element. * Creates a field element.

View file

@ -0,0 +1,14 @@
module org.xbib.net.security.test {
requires java.logging;
requires transitive org.junit.jupiter.api;
requires org.hamcrest;
requires org.xbib.net.security;
requires org.bouncycastle.provider;
exports org.xbib.net.security.test;
exports org.xbib.net.security.test.ed25519;
exports org.xbib.net.security.test.eddsa;
exports org.xbib.net.security.test.eddsa.math;
exports org.xbib.net.security.test.eddsa.math.bigint;
exports org.xbib.net.security.test.eddsa.math.ed25519;
exports org.xbib.net.security.test.eddsa.spec;
}

View file

@ -1,10 +1,11 @@
package org.xbib.net.security; package org.xbib.net.security.test;
import java.io.InputStream; import java.io.InputStream;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.CertificateReader;
public class CertificateReaderTest { public class CertificateReaderTest {

View file

@ -1,7 +1,9 @@
package org.xbib.net.security; package org.xbib.net.security.test;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.CertificateProvider;
import org.xbib.net.security.CertificateReader;
import org.xbib.net.security.util.HexUtil; import org.xbib.net.security.util.HexUtil;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;

View file

@ -1,6 +1,7 @@
package org.xbib.net.security; package org.xbib.net.security.test;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.PrivateKeyReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.ed25519; package org.xbib.net.security.test.ed25519;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.KeyPair; import java.security.KeyPair;

View file

@ -1,4 +1,6 @@
package org.xbib.net.security.eddsa; package org.xbib.net.security.test.eddsa;
import org.xbib.net.security.eddsa.Utils;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa; package org.xbib.net.security.test.eddsa;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -13,6 +13,10 @@ import java.security.SignatureException;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.EdDSAEngine;
import org.xbib.net.security.eddsa.EdDSAPrivateKey;
import org.xbib.net.security.eddsa.EdDSAPublicKey;
import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable;
import org.xbib.net.security.eddsa.spec.EdDSAParameterSpec; import org.xbib.net.security.eddsa.spec.EdDSAParameterSpec;
import org.xbib.net.security.eddsa.spec.EdDSAPrivateKeySpec; import org.xbib.net.security.eddsa.spec.EdDSAPrivateKeySpec;

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa; package org.xbib.net.security.test.eddsa;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -6,6 +6,8 @@ import static org.hamcrest.Matchers.*;
import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.PKCS8EncodedKeySpec;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.EdDSAPrivateKey;
import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.spec.EdDSAPrivateKeySpec; import org.xbib.net.security.eddsa.spec.EdDSAPrivateKeySpec;
/** /**

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa; package org.xbib.net.security.test.eddsa;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -6,6 +6,8 @@ import static org.hamcrest.Matchers.*;
import java.security.spec.X509EncodedKeySpec; import java.security.spec.X509EncodedKeySpec;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.EdDSAPublicKey;
import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.spec.EdDSAPublicKeySpec; import org.xbib.net.security.eddsa.spec.EdDSAPublicKeySpec;
/** /**

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa; package org.xbib.net.security.test.eddsa;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.KeyPairGenerator; import java.security.KeyPairGenerator;
@ -7,6 +7,7 @@ import java.security.Security;
import java.security.Signature; import java.security.Signature;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.EdDSASecurityProvider;
/** /**
* *

View file

@ -1,9 +1,10 @@
package org.xbib.net.security.eddsa; package org.xbib.net.security.test.eddsa;
import org.hamcrest.core.IsEqual; import org.hamcrest.core.IsEqual;
import java.security.SecureRandom; import java.security.SecureRandom;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.Utils;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;

View file

@ -1,10 +1,13 @@
package org.xbib.net.security.eddsa.math; package org.xbib.net.security.test.eddsa.math;
import org.hamcrest.core.IsEqual; import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsNot; import org.hamcrest.core.IsNot;
import java.math.BigInteger; import java.math.BigInteger;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.math.Field;
import org.xbib.net.security.eddsa.math.FieldElement;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
/** /**

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa.math; package org.xbib.net.security.test.eddsa.math;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -10,6 +10,9 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.math.Curve;
import org.xbib.net.security.eddsa.math.FieldElement;
import org.xbib.net.security.eddsa.math.GroupElement;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable;

View file

@ -1,9 +1,12 @@
package org.xbib.net.security.eddsa.math; package org.xbib.net.security.test.eddsa.math;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.Ed25519TestVectors; import org.xbib.net.security.test.eddsa.Ed25519TestVectors;
import org.xbib.net.security.eddsa.Utils; import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.math.Curve;
import org.xbib.net.security.eddsa.math.FieldElement;
import org.xbib.net.security.eddsa.math.GroupElement;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable;
import org.hamcrest.core.IsEqual; import org.hamcrest.core.IsEqual;

View file

@ -1,7 +1,11 @@
package org.xbib.net.security.eddsa.math; package org.xbib.net.security.test.eddsa.math;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.Utils; import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.math.Curve;
import org.xbib.net.security.eddsa.math.Field;
import org.xbib.net.security.eddsa.math.FieldElement;
import org.xbib.net.security.eddsa.math.GroupElement;
import org.xbib.net.security.eddsa.math.ed25519.Ed25519FieldElement; import org.xbib.net.security.eddsa.math.ed25519.Ed25519FieldElement;
import org.xbib.net.security.eddsa.math.ed25519.Ed25519LittleEndianEncoding; import org.xbib.net.security.eddsa.math.ed25519.Ed25519LittleEndianEncoding;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec;
@ -416,7 +420,6 @@ public class MathUtils {
return GroupElement.p3(g.getCurve(), g.getX().negate(), g.getY(), g.getZ(), g.getT().negate()); return GroupElement.p3(g.getCurve(), g.getX().negate(), g.getY(), g.getZ(), g.getT().negate());
} }
// Start TODO BR: Remove when finished!
@Test @Test
public void mathUtilsWorkAsExpected() { public void mathUtilsWorkAsExpected() {
final GroupElement neutral = GroupElement.p3(curve, curve.getField().ZERO, curve.getField().ONE, curve.getField().ONE, curve.getField().ZERO); final GroupElement neutral = GroupElement.p3(curve, curve.getField().ZERO, curve.getField().ONE, curve.getField().ONE, curve.getField().ZERO);
@ -468,5 +471,4 @@ public class MathUtils {
assertThat(curve.getZero(GroupElement.Representation.P3), IsEqual.equalTo(h)); assertThat(curve.getZero(GroupElement.Representation.P3), IsEqual.equalTo(h));
} }
} }
// End TODO BR: Remove when finished!
} }

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa.math; package org.xbib.net.security.test.eddsa.math;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -6,12 +6,13 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import org.xbib.net.security.eddsa.Utils; import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.math.Curve;
import org.xbib.net.security.eddsa.math.Field;
import org.xbib.net.security.eddsa.math.FieldElement;
import org.xbib.net.security.eddsa.math.GroupElement;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable;
/**
*
*/
public class PrecomputationTestVectors { public class PrecomputationTestVectors {
// Test files were generated using base.py and base2.py from ref10 // Test files were generated using base.py and base2.py from ref10
// (by printing hex(x%q) instead of the radix-255 representation). // (by printing hex(x%q) instead of the radix-255 representation).

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa.math.bigint; package org.xbib.net.security.test.eddsa.math.bigint;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -10,8 +10,10 @@ import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.Utils; import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.math.Field; import org.xbib.net.security.eddsa.math.Field;
import org.xbib.net.security.eddsa.math.FieldElement; import org.xbib.net.security.eddsa.math.FieldElement;
import org.xbib.net.security.eddsa.math.MathUtils; import org.xbib.net.security.test.eddsa.math.MathUtils;
import org.xbib.net.security.eddsa.math.AbstractFieldElementTest; import org.xbib.net.security.test.eddsa.math.AbstractFieldElementTest;
import org.xbib.net.security.eddsa.math.bigint.BigIntegerFieldElement;
import org.xbib.net.security.eddsa.math.bigint.BigIntegerLittleEndianEncoding;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.eddsa.math.bigint; package org.xbib.net.security.test.eddsa.math.bigint;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.Utils; import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.math.Field; import org.xbib.net.security.eddsa.math.Field;
import org.xbib.net.security.eddsa.math.ScalarOps; import org.xbib.net.security.eddsa.math.ScalarOps;
import org.xbib.net.security.eddsa.math.bigint.BigIntegerScalarOps;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable; import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable;

View file

@ -1,12 +1,13 @@
package org.xbib.net.security.eddsa.math.ed25519; package org.xbib.net.security.test.eddsa.math.ed25519;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.math.AbstractFieldElementTest; import org.xbib.net.security.test.eddsa.math.AbstractFieldElementTest;
import org.xbib.net.security.eddsa.math.Field; import org.xbib.net.security.eddsa.math.Field;
import org.xbib.net.security.eddsa.math.FieldElement; import org.xbib.net.security.eddsa.math.FieldElement;
import org.xbib.net.security.eddsa.math.MathUtils; import org.xbib.net.security.test.eddsa.math.MathUtils;
import org.hamcrest.core.IsEqual; import org.hamcrest.core.IsEqual;
import org.xbib.net.security.eddsa.math.ed25519.Ed25519FieldElement;
import java.math.BigInteger; import java.math.BigInteger;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;

View file

@ -1,9 +1,10 @@
package org.xbib.net.security.eddsa.math.ed25519; package org.xbib.net.security.test.eddsa.math.ed25519;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.math.FieldElement; import org.xbib.net.security.eddsa.math.FieldElement;
import org.xbib.net.security.eddsa.math.MathUtils; import org.xbib.net.security.test.eddsa.math.MathUtils;
import org.hamcrest.core.IsEqual; import org.hamcrest.core.IsEqual;
import org.xbib.net.security.eddsa.math.ed25519.Ed25519FieldElement;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.SecureRandom; import java.security.SecureRandom;

View file

@ -1,9 +1,10 @@
package org.xbib.net.security.eddsa.math.ed25519; package org.xbib.net.security.test.eddsa.math.ed25519;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.Utils; import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.math.MathUtils; import org.xbib.net.security.test.eddsa.math.MathUtils;
import org.hamcrest.core.IsEqual; import org.hamcrest.core.IsEqual;
import org.xbib.net.security.eddsa.math.ed25519.Ed25519ScalarOps;
import java.math.BigInteger; import java.math.BigInteger;

View file

@ -1,6 +1,9 @@
package org.xbib.net.security.eddsa.spec; package org.xbib.net.security.test.eddsa.spec;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;

View file

@ -1,10 +1,14 @@
package org.xbib.net.security.eddsa.spec; package org.xbib.net.security.test.eddsa.spec;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.security.eddsa.Utils; import org.xbib.net.security.eddsa.Utils;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveSpec;
import org.xbib.net.security.eddsa.spec.EdDSANamedCurveTable;
import org.xbib.net.security.eddsa.spec.EdDSAParameterSpec;
import org.xbib.net.security.eddsa.spec.EdDSAPrivateKeySpec;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.net.security.ssl.trustmanager; package org.xbib.net.security.test.trustmanager;
import org.xbib.net.security.ssl.util.TrustManagerUtils; import org.xbib.net.security.ssl.util.TrustManagerUtils;

View file

@ -1,3 +1,14 @@
dependencies { dependencies {
implementation libs.jna implementation libs.jna
} }
def moduleName = 'org.xbib.net.socket.test'
def patchArgs = ['--patch-module', "$moduleName=" + files(sourceSets.test.resources.srcDirs).asPath ]
tasks.named('compileTestJava') {
options.compilerArgs += patchArgs
}
tasks.named('test') {
jvmArgs += patchArgs
}

View file

@ -2,6 +2,7 @@ module org.xbib.net.socket {
requires java.logging; requires java.logging;
requires transitive com.sun.jna; requires transitive com.sun.jna;
exports org.xbib.net.socket; exports org.xbib.net.socket;
exports org.xbib.net.socket.notify;
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;
exports org.xbib.net.socket.v4.datagram; exports org.xbib.net.socket.v4.datagram;

View file

@ -0,0 +1,8 @@
module org.xbib.net.socket.test {
requires java.logging;
requires org.junit.jupiter.api;
requires org.xbib.net.socket;
exports org.xbib.net.socket.test.notify;
exports org.xbib.net.socket.test.v4;
exports org.xbib.net.socket.test.v6;
}

View file

@ -1,6 +1,7 @@
package org.xbib.net.socket.notify; package org.xbib.net.socket.test.notify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.net.socket.notify.SystemdNotify;
import java.io.IOException; import java.io.IOException;

View file

@ -1,4 +1,4 @@
package org.xbib.net.socket.v4; package org.xbib.net.socket.test.v4;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View file

@ -1,4 +1,4 @@
package org.xbib.net.socket.v6; package org.xbib.net.socket.test.v6;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View file

@ -2,3 +2,14 @@ dependencies {
api libs.datastructures.common api libs.datastructures.common
testImplementation libs.jackson testImplementation libs.jackson
} }
def moduleName = 'org.xbib.net.test'
def patchArgs = ['--patch-module', "$moduleName=" + files(sourceSets.test.resources.srcDirs).asPath ]
tasks.named('compileTestJava') {
options.compilerArgs += patchArgs
}
tasks.named('test') {
jvmArgs += patchArgs
}

View file

@ -1,5 +1,38 @@
import org.xbib.net.buffer.DataBufferFactory; import org.xbib.net.buffer.DataBufferFactory;
import org.xbib.net.buffer.DefaultDataBufferFactory; import org.xbib.net.buffer.DefaultDataBufferFactory;
import org.xbib.net.scheme.DnsScheme;
import org.xbib.net.scheme.FileScheme;
import org.xbib.net.scheme.FtpScheme;
import org.xbib.net.scheme.GitScheme;
import org.xbib.net.scheme.GitSecureHttpScheme;
import org.xbib.net.scheme.GopherScheme;
import org.xbib.net.scheme.HttpScheme;
import org.xbib.net.scheme.HttpsScheme;
import org.xbib.net.scheme.ImapScheme;
import org.xbib.net.scheme.ImapsScheme;
import org.xbib.net.scheme.IrcScheme;
import org.xbib.net.scheme.LdapScheme;
import org.xbib.net.scheme.LdapsScheme;
import org.xbib.net.scheme.MailtoScheme;
import org.xbib.net.scheme.NewsScheme;
import org.xbib.net.scheme.NntpScheme;
import org.xbib.net.scheme.Pop3Scheme;
import org.xbib.net.scheme.RedisScheme;
import org.xbib.net.scheme.RsyncScheme;
import org.xbib.net.scheme.RtmpScheme;
import org.xbib.net.scheme.RtspScheme;
import org.xbib.net.scheme.Scheme;
import org.xbib.net.scheme.SecureNewsScheme;
import org.xbib.net.scheme.SecurePop3Scheme;
import org.xbib.net.scheme.SftpScheme;
import org.xbib.net.scheme.SmtpScheme;
import org.xbib.net.scheme.SmtpsScheme;
import org.xbib.net.scheme.SshScheme;
import org.xbib.net.scheme.TelnetScheme;
import org.xbib.net.scheme.TftpScheme;
import org.xbib.net.scheme.UrnScheme;
import org.xbib.net.scheme.WsScheme;
import org.xbib.net.scheme.WssScheme;
module org.xbib.net { module org.xbib.net {
exports org.xbib.net; exports org.xbib.net;
@ -18,4 +51,38 @@ module org.xbib.net {
requires transitive java.logging; requires transitive java.logging;
uses DataBufferFactory; uses DataBufferFactory;
provides DataBufferFactory with DefaultDataBufferFactory; provides DataBufferFactory with DefaultDataBufferFactory;
uses Scheme;
provides Scheme with
DnsScheme,
FileScheme,
FtpScheme,
GitScheme,
GitSecureHttpScheme,
GopherScheme,
HttpScheme,
HttpsScheme,
ImapScheme,
ImapsScheme,
IrcScheme,
LdapScheme,
LdapsScheme,
MailtoScheme,
NewsScheme,
NntpScheme,
Pop3Scheme,
RedisScheme,
RsyncScheme,
RtmpScheme,
RtspScheme,
SecureNewsScheme,
SecurePop3Scheme,
SftpScheme,
SmtpScheme,
SmtpsScheme,
SshScheme,
TelnetScheme,
TftpScheme,
UrnScheme,
WsScheme,
WssScheme;
} }

View file

@ -36,7 +36,7 @@ public class PercentEncoder {
* @param charsetEncoder charset encoder to encode characters with. Make sure to not re-use CharsetEncoder instances * @param charsetEncoder charset encoder to encode characters with. Make sure to not re-use CharsetEncoder instances
* across threads. * across threads.
*/ */
PercentEncoder(BitSet safeChars, CharsetEncoder charsetEncoder) { public PercentEncoder(BitSet safeChars, CharsetEncoder charsetEncoder) {
this.safeChars = safeChars; this.safeChars = safeChars;
this.encoder = charsetEncoder; this.encoder = charsetEncoder;
this.stringHandler = new StringBuilderPercentEncoderOutputHandler(); this.stringHandler = new StringBuilderPercentEncoderOutputHandler();

View file

@ -4,13 +4,13 @@ package org.xbib.net.scheme;
* The DNS URI scheme. * The DNS URI scheme.
* @see <a href="https://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt">DNS RFC</a> * @see <a href="https://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt">DNS RFC</a>
*/ */
class DnsScheme extends HttpScheme { public class DnsScheme extends HttpScheme {
DnsScheme() { public DnsScheme() {
super("dns", 53); super("dns", 53);
} }
DnsScheme(String name, int port) { public DnsScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -3,9 +3,9 @@ package org.xbib.net.scheme;
/** /**
* File scheme. * File scheme.
*/ */
class FileScheme extends HttpScheme { public class FileScheme extends HttpScheme {
FileScheme() { public FileScheme() {
super("file", -1); super("file", -1);
} }

View file

@ -3,13 +3,13 @@ package org.xbib.net.scheme;
/** /**
* FTP scheme. * FTP scheme.
*/ */
class FtpScheme extends HttpScheme { public class FtpScheme extends HttpScheme {
FtpScheme() { public FtpScheme() {
super("ftp", 21); super("ftp", 21);
} }
FtpScheme(String name, int port) { public FtpScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -3,13 +3,13 @@ package org.xbib.net.scheme;
/** /**
* Git scheme. * Git scheme.
*/ */
class GitScheme extends HttpScheme { public class GitScheme extends HttpScheme {
GitScheme() { public GitScheme() {
super("git", 443); super("git", 443);
} }
GitScheme(String name, int port) { public GitScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -3,13 +3,13 @@ package org.xbib.net.scheme;
/** /**
* Git secure scheme. * Git secure scheme.
*/ */
class GitSecureHttpScheme extends HttpScheme { public class GitSecureHttpScheme extends HttpScheme {
GitSecureHttpScheme() { public GitSecureHttpScheme() {
super("git+https", 443); super("git+https", 443);
} }
GitSecureHttpScheme(String name, int port) { public GitSecureHttpScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -3,9 +3,9 @@ package org.xbib.net.scheme;
/** /**
* Gopher scheme. * Gopher scheme.
*/ */
class GopherScheme extends AbstractScheme { public class GopherScheme extends AbstractScheme {
GopherScheme() { public GopherScheme() {
super("gopher", 70); super("gopher", 70);
} }

View file

@ -8,13 +8,13 @@ import java.util.Locale;
/** /**
* HTTP scheme. * HTTP scheme.
*/ */
class HttpScheme extends AbstractScheme { public class HttpScheme extends AbstractScheme {
HttpScheme() { public HttpScheme() {
super("http", 80); super("http", 80);
} }
HttpScheme(String name, int port) { public HttpScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -0,0 +1,37 @@
package org.xbib.net.scheme;
import org.xbib.net.PathNormalizer;
import org.xbib.net.URL;
import java.util.Locale;
/**
* HTTPS scheme.
*/
public class HttpsScheme extends AbstractScheme {
public HttpsScheme() {
super("https", 443);
}
public HttpsScheme(String name, int port) {
super(name, port);
}
@Override
public URL normalize(URL url) {
String host = url.getHost();
if (host != null) {
host = host.toLowerCase(Locale.ROOT);
}
return URL.builder()
.scheme(url.getScheme())
.userInfo(url.getUserInfo())
.host(host, url.getProtocolVersion())
.port(url.getPort())
.path(PathNormalizer.normalize(url.getPath()))
.query(url.getQuery())
.fragment(url.getFragment())
.build();
}
}

View file

@ -5,13 +5,13 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc5092">IMAP RFC</a> * @see <a href="https://tools.ietf.org/html/rfc5092">IMAP RFC</a>
*/ */
class ImapScheme extends AbstractScheme { public class ImapScheme extends AbstractScheme {
ImapScheme() { public ImapScheme() {
super("imap", 143); super("imap", 143);
} }
ImapScheme(String name, int port) { public ImapScheme(String name, int port) {
super(name, port); super(name, port);
} }
} }

View file

@ -4,9 +4,9 @@ package org.xbib.net.scheme;
* The secure IMAP scheme. * The secure IMAP scheme.
* @see <a href="https://tools.ietf.org/html/rfc5092">IMAP scheme RFC</a> * @see <a href="https://tools.ietf.org/html/rfc5092">IMAP scheme RFC</a>
*/ */
class SecureImapScheme extends ImapScheme { public class ImapsScheme extends ImapScheme {
SecureImapScheme() { public ImapsScheme() {
super("imaps", 993); super("imaps", 993);
} }

View file

@ -5,13 +5,13 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt">IRC draft</a> * @see <a href="https://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt">IRC draft</a>
*/ */
class IrcScheme extends HttpScheme { public class IrcScheme extends HttpScheme {
IrcScheme() { public IrcScheme() {
super("irc", 194); super("irc", 194);
} }
IrcScheme(String name, int port) { public IrcScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -4,13 +4,13 @@ package org.xbib.net.scheme;
* The LDAP scheme. * The LDAP scheme.
* @see <a href="https://tools.ietf.org/html/rfc4516">LDAP RFC</a> * @see <a href="https://tools.ietf.org/html/rfc4516">LDAP RFC</a>
*/ */
class LdapScheme extends AbstractScheme { public class LdapScheme extends AbstractScheme {
LdapScheme() { public LdapScheme() {
super("ldap", 143); super("ldap", 143);
} }
LdapScheme(String name, int port) { public LdapScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc4516">LDAP RFC</a> * @see <a href="https://tools.ietf.org/html/rfc4516">LDAP RFC</a>
*/ */
class SecureLdapScheme extends LdapScheme { public class LdapsScheme extends LdapScheme {
SecureLdapScheme() { public LdapsScheme() {
super("ldaps", 636); super("ldaps", 636);
} }

View file

@ -5,13 +5,13 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc5538">news RFC</a> * @see <a href="https://tools.ietf.org/html/rfc5538">news RFC</a>
*/ */
class NewsScheme extends AbstractScheme { public class NewsScheme extends AbstractScheme {
NewsScheme() { public NewsScheme() {
super("nntp", 119); super("nntp", 119);
} }
NewsScheme(String name, int port) { public NewsScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc5538">NNTP RFC</a> * @see <a href="https://tools.ietf.org/html/rfc5538">NNTP RFC</a>
*/ */
class NntpScheme extends AbstractScheme { public class NntpScheme extends AbstractScheme {
NntpScheme() { public NntpScheme() {
super("nntp", 119); super("nntp", 119);
} }

View file

@ -5,13 +5,13 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc1081">POP3 RFC</a> * @see <a href="https://tools.ietf.org/html/rfc1081">POP3 RFC</a>
*/ */
class Pop3Scheme extends AbstractScheme { public class Pop3Scheme extends AbstractScheme {
Pop3Scheme() { public Pop3Scheme() {
super("pop3", 110); super("pop3", 110);
} }
Pop3Scheme(String name, int port) { public Pop3Scheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -3,9 +3,9 @@ package org.xbib.net.scheme;
/** /**
* Redis scheme. * Redis scheme.
*/ */
class RedisScheme extends AbstractScheme { public class RedisScheme extends AbstractScheme {
RedisScheme() { public RedisScheme() {
super("redis", 6379); super("redis", 6379);
} }

View file

@ -3,9 +3,9 @@ package org.xbib.net.scheme;
/** /**
* Rsync scheme. * Rsync scheme.
*/ */
class RsyncScheme extends SshScheme { public class RsyncScheme extends SshScheme {
RsyncScheme() { public RsyncScheme() {
super("rsync", 873); super("rsync", 873);
} }

View file

@ -3,9 +3,9 @@ package org.xbib.net.scheme;
/** /**
* Rtmp scheme. * Rtmp scheme.
*/ */
class RtmpScheme extends AbstractScheme { public class RtmpScheme extends AbstractScheme {
RtmpScheme() { public RtmpScheme() {
super("rtmp", 1935); super("rtmp", 1935);
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://www.ietf.org/rfc/rfc2326.txt">RTSP RFC</a> * @see <a href="https://www.ietf.org/rfc/rfc2326.txt">RTSP RFC</a>
*/ */
class RtspScheme extends AbstractScheme { public class RtspScheme extends AbstractScheme {
RtspScheme() { public RtspScheme() {
super("rtsp", 554); super("rtsp", 554);
} }

View file

@ -23,12 +23,12 @@ public final class SchemeRegistry {
schemes.put(Scheme.GIT_HTTPS, new GitSecureHttpScheme()); schemes.put(Scheme.GIT_HTTPS, new GitSecureHttpScheme());
schemes.put(Scheme.GOPHER, new GopherScheme()); schemes.put(Scheme.GOPHER, new GopherScheme());
schemes.put(Scheme.HTTP, new HttpScheme()); schemes.put(Scheme.HTTP, new HttpScheme());
schemes.put(Scheme.HTTPS, new SecureHttpScheme()); schemes.put(Scheme.HTTPS, new HttpsScheme());
schemes.put(Scheme.IMAP, new ImapScheme()); schemes.put(Scheme.IMAP, new ImapScheme());
schemes.put(Scheme.IMAPS, new SecureImapScheme()); schemes.put(Scheme.IMAPS, new ImapsScheme());
schemes.put(Scheme.IRC, new IrcScheme()); schemes.put(Scheme.IRC, new IrcScheme());
schemes.put(Scheme.LDAP, new LdapScheme()); schemes.put(Scheme.LDAP, new LdapScheme());
schemes.put(Scheme.LDAPS, new SecureLdapScheme()); schemes.put(Scheme.LDAPS, new LdapsScheme());
schemes.put(Scheme.MAILTO, new MailtoScheme()); schemes.put(Scheme.MAILTO, new MailtoScheme());
schemes.put(Scheme.NEWS, new NewsScheme()); schemes.put(Scheme.NEWS, new NewsScheme());
schemes.put(Scheme.NNTP, new NntpScheme()); schemes.put(Scheme.NNTP, new NntpScheme());
@ -40,14 +40,14 @@ public final class SchemeRegistry {
schemes.put(Scheme.RTSP, new RtspScheme()); schemes.put(Scheme.RTSP, new RtspScheme());
schemes.put(Scheme.SFTP, new SftpScheme()); schemes.put(Scheme.SFTP, new SftpScheme());
schemes.put(Scheme.SMTP, new SmtpScheme()); schemes.put(Scheme.SMTP, new SmtpScheme());
schemes.put(Scheme.SMTPS, new SecureSmtpScheme()); schemes.put(Scheme.SMTPS, new SmtpsScheme());
schemes.put(Scheme.SNEWS, new SecureNewsScheme()); schemes.put(Scheme.SNEWS, new SecureNewsScheme());
schemes.put(Scheme.SSH, new SshScheme()); schemes.put(Scheme.SSH, new SshScheme());
schemes.put(Scheme.TELNET, new TelnetScheme()); schemes.put(Scheme.TELNET, new TelnetScheme());
schemes.put(Scheme.TFTP, new TftpScheme()); schemes.put(Scheme.TFTP, new TftpScheme());
schemes.put(Scheme.URN, new UrnScheme()); schemes.put(Scheme.URN, new UrnScheme());
schemes.put(Scheme.WS, new WebSocketScheme()); schemes.put(Scheme.WS, new WsScheme());
schemes.put(Scheme.WSS, new SecureWebSocketScheme()); schemes.put(Scheme.WSS, new WssScheme());
for (Scheme scheme : ServiceLoader.load(Scheme.class)) { for (Scheme scheme : ServiceLoader.load(Scheme.class)) {
register(scheme); register(scheme);
} }

View file

@ -1,12 +0,0 @@
package org.xbib.net.scheme;
/**
* Secure HTTP scheme.
*/
class SecureHttpScheme extends HttpScheme {
SecureHttpScheme() {
super("https", 443);
}
}

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc5538">news RFC</a> * @see <a href="https://tools.ietf.org/html/rfc5538">news RFC</a>
*/ */
class SecureNewsScheme extends NewsScheme { public class SecureNewsScheme extends NewsScheme {
SecureNewsScheme() { public SecureNewsScheme() {
super("snews", 563); super("snews", 563);
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc2595">POP3 RFC</a> * @see <a href="https://tools.ietf.org/html/rfc2595">POP3 RFC</a>
*/ */
class SecurePop3Scheme extends Pop3Scheme { public class SecurePop3Scheme extends Pop3Scheme {
SecurePop3Scheme() { public SecurePop3Scheme() {
super("pop3s", 995); super("pop3s", 995);
} }
} }

View file

@ -3,9 +3,9 @@ package org.xbib.net.scheme;
/** /**
* Secure FTP scheme. * Secure FTP scheme.
*/ */
class SftpScheme extends SshScheme { public class SftpScheme extends SshScheme {
SftpScheme() { public SftpScheme() {
super("sftp", 22); super("sftp", 22);
} }

View file

@ -5,13 +5,13 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc5321">SMTP RFC</a> * @see <a href="https://tools.ietf.org/html/rfc5321">SMTP RFC</a>
*/ */
class SmtpScheme extends AbstractScheme { public class SmtpScheme extends AbstractScheme {
SmtpScheme() { public SmtpScheme() {
super("smtp", 25); super("smtp", 25);
} }
SmtpScheme(String name, int port) { public SmtpScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc4409">SMTP RFC</a> * @see <a href="https://tools.ietf.org/html/rfc4409">SMTP RFC</a>
*/ */
class SecureSmtpScheme extends SmtpScheme { public class SmtpsScheme extends SmtpScheme {
SecureSmtpScheme() { public SmtpsScheme() {
super("smtps", 587); super("smtps", 587);
} }

View file

@ -3,13 +3,13 @@ package org.xbib.net.scheme;
/** /**
* Secure shell scheme. * Secure shell scheme.
*/ */
class SshScheme extends HttpScheme { public class SshScheme extends HttpScheme {
SshScheme() { public SshScheme() {
super("ssh", 22); super("ssh", 22);
} }
SshScheme(String name, int port) { public SshScheme(String name, int port) {
super(name, port); super(name, port);
} }
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc4248">TELNET RFC</a> * @see <a href="https://tools.ietf.org/html/rfc4248">TELNET RFC</a>
*/ */
class TelnetScheme extends AbstractScheme { public class TelnetScheme extends AbstractScheme {
TelnetScheme() { public TelnetScheme() {
super("telnet", 23); super("telnet", 23);
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://tools.ietf.org/html/rfc1350">TFTP RFC</a> * @see <a href="https://tools.ietf.org/html/rfc1350">TFTP RFC</a>
*/ */
class TftpScheme extends FtpScheme { public class TftpScheme extends FtpScheme {
TftpScheme() { public TftpScheme() {
super("tftp", 69); super("tftp", 69);
} }
} }

View file

@ -5,9 +5,9 @@ package org.xbib.net.scheme;
* *
* @see <a href="https://www.ietf.org/rfc/rfc2141.txt">URN RFC</a> * @see <a href="https://www.ietf.org/rfc/rfc2141.txt">URN RFC</a>
*/ */
class UrnScheme extends AbstractScheme { public class UrnScheme extends AbstractScheme {
UrnScheme() { public UrnScheme() {
super("urn", -1); super("urn", -1);
} }

View file

@ -3,13 +3,13 @@ package org.xbib.net.scheme;
/** /**
* Web socket scheme. * Web socket scheme.
*/ */
class WebSocketScheme extends HttpScheme { public class WsScheme extends HttpScheme {
WebSocketScheme() { public WsScheme() {
super("ws", 80); super("ws", 80);
} }
WebSocketScheme(String name, int port) { public WsScheme(String name, int port) {
super(name, port); super(name, port);
} }

View file

@ -3,9 +3,9 @@ package org.xbib.net.scheme;
/** /**
* Secure web socket scheme. * Secure web socket scheme.
*/ */
class SecureWebSocketScheme extends WebSocketScheme { public class WssScheme extends WsScheme {
SecureWebSocketScheme() { public WssScheme() {
super("wss", 443); super("wss", 443);
} }

View file

@ -0,0 +1,12 @@
module org.xbib.net.test {
requires transitive org.junit.jupiter.api;
requires org.xbib.net;
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
exports org.xbib.net.test;
exports org.xbib.net.test.resource;
exports org.xbib.net.test.template;
exports org.xbib.net.test.util;
opens org.xbib.net.test;
opens org.xbib.net.test.template;
}

View file

@ -1,4 +0,0 @@
/**
* Classes for testing URL building und parsing.
*/
package org.xbib.net;

View file

@ -1,4 +0,0 @@
/**
* Classes for testing URL templates.
*/
package org.xbib.net.template;

Some files were not shown because too many files have changed in this diff Show more