Example usage for javax.net.ssl X509KeyManager getClientAliases

List of usage examples for javax.net.ssl X509KeyManager getClientAliases

Introduction

In this page you can find the example usage for javax.net.ssl X509KeyManager getClientAliases.

Prototype

public String[] getClientAliases(String keyType, Principal[] issuers);

Source Link

Document

Get the matching aliases for authenticating the client side of a secure socket given the public key type and the list of certificate issuer authorities recognized by the peer (if any).

Usage

From source file:de.betterform.connector.http.ssl.BetterFORMKeyStoreManager.java

public String[] getClientAliases(String keyType, Principal[] principals) {
    String[] customClientAliases = null;
    Iterator<X509KeyManager> iterator = this.customX509KeyManagers.iterator();
    while (iterator.hasNext()) {
        X509KeyManager x509KeyManager = iterator.next();
        customClientAliases = (String[]) ArrayUtils.addAll(customClientAliases,
                x509KeyManager.getClientAliases(keyType, principals));
    }/*from  www. ja  v a 2 s. co m*/
    return (String[]) ArrayUtils.addAll(customClientAliases,
            javaDefaultKeyManager.getClientAliases(keyType, principals));
}

From source file:org.codice.ddf.cxf.SecureCxfClientFactoryTest.java

@Test
public void testAliasSelectorKeyManager() {
    X509KeyManager keyManager = mock(X509KeyManager.class);
    String alias = "testAlias";
    String[] aliases = new String[] { alias };
    when(keyManager.chooseClientAlias(any(), any(), any())).thenReturn(alias);
    when(keyManager.getClientAliases(any(), any())).thenReturn(aliases);

    AliasSelectorKeyManager aliasSelectorKeyManager = new AliasSelectorKeyManager(keyManager, alias);
    String chosenAlias = aliasSelectorKeyManager.chooseClientAlias(new String[] { "x509" }, null, null);
    assertThat(chosenAlias, is(alias));/*from www . j a v a 2 s. c om*/
}