use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.
the class V15WireOperations method readCryptKeyCallback.
@Override
protected DbCryptData readCryptKeyCallback() throws IOException, SQLException {
final XdrInputStream xdrIn = getXdrIn();
// p_cc_data
final byte[] pluginData = xdrIn.readBuffer();
// p_cc_reply
final int replySize = xdrIn.readInt();
try {
return new DbCryptData(pluginData, replySize);
} catch (RuntimeException e) {
throw new FbExceptionBuilder().nonTransientConnectionException(JaybirdErrorCodes.jb_dbCryptDataError).cause(e).toSQLException();
}
}
use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.
the class StaticValueDbCryptCallbackSpiTest method fixedResponseWithBase64Config.
@Test
public void fixedResponseWithBase64Config() {
final DbCryptCallback dbCryptCallback = new StaticValueDbCryptCallbackSpi().createDbCryptCallback("base64:ZWFzdXJlLg==");
DbCryptData dbCryptData = dbCryptCallback.handleCallback(DbCryptData.EMPTY_DATA);
assertArrayEquals("easure.".getBytes(StandardCharsets.US_ASCII), dbCryptData.getPluginData());
}
use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.
the class StaticValueDbCryptCallbackSpiTest method fixedResponseWithStringConfig.
@Test
public void fixedResponseWithStringConfig() {
final String dbCryptConfig = "abc\u02a5\u0b2c\u1d38\u213b";
final DbCryptCallback dbCryptCallback = new StaticValueDbCryptCallbackSpi().createDbCryptCallback(dbCryptConfig);
DbCryptData dbCryptData = dbCryptCallback.handleCallback(DbCryptData.EMPTY_DATA);
assertArrayEquals(dbCryptConfig.getBytes(StandardCharsets.UTF_8), dbCryptData.getPluginData());
}
use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.
the class StaticValueDbCryptCallbackTest method returnsReplyWithFixedResponseValue_nonNull.
@Test
public void returnsReplyWithFixedResponseValue_nonNull() {
final byte[] responseData = { 2, 3, 4, 5, 6 };
DbCryptCallback callback = new StaticValueDbCryptCallback(responseData);
DbCryptData dbCryptData = callback.handleCallback(DbCryptData.EMPTY_DATA);
assertSame("pluginData", responseData, dbCryptData.getPluginData());
assertEquals("replySize", 0, dbCryptData.getReplySize());
}
use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.
the class V13WireOperations method handleCryptKeyCallback.
@Override
public final void handleCryptKeyCallback(DbCryptCallback dbCryptCallback) throws IOException, SQLException {
final DbCryptData serverPluginData = readCryptKeyCallback();
DbCryptData clientPluginResponse;
try {
clientPluginResponse = dbCryptCallback.handleCallback(serverPluginData);
} catch (Exception e) {
log.error("Error during database encryption callback, using default empty response", e);
clientPluginResponse = DbCryptData.EMPTY_DATA;
}
writeCryptKeyCallback(clientPluginResponse);
}
Aggregations