mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
998be94fee
commit
1788d04e64
|
@ -48,6 +48,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
@ -142,19 +143,22 @@ public class EntityCertificate {
|
|||
|
||||
try {
|
||||
X500Name name = new JcaX509CertificateHolder(certificate).getSubject();
|
||||
List<RDN> rdns = new ArrayList<>();
|
||||
rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.CN)));
|
||||
rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.EmailAddress)));
|
||||
for (RDN rdn : rdns) {
|
||||
for (AttributeTypeAndValue tv : rdn.getTypesAndValues()) {
|
||||
ASN1Encodable enc = tv.getValue();
|
||||
if (enc != null) {
|
||||
String email = enc.toString();
|
||||
if (!result.contains(email) &&
|
||||
Helper.EMAIL_ADDRESS.matcher(email).matches())
|
||||
result.add(email);
|
||||
if (name != null) {
|
||||
List<RDN> rdns = new ArrayList<>();
|
||||
rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.CN)));
|
||||
rdns.addAll(Arrays.asList(name.getRDNs(BCStyle.EmailAddress)));
|
||||
for (RDN rdn : rdns)
|
||||
for (AttributeTypeAndValue tv : rdn.getTypesAndValues()) {
|
||||
ASN1Encodable enc = tv.getValue();
|
||||
if (enc == null)
|
||||
continue;
|
||||
String email = enc.toString().toLowerCase(Locale.ROOT);
|
||||
if (result.contains(email))
|
||||
continue;
|
||||
if (!Helper.EMAIL_ADDRESS.matcher(email).matches())
|
||||
continue;
|
||||
result.add(email);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
|
|
Loading…
Reference in New Issue