diff --git a/core/build.gradle b/core/build.gradle index 8f44ba48eb2..9f123b9b53d 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -222,9 +222,9 @@ dependencies { testImplementation deps['org.apache.sshd:sshd-scp'] testImplementation deps['org.apache.sshd:sshd-sftp'] testImplementation deps['org.apache.tomcat:tomcat-annotations-api'] - implementation deps['org.bouncycastle:bcpg-jdk15on'] - implementation deps['org.bouncycastle:bcpkix-jdk15on'] - implementation deps['org.bouncycastle:bcprov-jdk15on'] + implementation deps['org.bouncycastle:bcpg-jdk18on'] + implementation deps['org.bouncycastle:bcpkix-jdk18on'] + implementation deps['org.bouncycastle:bcprov-jdk18on'] testImplementation deps['com.fasterxml.jackson.core:jackson-databind'] implementation deps['org.hibernate:hibernate-core'] implementation deps['org.hibernate:hibernate-hikaricp'] diff --git a/core/gradle.lockfile b/core/gradle.lockfile index 8117b33af18..c6b104cb61d 100644 --- a/core/gradle.lockfile +++ b/core/gradle.lockfile @@ -89,15 +89,16 @@ com.google.apis:google-api-services-gmail:v1-rev20220404-2.0.0=compileClasspath, com.google.apis:google-api-services-groupssettings:v1-rev20210624-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.apis:google-api-services-healthcare:v1-rev20240110-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.apis:google-api-services-iamcredentials:v1-rev20211203-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.apis:google-api-services-monitoring:v3-rev20240128-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.apis:google-api-services-monitoring:v3-rev20240303-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.apis:google-api-services-pubsub:v1-rev20220904-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.apis:google-api-services-sheets:v4-rev20230815-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.apis:google-api-services-sqladmin:v1beta4-rev20240205-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.apis:google-api-services-storage:v1-rev20240209-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.appengine:appengine-api-1.0-sdk:1.9.86=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath -com.google.appengine:appengine-api-1.0-sdk:2.0.25=testCompileClasspath,testRuntimeClasspath -com.google.appengine:appengine-api-stubs:2.0.25=testCompileClasspath,testRuntimeClasspath -com.google.appengine:appengine-testing:1.9.86=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.appengine:appengine-api-1.0-sdk:2.0.25=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.appengine:appengine-api-stubs:2.0.25=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.appengine:appengine-remote-api:2.0.25=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.appengine:appengine-testing:2.0.25=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.appengine:appengine-tools-sdk:2.0.25=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.auth:google-auth-library-credentials:1.23.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.auth:google-auth-library-oauth2-http:1.23.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.auto.service:auto-service-annotations:1.0.1=errorprone,nonprodAnnotationProcessor,testAnnotationProcessor @@ -371,14 +372,16 @@ org.apache.ftpserver:ftpserver-core:1.2.0=testCompileClasspath,testRuntimeClassp org.apache.httpcomponents:httpclient:4.5.14=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents:httpcore:4.4.16=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.mina:mina-core:2.1.6=testCompileClasspath,testRuntimeClasspath -org.apache.sshd:sshd-core:2.0.0=testCompileClasspath,testRuntimeClasspath -org.apache.sshd:sshd-scp:2.0.0=testCompileClasspath,testRuntimeClasspath -org.apache.sshd:sshd-sftp:2.0.0=testCompileClasspath,testRuntimeClasspath +org.apache.sshd:sshd-common:2.12.1=testCompileClasspath,testRuntimeClasspath +org.apache.sshd:sshd-core:2.12.1=testCompileClasspath,testRuntimeClasspath +org.apache.sshd:sshd-scp:2.12.1=testCompileClasspath,testRuntimeClasspath +org.apache.sshd:sshd-sftp:2.12.1=testCompileClasspath,testRuntimeClasspath org.apache.tomcat:tomcat-annotations-api:11.0.0-M17=testCompileClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.bouncycastle:bcpg-jdk15on:1.67=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.bouncycastle:bcpkix-jdk15on:1.67=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.bouncycastle:bcprov-jdk15on:1.67=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.bouncycastle:bcpg-jdk18on:1.77=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.bouncycastle:bcpkix-jdk18on:1.77=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.bouncycastle:bcprov-jdk18on:1.77=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.bouncycastle:bcutil-jdk18on:1.77=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.checkerframework:checker-compat-qual:2.5.3=compileClasspath,nonprodCompileClasspath,testCompileClasspath org.checkerframework:checker-compat-qual:2.5.5=annotationProcessor,testAnnotationProcessor org.checkerframework:checker-compat-qual:2.5.6=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath @@ -489,7 +492,7 @@ org.seleniumhq.selenium:selenium-opera-driver:3.141.59=testCompileClasspath,test org.seleniumhq.selenium:selenium-remote-driver:3.141.59=testCompileClasspath,testRuntimeClasspath org.seleniumhq.selenium:selenium-safari-driver:3.141.59=testCompileClasspath,testRuntimeClasspath org.seleniumhq.selenium:selenium-support:3.141.59=testCompileClasspath,testRuntimeClasspath -org.slf4j:jcl-over-slf4j:1.7.30=testRuntimeClasspath +org.slf4j:jcl-over-slf4j:1.7.32=testCompileClasspath,testRuntimeClasspath org.slf4j:jul-to-slf4j:1.7.30=testRuntimeClasspath org.slf4j:slf4j-api:2.0.12=compileClasspath,nonprodCompileClasspath,nonprodRuntimeClasspath,testCompileClasspath org.slf4j:slf4j-api:2.1.0-alpha1=deploy_jar,runtimeClasspath,testRuntimeClasspath diff --git a/core/src/main/java/google/registry/keyring/api/PgpHelper.java b/core/src/main/java/google/registry/keyring/api/PgpHelper.java index 2addf4b1ec3..7257816945c 100644 --- a/core/src/main/java/google/registry/keyring/api/PgpHelper.java +++ b/core/src/main/java/google/registry/keyring/api/PgpHelper.java @@ -73,21 +73,17 @@ public static PGPPublicKey loadPublicKeyBytes(byte[] data) { */ public static PGPPublicKey lookupPublicKey( PGPPublicKeyRingCollection keyring, String query, KeyRequirement want) { - try { - Iterator results = - keyring.getKeyRings(checkNotNull(query, "query"), true, true); - verify(results.hasNext(), "No public key found matching substring: %s", query); - while (results.hasNext()) { - Optional result = lookupPublicSubkey(results.next(), want); - if (result.isPresent()) { - return result.get(); - } + Iterator results = + keyring.getKeyRings(checkNotNull(query, "query"), true, true); + verify(results.hasNext(), "No public key found matching substring: %s", query); + while (results.hasNext()) { + Optional result = lookupPublicSubkey(results.next(), want); + if (result.isPresent()) { + return result.get(); } - throw new VerifyException(String.format( - "No public key (%s) found matching substring: %s", want, query)); - } catch (PGPException e) { - throw new VerifyException(String.format("Public key lookup failed for query: %s", query), e); } + throw new VerifyException( + String.format("No public key (%s) found matching substring: %s", want, query)); } /** diff --git a/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java b/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java index 8a7d105e41d..ee63702a158 100644 --- a/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java +++ b/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java @@ -50,7 +50,7 @@ import schemacrawler.tools.options.OutputOptionsBuilder; /** Command to generate ER diagrams for SQL schema. */ -@Parameters(separators = " =", commandDescription = "Generate ER diagrams for SQL schmea.") +@Parameters(separators = " =", commandDescription = "Generate ER diagrams for SQL schema.") public class GenerateSqlErDiagramCommand implements Command { private static final String DB_NAME = "postgres"; @@ -101,14 +101,14 @@ public void run() throws Exception { checkState(outDir.toFile().mkdirs(), "Failed to create directory %s", outDir); } - PostgreSQLContainer postgresContainer = - new PostgreSQLContainer(NomulusPostgreSql.getDockerTag()) - .withDatabaseName(DB_NAME) - .withUsername(DB_USER) - .withPassword(DB_PASSWORD); - postgresContainer.start(); - - try (Connection conn = getConnection(postgresContainer)) { + try (PostgreSQLContainer postgresContainer = + new PostgreSQLContainer<>(NomulusPostgreSql.getDockerTag())) { + postgresContainer + .withDatabaseName(DB_NAME) + .withUsername(DB_USER) + .withPassword(DB_PASSWORD) + .start(); + Connection conn = getConnection(postgresContainer); initDb(conn); if (diagramType == ALL || diagramType == FULL) { improveDiagramHtml(generateErDiagram(conn, FULL_DIAGRAM_COMMAND, FULL_DIAGRAM_FILE_NAME)); @@ -116,8 +116,6 @@ public void run() throws Exception { if (diagramType == ALL || diagramType == BRIEF) { improveDiagramHtml(generateErDiagram(conn, BRIEF_DIAGRAM_COMMAND, BRIEF_DIAGRAM_FILE_NAME)); } - } finally { - postgresContainer.stop(); } } @@ -125,7 +123,7 @@ private void improveDiagramHtml(Path diagram) { try { Document doc = Jsoup.parse(diagram.toFile(), StandardCharsets.UTF_8.name()); - // Add the last name of the flyway file to the HTML so we can have a test to verify that if + // Add the last name of the flyway file to the HTML, so we can have a test to verify that if // the generated diagram is up to date. doc.select("body > table > tbody") .first() @@ -140,11 +138,9 @@ private void improveDiagramHtml(Path diagram) { + ""); // Add pan and zoom support for the embedded SVG in the HTML. - StringBuilder svgPanZoomLib = - new StringBuilder(""); - doc.select("head").first().append(svgPanZoomLib.toString()); + String svgPanZoomLib = + ""; + doc.select("head").first().append(svgPanZoomLib); doc.select("svg") .first() .attributes() @@ -163,8 +159,7 @@ private void improveDiagramHtml(Path diagram) { + "});" + ""); - Files.write( - diagram, doc.outerHtml().getBytes(StandardCharsets.UTF_8), StandardOpenOption.WRITE); + Files.writeString(diagram, doc.outerHtml(), StandardOpenOption.WRITE); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -194,7 +189,7 @@ private Path generateErDiagram(Connection connection, String command, String fil return outputFile; } - private static Connection getConnection(PostgreSQLContainer container) { + private static Connection getConnection(PostgreSQLContainer container) { Properties info = new Properties(); info.put("user", container.getUsername()); info.put("password", container.getPassword()); diff --git a/core/src/test/java/google/registry/testing/sftp/TestSftpServer.java b/core/src/test/java/google/registry/testing/sftp/TestSftpServer.java index e2a073ad557..af7da3a7cda 100644 --- a/core/src/test/java/google/registry/testing/sftp/TestSftpServer.java +++ b/core/src/test/java/google/registry/testing/sftp/TestSftpServer.java @@ -27,18 +27,17 @@ import javax.annotation.Nullable; import org.apache.ftpserver.FtpServer; import org.apache.ftpserver.ftplet.FtpException; -import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory; import org.apache.sshd.common.keyprovider.KeyPairProvider; import org.apache.sshd.common.random.SingletonRandomFactory; +import org.apache.sshd.common.session.SessionContext; +import org.apache.sshd.scp.server.ScpCommandFactory; import org.apache.sshd.server.ServerBuilder; import org.apache.sshd.server.SshServer; import org.apache.sshd.server.auth.password.PasswordAuthenticator; import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator; -import org.apache.sshd.server.command.Command; -import org.apache.sshd.server.scp.ScpCommandFactory; import org.apache.sshd.server.session.ServerSession; -import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory; +import org.apache.sshd.sftp.server.SftpSubsystemFactory; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.openssl.PEMKeyPair; import org.bouncycastle.openssl.PEMParser; @@ -131,7 +130,7 @@ public boolean authenticate( server.setCommandFactory(new ScpCommandFactory()); server.setPort(port); - NamedFactory sftpSubsystemFactory = new SftpSubsystemFactory.Builder().build(); + SftpSubsystemFactory sftpSubsystemFactory = new SftpSubsystemFactory.Builder().build(); server.setSubsystemFactories(ImmutableList.of(sftpSubsystemFactory)); if (authorizedPassword != null) { @@ -150,17 +149,17 @@ public boolean authenticate(String username, String password, ServerSession sess ImmutableMap.of(KEY_TYPE, HOST_KEY_PAIR); @Override - public Iterable loadKeys() { + public Iterable loadKeys(SessionContext context) { return keyPairByTypeMap.values(); } @Override - public Iterable getKeyTypes() { + public Iterable getKeyTypes(SessionContext context) { return keyPairByTypeMap.keySet(); } @Override - public KeyPair loadKey(final String type) { + public KeyPair loadKey(SessionContext context, final String type) { return keyPairByTypeMap.get(type); } }; diff --git a/core/src/test/java/google/registry/tools/GenerateSqlErDiagramCommandTest.java b/core/src/test/java/google/registry/tools/GenerateSqlErDiagramCommandTest.java index 2860469dce5..fb0e1849e3f 100644 --- a/core/src/test/java/google/registry/tools/GenerateSqlErDiagramCommandTest.java +++ b/core/src/test/java/google/registry/tools/GenerateSqlErDiagramCommandTest.java @@ -45,7 +45,7 @@ class GenerateSqlErDiagramCommandTest extends CommandTestCase