/** * 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()); }
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"); } } } } }
public ASN1Primitive toASN1Primitive() { if (oid != null) { return oid; } return attribute.toASN1Primitive(); } }
/** * Return an array of attributes matching the passed in type OID. * * @param type the type of the attribute being looked for. * @return an array of Attribute of the requested type, zero length if none present. */ public Attribute[] getAttributes(ASN1ObjectIdentifier type) { ASN1Set attrSet = certificationRequest.getCertificationRequestInfo().getAttributes(); if (attrSet == null) { return EMPTY_ARRAY; } List list = new ArrayList(); for (int i = 0; i != attrSet.size(); i++) { Attribute attr = Attribute.getInstance(attrSet.getObjectAt(i)); if (attr.getAttrType().equals(type)) { list.add(attr); } } if (list.size() == 0) { return EMPTY_ARRAY; } return (Attribute[])list.toArray(new Attribute[list.size()]); }
public Attribute[] getAttributes() { ASN1Set attrs = safeBag.getBagAttributes(); if (attrs == null) { return null; } Attribute[] attributes = new Attribute[attrs.size()]; for (int i = 0; i != attrs.size(); i++) { attributes[i] = Attribute.getInstance(attrs.getObjectAt(i)); } return attributes; }
/** * Add an attribute with multiple values to the certification request we are building. * Removed existing attributes with the same attrType. * * @param attrType the OID giving the type of the attribute. * @param attrValue the ASN.1 structure that forms the value of the attribute. * @return this builder object. */ public PKCS10CertificationRequestBuilder setAttribute(ASN1ObjectIdentifier attrType, ASN1Encodable[] attrValue) { // Remove existing copies of the attribute. for (Iterator it = attributes.iterator(); it.hasNext(); ) { if (((Attribute)it.next()).getAttrType().equals(attrType)) { throw new IllegalStateException("Attribute " + attrType.toString() + " is already set"); } } addAttribute(attrType, attrValue); return this; }
/** * Return an array of attributes matching the passed in type OID. * * @param type the type of the attribute being looked for. * @return an array of Attribute of the requested type, zero length if none present. */ public Attribute[] getAttributes(ASN1ObjectIdentifier type) { ASN1Set attrSet = certificationRequest.getCertificationRequestInfo().getAttributes(); if (attrSet == null) { return EMPTY_ARRAY; } List list = new ArrayList(); for (int i = 0; i != attrSet.size(); i++) { Attribute attr = Attribute.getInstance(attrSet.getObjectAt(i)); if (attr.getAttrType().equals(type)) { list.add(attr); } } if (list.size() == 0) { return EMPTY_ARRAY; } return (Attribute[])list.toArray(new Attribute[list.size()]); }
public Attribute[] getAttributes() { ASN1Set attrs = safeBag.getBagAttributes(); if (attrs == null) { return null; } Attribute[] attributes = new Attribute[attrs.size()]; for (int i = 0; i != attrs.size(); i++) { attributes[i] = Attribute.getInstance(attrs.getObjectAt(i)); } return attributes; }
/** * Set an attribute to the certification request we are building. * Removed existing attributes with the same attrType. * * @param attrType the OID giving the type of the attribute. * @param attrValue the ASN.1 structure that forms the value of the attribute. * @return this builder object. */ public PKCS10CertificationRequestBuilder setAttribute(ASN1ObjectIdentifier attrType, ASN1Encodable attrValue) { // Remove existing copies of the attribute. for (Iterator it = attributes.iterator(); it.hasNext(); ) { if (((Attribute)it.next()).getAttrType().equals(attrType)) { throw new IllegalStateException("Attribute " + attrType.toString() + " is already set"); } } addAttribute(attrType, attrValue); return this; }
/** * 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));
/** * Create a CSRAttributesResponse from the passed in ASN.1 structure. * * @param csrAttrs an RFC 7030 CsrAttrs structure. */ public CSRAttributesResponse(CsrAttrs csrAttrs) throws ESTException { this.csrAttrs = csrAttrs; this.index = new HashMap<ASN1ObjectIdentifier, AttrOrOID>(csrAttrs.size()); AttrOrOID[] attrOrOIDs = csrAttrs.getAttrOrOIDs(); for (int i = 0; i != attrOrOIDs.length; i++) { AttrOrOID attrOrOID = attrOrOIDs[i]; if (attrOrOID.isOid()) { index.put(attrOrOID.getOid(), attrOrOID); } else { index.put(attrOrOID.getAttribute().getAttrType(), attrOrOID); } } }
/** * Add an attribute to the certification request we are building. * * @param attrType the OID giving the type of the attribute. * @param attrValue the ASN.1 structure that forms the value of the attribute. * @return this builder object. */ public PKCS10CertificationRequestBuilder addAttribute(ASN1ObjectIdentifier attrType, ASN1Encodable attrValue) { attributes.add(new Attribute(attrType, new DERSet(attrValue))); return this; }
/** * Return the attributes, if any associated with this request. * * @return an array of Attribute, zero length if none present. */ public Attribute[] getAttributes() { ASN1Set attrSet = certificationRequest.getCertificationRequestInfo().getAttributes(); if (attrSet == null) { return EMPTY_ARRAY; } Attribute[] attrs = new Attribute[attrSet.size()]; for (int i = 0; i != attrSet.size(); i++) { attrs[i] = Attribute.getInstance(attrSet.getObjectAt(i)); } return attrs; }
/** * Add an attribute with multiple values to the certification request we are building. * * @param attrType the OID giving the type of the attribute. * @param attrValues an array of ASN.1 structures that form the value of the attribute. * @return this builder object. */ public PKCS10CertificationRequestBuilder addAttribute(ASN1ObjectIdentifier attrType, ASN1Encodable[] attrValues) { attributes.add(new Attribute(attrType, new DERSet(attrValues))); return this; }
/** * Return the attributes, if any associated with this request. * * @return an array of Attribute, zero length if none present. */ public Attribute[] getAttributes() { ASN1Set attrSet = certificationRequest.getCertificationRequestInfo().getAttributes(); if (attrSet == null) { return EMPTY_ARRAY; } Attribute[] attrs = new Attribute[attrSet.size()]; for (int i = 0; i != attrSet.size(); i++) { attrs[i] = Attribute.getInstance(attrSet.getObjectAt(i)); } return attrs; }
/** * Add an attribute with multiple values to the certification request we are building. * * @param attrType the OID giving the type of the attribute. * @param attrValues an array of ASN.1 structures that form the value of the attribute. * @return this builder object. */ public PKCS10CertificationRequestBuilder addAttribute(ASN1ObjectIdentifier attrType, ASN1Encodable[] attrValues) { attributes.add(new Attribute(attrType, new DERSet(attrValues))); return this; }
v.add(Attribute.getInstance(it.next()));
/** * Add an attribute to the certification request we are building. * * @param attrType the OID giving the type of the attribute. * @param attrValue the ASN.1 structure that forms the value of the attribute. * @return this builder object. */ public PKCS10CertificationRequestBuilder addAttribute(ASN1ObjectIdentifier attrType, ASN1Encodable attrValue) { attributes.add(new Attribute(attrType, new DERSet(attrValue))); return this; }
v.add(Attribute.getInstance(it.next()));