Search in sources :

Example 1 with CertificateIdentityCallback

use of ch.cyberduck.core.CertificateIdentityCallback in project cyberduck by iterate-ch.

the class CertificateStoreX509KeyManagerTest method testChooseClientAliasStartcom.

@Test
public void testChooseClientAliasStartcom() throws Exception {
    final AtomicBoolean choose = new AtomicBoolean();
    final X509KeyManager m = new CertificateStoreX509KeyManager(new DisabledCertificateIdentityCallback(), new Host(new TestProtocol(), "test2.cyberduck.ch"), new DisabledCertificateStore() {

        @Override
        public X509Certificate choose(final CertificateIdentityCallback prompt, final String[] keyTypes, final Principal[] issuers, final Host bookmark) throws ConnectionCanceledException {
            for (Principal issuer : issuers) {
                assertEquals("CN=StartCom Class 2 Primary Intermediate Client CA", issuer.getName());
            }
            choose.set(true);
            throw new ConnectionCanceledException();
        }
    }).init();
    assertNull(m.chooseClientAlias(new String[] { "RSA", "DSA" }, new Principal[] { new X500Principal("CN=StartCom Class 2 Primary Intermediate Client CA") }, new Socket("test.cyberduck.ch", 443)));
    assertTrue(choose.get());
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) DisabledCertificateStore(ch.cyberduck.core.DisabledCertificateStore) DisabledCertificateIdentityCallback(ch.cyberduck.core.DisabledCertificateIdentityCallback) Host(ch.cyberduck.core.Host) CertificateIdentityCallback(ch.cyberduck.core.CertificateIdentityCallback) DisabledCertificateIdentityCallback(ch.cyberduck.core.DisabledCertificateIdentityCallback) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) X500Principal(javax.security.auth.x500.X500Principal) X500Principal(javax.security.auth.x500.X500Principal) BasicUserPrincipal(org.apache.http.auth.BasicUserPrincipal) Principal(java.security.Principal) Socket(java.net.Socket) Test(org.junit.Test)

Aggregations

CertificateIdentityCallback (ch.cyberduck.core.CertificateIdentityCallback)1 DisabledCertificateIdentityCallback (ch.cyberduck.core.DisabledCertificateIdentityCallback)1 DisabledCertificateStore (ch.cyberduck.core.DisabledCertificateStore)1 Host (ch.cyberduck.core.Host)1 TestProtocol (ch.cyberduck.core.TestProtocol)1 ConnectionCanceledException (ch.cyberduck.core.exception.ConnectionCanceledException)1 Socket (java.net.Socket)1 Principal (java.security.Principal)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 X500Principal (javax.security.auth.x500.X500Principal)1 BasicUserPrincipal (org.apache.http.auth.BasicUserPrincipal)1 Test (org.junit.Test)1