Search in sources :

Example 6 with DbCryptData

use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.

the class V13WireOperations method readCryptKeyCallback.

/**
 * Reads the database encryption callback data from the connection.
 *
 * @return Database encryption callback data received from server
 * @throws IOException
 *         For errors reading data from the socket
 * @throws SQLException
 *         For database errors
 */
protected DbCryptData readCryptKeyCallback() throws IOException, SQLException {
    final XdrInputStream xdrIn = getXdrIn();
    // p_cc_data
    final byte[] pluginData = xdrIn.readBuffer();
    try {
        return new DbCryptData(pluginData, Integer.MIN_VALUE);
    } catch (RuntimeException e) {
        throw new FbExceptionBuilder().nonTransientConnectionException(JaybirdErrorCodes.jb_dbCryptDataError).cause(e).toSQLException();
    }
}
Also used : XdrInputStream(org.firebirdsql.gds.impl.wire.XdrInputStream) DbCryptData(org.firebirdsql.gds.ng.dbcrypt.DbCryptData) FbExceptionBuilder(org.firebirdsql.gds.ng.FbExceptionBuilder)

Example 7 with DbCryptData

use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.

the class StaticValueDbCryptCallbackTest method returnsReplyWithFixedResponseValue_null.

@Test
public void returnsReplyWithFixedResponseValue_null() {
    DbCryptCallback callback = new StaticValueDbCryptCallback(null);
    DbCryptData dbCryptData = callback.handleCallback(DbCryptData.EMPTY_DATA);
    assertNull("pluginData", dbCryptData.getPluginData());
    assertEquals("replySize", 0, dbCryptData.getReplySize());
}
Also used : DbCryptData(org.firebirdsql.gds.ng.dbcrypt.DbCryptData) DbCryptCallback(org.firebirdsql.gds.ng.dbcrypt.DbCryptCallback) Test(org.junit.Test)

Example 8 with DbCryptData

use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.

the class StaticValueDbCryptCallbackSpiTest method fixedResponseWithBase64urlConfig.

@Test
public void fixedResponseWithBase64urlConfig() {
    final DbCryptCallback dbCryptCallback = new StaticValueDbCryptCallbackSpi().createDbCryptCallback("base64url:PDw_Pz8-Pg==");
    DbCryptData dbCryptData = dbCryptCallback.handleCallback(DbCryptData.EMPTY_DATA);
    assertArrayEquals("<<???>>".getBytes(StandardCharsets.US_ASCII), dbCryptData.getPluginData());
}
Also used : DbCryptData(org.firebirdsql.gds.ng.dbcrypt.DbCryptData) DbCryptCallback(org.firebirdsql.gds.ng.dbcrypt.DbCryptCallback) Test(org.junit.Test)

Example 9 with DbCryptData

use of org.firebirdsql.gds.ng.dbcrypt.DbCryptData in project jaybird by FirebirdSQL.

the class StaticValueDbCryptCallbackSpiTest method fixedResponseWithNullConfig.

@Test
public void fixedResponseWithNullConfig() {
    final DbCryptCallback dbCryptCallback = new StaticValueDbCryptCallbackSpi().createDbCryptCallback(null);
    DbCryptData dbCryptData = dbCryptCallback.handleCallback(DbCryptData.EMPTY_DATA);
    assertNull(dbCryptData.getPluginData());
}
Also used : DbCryptData(org.firebirdsql.gds.ng.dbcrypt.DbCryptData) DbCryptCallback(org.firebirdsql.gds.ng.dbcrypt.DbCryptCallback) Test(org.junit.Test)

Aggregations

DbCryptData (org.firebirdsql.gds.ng.dbcrypt.DbCryptData)9 DbCryptCallback (org.firebirdsql.gds.ng.dbcrypt.DbCryptCallback)6 Test (org.junit.Test)6 XdrInputStream (org.firebirdsql.gds.impl.wire.XdrInputStream)2 FbExceptionBuilder (org.firebirdsql.gds.ng.FbExceptionBuilder)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1