mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Encrypting password values that are stored in the cluster_details table
This commit is contained in:
parent
b957933a0e
commit
023c2e4f59
@ -22,6 +22,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
|
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -49,7 +50,11 @@ public class ClusterDetailsDaoImpl extends GenericDaoBase<ClusterDetailsVO, Long
|
|||||||
sc.setParameters("clusterId", clusterId);
|
sc.setParameters("clusterId", clusterId);
|
||||||
sc.setParameters("name", name);
|
sc.setParameters("name", name);
|
||||||
|
|
||||||
return findOneIncludingRemovedBy(sc);
|
ClusterDetailsVO detail = findOneIncludingRemovedBy(sc);
|
||||||
|
if("password".equals(name) && detail != null){
|
||||||
|
detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));
|
||||||
|
}
|
||||||
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,8 +66,12 @@ public class ClusterDetailsDaoImpl extends GenericDaoBase<ClusterDetailsVO, Long
|
|||||||
List<ClusterDetailsVO> results = search(sc, null);
|
List<ClusterDetailsVO> results = search(sc, null);
|
||||||
Map<String, String> details = new HashMap<String, String>(results.size());
|
Map<String, String> details = new HashMap<String, String>(results.size());
|
||||||
for (ClusterDetailsVO result : results) {
|
for (ClusterDetailsVO result : results) {
|
||||||
|
if("password".equals(result.getName())){
|
||||||
|
details.put(result.getName(), DBEncryptionUtil.decrypt(result.getValue()));
|
||||||
|
} else {
|
||||||
details.put(result.getName(), result.getValue());
|
details.put(result.getName(), result.getValue());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +95,11 @@ public class ClusterDetailsDaoImpl extends GenericDaoBase<ClusterDetailsVO, Long
|
|||||||
expunge(sc);
|
expunge(sc);
|
||||||
|
|
||||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||||
ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, detail.getKey(), detail.getValue());
|
String value = detail.getValue();
|
||||||
|
if("password".equals(detail.getKey())){
|
||||||
|
value = DBEncryptionUtil.encrypt(value);
|
||||||
|
}
|
||||||
|
ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, detail.getKey(), value);
|
||||||
persist(vo);
|
persist(vo);
|
||||||
}
|
}
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user