Skip to content

Commit

Permalink
[misc] correct javadoc entries
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Nov 15, 2024
1 parent e3df57b commit 3f1706e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/mariadb/jdbc/message/server/OkPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public static OkPacket parse(ReadableByteBuf buf, Context context) {
*
* @param buf packet buffer
* @param context connection context
* @return Ok_Packet object
*/
public static OkPacket parseWithInfo(ReadableByteBuf buf, Context context) {
buf.skip(); // ok header
Expand Down Expand Up @@ -248,6 +249,11 @@ public long getLastInsertId() {
return lastInsertId;
}

/**
* Get ok packet info byte array.
* That is usually a string value, but for first Ok_Packet, containing fingerprint info.
* @return info
*/
public byte[] getInfo() {
return info;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
/** Parsec password plugin utility */
public class ParsecPasswordPluginTool {

/**
* Bouncy Castle implementation to get raw public key from raw private key
* @param rawPrivateKey raw ed25519 private key
* @return raw public key
* @throws SQLException exception
* @throws IOException exception
* @throws InvalidAlgorithmParameterException exception
* @throws NoSuchAlgorithmException exception
*/
public static byte[] process(byte[] rawPrivateKey)
throws SQLException,
IOException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public class SendPamAuthPacket implements AuthenticationPlugin {
* Initialization.
*
* @param authenticationData authentication data (password/token)
* @param seed server provided seed
* @param conf Connection string options
* @param hostAddress host information
*/
public SendPamAuthPacket(String authenticationData, Configuration conf) {
this.authenticationData = authenticationData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// Copyright (c) 2015-2024 MariaDB Corporation Ab
package org.mariadb.jdbc.util.timeout;

/**
* Default no op query timeout.
*/
public class NoOpQueryTimeoutHandler implements QueryTimeoutHandler {
public static final NoOpQueryTimeoutHandler INSTANCE = new NoOpQueryTimeoutHandler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// Copyright (c) 2015-2024 MariaDB Corporation Ab
package org.mariadb.jdbc.util.timeout;

/**
* Query Timeout handler for server that doesn't support query specific timeout
*/
public interface QueryTimeoutHandler extends AutoCloseable {
QueryTimeoutHandler create(int queryTimeout);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
import java.sql.SQLException;
import java.util.Arrays;

/** Parsec password plugin utility*/
/**
* Parsec password plugin utility
*/
public class ParsecPasswordPluginTool {

public static byte[] process(byte[] rawPrivateKey)
throws SQLException, IOException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {

KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("Ed25519");
keyPairGenerator.initialize(NamedParameterSpec.ED25519, new StaticSecureRandom(rawPrivateKey));
keyPairGenerator.initialize(NamedParameterSpec.ED25519, new SecureRandom() {
public void nextBytes(byte[] bytes) {
System.arraycopy(rawPrivateKey, 0, bytes, 0, rawPrivateKey.length);
}
});

// public key in SPKI format; the last 32 bytes are the raw public key
byte[] spki =
Expand All @@ -28,16 +34,4 @@ public static byte[] process(byte[] rawPrivateKey)
Arrays.copyOfRange(spki, spki.length - 32, spki.length);
return rawPublicKey;
}

private static class StaticSecureRandom extends SecureRandom {
private byte[] privateKey;

public StaticSecureRandom(byte[] privateKey) {
this.privateKey = privateKey;
}

public void nextBytes(byte[] bytes) {
System.arraycopy(privateKey, 0, bytes, 0, privateKey.length);
}
}
}

0 comments on commit 3f1706e

Please sign in to comment.