@ -710,6 +710,30 @@ public class CertificateGenerator {
}
}
public void saveCertificate ( org . wso2 . carbon . certificate . mgt . core . bean . Certificate
certificate ) throws KeystoreException {
if ( certificate = = null ) {
return ;
}
try {
CertificateDAO certificateDAO = CertificateManagementDAOFactory . getCertificateDAO ( ) ;
CertificateManagementDAOFactory . beginTransaction ( ) ;
certificateDAO . addCertificate ( certificate ) ;
CertificateManagementDAOFactory . commitTransaction ( ) ;
} catch ( CertificateManagementDAOException e ) {
String errorMsg = "Error occurred when saving the generated certificate in database" ;
log . error ( errorMsg ) ;
CertificateManagementDAOFactory . rollbackTransaction ( ) ;
throw new KeystoreException ( errorMsg , e ) ;
} catch ( TransactionManagementException e ) {
String errorMsg = "Error occurred when saving the generated certificate in database" ;
log . error ( errorMsg ) ;
throw new KeystoreException ( errorMsg , e ) ;
}
}
public void saveCertInKeyStore ( List < org . wso2 . carbon . certificate . mgt . core . bean . Certificate > certificate )
throws KeystoreException {
@ -845,11 +869,10 @@ public class CertificateGenerator {
org . wso2 . carbon . certificate . mgt . core . bean . Certificate certificate =
new org . wso2 . carbon . certificate . mgt . core . bean . Certificate ( ) ;
List < org . wso2 . carbon . certificate . mgt . core . bean . Certificate > certificates = new ArrayList < > ( ) ;
certificate . setTenantId ( PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantId ( ) ) ;
certificate . setCertificate ( issuedCert ) ;
certificate s. add ( certificat e) ;
saveCert InKeyStore( certificates ) ;
certificate . setDeviceIdentifier ( commonNam e) ;
saveCert ificate( certificate ) ;
} catch ( OperatorCreationException e ) {
String errorMsg = "Error creating the content signer" ;