Пример #1
0
 private @Nullable String getNameFromCert(TrustAnchor rootAuthority)
     throws PaymentRequestException.PkiVerificationException {
   org.spongycastle.asn1.x500.X500Name name =
       new X500Name(rootAuthority.getTrustedCert().getSubjectX500Principal().getName());
   String commonName = null, org = null, location = null, country = null;
   for (RDN rdn : name.getRDNs()) {
     AttributeTypeAndValue pair = rdn.getFirst();
     String val = ((ASN1String) pair.getValue()).getString();
     if (pair.getType().equals(RFC4519Style.cn)) commonName = val;
     else if (pair.getType().equals(RFC4519Style.o)) org = val;
     else if (pair.getType().equals(RFC4519Style.l)) location = val;
     else if (pair.getType().equals(RFC4519Style.c)) country = val;
   }
   if (org != null) {
     return Joiner.on(", ").skipNulls().join(org, location, country);
   } else {
     return commonName;
   }
 }
Пример #2
0
 private String getNameFromCert(TrustAnchor rootAuthority)
     throws PaymentRequestException.PkiVerificationException {
   org.spongycastle.asn1.x500.X500Name name =
       new X500Name(rootAuthority.getTrustedCert().getSubjectX500Principal().getName());
   String commonName = null, org = null, location = null, country = null;
   for (RDN rdn : name.getRDNs()) {
     AttributeTypeAndValue pair = rdn.getFirst();
     String val = ((ASN1String) pair.getValue()).getString();
     if (pair.getType().equals(RFC4519Style.cn)) commonName = val;
     else if (pair.getType().equals(RFC4519Style.o)) org = val;
     else if (pair.getType().equals(RFC4519Style.l)) location = val;
     else if (pair.getType().equals(RFC4519Style.c)) country = val;
   }
   if (org != null && location != null && country != null) {
     return org + ", " + location + ", " + country;
   } else {
     if (commonName == null)
       throw new PaymentRequestException.PkiVerificationException(
           "Could not find any identity info for root CA");
     return commonName;
   }
 }