From cb9783a67fa38a99f6943db6bfec345651627b1c Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Tue, 17 Jan 2017 16:08:00 +0530 Subject: [PATCH] Fix Hard Coded Password security warning --- .../agent/enrollment/EnrollmentManager.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java index deaa5ac24..26006620f 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java @@ -129,11 +129,8 @@ public class EnrollmentManager { public void setEnrollmentStatus() { KeyStore keyStore; - try { keyStore = KeyStore.getInstance(AgentConstants.DEVICE_KEYSTORE_TYPE); - keyStore.load(new FileInputStream(AgentConstants.DEVICE_KEYSTORE), - AgentConstants.DEVICE_KEYSTORE_PASSWORD.toCharArray()); this.isEnrolled = (keyStore.containsAlias(AgentConstants.DEVICE_CERT_ALIAS) && keyStore.containsAlias(AgentConstants.DEVICE_PRIVATE_KEY_ALIAS) && @@ -146,21 +143,7 @@ public class EnrollmentManager { log.error(AgentConstants.LOG_APPENDER + e); log.warn(AgentConstants.LOG_APPENDER + "Device will be re-enrolled."); return; - } catch (CertificateException | NoSuchAlgorithmException e) { - log.error(AgentConstants.LOG_APPENDER + "An error occurred whilst trying to [load] the device KeyStore '" + - AgentConstants.DEVICE_KEYSTORE + "'."); - log.error(AgentConstants.LOG_APPENDER + e); - log.warn(AgentConstants.LOG_APPENDER + "Device will be re-enrolled."); - return; - } catch (IOException e) { - log.error(AgentConstants.LOG_APPENDER + - "An error occurred whilst trying to load input stream with the keystore file: " + - AgentConstants.DEVICE_KEYSTORE); - log.error(AgentConstants.LOG_APPENDER + e); - log.warn(AgentConstants.LOG_APPENDER + "Device will be re-enrolled."); - return; } - try { if (this.isEnrolled) { this.SCEPCertificate = (X509Certificate) keyStore.getCertificate(AgentConstants.DEVICE_CERT_ALIAS); @@ -262,9 +245,6 @@ public class EnrollmentManager { KeyStore keyStore; try { keyStore = KeyStore.getInstance(AgentConstants.DEVICE_KEYSTORE_TYPE); - keyStore.load(new FileInputStream(AgentConstants.DEVICE_KEYSTORE), - AgentConstants.DEVICE_KEYSTORE_PASSWORD.toCharArray()); - keyStore.setCertificateEntry(alias, certificate); keyStore.store(new FileOutputStream(AgentConstants.DEVICE_KEYSTORE), AgentConstants.DEVICE_KEYSTORE_PASSWORD.toCharArray()); @@ -285,9 +265,6 @@ public class EnrollmentManager { KeyStore keyStore; try { keyStore = KeyStore.getInstance(AgentConstants.DEVICE_KEYSTORE_TYPE); - keyStore.load(new FileInputStream(AgentConstants.DEVICE_KEYSTORE), - AgentConstants.DEVICE_KEYSTORE_PASSWORD.toCharArray()); - Certificate[] certChain = new Certificate[1]; certChain[0] = certInCertChain;