Code example for TrustManagerFactory

Methods: getTrustManagersinit

-1
    private void checkResult(TrustManagerFactory tmf) throws Exception {
        KeyStore kStore = null;
        ManagerFactoryParameters mfp = null;
         
        try { 
            tmf.init(kStore);
            fail("KeyStoreException must be thrown");
        } catch (KeyStoreException e) {
        } 
        try { 
            tmf.init(mfp);
            fail("InvalidAlgorithmParameterException must be thrown");
        } catch (InvalidAlgorithmParameterException e) {
        } 
        assertNull("getTrustManagers() should return null object", tmf
                .getTrustManagers());     
         
        try { 
            kStore = KeyStore.getInstance(KeyStore.getDefaultType());
            kStore.load(null, null);            
        } catch (KeyStoreException e) {
            fail("default keystore is not supported");
            return; 
        } 
        tmf.init(kStore);
        mfp = (ManagerFactoryParameters) new MyTrustManagerFactorySpi.Parameters(null);
        try { 
            tmf.init(mfp);
            fail("RuntimeException must be thrown");
        } catch (RuntimeException e) {
            assertTrue("Incorrect exception", e.getCause() instanceof KeyStoreException);
        } 
        mfp = (ManagerFactoryParameters) new MyTrustManagerFactorySpi.Parameters(kStore);
        tmf.init(mfp);
    } 
     
    /** 
     * Test for <code>getInstance(String algorithm)</code> method 
     * Assertions: 
Connect your IDE to all the code out there  Get Codota for Java