continue; if (attribute.getAttrType().equals(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest)) { final Extensions extensions = Extensions.getInstance(attribute.getAttrValues().getObjectAt(0)); final GeneralNames gns = GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName); if (gns != null && gns.getNames() != null && gns.getNames().length > 0) {
private static String getChallengePassword(CertificationRequestInfo csr) { ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) { ASN1String str = (ASN1String) attr.getAttributeValues()[0]; return str.getString(); } } return null; }
private static void validateAttributes(ASN1Set attributes) { if (attributes == null) { return; } for (Enumeration en = attributes.getObjects(); en.hasMoreElements();) { Attribute attr = Attribute.getInstance(en.nextElement()); if (attr.getAttrType().equals(PKCSObjectIdentifiers.pkcs_9_at_challengePassword)) { if (attr.getAttrValues().size() != 1) { throw new IllegalArgumentException("challengePassword attribute must have one value"); } } } } }
/** * Extract extensions from CSR object */ public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) { Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest); for (Attribute attribute : attributess) { ASN1Set attValue = attribute.getAttrValues(); if (attValue != null) { ASN1Encodable extension = attValue.getObjectAt(0); if (extension instanceof Extensions) { return (Extensions) extension; } else if (extension instanceof DERSequence) { return Extensions.getInstance(extension); } } } return null; }
private static void populateTextField(Attribute[] attrs, JTextField textField, ASN1ObjectIdentifier pkcs9Attr) { if (attrs != null) { for (Attribute attribute : attrs) { ASN1ObjectIdentifier attributeOid = attribute.getAttrType(); if (attributeOid.equals(pkcs9Attr)) { ASN1Encodable challenge = attribute.getAttributeValues()[0]; // data type can be one of IA5String or UTF8String if (challenge instanceof DERPrintableString) { textField.setText(((DERPrintableString) challenge).getString()); } else if (challenge instanceof DERUTF8String) { textField.setText(((DERUTF8String) challenge).getString()); } textField.setCaretPosition(0); } } } } }
/** * return an Attribute object from the given object. * * @param o the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static Attribute getInstance( Object o) { if (o == null || o instanceof Attribute) { return (Attribute)o; } if (o instanceof ASN1Sequence) { return new Attribute((ASN1Sequence)o); } throw new IllegalArgumentException("unknown object in factory: " + o.getClass().getName()); }
return new AttrOrOID(Attribute.getInstance(asn1Prim));
/** * Extract sequence with extensions from CSR * * @param pkcs10Csr The CSR * @return Extensions from that CSR (if any) */ public static X509ExtensionSet getExtensions(PKCS10CertificationRequest pkcs10Csr) { Attribute[] attributes = pkcs10Csr.getAttributes(pkcs_9_at_extensionRequest); X509ExtensionSet x509ExtensionSet = new X509ExtensionSet(); if ((attributes != null) && (attributes.length > 0)) { ASN1Encodable[] attributeValues = attributes[0].getAttributeValues(); if (attributeValues.length > 0) { ASN1Sequence asn1Sequence = ASN1Sequence.getInstance(attributeValues[0]); x509ExtensionSet = new X509ExtensionSet(asn1Sequence); } } return x509ExtensionSet; }
public static String getChallengePassword(CertificationRequestInfo csr) { Args.notNull(csr, "csr"); ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) { ASN1String str = (ASN1String) attr.getAttributeValues()[0]; return str.getString(); } } return null; }
private Optional<Extensions> getExtensions() { return Optional.of(csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest)) .filter(attributes -> attributes.length > 0) .map(attributes -> attributes[0]) .map(attribute -> Extensions.getInstance(attribute.getAttrValues().getObjectAt(0))); }
proxySubjectName, subjectPublicKeyInfo); for (Attribute attribute: attributes) builder.addAttribute(attribute.getAttrType(), attribute.getAttributeValues()); AlgorithmIdentifier signatureAi = new AlgorithmIdentifier(OIWObjectIdentifiers.sha1WithRSA); AlgorithmIdentifier hashAi = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1);
/** * return an Attribute object from the given object. * * @param o the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static Attribute getInstance( Object o) { if (o == null || o instanceof Attribute) { return (Attribute)o; } if (o instanceof ASN1Sequence) { return new Attribute((ASN1Sequence)o); } throw new IllegalArgumentException("unknown object in factory: " + o.getClass().getName()); }
public static Extensions getExtensions(CertificationRequestInfo csr) { Args.notNull(csr, "csr"); ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_extensionRequest.equals(attr.getAttrType())) { return Extensions.getInstance(attr.getAttributeValues()[0]); } } return null; }
private ASN1Encodable getChallengePassword(Attribute[] attributes) { for (Attribute attribute : attributes) { if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attribute.getAttrType())) { if (attribute.getAttrValues() != null && attribute.getAttrValues().size() > 0) { return attribute.getAttrValues().getObjectAt(0); } } } return null; }
/** * Extract extensions from CSR object */ public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) { Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest); for (Attribute attribute : attributess) { ASN1Set attValue = attribute.getAttrValues(); if (attValue != null) { ASN1Encodable extension = attValue.getObjectAt(0); if (extension instanceof Extensions) { return (Extensions) extension; } else if (extension instanceof DERSequence) { return Extensions.getInstance(extension); } } } return null; }
private static void addAttribute(List<Attribute> attributes, ASN1Encodable ext) { Attribute a = new Attribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new DERSet(ext)); attributes.add(a); } }
ASN1Set attrs = certTemp.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_extensionRequest.equals(attr.getAttrType())) { extensions = Extensions.getInstance(attr.getAttributeValues()[0]);
/** * Extracts the <tt>Challenge password</tt> from the provided CSR. * <p> * * @param csr * the CSR to extract from. * @return the extracted <tt>Challenge password</tt> */ public static String getChallengePassword(final PKCS10CertificationRequest csr) { Attribute[] attrs = csr.getAttributes(); for (Attribute attr : attrs) { if (attr.getAttrType().equals( PKCSObjectIdentifiers.pkcs_9_at_challengePassword)) { // According to RFC 2985 this may be any of the DirectoryString // types, but we can be more flexible and allow any ASN.1 // string. ASN1String challengePassword = (ASN1String) attr .getAttrValues().getObjectAt(0); return challengePassword.getString(); } } return null; }
/** * Extract extensions from CSR object */ public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) { Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest); for (Attribute attribute : attributess) { ASN1Set attValue = attribute.getAttrValues(); if (attValue != null) { ASN1Encodable extension = attValue.getObjectAt(0); if (extension instanceof Extensions) { return (Extensions) extension; } else if (extension instanceof DERSequence) { return Extensions.getInstance(extension); } } } return null; }
ASN1Set attrs = csr.getCertificationRequestInfo().getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_extensionRequest.equals(attr.getAttrType())) { extensions = Extensions.getInstance(attr.getAttributeValues()[0]);