@Test public void certsWithSubjectMatch() throws NamingException { SSLAwareTokenResolver tr = new SSLAwareTokenResolver<Object,Object,Object>(new CommonNameCertInfoExtractor()) { public List<IdentityToken> resolve(Object input, Object transportAuthTokens) { return null; } public void rewrite(List<IdentityToken> credentials, Object output) {} public boolean isRewriteSupported() { return false; } }; assertEquals("ClientName", tr.findCertInfo(createCert(true, "CN=ClientName, OU=Betfair, O=Betfair, ST=London, C=UK"))); assertEquals("ClientName", tr.findCertInfo(createCert(true, "C=BE, ST=Brussel, L=Brussel, O=Vereniging van VlaamseBalies, OU=Vereniging van Vlaamse Balies,CN=ClientName"))); assertEquals("ClientName", tr.findCertInfo(createCert(true, "C=BE, fCN=foo, CN=ClientName, O=Vereniging"))); assertEquals("ClientName", tr.findCertInfo(createCert(true, "C=BE,CN=ClientName"))); assertEquals("ClientName", tr.findCertInfo(createCert(true, "C=BE,cn=ClientName,fo=bat"))); assertEquals("ClientName", tr.findCertInfo(createCert(true, "CN=ClientName"))); }
protected String findCertInfo(X509Certificate[] x509certificates) throws NamingException { if (x509certificates != null && x509certificates.length != 0) { Principal subject = x509certificates[0].getSubjectDN(); if (subject != null && subject.getName() != null) { List<Rdn> rdns; try { rdns = new LdapName(subject.getName()).getRdns(); } catch (InvalidNameException ine) { return null; } return certInfoExtractor.extractCertInfo(rdns); } } return null; }
SSLAwareTokenResolver implements IdentityTokenResolver<I,O,C> { protected String findCertInfo(X509Certificate[] x509certificates) throws NamingException { if (x509certificates != null && x509certificates.length != 0) { Principal subject = x509certificates[0].getSubjectDN(); if (subject != null && subject.getName() != null) { List<Rdn> rdns; try { rdns = new LdapName(subject.getName()).getRdns(); } catch (InvalidNameException ine) { return null; } return certInfoExtractor.extractCertInfo(rdns); } } return null; } }
SSLAwareTokenResolver implements IdentityTokenResolver<I,O,C> { protected String findCertInfo(X509Certificate[] x509certificates) throws NamingException { if (x509certificates != null && x509certificates.length != 0) { Principal subject = x509certificates[0].getSubjectDN(); if (subject != null && subject.getName() != null) { List<Rdn> rdns; try { rdns = new LdapName(subject.getName()).getRdns(); } catch (InvalidNameException ine) { return null; } return certInfoExtractor.extractCertInfo(rdns); } } return null; } protected  SSLAwareTokenResolver(CertInfoExtractor certInfoExtractor); }
SSLAwareTokenResolver implements IdentityTokenResolver<I,O,C> { protected String findCertInfo(X509Certificate[] x509certificates) throws NamingException { if (x509certificates != null && x509certificates.length != 0) { Principal subject = x509certificates[0].getSubjectDN(); if (subject != null && subject.getName() != null) { List<Rdn> rdns; try { rdns = new LdapName(subject.getName()).getRdns(); } catch (InvalidNameException ine) { return null; } return certInfoExtractor.extractCertInfo(rdns); } } return null; } protected  SSLAwareTokenResolver(CertInfoExtractor certInfoExtractor);  }
SSLAwareTokenResolver implements IdentityTokenResolver<I,O,C> { protected String findCertInfo(X509Certificate[] x509certificates) throws NamingException { if (x509certificates != null && x509certificates.length != 0) { Principal subject = x509certificates[0].getSubjectDN(); if (subject != null && subject.getName() != null) { List<Rdn> rdns; try { rdns = new LdapName(subject.getName()).getRdns(); } catch (InvalidNameException ine) { return null; } return certInfoExtractor.extractCertInfo(rdns); } } return null; } protected  SSLAwareTokenResolver(CertInfoExtractor certInfoExtractor);  static final String SSL_CERT_INFO; }