FileDocCategorySizeDatePackage
UnifiedX509KeyManager.javaAPI DocGlassfish v2 API6134Fri May 04 22:35:36 BST 2007com.sun.enterprise.security.ssl

UnifiedX509KeyManager

public class UnifiedX509KeyManager extends Object implements X509KeyManager
This class combines an array of X509KeyManagers into one.
author
Shing Wai Chan

Fields Summary
private X509KeyManager[]
mgrs
private String[]
tokenNames
Constructors Summary
public UnifiedX509KeyManager(X509KeyManager[] mgrs, String[] tokenNames)

param
mgrs
param
tokenNames Array of tokenNames with order corresponding to mgrs


                       
         
        if (mgrs == null || tokenNames == null) {
            throw new IllegalArgumentException("Null array of X509KeyManagers or tokenNames");
        }
        if (mgrs.length != tokenNames.length) {
            throw new IllegalArgumentException("Size of X509KeyManagers array and tokenNames array do not match.");
        }
        this.mgrs = mgrs;
        this.tokenNames = tokenNames;
    
Methods Summary
public java.lang.StringchooseClientAlias(java.lang.String[] keyType, java.security.Principal[] issuers, java.net.Socket socket)

        String alias = null;
        for (int i = 0; i < mgrs.length; i++) {
            alias = mgrs[i].chooseClientAlias(keyType, issuers, socket);
            if (alias != null) {
                break;
            }
        }
        return alias;
    
public java.lang.StringchooseServerAlias(java.lang.String keyType, java.security.Principal[] issuers, java.net.Socket socket)

        String alias = null;
        for (int i = 0; i < mgrs.length; i++) {
            alias = mgrs[i].chooseServerAlias(keyType, issuers, socket);
            if (alias != null) {
                break;
            }
        }
        return alias;
    
public java.security.cert.X509Certificate[]getCertificateChain(java.lang.String alias)

        X509Certificate[] chain = null;
        for (int i = 0; i < mgrs.length; i++) {
            chain = mgrs[i].getCertificateChain(alias);
            if (chain != null) {
                break;
            }
        }
        return chain;
    
public java.lang.String[]getClientAliases(java.lang.String keyType, java.security.Principal[] issuers)

        ArrayList clientAliases = new ArrayList();
        for (int i = 0; i < mgrs.length; i++) {
            String[] clAliases = mgrs[i].getClientAliases(keyType, issuers);
            if (clAliases != null && clAliases.length > 0) {
                for (int j = 0; j < clAliases.length; j++) {
                    clientAliases.add(clAliases[j]);
                }
            }
        }

        return (clientAliases.size() == 0) ? null :
            (String[])clientAliases.toArray(new String[clientAliases.size()]);
    
public java.security.PrivateKeygetPrivateKey(java.lang.String alias)

        PrivateKey privKey  = null;
        for (int i = 0; i < mgrs.length; i++) {
            privKey = mgrs[i].getPrivateKey(alias);
            if (privKey != null) {
                break;
            }
        }
        return privKey;
    
public java.lang.String[]getServerAliases(java.lang.String keyType, java.security.Principal[] issuers)

        ArrayList serverAliases = new ArrayList();
        for (int i = 0; i < mgrs.length; i++) {
            String[] serAliases = mgrs[i].getClientAliases(keyType, issuers);
            if (serAliases != null && serAliases.length > 0) {
                for (int j = 0; j < serAliases.length; j++) {
                    serverAliases.add(serAliases[j]);
                }
            }
        }

        return (serverAliases.size() == 0) ? null :
            (String[])serverAliases.toArray(new String[serverAliases.size()]);
    
java.lang.String[]getTokenNames()

        String[] tokens = new String[tokenNames.length];
        System.arraycopy(tokenNames, 0, tokens, 0, tokenNames.length);
        return tokens;
    
javax.net.ssl.X509KeyManager[]getX509KeyManagers()

        X509KeyManager[] kmgrs = new X509KeyManager[mgrs.length];
        System.arraycopy(mgrs, 0, kmgrs, 0, mgrs.length);
        return kmgrs;