Search in sources :

Example 1 with CreateUnSignedPKCS7

use of org.nhindirect.trustbundle.core.CreateUnSignedPKCS7 in project nhin-d by DirectProject.

the class ButtonSelector method actionPerformed.

public void actionPerformed(ActionEvent event) {
    //System.out.println("Event"+event.getActionCommand());
    if (event.getActionCommand().equalsIgnoreCase("Create Bundle")) {
        Component[] data = pane.getComponents();
        JTextField anchorDir = (JTextField) data[4];
        JTextField metaDataFile = (JTextField) data[7];
        JTextField destDir = (JTextField) data[10];
        JTextField bundleName = (JTextField) data[13];
        CreateUnSignedPKCS7 unCert = new CreateUnSignedPKCS7();
        error = unCert.getParameters(anchorDir.getText(), metaDataFile.getText(), destDir.getText(), bundleName.getText());
        JTextPane feedback = (JTextPane) data[16];
        feedback.setText(error);
    } else if (event.getActionCommand().equalsIgnoreCase("Create Signed Bundle")) {
        Component[] data = pane.getComponents();
        JTextField anchorDir = (JTextField) data[4];
        JTextField metaDataFile = (JTextField) data[7];
        JTextField certificateDir = (JTextField) data[10];
        JPasswordField passkey = (JPasswordField) data[13];
        //String passVal=new String();
        //System.out.println("The password:"+String.copyValueOf(passkey.getPassword()));
        JTextField destDir = (JTextField) data[15];
        JTextField bundleName = (JTextField) data[18];
        CreateSignedPKCS7 unCert = new CreateSignedPKCS7();
        error = unCert.getParameters(anchorDir.getText(), metaDataFile.getText(), certificateDir.getText(), String.copyValueOf(passkey.getPassword()), destDir.getText(), bundleName.getText());
        //System.out.println("The destination file path is:"+error);
        JTextPane feedback = (JTextPane) data[21];
        feedback.setText(error);
    } else {
        Component[] data = pane.getComponents();
        JTextField trustBundle = (JTextField) data[4];
        ViewTrustBundlePKCS7 unCert = new ViewTrustBundlePKCS7();
        error = unCert.getParameters(trustBundle.getText());
        new PreviewTrustBundle(error);
        PreviewTrustBundle.createAndShowGUI();
    //JTextPane feedback = (JTextPane) data[8];
    //feedback.setText(error);
    }
}
Also used : ViewTrustBundlePKCS7(org.nhindirect.trustbundle.core.ViewTrustBundlePKCS7) JTextPane(javax.swing.JTextPane) CreateUnSignedPKCS7(org.nhindirect.trustbundle.core.CreateUnSignedPKCS7) JPasswordField(javax.swing.JPasswordField) CreateSignedPKCS7(org.nhindirect.trustbundle.core.CreateSignedPKCS7) Component(java.awt.Component) JTextField(javax.swing.JTextField) PreviewTrustBundle(org.nhindirect.trustbundle.ui.PreviewTrustBundle)

Example 2 with CreateUnSignedPKCS7

use of org.nhindirect.trustbundle.core.CreateUnSignedPKCS7 in project nhin-d by DirectProject.

the class TestCreateUnSignedPKCS7 method testGetParameters.

@Test
public void testGetParameters() {
    /*fail("Not yet implemented");*/
    //Case-1 Check the Blank Anchor directory
    CreateUnSignedPKCS7 unsigned = new CreateUnSignedPKCS7();
    errorMsg = unsigned.getParameters("Select Trust Anchor Directory", metaDataFile, destDir, bundleName1);
    assertEquals("Error: Kindly Provide Trust Anchor Directory", errorMsg);
    //Case-2 Check the Blank Anchor directory
    errorMsg = unsigned.getParameters("You pressed cancel", metaDataFile, destDir, bundleName1);
    assertEquals("Error: Kindly Provide Trust Anchor Directory", errorMsg);
    //Case-3 Check the Blank Destination directory
    errorMsg = unsigned.getParameters(anchorDir, metaDataFile, "Select Trust Bundle Destination Directory", bundleName1);
    assertEquals("Error: Kindly Provide Trust Bundle Destination Directory", errorMsg);
    //Case-4 Check the Blank Destination directory
    errorMsg = unsigned.getParameters(anchorDir, metaDataFile, "You pressed cancel", bundleName1);
    assertEquals("Error: Kindly Provide Trust Bundle Destination Directory", errorMsg);
    //Case-5 Check the MetaDataFile
    errorMsg = unsigned.getParameters(anchorDir, metaDataFile, destDir, bundleName1);
    assertEquals("Message: " + bundleName1 + " created successfully!", errorMsg);
    //Case-6 Check the MetaDataFile with different extension
    metaDataFile = projectPath.concat(metaDataFileDir1);
    errorMsg = unsigned.getParameters(anchorDir, metaDataFile, destDir, bundleName1);
    assertEquals("Error: Kindly Provide A XML Meta data file", errorMsg);
    //Case-7 Check the Blank MetaDataFile
    errorMsg = unsigned.getParameters(anchorDir, "Select Meta Data", destDir, bundleName1);
    assertEquals("Error: Kindly Provide A XML Meta data file", errorMsg);
    //Case-8 Check the Blank MetaDataFile
    errorMsg = unsigned.getParameters(anchorDir, "You pressed", destDir, bundleName1);
    assertEquals("Error: Kindly Provide A XML Meta data file", errorMsg);
    //Case-9 Check the Blank Bundle Name
    errorMsg = unsigned.getParameters(anchorDir, metaDataFile, destDir, "");
    assertEquals("Error: Kindly Provide A Proper Trust Bundle Name with a .p7b or .p7c extension", errorMsg);
    //Case-10 Check the Bundle Name with different extension
    errorMsg = unsigned.getParameters(anchorDir, metaDataFile, destDir, "unsigned.txt");
    assertEquals("Error: Kindly Provide A Proper Trust Bundle Name with a .p7b or .p7c extension", errorMsg);
}
Also used : CreateUnSignedPKCS7(org.nhindirect.trustbundle.core.CreateUnSignedPKCS7) Test(org.junit.Test)

Example 3 with CreateUnSignedPKCS7

use of org.nhindirect.trustbundle.core.CreateUnSignedPKCS7 in project nhin-d by DirectProject.

the class TestCreateUnSignedPKCS7 method testCreate.

@Test
public void testCreate() {
    CreateUnSignedPKCS7 unsigned = new CreateUnSignedPKCS7();
    //Case-1 Check with no MetaData and bundle name with extension .p7b
    outStr1 = unsigned.create(anchorDir, createFile1, metaFile, metaExists);
    assertEquals(bundleName1, outStr1.getName());
    //Case-2 Check with MetaData and bundle name with extension .p7b
    outStr1 = unsigned.create(anchorDir, createFile2, new File(metaDataFile), true);
    assertEquals(bundleName2, outStr1.getName());
    //Case-3 Check with no MetaData and bundle name with extension .p7c
    outStr1 = unsigned.create(anchorDir, createFile3, metaFile, metaExists);
    assertEquals(bundleName3, outStr1.getName());
    //Case-4 Check with MetaData and bundle name with extension .p7c
    outStr1 = unsigned.create(anchorDir, createFile4, new File(metaDataFile), true);
    assertEquals(bundleName4, outStr1.getName());
    //Case-5 Check with wrong destination directory with NoMetaData
    outStr1 = unsigned.create(anchorDir, new File("C:\\JunitTesting\\wrong\\UnSignedNoMetaData.p7b"), metaFile, metaExists);
    assertEquals(null, outStr1);
    //Case-6 Check with wrong destination directory with MetaData
    outStr1 = unsigned.create(anchorDir, new File("C:\\wrong\\UnSignedNoMetaData.p7b"), new File(metaDataFile), metaExists);
    assertEquals(null, outStr1);
    //Case-7 Check with wrong anchor directory with NoMetaData
    outStr1 = unsigned.create("C:\\JunitTesting\\wrong", metaFile, metaFile, metaExists);
    assertEquals(null, outStr1);
    //Case-8 Check with wrong anchor directory with MetaData
    outStr1 = unsigned.create("C:\\JunitTesting\\wrong", createFile, new File(metaDataFile), metaExists);
    assertEquals(null, outStr1);
    //Case-9 Check with Blank anchor directory with noMetaData
    outStr1 = unsigned.create("", createFile, metaFile, metaExists);
    assertEquals(null, outStr1);
    //Case-10 Check with Blank anchor directory with MetaData
    outStr1 = unsigned.create("", createFile, new File(metaDataFile), metaExists);
    assertEquals(null, outStr1);
    //Case-11 Check with Blank destination directory with noMetaData
    outStr1 = unsigned.create(anchorDir, new File(""), metaFile, metaExists);
    assertEquals(null, outStr1);
    //Case-12 Check with Blank anchor directory with MetaData
    outStr1 = unsigned.create(anchorDir, new File(""), new File(metaDataFile), metaExists);
    assertEquals(null, outStr1);
    //Case-13 Check with Blank MetaData File
    outStr1 = unsigned.create(anchorDir, createFile, new File(""), metaExists);
    assertEquals(bundleName1, outStr1.getName());
}
Also used : CreateUnSignedPKCS7(org.nhindirect.trustbundle.core.CreateUnSignedPKCS7) File(java.io.File) Test(org.junit.Test)

Aggregations

CreateUnSignedPKCS7 (org.nhindirect.trustbundle.core.CreateUnSignedPKCS7)3 Test (org.junit.Test)2 Component (java.awt.Component)1 File (java.io.File)1 JPasswordField (javax.swing.JPasswordField)1 JTextField (javax.swing.JTextField)1 JTextPane (javax.swing.JTextPane)1 CreateSignedPKCS7 (org.nhindirect.trustbundle.core.CreateSignedPKCS7)1 ViewTrustBundlePKCS7 (org.nhindirect.trustbundle.core.ViewTrustBundlePKCS7)1 PreviewTrustBundle (org.nhindirect.trustbundle.ui.PreviewTrustBundle)1