提交 54fbfde2 authored 作者: Thomas Mueller's avatar Thomas Mueller

Remove duplicated code

上级 d2787fcf
...@@ -31,9 +31,8 @@ public class CipherFactory { ...@@ -31,9 +31,8 @@ public class CipherFactory {
return new XTEA(); return new XTEA();
} else if ("AES".equalsIgnoreCase(algorithm)) { } else if ("AES".equalsIgnoreCase(algorithm)) {
return new AES(); return new AES();
} else {
throw Message.getSQLException(ErrorCode.UNSUPPORTED_CIPHER, algorithm);
} }
throw Message.getSQLException(ErrorCode.UNSUPPORTED_CIPHER, algorithm);
} }
/** /**
......
...@@ -8,9 +8,7 @@ package org.h2.security; ...@@ -8,9 +8,7 @@ package org.h2.security;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.constant.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.message.Message;
import org.h2.store.DataHandler; import org.h2.store.DataHandler;
import org.h2.store.FileStore; import org.h2.store.FileStore;
import org.h2.util.RandomUtils; import org.h2.util.RandomUtils;
...@@ -32,15 +30,8 @@ public class SecureFileStore extends FileStore { ...@@ -32,15 +30,8 @@ public class SecureFileStore extends FileStore {
public SecureFileStore(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations) throws SQLException { public SecureFileStore(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations) throws SQLException {
super(handler, name, mode); super(handler, name, mode);
this.key = key; this.key = key;
if ("XTEA".equalsIgnoreCase(cipher)) { this.cipher = CipherFactory.getBlockCipher(cipher);
this.cipher = new XTEA(); this.cipherForInitVector = CipherFactory.getBlockCipher(cipher);
this.cipherForInitVector = new XTEA();
} else if ("AES".equalsIgnoreCase(cipher)) {
this.cipher = new AES();
this.cipherForInitVector = new AES();
} else {
throw Message.getSQLException(ErrorCode.UNSUPPORTED_CIPHER, cipher);
}
this.keyIterations = keyIterations; this.keyIterations = keyIterations;
bufferForInitVector = new byte[Constants.FILE_BLOCK_SIZE]; bufferForInitVector = new byte[Constants.FILE_BLOCK_SIZE];
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论