diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/CertificateKeystoreConfig.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/CertificateKeystoreConfig.java
deleted file mode 100644
index 972975a645..0000000000
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/CertificateKeystoreConfig.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * you may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.wso2.carbon.device.mgt.iot.devicetype.config;
-
-
-import org.wso2.carbon.device.mgt.iot.devicetype.util.DeviceTypeConfigUtil;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Class for holding CertificateKeystore data.
- */
-@XmlRootElement(name = "CertificateKeystore")
-public class CertificateKeystoreConfig {
-
- private String certificateKeystoreLocation;
- private String certificateKeystoreType;
- private String certificateKeystorePassword;
- private String caCertAlias;
- private String caPrivateKeyPassword;
- private String raCertAlias;
- private String raPrivateKeyPassword;
-
- @XmlElement(name = "CertificateKeystoreLocation", required = true)
- public String getCertificateKeystoreLocation() {
- return certificateKeystoreLocation;
- }
-
- public void setCertificateKeystoreLocation(String certificateKeystoreLocation) {
- if (certificateKeystoreLocation != null && certificateKeystoreLocation.toLowerCase().
- contains(DeviceTypeConfigUtil.CARBON_HOME_ENTRY)) {
- certificateKeystoreLocation = certificateKeystoreLocation.replace(DeviceTypeConfigUtil.CARBON_HOME_ENTRY,
- System.getProperty(DeviceTypeConfigUtil.CARBON_HOME));
- }
- this.certificateKeystoreLocation = certificateKeystoreLocation;
- }
-
- @XmlElement(name = "CertificateKeystoreType", required = true)
- public String getCertificateKeystoreType() {
- return certificateKeystoreType;
- }
-
- public void setCertificateKeystoreType(String certificateKeystoreType) {
- this.certificateKeystoreType = certificateKeystoreType;
- }
-
- @XmlElement(name = "CertificateKeystorePassword", required = true)
- public String getCertificateKeystorePassword() {
- return certificateKeystorePassword;
- }
-
- public void setCertificateKeystorePassword(String certificateKeystorePassword) {
- this.certificateKeystorePassword = certificateKeystorePassword;
- }
-
- @XmlElement(name = "CACertAlias", required = true)
- public String getCACertAlias() {
- return caCertAlias;
- }
-
- public void setCACertAlias(String caCertAlias) {
- this.caCertAlias = caCertAlias;
- }
-
- @XmlElement(name = "CAPrivateKeyPassword", required = true)
- public String getCAPrivateKeyPassword() {
- return caPrivateKeyPassword;
- }
-
- public void setCAPrivateKeyPassword(String caPrivateKeyPassword) {
- this.caPrivateKeyPassword = caPrivateKeyPassword;
- }
-
- @XmlElement(name = "RACertAlias", required = true)
- public String getRACertAlias() {
- return raCertAlias;
- }
-
- public void setRACertAlias(String raCertAlias) {
- this.raCertAlias = raCertAlias;
- }
-
- @XmlElement(name = "RAPrivateKeyPassword", required = true)
- public String getRAPrivateKeyPassword() {
- return raPrivateKeyPassword;
- }
-
- public void setRAPrivateKeyPassword(String raPrivateKeyPassword) {
- this.raPrivateKeyPassword = raPrivateKeyPassword;
- }
-}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java
index 55b8165661..369b9af675 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java
@@ -30,7 +30,6 @@ public class DeviceManagementConfiguration {
private DeviceManagementConfigRepository deviceManagementConfigRepository;
private PushNotificationConfig pushNotificationConfig;
private String deviceType;
- private CertificateKeystoreConfig certificateKeystoreConfig;
private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class);
@@ -63,14 +62,4 @@ public class DeviceManagementConfiguration {
public void setPushNotificationConfig(PushNotificationConfig pushNotificationConfig) {
this.pushNotificationConfig = pushNotificationConfig;
}
-
- @XmlElement(name = "CertificateKeystore", required = false)
- public CertificateKeystoreConfig getCertificateKeystoreConfig() {
- return certificateKeystoreConfig;
- }
-
- public void setCertificateKeystoreConfig(
- CertificateKeystoreConfig certificateKeystoreConfig) {
- this.certificateKeystoreConfig = certificateKeystoreConfig;
- }
}
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
index a0e37cdfd6..eb44632880 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
@@ -76,8 +76,7 @@
javax.crypto,
org.apache.commons.codec.binary,
org.json.*;version="${commons-json.version.range}",
- org.wso2.carbon.certificate.mgt.core.exception,
- org.wso2.carbon.certificate.mgt.core.service,
+ org.wso2.carbon.certificate.mgt.core.*,
org.wso2.carbon.certificate.mgt.core.util,
org.wso2.carbon.device.mgt.analytics.data.publisher.exception,
org.wso2.carbon.device.mgt.analytics.data.publisher.service,
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java
index 9f318e1656..9a8defc4b3 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java
@@ -21,12 +21,10 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.CertificateKeystoreConfig;
-import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
+import org.wso2.carbon.certificate.mgt.core.config.CertificateConfigurationManager;
+import org.wso2.carbon.certificate.mgt.core.config.CertificateKeystoreConfig;
+import org.wso2.carbon.certificate.mgt.core.exception.CertificateManagementException;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
@@ -53,21 +51,16 @@ public class VirtualFirealarmSecurityManager {
private static final Log log = LogFactory.getLog(VirtualFirealarmSecurityManager.class);
private static PrivateKey serverPrivateKey;
- private static CertificateKeystoreConfig certificateKeystoreConfig;
private static final String SIGNATURE_ALG = "SHA1withRSA";
private static final String CIPHER_PADDING = "RSA/ECB/PKCS1Padding";
-
+ private static CertificateKeystoreConfig certificateKeystoreConfig;
private VirtualFirealarmSecurityManager() {
}
- private static CertificateKeystoreConfig getCertKeyStoreConfig() {
+ private static CertificateKeystoreConfig getCertKeyStoreConfig() throws CertificateManagementException {
if (certificateKeystoreConfig == null) {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance().
- getDeviceTypeConfigService().getConfiguration(
- VirtualFireAlarmConstants.DEVICE_TYPE,
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
- certificateKeystoreConfig = deviceManagementConfiguration.getCertificateKeystoreConfig();
+ certificateKeystoreConfig = CertificateConfigurationManager.getInstance().getCertificateKeyStoreConfig();
}
return certificateKeystoreConfig;
}
@@ -80,8 +73,8 @@ public class VirtualFirealarmSecurityManager {
PrivateKey privateKey = null;
InputStream inputStream = null;
KeyStore keyStore;
- CertificateKeystoreConfig certificateKeystoreConfig = getCertKeyStoreConfig();
try {
+ CertificateKeystoreConfig certificateKeystoreConfig = getCertKeyStoreConfig();
keyStore = KeyStore.getInstance(certificateKeystoreConfig.getCertificateKeystoreType());
inputStream = new FileInputStream(certificateKeystoreConfig.getCertificateKeystoreLocation());
@@ -108,6 +101,9 @@ public class VirtualFirealarmSecurityManager {
} catch (UnrecoverableKeyException e) {
String errorMsg = "Key is unrecoverable when retrieving CA private key";
log.error(errorMsg, e);
+ } catch (CertificateManagementException e) {
+ String errorMsg = "Failed to load the certificate";
+ log.error(errorMsg, e);
} finally {
try {
if (inputStream != null) {
diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/conf/android-sense-config.xml b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/conf/android-sense-config.xml
index 994309e653..d4863f8f7b 100644
--- a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/conf/android-sense-config.xml
+++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/conf/android-sense-config.xml
@@ -43,20 +43,4 @@
true
-
-
- ${carbon.home}/repository/resources/security/wso2certs.jks
-
- JKS
-
- wso2carbon
-
- cacert
-
- cacert
-
- racert
-
- racert
-
diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/conf/arduino-config.xml b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/conf/arduino-config.xml
index 5c2e2b2902..6cb535f801 100644
--- a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/conf/arduino-config.xml
+++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/conf/arduino-config.xml
@@ -30,20 +30,4 @@
false
-
-
- ${carbon.home}/repository/resources/security/wso2certs.jks
-
- JKS
-
- wso2carbon
-
- cacert
-
- cacert
-
- racert
-
- racert
-
diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/conf/raspberrypi-config.xml b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/conf/raspberrypi-config.xml
index 5685c06960..a68818a732 100644
--- a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/conf/raspberrypi-config.xml
+++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/conf/raspberrypi-config.xml
@@ -43,20 +43,4 @@
true
-
-
- ${carbon.home}/repository/resources/security/wso2certs.jks
-
- JKS
-
- wso2carbon
-
- cacert
-
- cacert
-
- racert
-
- racert
-
diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual-fire-alarm-config.xml b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual-fire-alarm-config.xml
index a88883a88b..f2eb16ae57 100644
--- a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual-fire-alarm-config.xml
+++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual-fire-alarm-config.xml
@@ -54,20 +54,4 @@
localhost
-
-
- ${carbon.home}/repository/resources/security/wso2certs.jks
-
- JKS
-
- wso2carbon
-
- cacert
-
- cacert
-
- racert
-
- racert
-