use of com.github.zhenwei.core.asn1.ASN1ParsingException in project jmulticard by ctt-gob-es.
the class ExtensionsGenerator method addExtension.
/**
* Add an extension with the given oid and the passed in byte array to be wrapped in the
* OCTET STRING associated with the extension.
*
* @param oid OID for the extension.
* @param critical true if critical, false otherwise.
* @param value the byte array to be wrapped.
*/
public void addExtension(ASN1ObjectIdentifier oid, boolean critical, byte[] value) {
if (extensions.containsKey(oid)) {
if (dupsAllowed.contains(oid)) {
Extension existingExtension = (Extension) extensions.get(oid);
ASN1Sequence seq1 = ASN1Sequence.getInstance(DEROctetString.getInstance(existingExtension.getExtnValue()).getOctets());
ASN1Sequence seq2 = ASN1Sequence.getInstance(value);
ASN1EncodableVector items = new ASN1EncodableVector(seq1.size() + seq2.size());
for (Enumeration en = seq1.getObjects(); en.hasMoreElements(); ) {
items.add((ASN1Encodable) en.nextElement());
}
for (Enumeration en = seq2.getObjects(); en.hasMoreElements(); ) {
items.add((ASN1Encodable) en.nextElement());
}
try {
extensions.put(oid, new Extension(oid, critical, new DERSequence(items).getEncoded()));
} catch (IOException e) {
throw new ASN1ParsingException(e.getMessage(), e);
}
} else {
throw new IllegalArgumentException("extension " + oid + " already added");
}
} else {
extOrdering.addElement(oid);
extensions.put(oid, new Extension(oid, critical, new DEROctetString(Arrays.clone(value))));
}
}
use of com.github.zhenwei.core.asn1.ASN1ParsingException in project LinLong-Java by zhenwei1108.
the class AuthEnvelopedDataParser method getAuthAttrs.
public ASN1SetParser getAuthAttrs() throws IOException {
if (nextObject == null) {
nextObject = seq.readObject();
}
if (nextObject instanceof ASN1TaggedObjectParser) {
ASN1TaggedObjectParser o = (ASN1TaggedObjectParser) nextObject;
nextObject = null;
return (ASN1SetParser) ASN1Util.parseContextBaseUniversal(o, 1, false, BERTags.SET_OF);
}
// EncryptedContentInfo is not id-data."
if (!isData) {
throw new ASN1ParsingException("authAttrs must be present with non-data content");
}
return null;
}
use of com.github.zhenwei.core.asn1.ASN1ParsingException in project LinLong-Java by zhenwei1108.
the class ExtensionsGenerator method addExtension.
/**
* Add an extension with the given oid and the passed in byte array to be wrapped in the OCTET
* STRING associated with the extension.
*
* @param oid OID for the extension.
* @param critical true if critical, false otherwise.
* @param value the byte array to be wrapped.
*/
public void addExtension(ASN1ObjectIdentifier oid, boolean critical, byte[] value) {
if (extensions.containsKey(oid)) {
if (dupsAllowed.contains(oid)) {
Extension existingExtension = (Extension) extensions.get(oid);
ASN1Sequence seq1 = ASN1Sequence.getInstance(DEROctetString.getInstance(existingExtension.getExtnValue()).getOctets());
ASN1Sequence seq2 = ASN1Sequence.getInstance(value);
ASN1EncodableVector items = new ASN1EncodableVector(seq1.size() + seq2.size());
for (Enumeration en = seq1.getObjects(); en.hasMoreElements(); ) {
items.add((ASN1Encodable) en.nextElement());
}
for (Enumeration en = seq2.getObjects(); en.hasMoreElements(); ) {
items.add((ASN1Encodable) en.nextElement());
}
try {
extensions.put(oid, new Extension(oid, critical, new DERSequence(items).getEncoded()));
} catch (IOException e) {
throw new ASN1ParsingException(e.getMessage(), e);
}
} else {
throw new IllegalArgumentException("extension " + oid + " already added");
}
} else {
extOrdering.addElement(oid);
extensions.put(oid, new Extension(oid, critical, new DEROctetString(value)));
}
}
Aggregations