Skip to content

Commit cc61d41

Browse files
committed
Fixed Willena#28. A new Property for this setting has been added.
1 parent fea73df commit cc61d41

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/main/java/org/sqlite/SQLiteConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void apply(Connection conn) throws SQLException {
188188
pragmaParams.remove(Pragma.LIMIT_WORKER_THREADS.pragmaName);
189189

190190

191-
//Remove SQLiteMC related PRAGMAS, so that we are not applying twice the configuration
191+
//Remove SQLiteMC related PRAGMAS, so that we are not applied twice
192192
//TODO : Clone the pragmaTable and remove each Pragma when used so that no checking is required ?
193193
// will make a lighter code ?
194194
pragmaParams.remove(Pragma.KEY.pragmaName);
@@ -205,6 +205,8 @@ public void apply(Connection conn) throws SQLException {
205205
pragmaParams.remove(Pragma.KDF_ALGORITHM.pragmaName);
206206
pragmaParams.remove(Pragma.HMAC_ALGORITHM.pragmaName);
207207
pragmaParams.remove(Pragma.PLAINTEXT_HEADER_SIZE.pragmaName);
208+
pragmaParams.remove(Pragma.MC_USE_SQL_INTERFACE.pragmaName);
209+
208210

209211
Statement stat = conn.createStatement();
210212
try {
@@ -454,7 +456,8 @@ public static enum Pragma {
454456
HMAC_SALT_MASK("hmac_salt_mask", null),
455457
KDF_ALGORITHM("kdf_algorithm", null),
456458
HMAC_ALGORITHM("hmac_algorithm", null),
457-
PLAINTEXT_HEADER_SIZE("plaintext_header_size", null);
459+
PLAINTEXT_HEADER_SIZE("plaintext_header_size", null),
460+
MC_USE_SQL_INTERFACE("mc_use_sql_interface", OnOff);
458461

459462
public final String pragmaName;
460463
public final String[] choices;

src/main/java/org/sqlite/mc/SQLiteMCConfig.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class SQLiteMCConfig extends SQLiteConfig {
1313

1414
private static final Pragma[] CIPHER_PRAGMA_ORDER = new Pragma[]{
1515
Pragma.CIPHER,
16-
Pragma.HMAC_CHECK,
1716
Pragma.LEGACY,
17+
Pragma.HMAC_CHECK,
1818
Pragma.LEGACY_PAGE_SIZE,
1919
Pragma.KDF_ITER,
2020
Pragma.FAST_KDF_ITER,
@@ -34,8 +34,6 @@ public SQLiteMCConfig(Properties prop) {
3434
super(prop);
3535
}
3636

37-
private boolean useSQLInterface = false;
38-
3937
protected boolean isValid(Integer value, int min, int max) {
4038
return (value >= min && value <= max);
4139
}
@@ -110,17 +108,19 @@ protected SQLiteMCConfig setPlaintextHeaderSize(int value) {
110108
}
111109

112110
public SQLiteMCConfig useSQLInterface(boolean sqlInterface) {
113-
this.useSQLInterface = sqlInterface;
111+
setPragma(Pragma.MC_USE_SQL_INTERFACE, sqlInterface?"true":"false");
114112
return this;
115113
}
116114

117115
public void applyCipherParameters(Connection conn, Statement stat) throws SQLException {
118-
applyCipherParametersByNames(CIPHER_PRAGMA_ORDER, conn, stat, useSQLInterface);
116+
applyCipherParametersByNames(CIPHER_PRAGMA_ORDER, conn, stat);
119117
}
120118

121-
protected void applyCipherParametersByNames(Pragma[] pragmas, Connection conn, Statement statement, boolean useSQLInterface) throws SQLException {
119+
protected void applyCipherParametersByNames(Pragma[] pragmas, Connection conn, Statement statement) throws SQLException {
122120
Properties p = super.toProperties();
123121

122+
boolean useSQLInterface = Boolean.parseBoolean(p.getProperty(Pragma.MC_USE_SQL_INTERFACE.getPragmaName(), "false" ));
123+
124124
String cipherProperty = p.getProperty(Pragma.CIPHER.getPragmaName(), null);
125125
if (cipherProperty == null)
126126
throw new SQLException("Cipher name could not be empty at this stage");

0 commit comments

Comments
 (0)