// Path: keystore-service/src/main/java/com/stnetix/ariaddna/keystore/exceptions/KeyStoreException.java
// public class KeyStoreException extends AriaddnaException {
//     public KeyStoreException(Throwable cause) {
//         super(cause);
//     }
// 
//     public KeyStoreException(String traceMessage) {
//         super(traceMessage);
//     }
// 
//     public KeyStoreException(String traceMessage, String errorMessage) {
//         super(traceMessage, errorMessage);
//     }
// 
//     public KeyStoreException(String traceMessage, Throwable cause) {
//         super(traceMessage, cause);
//     }
// 
//     public KeyStoreException(String traceMessage, String errorMessage, Throwable cause) {
//         super(traceMessage, errorMessage, cause);
//     }
// }


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.KeyStore;
import sun.security.x509.X509CertImpl;
import com.stnetix.ariaddna.commonutils.logger.AriaddnaLogger;
import com.stnetix.ariaddna.keystore.exceptions.KeyStoreException;
            FileOutputStream fos = new FileOutputStream(keyStoreFile);
            keyStore.store(fos, pass);
            LOGGER.info("Certificate with filename {} deleted from keyStore with filename {}",
                    certFile.getAbsolutePath(), keyStoreFile.getAbsolutePath());
            fos.close();
            persistHelper.deleteCertificate(alias);

        } catch (Exception e) {
            LOGGER.error("Exception: ", e);
            throw new KeyStoreException("Caused by: ", e);
        }
    }

    public void setCertDisable(File certFile) throws KeyStoreException {
        X509CertImpl cert = (X509CertImpl) certFactory.getCertByFile(certFile);
        String alias = certFactory.getCertSubjectName(cert);
        persistHelper.setCertificateDisable(alias);
    }

    private File generateKeyStoreByName(String name) throws KeyStoreException {
        KeyStore keyStore = null;
        try (FileOutputStream fos = new FileOutputStream(name)) {
            keyStore = KeyStore.getInstance(KEYSTORE_FORMAT);
            keyStore.load(null, pass);
            keyStore.store(fos, pass);
            File keyStoreFile = new File(name);
            LOGGER.info("KeyStore was create with file name {}", keyStoreFile.getAbsolutePath());
            return keyStoreFile;
        } catch (Exception e) {
            LOGGER.error("KeyStore object is not create. Exception: ", e);
// Path: keystore-service/src/main/java/com/stnetix/ariaddna/keystore/exceptions/KeyStoreException.java
// public class KeyStoreException extends AriaddnaException {
//     public KeyStoreException(Throwable cause) {
//         super(cause);
//     }
// 
//     public KeyStoreException(String traceMessage) {
//         super(traceMessage);
//     }
// 
//     public KeyStoreException(String traceMessage, String errorMessage) {
//         super(traceMessage, errorMessage);
//     }
// 
//     public KeyStoreException(String traceMessage, Throwable cause) {
//         super(traceMessage, cause);
//     }
// 
//     public KeyStoreException(String traceMessage, String errorMessage, Throwable cause) {
//         super(traceMessage, errorMessage, cause);
//     }
// }


// Path: keystore-service/src/main/java/com/stnetix/ariaddna/keystore/utils/KeyFactory.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.KeyStore;
import sun.security.x509.X509CertImpl;
import com.stnetix.ariaddna.commonutils.logger.AriaddnaLogger;
import com.stnetix.ariaddna.keystore.exceptions.KeyStoreException;

            FileOutputStream fos = new FileOutputStream(keyStoreFile);
            keyStore.store(fos, pass);
            LOGGER.info("Certificate with filename {} deleted from keyStore with filename {}",
                    certFile.getAbsolutePath(), keyStoreFile.getAbsolutePath());
            fos.close();
            persistHelper.deleteCertificate(alias);

        } catch (Exception e) {
            LOGGER.error("Exception: ", e);
            throw new KeyStoreException("Caused by: ", e);
        }
    }

    public void setCertDisable(File certFile) throws KeyStoreException {
        X509CertImpl cert = (X509CertImpl) certFactory.getCertByFile(certFile);
        String alias = certFactory.getCertSubjectName(cert);
        persistHelper.setCertificateDisable(alias);
    }

    private File generateKeyStoreByName(String name) throws KeyStoreException {
        KeyStore keyStore = null;
        try (FileOutputStream fos = new FileOutputStream(name)) {
            keyStore = KeyStore.getInstance(KEYSTORE_FORMAT);
            keyStore.load(null, pass);
            keyStore.store(fos, pass);
            File keyStoreFile = new File(name);
            LOGGER.info("KeyStore was create with file name {}", keyStoreFile.getAbsolutePath());
            return keyStoreFile;
        } catch (Exception e) {
            LOGGER.error("KeyStore object is not create. Exception: ", e);
            throw new KeyStoreException("Caused by: ", e);