Refactoring

pull/184/head
M66B 4 years ago
parent 998be94fee
commit 1788d04e64

@ -48,6 +48,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import javax.security.auth.x500.X500Principal; import javax.security.auth.x500.X500Principal;
@ -142,19 +143,22 @@ public class EntityCertificate {
try { try {
X500Name name = new JcaX509CertificateHolder(certificate).getSubject(); X500Name name = new JcaX509CertificateHolder(certificate).getSubject();
List<RDN> rdns = new ArrayList<>(); if (name != null) {
rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.CN))); List<RDN> rdns = new ArrayList<>();
rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.EmailAddress))); rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.CN)));
for (RDN rdn : rdns) { rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.EmailAddress)));
for (AttributeTypeAndValue tv : rdn.getTypesAndValues()) { for (RDN rdn : rdns)
ASN1Encodable enc = tv.getValue(); for (AttributeTypeAndValue tv : rdn.getTypesAndValues()) {
if (enc != null) { ASN1Encodable enc = tv.getValue();
String email = enc.toString(); if (enc == null)
if (!result.contains(email) && continue;
Helper.EMAIL_ADDRESS.matcher(email).matches()) String email = enc.toString().toLowerCase(Locale.ROOT);
result.add(email); if (result.contains(email))
continue;
if (!Helper.EMAIL_ADDRESS.matcher(email).matches())
continue;
result.add(email);
} }
}
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);

Loading…
Cancel
Save