Search in sources :

Example 1 with Type

use of org.apache.tomcat.util.net.SSLHostConfigCertificate.Type in project tomcat by apache.

the class CertificateCreateRule method begin.

@Override
public void begin(String namespace, String name, Attributes attributes) throws Exception {
    SSLHostConfig sslHostConfig = (SSLHostConfig) digester.peek();
    Type type;
    String typeValue = attributes.getValue("type");
    if (typeValue == null || typeValue.length() == 0) {
        type = Type.UNDEFINED;
    } else {
        type = Type.valueOf(typeValue);
    }
    SSLHostConfigCertificate certificate = new SSLHostConfigCertificate(sslHostConfig, type);
    digester.push(certificate);
}
Also used : Type(org.apache.tomcat.util.net.SSLHostConfigCertificate.Type) SSLHostConfigCertificate(org.apache.tomcat.util.net.SSLHostConfigCertificate) SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig)

Example 2 with Type

use of org.apache.tomcat.util.net.SSLHostConfigCertificate.Type in project tomcat by apache.

the class OpenSSLContext method findAlias.

/*
     * Find a valid alias when none was specified in the config.
     */
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;
}
Also used : Type(org.apache.tomcat.util.net.SSLHostConfigCertificate.Type) ArrayList(java.util.ArrayList)

Aggregations

Type (org.apache.tomcat.util.net.SSLHostConfigCertificate.Type)2 ArrayList (java.util.ArrayList)1 SSLHostConfig (org.apache.tomcat.util.net.SSLHostConfig)1 SSLHostConfigCertificate (org.apache.tomcat.util.net.SSLHostConfigCertificate)1