All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xbib.net.security.ssl.keymanager.CombinableX509ExtendedKeyManager Maven / Gradle / Ivy

The newest version!
package org.xbib.net.security.ssl.keymanager;

import javax.net.ssl.X509ExtendedKeyManager;
import javax.net.ssl.X509KeyManager;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
 * NOTE:
 * Please don't use this class directly as it is part of the internal API. Class name and methods can be changed any time.
 */
interface CombinableX509ExtendedKeyManager extends X509KeyManager {

    List getKeyManagers();

    default  T extractInnerField(Function keyManagerMapper, Predicate predicate) {
        return getKeyManagers().stream()
                .map(keyManagerMapper)
                .filter(predicate)
                .findFirst()
                .orElse(null);
    }

    default String[] getAliases(Function aliasExtractor) {
        List aliases = getKeyManagers().stream()
                .map(aliasExtractor)
                .filter(Objects::nonNull)
                .flatMap(Arrays::stream)
                .collect(Collectors.toList());

        return aliases.isEmpty() ? null : aliases.toArray(new String[]{});
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy