if (gns != null && gns.getNames() != null && gns.getNames().length > 0) { for (final GeneralName name : gns.getNames()) { if (name.getTagNo() == GeneralName.dNSName) { dnsNames.add(name.getName().toString()); if (name.getTagNo() == GeneralName.iPAddress) { final InetAddress address = InetAddress.getByAddress(DatatypeConverter.parseHexBinary(name.getName().toString().substring(1))); ipAddresses.add(address.toString().replace("/", ""));
if (genName.getTagNo() == GeneralName.uniformResourceIdentifier)
/** * Create a new instance from a Bouncy Castle general name. * * @param name the Bouncy Castle general name. */ public X509DirectoryName(GeneralName name) { super(X500Name.getInstance(name.getName())); if (name.getTagNo() != GeneralName.directoryName) { throw new IllegalArgumentException("Incompatible general name: " + name.getTagNo()); } }
/** * Create a new instance from a Bouncy Castle general name. * * @param name the Bouncy Castle general name. */ public X509Rfc822Name(GeneralName name) { this(DERIA5String.getInstance(name.getName()).getString()); if (name.getTagNo() != GeneralName.rfc822Name) { throw new IllegalArgumentException("Incompatible general name: " + name.getTagNo()); } }
/** * Create a new instance from a Bouncy Castle general name. * * @param name the Bouncy Castle general name. */ public X509URI(GeneralName name) { this(DERIA5String.getInstance(name.getName()).getString()); if (name.getTagNo() != GeneralName.uniformResourceIdentifier) { throw new IllegalArgumentException("Incompatible general name: " + name.getTagNo()); } }
/** * Create a new instance from a Bouncy Castle general name. * * @param name the Bouncy Castle general name. */ public X509IpAddress(GeneralName name) { if (name.getTagNo() != GeneralName.iPAddress) { throw new IllegalArgumentException("Incompatible general name: " + name.getTagNo()); } this.ipAddress = DEROctetString.getInstance(name.getName()).getOctets(); }
/** * Create a new instance from a Bouncy Castle general name. * * @param name the Bouncy Castle general name. */ public X509DnsName(GeneralName name) { if (name.getTagNo() != GeneralName.dNSName) { throw new IllegalArgumentException("Incompatible general name: " + name.getTagNo()); } this.domain = DERIA5String.getInstance(name.getName()).getString(); }
/** * Returns the URL inside the proxy tracing data structure. * * @return The URL in String format. */ public String getURL() { if (name.getTagNo() != GeneralName.uniformResourceIdentifier) return null; DERIA5String ia5String = (DERIA5String) name.getName(); return ia5String.getString(); }
private static X500Name getX500Sender(PKIHeader reqHeader) { GeneralName requestSender = reqHeader.getSender(); if (requestSender.getTagNo() != GeneralName.directoryName) { return null; } return (X500Name) requestSender.getName(); }
private Object[] getNames(GeneralName[] names) { List l = new ArrayList(names.length); for (int i = 0; i != names.length; i++) { if (names[i].getTagNo() == GeneralName.directoryName) { try { l.add(new X500Principal( ((ASN1Encodable)names[i].getName()).toASN1Primitive().getEncoded())); } catch (IOException e) { throw new RuntimeException("badly formed Name object"); } } } return l.toArray(new Object[l.size()]); }
/** * Constructor. * @param roleAuthority the role authority of this RoleSyntax. * @param roleName the role name of this RoleSyntax. */ public RoleSyntax( GeneralNames roleAuthority, GeneralName roleName) { if(roleName == null || roleName.getTagNo() != GeneralName.uniformResourceIdentifier || ((ASN1String)roleName.getName()).getString().equals("")) { throw new IllegalArgumentException("the role name MUST be non empty and MUST " + "use the URI option of GeneralName"); } this.roleAuthority = roleAuthority; this.roleName = roleName; }
SubjectAlternativeName(GeneralName bcGeneralName) { this.type = Type.fromTag(bcGeneralName.getTagNo()); this.value = getValue(bcGeneralName); }
/** * Constructor. * @param roleAuthority the role authority of this RoleSyntax. * @param roleName the role name of this RoleSyntax. */ public RoleSyntax( GeneralNames roleAuthority, GeneralName roleName) { if(roleName == null || roleName.getTagNo() != GeneralName.uniformResourceIdentifier || ((ASN1String)roleName.getName()).getString().equals("")) { throw new IllegalArgumentException("the role name MUST be non empty and MUST " + "use the URI option of GeneralName"); } this.roleAuthority = roleAuthority; this.roleName = roleName; }
private static String parseGn(GeneralName gn) { try { if (GeneralName.uniformResourceIdentifier == gn.getTagNo()) { ASN1String str = (ASN1String) ((DERTaggedObject) gn.toASN1Primitive()).getObject(); return str.getString(); } } catch (Exception e) { LOG.warn("Unable to parse GN " + gn, e); } return null; }
public static List<String> extractOcspUrls(AuthorityInformationAccess aia) throws CertificateEncodingException { AccessDescription[] accessDescriptions = aia.getAccessDescriptions(); List<AccessDescription> ocspAccessDescriptions = new LinkedList<>(); for (AccessDescription accessDescription : accessDescriptions) { if (accessDescription.getAccessMethod().equals(X509ObjectIdentifiers.id_ad_ocsp)) { ocspAccessDescriptions.add(accessDescription); } } final int n = ocspAccessDescriptions.size(); List<String> ocspUris = new ArrayList<>(n); for (int i = 0; i < n; i++) { GeneralName accessLocation = ocspAccessDescriptions.get(i).getAccessLocation(); if (accessLocation.getTagNo() == GeneralName.uniformResourceIdentifier) { String ocspUri = ((ASN1String) accessLocation.getName()).getString(); ocspUris.add(ocspUri); } } return ocspUris; }
/** * Creates a {@link GeneralName} object from DER data. * * @param enc DER encoded general names data. * * @return General name. */ public static GeneralName createGeneralName(final DEREncodable enc) { final org.bouncycastle.asn1.x509.GeneralName name = org.bouncycastle.asn1.x509.GeneralName.getInstance(enc); return new GeneralName( name.getName().toString(), GeneralNameType.fromTagNumber(name.getTagNo())); }
private String getValue(GeneralName bcGeneralName) { ASN1Encodable name = bcGeneralName.getName(); switch (bcGeneralName.getTagNo()) { case GeneralName.rfc822Name: case GeneralName.dNSName: case GeneralName.uniformResourceIdentifier: return DERIA5String.getInstance(name).getString(); case GeneralName.directoryName: return X500Name.getInstance(name).toString(); default: return name.toString(); } }
private String getSubjectAlternativeNames(final X509Certificate certificate, final int index, final int type) { final byte[] extVal = certificate.getExtensionValue(Extension.issuerAlternativeName.getId()); if (extVal == null) { return null; } try { final Enumeration<?> it = DERSequence.getInstance(X509ExtensionUtil.fromExtensionValue(extVal)).getObjects(); int i = index; while (it.hasMoreElements()) { if (index == i++) { final GeneralName genName = GeneralName.getInstance(it.nextElement()); if (genName.getTagNo() == type) { return ASN1String.class.cast(genName.getName()).getString(); } } } } catch (final IOException e) { // no-op } return null; }
private String getUrl(DistributionPointName distributionPoint) { if ((distributionPoint != null) && (DistributionPointName.FULL_NAME == distributionPoint.getType())) { final GeneralNames generalNames = (GeneralNames) distributionPoint.getName(); if ((generalNames != null) && (generalNames.getNames() != null && generalNames.getNames().length > 0)) { for (GeneralName generalName : generalNames.getNames()) { if (GeneralName.uniformResourceIdentifier == generalName.getTagNo()) { ASN1String str = (ASN1String) ((DERTaggedObject) generalName.toASN1Primitive()).getObject(); return str.getString(); } } } } return null; }
@Override protected boolean intendsMe(GeneralName requestRecipient) { if (requestRecipient == null) { return false; } if (getSender().equals(requestRecipient)) { return true; } if (requestRecipient.getTagNo() == GeneralName.directoryName) { X500Name x500Name = X500Name.getInstance(requestRecipient.getName()); if (x500Name.equals(caManager.getSignerWrapper(getResponderName()).getSubjectAsX500Name())) { return true; } } return false; } // method intendsMe