All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gatling.recorder.internal.bouncycastle.oer.its.ItsUtils Maven / Gradle / Ivy

package io.gatling.recorder.internal.bouncycastle.oer.its;

import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import io.gatling.recorder.internal.bouncycastle.asn1.ASN1Encodable;
import io.gatling.recorder.internal.bouncycastle.asn1.ASN1Sequence;
import io.gatling.recorder.internal.bouncycastle.asn1.DERSequence;
import io.gatling.recorder.internal.bouncycastle.util.Arrays;

public class ItsUtils
{

    /**
     * 
     *     OCTET STRING (SIZE(n))
     * 
*/ public static byte[] octetStringFixed(byte[] octets, int n) { if (octets.length != n) { throw new IllegalArgumentException("octet string out of range"); } return octets; } /** *
     *     OCTET STRING (SIZE(1..32))
     * 
*/ public static byte[] octetStringFixed(byte[] octets) { if (octets.length < 1 || octets.length > 32) { throw new IllegalArgumentException("octet string out of range"); } return Arrays.clone(octets); } public static ASN1Sequence toSequence(List objs) { return new DERSequence((ASN1Encodable[])objs.toArray(new ASN1Encodable[0])); } public static ASN1Sequence toSequence(ASN1Encodable... objs) { return new DERSequence(objs); } @Deprecated public static List fillList(final Class type, final ASN1Sequence sequence) { return AccessController.doPrivileged(new PrivilegedAction>() { public List run() { try { List accumulator = new ArrayList(); for (Iterator it = sequence.iterator(); it.hasNext(); ) { Method m = type.getMethod("getInstance", Object.class); accumulator.add(type.cast(m.invoke(null, it.next()))); } return accumulator; } catch (Exception ex) { throw new IllegalStateException("could not invoke getInstance on type " + ex.getMessage(), ex); } } }); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy