From 33e39415de0e18d97c580e4cdeca687376f7b9f5 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Thu, 2 Nov 2017 14:18:45 +0530 Subject: [PATCH 1/2] Revert "Fix for EMM-1298" --- .../api/impl/CertificateManagementAdminServiceImpl.java | 7 ++----- .../app/pages/cdmf.page.certificate.create/create.hbs | 8 ++++++++ .../public/js/certificate-create.js | 8 +++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java index 3b014fe693..d79f46e1d6 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java @@ -44,7 +44,6 @@ import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerSer import javax.ws.rs.*; import javax.ws.rs.core.Response; -import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -73,10 +72,8 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem for (EnrollmentCertificate enrollmentCertificate : enrollmentCertificates) { certificate = new org.wso2.carbon.certificate.mgt.core.bean.Certificate(); certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - X509Certificate x509Certificate = certificateService - .pemToX509Certificate(enrollmentCertificate.getPem()); - certificate.setSerial(x509Certificate.getSerialNumber().toString()); - certificate.setCertificate(x509Certificate); + certificate.setSerial(enrollmentCertificate.getSerial()); + certificate.setCertificate(certificateService.pemToX509Certificate(enrollmentCertificate.getPem())); certificates.add(certificate); } certificateService.saveCertificate(certificates); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs index 004dc69f7d..b128ceaf92 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs @@ -51,6 +51,14 @@ + + +
+
+ +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js index 6de3971b80..4ccd72a11f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js @@ -92,11 +92,17 @@ $(document).ready(function () { * when a user clicks on "Add Certificate" button. */ $("button#add-certificate-btn").click(function () { - if (!pemContent) { + var serialNoInput = $("input#serialNo"); + var serialNo = serialNoInput.val(); + if (!serialNo) { + $(errorMsg).text("Serial Number is a required field. It cannot be empty."); + $(errorMsgWrapper).removeClass("hidden"); + } else if (!pemContent) { $(errorMsg).text(" .pem file must contains certificate information."); $(errorMsgWrapper).removeClass("hidden"); } else { var addCertificateFormData = {}; + addCertificateFormData.serial = serialNo; addCertificateFormData.pem = pemContent; var certificateList = []; certificateList.push(addCertificateFormData); From 33345f5b52d170978bf4775131f29b0ab999bafe Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Thu, 2 Nov 2017 14:42:08 +0530 Subject: [PATCH 2/2] Adding missing import --- .../jaxrs/api/impl/CertificateManagementAdminServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java index d79f46e1d6..5957b1b8cf 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java @@ -44,6 +44,7 @@ import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerSer import javax.ws.rs.*; import javax.ws.rs.core.Response; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.HashMap; import java.util.List;