Java Code Examples for javax.net.ssl.X509KeyManager#chooseServerAlias()

The following examples show how to use javax.net.ssl.X509KeyManager#chooseServerAlias() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenSSLContext.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private static String findAlias(X509KeyManager keyManager,
        SSLHostConfigCertificate certificate) {

    Type type = certificate.getType();
    String result = null;

    List<Type> candidateTypes = new ArrayList<>();
    if (Type.UNDEFINED.equals(type)) {
        // Try all types to find an suitable alias
        candidateTypes.addAll(Arrays.asList(Type.values()));
        candidateTypes.remove(Type.UNDEFINED);
    } else {
        // Look for the specific type to find a suitable alias
        candidateTypes.add(type);
    }

    Iterator<Type> iter = candidateTypes.iterator();
    while (result == null && iter.hasNext()) {
        result = keyManager.chooseServerAlias(iter.next().toString(),  null,  null);
    }

    return result;
}
 
Example 2
Source File: FileTrustStoreSslSocketFactory.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Override
public String chooseServerAlias(final String keyType, final Principal[] issuers, final Socket socket) {
    for (final X509KeyManager keyManager : keyManagers) {
        final String alias = keyManager.chooseServerAlias(keyType, issuers, socket);
        if (alias != null) {
            return alias;
        }
    }
    return null;
}
 
Example 3
Source File: SSLKeyManager.java    From PADListener with GNU General Public License v2.0 5 votes vote down vote up
public synchronized String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
    if (_preferredKeyManager != null)
        return _preferredKeyManager.chooseServerAlias(keyType, issuers, socket);
    
    Iterator<String> it = _managers.keySet().iterator();
    while (it.hasNext()) {
        String source = it.next();
        X509KeyManager km = _managers.get(source);
        String alias = km.chooseServerAlias(keyType, issuers, socket);
        if (alias != null) return source + SEP + alias;
    }
    return null;
}
 
Example 4
Source File: CompositeX509KeyManager.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Chooses the first non-null server alias returned from the delegate {@link X509TrustManagers},
 * or {@code null} if there are no matches.
 */
@Override
public @Nullable String chooseServerAlias(String keyType, Principal[] issuers, Socket socket){
	for (List<X509KeyManager> keyManagers : keyManagers.values()) {
		for (X509KeyManager x509KeyManager : keyManagers) {
			String alias = x509KeyManager.chooseServerAlias(keyType, issuers, socket);
			if (alias != null) {
				return alias;
			}
		}
	}
	return null;
}