IDEMPIERE-613 Column Encryption Enhancement. Fixerd synchronization and release of resource .

This commit is contained in:
Heng Sin Low 2013-02-08 18:27:26 +08:00
parent 3e5608734b
commit d26c8845b5
1 changed files with 9 additions and 2 deletions

View File

@ -57,9 +57,11 @@ public class DefaultKeyStore implements IKeyStore {
public DefaultKeyStore(){
File file = new File(Ini.getAdempiereHome(), IDEMPIERE_KEYSTORE_PROPERTIES);
if (file.exists()) {
FileInputStream is = null;
try{
is = new FileInputStream(file);
Properties p = new Properties();
p.load(new FileInputStream(file));
p.load(is);
String s = p.getProperty("password");
String a = p.getProperty("algorithm");
if (!Util.isEmpty(s) && !Util.isEmpty(a)) {
@ -80,6 +82,11 @@ public class DefaultKeyStore implements IKeyStore {
log.log(Level.SEVERE, "", ex);
password = null;
createLegacyKey();
} finally {
try {
if (is != null)
is.close();
} catch (Exception e) {}
}
} else {
createLegacyKey();
@ -92,7 +99,7 @@ public class DefaultKeyStore implements IKeyStore {
}
@Override
public SecretKey getKey(int AD_Client_ID) {
public synchronized SecretKey getKey(int AD_Client_ID) {
if (password != null) {
try {
PasswordProtection protParam = new PasswordProtection(password);