Search in sources :

Example 1 with DViewCsr

use of org.kse.gui.dialogs.DViewCsr in project keystore-explorer by kaikramer.

the class ExamineClipboardAction method showCsr.

private void showCsr(InputStream is, CryptoFileType fileType) {
    if (is == null) {
        return;
    }
    try {
        PKCS10CertificationRequest pkcs10Csr = null;
        Spkac spkacCsr = null;
        try {
            if (fileType == CryptoFileType.PKCS10_CSR) {
                pkcs10Csr = Pkcs10Util.loadCsr(is);
            } else if (fileType == CryptoFileType.SPKAC_CSR) {
                spkacCsr = new Spkac(is);
            }
        } catch (Exception ex) {
            String problemStr = res.getString("ExamineClipboardAction.NoOpenCsr.Problem");
            String[] causes = new String[] { res.getString("ExamineClipboardAction.NotCsr.Cause"), res.getString("ExamineClipboardAction.CorruptedCsr.Cause") };
            Problem problem = new Problem(problemStr, causes, ex);
            DProblem dProblem = new DProblem(frame, res.getString("ExamineClipboardAction.ProblemOpeningCsr.Title"), problem);
            dProblem.setLocationRelativeTo(frame);
            dProblem.setVisible(true);
            return;
        }
        if (pkcs10Csr != null) {
            DViewCsr dViewCsr = new DViewCsr(frame, res.getString("ExamineClipboardAction.CsrDetails.Title"), pkcs10Csr);
            dViewCsr.setLocationRelativeTo(frame);
            dViewCsr.setVisible(true);
        } else {
            DViewCsr dViewCsr = new DViewCsr(frame, res.getString("ExamineClipboardAction.CsrDetails.Title"), spkacCsr);
            dViewCsr.setLocationRelativeTo(frame);
            dViewCsr.setVisible(true);
        }
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}
Also used : PKCS10CertificationRequest(org.bouncycastle.pkcs.PKCS10CertificationRequest) DViewCsr(org.kse.gui.dialogs.DViewCsr) Spkac(org.kse.crypto.csr.spkac.Spkac) Problem(org.kse.gui.error.Problem) DProblem(org.kse.gui.error.DProblem) CryptoException(org.kse.crypto.CryptoException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) DProblem(org.kse.gui.error.DProblem)

Example 2 with DViewCsr

use of org.kse.gui.dialogs.DViewCsr in project keystore-explorer by kaikramer.

the class ExamineFileAction method openCsr.

private void openCsr(File file, CryptoFileType fileType) throws CryptoException {
    if (file == null) {
        return;
    }
    PKCS10CertificationRequest pkcs10Csr = null;
    Spkac spkacCsr = null;
    try {
        if (fileType == CryptoFileType.PKCS10_CSR) {
            pkcs10Csr = Pkcs10Util.loadCsr(new FileInputStream(file));
        } else if (fileType == CryptoFileType.SPKAC_CSR) {
            spkacCsr = new Spkac(new FileInputStream(file));
        }
    } catch (Exception ex) {
        String problemStr = MessageFormat.format(res.getString("ExamineFileAction.NoOpenCsr.Problem"), file.getName());
        String[] causes = new String[] { res.getString("ExamineFileAction.NotCsr.Cause"), res.getString("ExamineFileAction.CorruptedCsr.Cause") };
        Problem problem = new Problem(problemStr, causes, ex);
        DProblem dProblem = new DProblem(frame, res.getString("ExamineFileAction.ProblemOpeningCsr.Title"), problem);
        dProblem.setLocationRelativeTo(frame);
        dProblem.setVisible(true);
        return;
    }
    if (pkcs10Csr != null) {
        DViewCsr dViewCsr = new DViewCsr(frame, MessageFormat.format(res.getString("ExamineFileAction.CsrDetailsFile.Title"), file.getName()), pkcs10Csr);
        dViewCsr.setLocationRelativeTo(frame);
        dViewCsr.setVisible(true);
    } else {
        DViewCsr dViewCsr = new DViewCsr(frame, MessageFormat.format(res.getString("ExamineFileAction.CsrDetailsFile.Title"), file.getName()), spkacCsr);
        dViewCsr.setLocationRelativeTo(frame);
        dViewCsr.setVisible(true);
    }
}
Also used : PKCS10CertificationRequest(org.bouncycastle.pkcs.PKCS10CertificationRequest) DViewCsr(org.kse.gui.dialogs.DViewCsr) Spkac(org.kse.crypto.csr.spkac.Spkac) Problem(org.kse.gui.error.Problem) DProblem(org.kse.gui.error.DProblem) FileInputStream(java.io.FileInputStream) CryptoException(org.kse.crypto.CryptoException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) DProblem(org.kse.gui.error.DProblem)

Aggregations

IOException (java.io.IOException)2 PKCS10CertificationRequest (org.bouncycastle.pkcs.PKCS10CertificationRequest)2 CryptoException (org.kse.crypto.CryptoException)2 Spkac (org.kse.crypto.csr.spkac.Spkac)2 DViewCsr (org.kse.gui.dialogs.DViewCsr)2 DProblem (org.kse.gui.error.DProblem)2 Problem (org.kse.gui.error.Problem)2 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1