diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java index 853741206d7..fb09454df0c 100755 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java @@ -613,7 +613,7 @@ public class CertificateGenerator { return null; } - public X509Certificate getSignCertificateFromCSR(String binarySecurityToken, + public X509Certificate getSignedCertificateFromCSR(String binarySecurityToken, X509Certificate caCert, List certPropertyList) throws KeystoreException { byte[] byteArrayBst = DatatypeConverter.parseBase64Binary(binarySecurityToken); @@ -635,7 +635,7 @@ public class CertificateGenerator { private static X509Certificate signCSR(JcaPKCS10CertificationRequest jcaRequest, PrivateKey privateKey, X509Certificate caCert, - List certParameterList) { + List certParameterList) throws KeystoreException { String commonName = (String) certParameterList.get(PropertyIndex.COMMON_NAME_INDEX.getValue()); @@ -644,7 +644,7 @@ public class CertificateGenerator { int notAfterDays = (Integer) certParameterList.get(PropertyIndex.NOT_AFTER_DAYS_INDEX.getValue()); X509v3CertificateBuilder certificateBuilder; - X509Certificate signedCertificate = null; + X509Certificate signedCertificate; try { ContentSigner signer; @@ -674,16 +674,20 @@ public class CertificateGenerator { ConfigurationUtil.PROVIDER).getCertificate( certificateBuilder.build(signer)); } catch (InvalidKeyException e) { - //throw new CertificateGenerationException("CSR's public key is invalid", e); + String errorMsg = "CSR's public key is invalid"; + throw new KeystoreException(errorMsg, e); } catch (NoSuchAlgorithmException e) { - //throw new CertificateGenerationException("Certificate cannot be generated", e); + String errorMsg = "Certificate cannot be generated"; + throw new KeystoreException(errorMsg, e); } catch (CertIOException e) { - // throw new CertificateGenerationException( - // "Cannot add extension(s) to signed certificate", e); + String errorMsg = "Cannot add extension(s) to signed certificate"; + throw new KeystoreException(errorMsg, e); } catch (OperatorCreationException e) { - // throw new CertificateGenerationException("Content signer cannot be created", e); + String errorMsg = "Content signer cannot be created"; + throw new KeystoreException(errorMsg, e); } catch (CertificateException e) { - //throw new CertificateGenerationException("Signed certificate cannot be generated", e); + String errorMsg = "Signed certificate cannot be generated"; + throw new KeystoreException(errorMsg, e); } return signedCertificate; } diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementService.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementService.java index 2a969bfa1a3..7810878bcf0 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementService.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementService.java @@ -54,6 +54,6 @@ public interface CertificateManagementService { String extractChallengeToken(X509Certificate certificate); - X509Certificate getSignCertificateFromCSR(String binarySecurityToken, X509Certificate caCert, + X509Certificate getSignedCertificateFromCSR(String binarySecurityToken, X509Certificate caCert, List certParameterList) throws KeystoreException; } diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementServiceImpl.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementServiceImpl.java index 71b1d32db74..dc8487219ef 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementServiceImpl.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/service/CertificateManagementServiceImpl.java @@ -101,10 +101,9 @@ public class CertificateManagementServiceImpl implements CertificateManagementSe return certificateGenerator.extractChallengeToken(certificate); } - public X509Certificate getSignCertificateFromCSR(String binarySecurityToken, + public X509Certificate getSignedCertificateFromCSR(String binarySecurityToken, X509Certificate caCert, List certParameterList) throws KeystoreException { - return certificateGenerator.getSignCertificateFromCSR(binarySecurityToken, caCert, - certParameterList); + return certificateGenerator.getSignedCertificateFromCSR(binarySecurityToken, caCert, certParameterList); } }