mirror of https://github.com/apache/cloudstack.git
bug 12337: Encrypt only password in host_detail table. Removed unused and duplicate references of HostDetailDao
status 12337: resolved fixed reviewed-by: Abhi
This commit is contained in:
parent
462ad5cfc2
commit
e2cb4f94d6
|
|
@ -38,7 +38,7 @@ public class DetailVO {
|
|||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="value", encryptable=true)
|
||||
@Column(name="value")
|
||||
private String value;
|
||||
|
||||
protected DetailVO() {
|
||||
|
|
|
|||
|
|
@ -153,8 +153,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
@Inject
|
||||
protected HostDao _hostDao = null;
|
||||
@Inject
|
||||
protected HostDetailsDao _detailsDao = null;
|
||||
@Inject
|
||||
protected DataCenterDao _dcDao = null;
|
||||
@Inject
|
||||
protected DataCenterIpAddressDao _privateIPAddressDao = null;
|
||||
|
|
@ -173,8 +171,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
@Inject
|
||||
protected StoragePoolHostDao _storagePoolHostDao = null;
|
||||
@Inject
|
||||
protected HostDetailsDao _hostDetailsDao = null;
|
||||
@Inject
|
||||
protected ClusterDao _clusterDao = null;
|
||||
@Inject
|
||||
protected ClusterDetailsDao _clusterDetailsDao = null;
|
||||
|
|
|
|||
|
|
@ -194,8 +194,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
@Inject
|
||||
VlanDao _vlanDao;
|
||||
@Inject
|
||||
HostDetailsDao _hostDetailsDao;
|
||||
@Inject
|
||||
IPAddressDao _publicIpAddressDao;
|
||||
@Inject
|
||||
DataCenterIpAddressDao _privateIpAddressDao;
|
||||
|
|
@ -343,7 +341,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String sql = "update host_details set value=? where name=?";
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setString(1, DBEncryptionUtil.encrypt(value));
|
||||
pstmt.setString(1, value);
|
||||
pstmt.setString(2, "guest.network.device");
|
||||
|
||||
pstmt.executeUpdate();
|
||||
|
|
@ -354,7 +352,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String sql = "update host_details set value=? where name=?";
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setString(1, DBEncryptionUtil.encrypt(value));
|
||||
pstmt.setString(1, value);
|
||||
pstmt.setString(2, "private.network.device");
|
||||
|
||||
pstmt.executeUpdate();
|
||||
|
|
@ -365,7 +363,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String sql = "update host_details set value=? where name=?";
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setString(1, DBEncryptionUtil.encrypt(value));
|
||||
pstmt.setString(1, value);
|
||||
pstmt.setString(2, "public.network.device");
|
||||
|
||||
pstmt.executeUpdate();
|
||||
|
|
@ -376,7 +374,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String sql = "update host_details set value=? where name=?";
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setString(1, DBEncryptionUtil.encrypt(value));
|
||||
pstmt.setString(1, value);
|
||||
pstmt.setString(2, "storage.network.device1");
|
||||
|
||||
pstmt.executeUpdate();
|
||||
|
|
@ -387,7 +385,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String sql = "update host_details set value=? where name=?";
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setString(1, DBEncryptionUtil.encrypt(value));
|
||||
pstmt.setString(1, value);
|
||||
pstmt.setString(2, "storage.network.device2");
|
||||
|
||||
pstmt.executeUpdate();
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||
@Inject protected DataCenterDao _dcDao;
|
||||
@Inject protected HostPodDao _podDao;
|
||||
@Inject protected ClusterDao _clusterDao;
|
||||
@Inject protected HostDetailsDao _hostDetailsDao = null;
|
||||
@Inject protected GuestOSDao _guestOSDao = null;
|
||||
@Inject protected GuestOSCategoryDao _guestOSCategoryDao = null;
|
||||
@Inject protected DiskOfferingDao _diskOfferingDao;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
|||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.host.DetailVO;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
|
@ -51,7 +52,11 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
|
|||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("name", name);
|
||||
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
DetailVO detail = findOneIncludingRemovedBy(sc);
|
||||
if("password".equals(name) && detail != null){
|
||||
detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -62,7 +67,11 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
|
|||
List<DetailVO> results = search(sc, null);
|
||||
Map<String, String> details = new HashMap<String, String>(results.size());
|
||||
for (DetailVO result : results) {
|
||||
details.put(result.getName(), result.getValue());
|
||||
if("password".equals(result.getName())){
|
||||
details.put(result.getName(), DBEncryptionUtil.decrypt(result.getValue()));
|
||||
} else {
|
||||
details.put(result.getName(), result.getValue());
|
||||
}
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
|
@ -87,7 +96,11 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
|
|||
expunge(sc);
|
||||
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
DetailVO vo = new DetailVO(hostId, detail.getKey(), detail.getValue());
|
||||
String value = detail.getValue();
|
||||
if("password".equals(detail.getKey())){
|
||||
value = DBEncryptionUtil.encrypt(value);
|
||||
}
|
||||
DetailVO vo = new DetailVO(hostId, detail.getKey(), value);
|
||||
persist(vo);
|
||||
}
|
||||
txn.commit();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
|
||||
@Inject GuestOSDao _guestOsDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject HostDetailsDao _hostDetailsDao;
|
||||
|
||||
protected HypervGuru() {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||
@Inject HostDao _hostDao;
|
||||
@Inject NetworkServiceMapDao _ntwkSrvcProviderDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject HostDetailsDao _detailsDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
@Inject NicDao _nicDao;
|
||||
|
|
@ -316,7 +315,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||
}
|
||||
|
||||
public ExternalFirewallResponse createExternalFirewallResponse(Host externalFirewall) {
|
||||
Map<String, String> fwDetails = _detailsDao.findDetails(externalFirewall.getId());
|
||||
Map<String, String> fwDetails = _hostDetailDao.findDetails(externalFirewall.getId());
|
||||
ExternalFirewallResponse response = new ExternalFirewallResponse();
|
||||
response.setId(externalFirewall.getId());
|
||||
response.setIpAddress(externalFirewall.getPrivateIpAddress());
|
||||
|
|
|
|||
|
|
@ -134,8 +134,6 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
HostDetailsDao _detailsDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
|
|
@ -329,7 +327,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
}
|
||||
|
||||
public ExternalLoadBalancerResponse createExternalLoadBalancerResponse(Host externalLoadBalancer) {
|
||||
Map<String, String> lbDetails = _detailsDao.findDetails(externalLoadBalancer.getId());
|
||||
Map<String, String> lbDetails = _hostDetailDao.findDetails(externalLoadBalancer.getId());
|
||||
ExternalLoadBalancerResponse response = new ExternalLoadBalancerResponse();
|
||||
response.setId(externalLoadBalancer.getId());
|
||||
response.setIpAddress(externalLoadBalancer.getPrivateIpAddress());
|
||||
|
|
@ -650,7 +648,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
}
|
||||
|
||||
private boolean externalLoadBalancerIsInline(HostVO externalLoadBalancer) {
|
||||
DetailVO detail = _detailsDao.findDetail(externalLoadBalancer.getId(), "inline");
|
||||
DetailVO detail = _hostDetailDao.findDetail(externalLoadBalancer.getId(), "inline");
|
||||
return (detail != null && detail.getValue().equals("true"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||
@Inject PortForwardingRulesDao _portForwardingRulesDao;
|
||||
@Inject LoadBalancerDao _loadBalancerDao;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject HostDetailsDao _detailsDao;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject VpnUserDao _vpnUsersDao;
|
||||
|
|
|
|||
|
|
@ -195,8 +195,6 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
protected ClusterManager _clusterMgr;
|
||||
@Inject
|
||||
protected StoragePoolHostDao _storagePoolHostDao;
|
||||
@Inject
|
||||
protected HostDetailsDao _detailsDao;
|
||||
@Inject(adapter = PodAllocator.class)
|
||||
protected Adapters<PodAllocator> _podAllocators = null;
|
||||
|
||||
|
|
@ -1800,9 +1798,9 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
return false;
|
||||
}
|
||||
|
||||
DetailVO nv = _detailsDao.findDetail(hostId, ApiConstants.USERNAME);
|
||||
DetailVO nv = _hostDetailsDao.findDetail(hostId, ApiConstants.USERNAME);
|
||||
String username = nv.getValue();
|
||||
nv = _detailsDao.findDetail(hostId, ApiConstants.PASSWORD);
|
||||
nv = _hostDetailsDao.findDetail(hostId, ApiConstants.PASSWORD);
|
||||
String password = nv.getValue();
|
||||
UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand(username, password);
|
||||
attache.updatePassword(cmd);
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ import com.cloud.utils.component.Adapters;
|
|||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
|
|
@ -3658,7 +3659,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
DetailVO nv = _detailsDao.findDetail(h.getId(), ApiConstants.USERNAME);
|
||||
if (nv.getValue().equals(cmd.getUsername())) {
|
||||
DetailVO nvp = new DetailVO(h.getId(), ApiConstants.PASSWORD, cmd.getPassword());
|
||||
nvp.setValue(cmd.getPassword());
|
||||
nvp.setValue(DBEncryptionUtil.encrypt(cmd.getPassword()));
|
||||
_detailsDao.persist(nvp);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("The username is not under use by management server.");
|
||||
|
|
@ -3676,7 +3677,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
DetailVO nv = _detailsDao.findDetail(h.getId(), ApiConstants.USERNAME);
|
||||
if (nv.getValue().equals(cmd.getUsername())) {
|
||||
DetailVO nvp = _detailsDao.findDetail(h.getId(), ApiConstants.PASSWORD);
|
||||
nvp.setValue(cmd.getPassword());
|
||||
nvp.setValue(DBEncryptionUtil.encrypt(cmd.getPassword()));
|
||||
_detailsDao.persist(nvp);
|
||||
} else {
|
||||
// if one host in the cluster has diff username then rollback to maintain consistency
|
||||
|
|
|
|||
|
|
@ -222,8 +222,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
@Inject
|
||||
protected ConsoleProxyDao _consoleProxyDao;
|
||||
@Inject
|
||||
protected HostDetailsDao _detailsDao;
|
||||
@Inject
|
||||
protected SnapshotDao _snapshotDao;
|
||||
@Inject
|
||||
protected SnapshotManager _snapMgr;
|
||||
|
|
|
|||
|
|
@ -152,8 +152,6 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
@Inject
|
||||
protected SnapshotScheduleDao _snapshotScheduleDao;
|
||||
@Inject
|
||||
protected HostDetailsDao _detailsDao;
|
||||
@Inject
|
||||
protected DomainDao _domainDao;
|
||||
@Inject
|
||||
protected StorageManager _storageMgr;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ import com.cloud.storage.DiskOfferingVO;
|
|||
import com.cloud.storage.dao.DiskOfferingDaoImpl;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NfsUtils;
|
||||
|
|
@ -534,16 +533,16 @@ public class DatabaseConfig {
|
|||
stmt.setLong(2, 1);
|
||||
stmt.setString(3, "mount.path");
|
||||
if (nfs) {
|
||||
stmt.setString(4, DBEncryptionUtil.encrypt(mountPoint));
|
||||
stmt.setString(4, mountPoint);
|
||||
} else {
|
||||
stmt.setString(4, DBEncryptionUtil.encrypt(url.replaceFirst("file:/", "")));
|
||||
stmt.setString(4, url.replaceFirst("file:/", ""));
|
||||
}
|
||||
stmt.executeUpdate();
|
||||
|
||||
stmt.setLong(1, 3);
|
||||
stmt.setLong(2, 1);
|
||||
stmt.setString(3, "orig.url");
|
||||
stmt.setString(4, DBEncryptionUtil.encrypt(url));
|
||||
stmt.setString(4, url);
|
||||
stmt.executeUpdate();
|
||||
|
||||
stmt = txn.prepareAutoCloseStatement(insertSql2);
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ public class Upgrade2214to30 implements DbUpgrade {
|
|||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = conn.prepareStatement("select id, value from host_details");
|
||||
pstmt = conn.prepareStatement("select id, value from host_details where name = 'password'");
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
|
|
|
|||
|
|
@ -240,8 +240,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
@Inject
|
||||
protected HostDao _hostDao = null;
|
||||
@Inject
|
||||
protected HostDetailsDao _detailsDao = null;
|
||||
@Inject
|
||||
protected DomainRouterDao _routerDao = null;
|
||||
@Inject
|
||||
protected ServiceOfferingDao _offeringDao = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue