static X509Principal convertPrincipal( X500Principal principal) { try { return new X509Principal(principal.getEncoded()); } catch (IOException e) { throw new IllegalArgumentException("cannot convert principal"); } }
/** * return a DER encoded byte array representing this object */ public byte[] getEncoded() { try { return this.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new RuntimeException(e.toString()); } } }
/** * Constructor from an encoded byte array. */ public X509Principal( byte[] bytes) throws IOException { super(readSequence(new ASN1InputStream(bytes))); }
private boolean matchesDN(X509Principal subject, GeneralNames targets) { GeneralName[] names = targets.getNames(); for (int i = 0; i != names.length; i++) { GeneralName gn = names[i]; if (gn.getTagNo() == GeneralName.directoryName) { try { if (new X509Principal(((ASN1Encodable)gn.getName()).toASN1Primitive() .getEncoded()).equals(subject)) { return true; } } catch (IOException e) { } } } return false; }
X509Principal x509 = new X509Principal(x500Principal.getName()); //Because X509Principal parses the String for us ((TextView) infoLayout.findViewById(R.id.alias_certificate_name)).setText((String) x509.getValues(X509Name.CN).get(0)); ((TextView) infoLayout.findViewById(R.id.alias_certificate_organizational_unit)).setText((String) x509.getValues(X509Name.OU).get(0)); ((TextView) infoLayout.findViewById(R.id.alias_certificate_organization)).setText((String) x509.getValues(X509Name.O).get(0)); ((TextView) infoLayout.findViewById(R.id.alias_certificate_city)).setText((String) x509.getValues(X509Name.L).get(0)); ((TextView) infoLayout.findViewById(R.id.alias_certificate_state)).setText((String) x509.getValues(X509Name.ST).get(0)); ((TextView) infoLayout.findViewById(R.id.alias_certificate_country)).setText((String) x509.getValues(X509Name.C).get(0)); } else {
X509Principal issuer = new X509Principal(issuerAndSerialNumber.getObjectAt(0).toASN1Primitive().getEncoded()); BigInteger serialNumber = ((ASN1Integer)issuerAndSerialNumber.getObjectAt(1)).getValue(); for (Object element : certs) { issuer.getName() + " / " + serialNumber.toString(16)));
public String getName() { return this.toString(); }
private boolean matchesDN(X509Principal subject, GeneralNames targets) { GeneralName[] names = targets.getNames(); for (int i = 0; i != names.length; i++) { GeneralName gn = names[i]; if (gn.getTagNo() == GeneralName.directoryName) { try { if (new X509Principal(((ASN1Encodable)gn.getName()).toASN1Primitive() .getEncoded()).equals(subject)) { return true; } } catch (IOException e) { } } } return false; }
public String getName() { return this.toString(); }
static X509Principal convertPrincipal( X500Principal principal) { try { return new X509Principal(principal.getEncoded()); } catch (IOException e) { throw new IllegalArgumentException("cannot convert principal"); } }
/** * return a DER encoded byte array representing this object */ public byte[] getEncoded() { try { return this.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new RuntimeException(e.toString()); } } }
/** * Constructor from an encoded byte array. */ public X509Principal( byte[] bytes) throws IOException { super(readSequence(new ASN1InputStream(bytes))); }
private static X509Name convertName( X500Principal name) { try { return new X509Principal(name.getEncoded()); } catch (IOException e) { throw new IllegalArgumentException("can't convert name"); } }
digest.update(issuerName.getEncoded());
public AttributeCertificateIssuer(X500Principal principal) throws IOException { this(new X509Principal(principal.getEncoded())); }
private static X509Name convertName( X500Principal name) { try { return new X509Principal(name.getEncoded()); } catch (IOException e) { throw new IllegalArgumentException("can't convert name"); } }
public AttributeCertificateIssuer(X500Principal principal) throws IOException { this(new X509Principal(principal.getEncoded())); }
/** * Set the requestor name to the passed in X500Principal * * @param requestorName a X500Principal representing the requestor name. */ public void setRequestorName( X500Principal requestorName) { try { this.requestorName = new GeneralName(GeneralName.directoryName, new X509Principal(requestorName.getEncoded())); } catch (IOException e) { throw new IllegalArgumentException("cannot encode principal: " + e); } }
/** * Set the subject distinguished name. The subject describes the entity associated with the public key. */ public void setSubjectDN( X500Principal subject) { try { tbsGen.setSubject(new X509Principal(subject.getEncoded())); } catch (IOException e) { throw new IllegalArgumentException("can't process principal: " + e); } }
/** * Set the issuer distinguished name - the issuer is the entity whose private key is used to sign the * certificate. */ public void setIssuerDN( X500Principal issuer) { try { tbsGen.setIssuer(new X509Principal(issuer.getEncoded())); } catch (IOException e) { throw new IllegalArgumentException("can't process principal: " + e); } }