mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
DB update script 6
This commit is contained in:
parent
00b00f0d0c
commit
906de329ae
@ -14,6 +14,8 @@ import javax.crypto.spec.PBEKeySpec;
|
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
/**
|
||||
* Encryption utilities.
|
||||
*
|
||||
@ -47,6 +49,9 @@ public class EncryptionUtil {
|
||||
*/
|
||||
public static InputStream encryptStream(InputStream is, String privateKey) throws Exception {
|
||||
checkBouncyCastleProvider();
|
||||
if (Strings.isNullOrEmpty(privateKey)) {
|
||||
throw new IllegalArgumentException("The private key is null or empty");
|
||||
}
|
||||
return new CipherInputStream(is, getCipher(privateKey, Cipher.ENCRYPT_MODE));
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
db.version=5
|
||||
db.version=6
|
@ -0,0 +1,2 @@
|
||||
alter table T_USER add column USE_PRIVATEKEY_C varchar(100) default '' not null;
|
||||
update T_CONFIG set CFG_VALUE_C='6' where CFG_ID_C='DB_VERSION';
|
@ -21,6 +21,7 @@ public class TestJpa extends BaseTransactionalTest {
|
||||
user.setEmail("toto@docs.com");
|
||||
user.setLocaleId("fr");
|
||||
user.setRoleId("admin");
|
||||
user.setPrivateKey("AwesomePrivateKey");
|
||||
String id = userDao.create(user);
|
||||
|
||||
TransactionUtil.commit();
|
||||
|
@ -31,6 +31,12 @@ public class TestEncryptUtil {
|
||||
|
||||
@Test
|
||||
public void encryptStreamTest() throws Exception {
|
||||
try {
|
||||
EncryptionUtil.encryptStream(this.getClass().getResourceAsStream("/file/udhr.pdf"), "");
|
||||
Assert.fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// NOP
|
||||
}
|
||||
InputStream inputStream = EncryptionUtil.encryptStream(this.getClass().getResourceAsStream("/file/udhr.pdf"), pk);
|
||||
byte[] encryptedData = Streams.readAll(inputStream);
|
||||
byte[] assertData = Streams.readAll(this.getClass().getResourceAsStream("/file/udhr_encrypted.pdf"));
|
||||
|
@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=5
|
||||
db.version=6
|
@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=5
|
||||
db.version=6
|
Loading…
Reference in New Issue
Block a user