Code example for KeyStore

Methods: load

1
        char[] password = "PASSWORD".toCharArray();
        try { 
            keyStore.load(is, password);
            assertTrue(keyStore.containsAlias("keyalias"));
        } catch (NoSuchAlgorithmException e) {
            fail("unexpected exception: " + e);
        } catch (CertificateException e) {
            fail("unexpected exception: " + e);
        } catch (IOException e) {
            fail("unexpected exception: " + e);
        } catch (KeyStoreException e) {
            fail("unexpected exception: " + e);
        } 
         
        try { 
            keyStore.load(new ByteArrayInputStream("".getBytes()), password);
            fail("expected IOException");
        } catch (NoSuchAlgorithmException e) {
            fail("unexpected exception: " + e);
        } catch (CertificateException e) {
            fail("unexpected exception: " + e);
        } catch (IOException e) {
            // ok 
        } 
         
        try { 
            keyStore.load(is, null);
            fail("expected NoSuchAlgorithmException");
        } catch (NoSuchAlgorithmException e) {
            // ok 
        } catch (CertificateException e) {
            fail("unexpected exception: " + e);
        } catch (IOException e) {
            fail("unexpected exception: " + e);
        } 
         
        try { 
            keyStore.load(is, new char[] {});
            fail("expected CertificateException");
        } catch (NoSuchAlgorithmException e) {
            fail("unexpected exception: " + e);
        } catch (CertificateException e) {
            // ok 
        } catch (IOException e) {
            fail("unexpected exception: " + e);
        } 
    } 
 
    @TestTargetNew( 
            level=TestLevel.COMPLETE, 
            method="load", 
            args={KeyStore.LoadStoreParameter.class}
    ) 
    public void testLoadLoadStoreParameter() { 
        try {