/** * 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 instanceof Attribute) { return (Attribute)o; } if (o != null) { return new Attribute(ASN1Sequence.getInstance(o)); } return null; }
private String getVeriSignNonVerified(byte[] octets) throws IOException { /* NonVerified ::= SET OF ATTRIBUTE */ StringBuilder sb = new StringBuilder(); ASN1Set asn1Set = ASN1Set.getInstance(octets); for (ASN1Encodable attribute : asn1Set.toArray()) { ASN1ObjectIdentifier attributeId = ((Attribute) attribute).getAttrType(); ASN1Set attributeValues = ((Attribute) attribute).getAttrValues(); for (ASN1Encodable attributeValue : attributeValues.toArray()) { String attributeValueStr = getAttributeValueString(attributeId, attributeValue); sb.append(MessageFormat.format("{0}={1}", attributeId.getId(), attributeValueStr)); sb.append(NEWLINE); } } return sb.toString(); } }
ASN1ObjectIdentifier attributeType = ((Attribute) attribute).getAttrType(); AttributeTypeType att = AttributeTypeType.resolveOid(attributeType.getId()); String attributeTypeStr = (att == AttributeTypeType.UNKNOWN) ? attributeType.getId() : att.friendly(); ASN1Encodable[] attributeValues = ((Attribute) attribute).getAttributeValues();
for (int i = 0; i < n; i++) { Attribute attr = (Attribute) reqSubDirAttrs.get(i); ASN1ObjectIdentifier attrType = attr.getAttrType(); ASN1Encodable attrVal = attr.getAttributeValues()[0]; throw new BadCertTemplateException("invalid dateOfBirth " + timeStirng); attrs.add(new Attribute(attrType, new DERSet(dateOfBirth))); continue; if (placeOfBirth != null) { ASN1Encodable attrVal = new DERUTF8String(placeOfBirth); attrs.add(new Attribute(attrType, new DERSet(attrVal))); continue; attrs.add(new Attribute(attrType, new DERSet(attrVal))); continue; attrs.add(new Attribute(attrType, new DERSet(attrVal))); attrs.add(new Attribute(attrType, new DERSet(attrVal))); attrs.add(new Attribute(attrType, new DERSet(attrVal)));
final Attribute attribute = new Attribute( ( DERSequence ) attributesAsn1Set.getObjectAt( i ) ); if ( attribute.getAttrType().equals( PKCSObjectIdentifiers.pkcs_9_at_extensionRequest ) ) { final ASN1Set attributeValues = attribute.getAttrValues();
Attribute attr = Attribute.getInstance(reqSubDirAttrs.get(i)); ASN1ObjectIdentifier attrType = attr.getAttrType(); ASN1Encodable attrVal = attr.getAttributeValues()[0]; final int n = subDirAttrs.size(); for (int i = 0; i < n; i++) { Attribute attr = Attribute.getInstance(subDirAttrs.get(i)); ASN1ObjectIdentifier attrType = attr.getAttrType(); if ( !attrTypes.contains(attrType)) { failureMsg.append("attribute of type " + attrType.getId() ASN1Encodable[] attrs = attr.getAttributeValues(); if (attrs.length != 1) { failureMsg.append("attribute of type " + attrType.getId()
/** * @param at an object representing an attribute. */ X509Attribute( ASN1Encodable at) { this.attr = Attribute.getInstance(at); }
result.tagsOther = new ArrayList<ASN1Encodable>(); for (Attribute attr : attributes) { log.debug("attr {} is {}", attr.hashCode(), attr.toString()); result.attributes.add(attr); for (ASN1Encodable value : attr.getAttributeValues()) { if( attr.getAttrType().toString().equals(UTF8NameValueMicroformat.OID)) { log.debug("name-value microformat attribute: {}", DERUTF8String.getInstance(value).getString()); // our values are just UTF-8 strings but if you use new String(value.getEncoded()) you will get two extra spaces at the beginning of the string UTF8NameValueMicroformat microformat = new UTF8NameValueMicroformat(DERUTF8String.getInstance(value)); result.tags1.add(microformat); else if( attr.getAttrType().toString().equals(UTF8NameValueSequence.OID)) { UTF8NameValueSequence sequence = new UTF8NameValueSequence(ASN1Sequence.getInstance(value)); String name = sequence.getName(); log.debug("unrecognzied attribute type {}", attr.getAttrType().toString()); result.tagsOther.add(value);
final org.bouncycastle.asn1.x509.Attribute attribute = org.bouncycastle.asn1.x509.Attribute.getInstance(objectAt); final ASN1Set attrValues1 = attribute.getAttrValues(); DERSequence derSequence = (DERSequence) attrValues1.getObjectAt(0); RoleSyntax roleSyntax = RoleSyntax.getInstance(derSequence);
public String getOID() { return attr.getAttrType().getId(); }
public ASN1Encodable[] getValues() { ASN1Set s = attr.getAttrValues(); ASN1Encodable[] values = new ASN1Encodable[s.size()]; for (int i = 0; i != s.size(); i++) { values[i] = (ASN1Encodable)s.getObjectAt(i); } return values; }
ASN1Primitive theVOMSDerObject = a.getAttributeValues()[0] .toASN1Primitive();
for (int i = 0; i < n; i++) { Attribute attr = (Attribute) reqSubDirAttrs.get(i); ASN1ObjectIdentifier attrType = attr.getAttrType(); ASN1Encodable attrVal = attr.getAttributeValues()[0]; throw new BadCertTemplateException("invalid dateOfBirth " + timeStirng); attrs.add(new Attribute(attrType, new DERSet(dateOfBirth))); continue; if (placeOfBirth != null) { ASN1Encodable attrVal = new DERUTF8String(placeOfBirth); attrs.add(new Attribute(attrType, new DERSet(attrVal))); continue; attrs.add(new Attribute(attrType, new DERSet(attrVal))); continue; attrs.add(new Attribute(attrType, new DERSet(attrVal))); attrs.add(new Attribute(attrType, new DERSet(attrVal))); attrs.add(new Attribute(attrType, new DERSet(attrVal)));
/** * Constructor from ASN1Sequence. * * The sequence is of type SubjectDirectoryAttributes: * * <pre> * SubjectDirectoryAttributes ::= Attributes * Attributes ::= SEQUENCE SIZE (1..MAX) OF Attribute * Attribute ::= SEQUENCE * { * type AttributeType * values SET OF AttributeValue * } * * AttributeType ::= OBJECT IDENTIFIER * AttributeValue ::= ANY DEFINED BY AttributeType * </pre> * * @param seq * The ASN.1 sequence. */ private SubjectDirectoryAttributes(ASN1Sequence seq) { Enumeration e = seq.getObjects(); while (e.hasMoreElements()) { ASN1Sequence s = ASN1Sequence.getInstance(e.nextElement()); attributes.addElement(Attribute.getInstance(s)); } }
for (final org.bouncycastle.asn1.x509.Attribute claimedRole : signerAttrValueArray) { final ASN1Encodable[] attrValues1 = claimedRole.getAttrValues().toArray(); for (final ASN1Encodable asn1Encodable : attrValues1) { if (asn1Encodable instanceof ASN1String) {
/** * 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 instanceof Attribute) { return (Attribute)o; } if (o != null) { return new Attribute(ASN1Sequence.getInstance(o)); } return null; }
/** * Constructor from ASN1Sequence. * * The sequence is of type SubjectDirectoryAttributes: * * <pre> * SubjectDirectoryAttributes ::= Attributes * Attributes ::= SEQUENCE SIZE (1..MAX) OF Attribute * Attribute ::= SEQUENCE * { * type AttributeType * values SET OF AttributeValue * } * * AttributeType ::= OBJECT IDENTIFIER * AttributeValue ::= ANY DEFINED BY AttributeType * </pre> * * @param seq * The ASN.1 sequence. */ private SubjectDirectoryAttributes(ASN1Sequence seq) { Enumeration e = seq.getObjects(); while (e.hasMoreElements()) { ASN1Sequence s = ASN1Sequence.getInstance(e.nextElement()); attributes.addElement(Attribute.getInstance(s)); } }
@SuppressWarnings( { "UseOfObsoleteCollectionType", "unchecked" } ) private DERSet generateSANAttribute( GeneralNames subGeneralNames ) { if ( subGeneralNames == null ) { return new DERSet(); } Vector oids = new Vector(); Vector values = new Vector(); oids.add( X509Extensions.SubjectAlternativeName ); values.add( new X509Extension( false, new DEROctetString( subGeneralNames ) ) ); X509Extensions extensions = new X509Extensions( oids, values ); Attribute attribute = new Attribute( PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new DERSet( extensions ) ); return new DERSet( attribute ); }
private SignerAttribute( ASN1Sequence seq) { int index = 0; values = new Object[seq.size()]; for (Enumeration e = seq.getObjects(); e.hasMoreElements();) { ASN1TaggedObject taggedObject = ASN1TaggedObject.getInstance(e.nextElement()); if (taggedObject.getTagNo() == 0) { ASN1Sequence attrs = ASN1Sequence.getInstance(taggedObject, true); Attribute[] attributes = new Attribute[attrs.size()]; for (int i = 0; i != attributes.length; i++) { attributes[i] = Attribute.getInstance(attrs.getObjectAt(i)); } values[index] = attributes; } else if (taggedObject.getTagNo() == 1) { values[index] = AttributeCertificate.getInstance(ASN1Sequence.getInstance(taggedObject, true)); } else { throw new IllegalArgumentException("illegal tag: " + taggedObject.getTagNo()); } index++; } }
/** * Create an X.59 Attribute with the type given by the passed in oid and the * value represented by an ASN.1 Set containing the objects in value. * * @param oid type of the attribute * @param value vector of values to go in the attribute's value set. */ public X509Attribute( String oid, ASN1EncodableVector value) { this.attr = new Attribute(new ASN1ObjectIdentifier(oid), new DERSet(value)); }