Merge pull request #171 from Kamidu/master

Preventing Infromation leakage
revert-dabc3590 IoTS-1.0.0-M3
Prabath Abeysekara 9 years ago
commit 2776577729

@ -63,10 +63,10 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
stmt.setString(4, mobileFeature.getDeviceType()); stmt.setString(4, mobileFeature.getDeviceType());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the MDM database."); log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the MDM database.");
} }
status = true; status = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding feature code - '" + String msg = "Error occurred while adding feature code - '" +
@ -183,6 +183,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileFeature mobileFeature = null; MobileFeature mobileFeature = null;
ResultSet resultSet = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
@ -190,7 +191,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
"WHERE CODE = ?"; "WHERE CODE = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblFeatureCode); stmt.setString(1, mblFeatureCode);
ResultSet resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1)); mobileFeature.setId(resultSet.getInt(1));
@ -207,7 +208,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
} }
return mobileFeature; return mobileFeature;
} }
@ -218,6 +219,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileFeature mobileFeature = null; MobileFeature mobileFeature = null;
ResultSet resultSet = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
@ -225,7 +227,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
" WHERE ID = ?"; " WHERE ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, mblFeatureId); stmt.setInt(1, mblFeatureId);
ResultSet resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1)); mobileFeature.setId(resultSet.getInt(1));
@ -242,7 +244,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
} }
return mobileFeature; return mobileFeature;
} }
@ -253,12 +255,13 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileFeature mobileFeature; MobileFeature mobileFeature;
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>(); List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>();
ResultSet resultSet = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE"; "SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
ResultSet resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1)); mobileFeature.setId(resultSet.getInt(1));
@ -277,7 +280,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
} }
} }
@ -287,6 +290,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileFeature mobileFeature; MobileFeature mobileFeature;
List<MobileFeature> mobileFeatures = new ArrayList<>(); List<MobileFeature> mobileFeatures = new ArrayList<>();
ResultSet resultSet = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
@ -294,7 +298,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
" WHERE DEVICE_TYPE = ?"; " WHERE DEVICE_TYPE = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceType); stmt.setString(1, deviceType);
ResultSet resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1)); mobileFeature.setId(resultSet.getInt(1));
@ -314,7 +318,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
} }
} }

Loading…
Cancel
Save