Java 类org.springframework.security.web.authentication.preauth.x509.SubjectDnX509PrincipalExtractor 实例源码

项目:soil_sealing    文件:Start.java   
private static boolean keyStoreContainsCertificate(KeyStore ks, String hostname)
        throws Exception {
    SubjectDnX509PrincipalExtractor ex = new SubjectDnX509PrincipalExtractor();
    Enumeration<String> e = ks.aliases();
    while (e.hasMoreElements()) {
        String alias = e.nextElement();
        if (ks.isCertificateEntry(alias)) {
            Certificate c = ks.getCertificate(alias);
            if (c instanceof X509Certificate) {
                X500Principal p = (X500Principal) ((X509Certificate) c)
                        .getSubjectX500Principal();
                if (p.getName().contains(hostname))
                    return true;
            }
        }
    }
    return false;
}