From 28775010bc22563a2c97479a86d7e21fd2e91826 Mon Sep 17 00:00:00 2001 From: nishan Date: Tue, 31 Oct 2023 14:39:04 +0530 Subject: [PATCH] set device identifire for certificate table --- .../mgt/core/dao/impl/AbstractCertificateDAOImpl.java | 5 +++-- .../core/certificate/mgt/core/impl/CertificateGenerator.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index 78ea14c99f3..888b3619ca9 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -53,8 +53,8 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ try { conn = this.getConnection(); stmt = conn.prepareStatement( - "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID, USERNAME)" - + " VALUES (?,?,?,?)"); + "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID, USERNAME, DEVICE_IDENTIFIER)" + + " VALUES (?,?,?,?,?)"); PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext. getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); @@ -70,6 +70,7 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ stmt.setBytes(2, bytes); stmt.setInt(3, certificate.getTenantId()); stmt.setString(4, username); + stmt.setString(5, certificate.getDeviceIdentifier()); stmt.addBatch(); } stmt.executeBatch(); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index a8fe131c41d..a692a45ab2b 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -871,6 +871,7 @@ public class CertificateGenerator { new io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate(); List certificates = new ArrayList<>(); certificate.setTenantId(tenantId); + certificate.setDeviceIdentifier(commonName); certificate.setCertificate(issuedCert); certificates.add(certificate); saveCertInKeyStore(certificates);