Search in sources :

Example 21 with DERObjectIdentifier

use of org.bouncycastle.asn1.DERObjectIdentifier in project XobotOS by xamarin.

the class CertPathValidatorUtilities method processCertD1ii.

protected static void processCertD1ii(int index, List[] policyNodes, DERObjectIdentifier _poid, Set _pq) {
    List policyNodeVec = policyNodes[index - 1];
    for (int j = 0; j < policyNodeVec.size(); j++) {
        PKIXPolicyNode _node = (PKIXPolicyNode) policyNodeVec.get(j);
        if (ANY_POLICY.equals(_node.getValidPolicy())) {
            Set _childExpectedPolicies = new HashSet();
            _childExpectedPolicies.add(_poid.getId());
            PKIXPolicyNode _child = new PKIXPolicyNode(new ArrayList(), index, _childExpectedPolicies, _node, _pq, _poid.getId(), false);
            _node.addChild(_child);
            policyNodes[index].add(_child);
            return;
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) CertificateList(org.bouncycastle.asn1.x509.CertificateList) CRLDistPoint(org.bouncycastle.asn1.x509.CRLDistPoint) DistributionPoint(org.bouncycastle.asn1.x509.DistributionPoint) HashSet(java.util.HashSet)

Example 22 with DERObjectIdentifier

use of org.bouncycastle.asn1.DERObjectIdentifier in project XobotOS by xamarin.

the class X509Name method equals.

/**
     * test for equality - note: case is ignored.
     */
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof X509Name || obj instanceof ASN1Sequence)) {
        return false;
    }
    DERObject derO = ((DEREncodable) obj).getDERObject();
    if (this.getDERObject().equals(derO)) {
        return true;
    }
    X509Name other;
    try {
        other = X509Name.getInstance(obj);
    } catch (IllegalArgumentException e) {
        return false;
    }
    int orderingSize = ordering.size();
    if (orderingSize != other.ordering.size()) {
        return false;
    }
    boolean[] indexes = new boolean[orderingSize];
    int start, end, delta;
    if (// guess forward
    ordering.elementAt(0).equals(other.ordering.elementAt(0))) {
        start = 0;
        end = orderingSize;
        delta = 1;
    } else // guess reversed - most common problem
    {
        start = orderingSize - 1;
        end = -1;
        delta = -1;
    }
    for (int i = start; i != end; i += delta) {
        boolean found = false;
        DERObjectIdentifier oid = (DERObjectIdentifier) ordering.elementAt(i);
        String value = (String) values.elementAt(i);
        for (int j = 0; j < orderingSize; j++) {
            if (indexes[j]) {
                continue;
            }
            DERObjectIdentifier oOid = (DERObjectIdentifier) other.ordering.elementAt(j);
            if (oid.equals(oOid)) {
                String oValue = (String) other.values.elementAt(j);
                if (equivalentStrings(value, oValue)) {
                    indexes[j] = true;
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            return false;
        }
    }
    return true;
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERObject(org.bouncycastle.asn1.DERObject) DEREncodable(org.bouncycastle.asn1.DEREncodable) DERString(org.bouncycastle.asn1.DERString) DERUniversalString(org.bouncycastle.asn1.DERUniversalString) DERObjectIdentifier(org.bouncycastle.asn1.DERObjectIdentifier)

Example 23 with DERObjectIdentifier

use of org.bouncycastle.asn1.DERObjectIdentifier in project XobotOS by xamarin.

the class X509Name method equals.

/**
     * @param inOrder if true the order of both X509 names must be the same,
     * as well as the values associated with each element.
     */
public boolean equals(Object obj, boolean inOrder) {
    if (!inOrder) {
        return this.equals(obj);
    }
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof X509Name || obj instanceof ASN1Sequence)) {
        return false;
    }
    DERObject derO = ((DEREncodable) obj).getDERObject();
    if (this.getDERObject().equals(derO)) {
        return true;
    }
    X509Name other;
    try {
        other = X509Name.getInstance(obj);
    } catch (IllegalArgumentException e) {
        return false;
    }
    int orderingSize = ordering.size();
    if (orderingSize != other.ordering.size()) {
        return false;
    }
    for (int i = 0; i < orderingSize; i++) {
        DERObjectIdentifier oid = (DERObjectIdentifier) ordering.elementAt(i);
        DERObjectIdentifier oOid = (DERObjectIdentifier) other.ordering.elementAt(i);
        if (oid.equals(oOid)) {
            String value = (String) values.elementAt(i);
            String oValue = (String) other.values.elementAt(i);
            if (!equivalentStrings(value, oValue)) {
                return false;
            }
        } else {
            return false;
        }
    }
    return true;
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERObject(org.bouncycastle.asn1.DERObject) DEREncodable(org.bouncycastle.asn1.DEREncodable) DERString(org.bouncycastle.asn1.DERString) DERUniversalString(org.bouncycastle.asn1.DERUniversalString) DERObjectIdentifier(org.bouncycastle.asn1.DERObjectIdentifier)

Example 24 with DERObjectIdentifier

use of org.bouncycastle.asn1.DERObjectIdentifier in project XobotOS by xamarin.

the class X509Name method toASN1Object.

public DERObject toASN1Object() {
    if (seq == null) {
        ASN1EncodableVector vec = new ASN1EncodableVector();
        ASN1EncodableVector sVec = new ASN1EncodableVector();
        DERObjectIdentifier lstOid = null;
        for (int i = 0; i != ordering.size(); i++) {
            ASN1EncodableVector v = new ASN1EncodableVector();
            DERObjectIdentifier oid = (DERObjectIdentifier) ordering.elementAt(i);
            v.add(oid);
            String str = (String) values.elementAt(i);
            v.add(converter.getConvertedValue(oid, str));
            if (lstOid == null || ((Boolean) this.added.elementAt(i)).booleanValue()) {
                sVec.add(new DERSequence(v));
            } else {
                vec.add(new DERSet(sVec));
                sVec = new ASN1EncodableVector();
                sVec.add(new DERSequence(v));
            }
            lstOid = oid;
        }
        vec.add(new DERSet(sVec));
        seq = new DERSequence(vec);
    }
    return seq;
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERString(org.bouncycastle.asn1.DERString) DERUniversalString(org.bouncycastle.asn1.DERUniversalString) DERObjectIdentifier(org.bouncycastle.asn1.DERObjectIdentifier) DERSet(org.bouncycastle.asn1.DERSet)

Example 25 with DERObjectIdentifier

use of org.bouncycastle.asn1.DERObjectIdentifier in project XobotOS by xamarin.

the class X509Name method toString.

/**
     * convert the structure to a string - if reverse is true the
     * oids and values are listed out starting with the last element
     * in the sequence (ala RFC 2253), otherwise the string will begin
     * with the first element of the structure. If no string definition
     * for the oid is found in oidSymbols the string value of the oid is
     * added. Two standard symbol tables are provided DefaultSymbols, and
     * RFC2253Symbols as part of this class.
     *
     * @param reverse if true start at the end of the sequence and work back.
     * @param oidSymbols look up table strings for oids.
     */
public String toString(boolean reverse, Hashtable oidSymbols) {
    StringBuffer buf = new StringBuffer();
    Vector components = new Vector();
    boolean first = true;
    StringBuffer ava = null;
    for (int i = 0; i < ordering.size(); i++) {
        if (((Boolean) added.elementAt(i)).booleanValue()) {
            ava.append('+');
            appendValue(ava, oidSymbols, (DERObjectIdentifier) ordering.elementAt(i), (String) values.elementAt(i));
        } else {
            ava = new StringBuffer();
            appendValue(ava, oidSymbols, (DERObjectIdentifier) ordering.elementAt(i), (String) values.elementAt(i));
            components.addElement(ava);
        }
    }
    if (reverse) {
        for (int i = components.size() - 1; i >= 0; i--) {
            if (first) {
                first = false;
            } else {
                buf.append(',');
            }
            buf.append(components.elementAt(i).toString());
        }
    } else {
        for (int i = 0; i < components.size(); i++) {
            if (first) {
                first = false;
            } else {
                buf.append(',');
            }
            buf.append(components.elementAt(i).toString());
        }
    }
    return buf.toString();
}
Also used : ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) Vector(java.util.Vector)

Aggregations

DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)43 IOException (java.io.IOException)22 ArrayList (java.util.ArrayList)22 HashSet (java.util.HashSet)21 List (java.util.List)21 Set (java.util.Set)21 Enumeration (java.util.Enumeration)18 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)16 X509Certificate (java.security.cert.X509Certificate)13 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)11 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)11 DEREncodable (org.bouncycastle.asn1.DEREncodable)10 DERObject (org.bouncycastle.asn1.DERObject)10 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)9 Iterator (java.util.Iterator)8 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)8 X962Parameters (org.bouncycastle.asn1.x9.X962Parameters)8 X9ECParameters (org.bouncycastle.asn1.x9.X9ECParameters)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7