Search in sources :

Example 46 with GeneralName

use of org.bouncycastle.asn1.x509.GeneralName in project XobotOS by xamarin.

the class X509CertSelector method addSubjectAlternativeName.

/**
     * Adds a subject alternative name to the respective criterion.
     *
     * @param tag
     *            the type of the name.
     * @param name
     *            the name in ASN.1 DER encoded form.
     * @throws IOException
     *             if the decoding of the name fails.
     */
public void addSubjectAlternativeName(int tag, byte[] name) throws IOException {
    GeneralName alt_name = new GeneralName(tag, name);
    // create only if there was not any errors
    if (subjectAltNames == null) {
        subjectAltNames = new ArrayList[9];
    }
    if (subjectAltNames[tag] == null) {
        subjectAltNames[tag] = new ArrayList<GeneralName>();
    }
    subjectAltNames[tag].add(alt_name);
}
Also used : GeneralName(org.apache.harmony.security.x509.GeneralName)

Example 47 with GeneralName

use of org.bouncycastle.asn1.x509.GeneralName in project XobotOS by xamarin.

the class X509CertSelector method addPathToName.

/**
     * Adds a {@literal "pathToName"} to the respective criterion.
     *
     * @param type
     *            the type of the name
     * @param name
     *            the name in ASN.1 DER encoded form.
     * @throws IOException
     *             if decoding fails.
     * @see #setPathToNames
     */
public void addPathToName(int type, byte[] name) throws IOException {
    GeneralName path_name = new GeneralName(type, name);
    // create only if there was not any errors
    if (pathToNames == null) {
        pathToNames = new ArrayList<GeneralName>();
    }
    pathToNames.add(path_name);
}
Also used : GeneralName(org.apache.harmony.security.x509.GeneralName)

Example 48 with GeneralName

use of org.bouncycastle.asn1.x509.GeneralName in project XobotOS by xamarin.

the class X509CertSelector method addSubjectAlternativeName.

/**
     * Adds a subject alternative name to the respective criterion.
     *
     * @param tag
     *            the type of the name
     * @param name
     *            the name in string format.
     * @throws IOException
     *             if parsing the name fails.
     */
public void addSubjectAlternativeName(int tag, String name) throws IOException {
    GeneralName alt_name = new GeneralName(tag, name);
    // create only if there was not any errors
    if (subjectAltNames == null) {
        subjectAltNames = new ArrayList[9];
    }
    if (subjectAltNames[tag] == null) {
        subjectAltNames[tag] = new ArrayList<GeneralName>();
    }
    subjectAltNames[tag].add(alt_name);
}
Also used : GeneralName(org.apache.harmony.security.x509.GeneralName)

Example 49 with GeneralName

use of org.bouncycastle.asn1.x509.GeneralName in project XobotOS by xamarin.

the class X509CertSelector method addPathToName.

/**
     * Adds a {@literal "pathToName"} to the respective criterion.
     *
     * @param type
     *            the type of the name.
     * @param name
     *            the name in string format.
     * @throws IOException
     *             if parsing fails.
     * @see #setPathToNames
     */
public void addPathToName(int type, String name) throws IOException {
    GeneralName path_name = new GeneralName(type, name);
    // create only if there was not any errors
    if (pathToNames == null) {
        pathToNames = new ArrayList<GeneralName>();
    }
    pathToNames.add(path_name);
}
Also used : GeneralName(org.apache.harmony.security.x509.GeneralName)

Example 50 with GeneralName

use of org.bouncycastle.asn1.x509.GeneralName in project XobotOS by xamarin.

the class X509CertSelector method toString.

/**
     * Returns a string representation of this {@code X509CertSelector}
     * instance.
     *
     * @return a string representation of this {@code X509CertSelector}
     *         instance.
     */
public String toString() {
    // For convenient reading of the string representation
    // all of the fields named according to the rfc 3280
    // (http://www.ietf.org/rfc/rfc3280.txt).
    StringBuilder result = new StringBuilder();
    result.append("X509CertSelector: \n[");
    if (this.certificateEquals != null) {
        result.append("\n  certificateEquals: ").append(certificateEquals);
    }
    if (this.serialNumber != null) {
        result.append("\n  serialNumber: ").append(serialNumber);
    }
    if (this.issuer != null) {
        result.append("\n  issuer: ").append(issuer);
    }
    if (this.subject != null) {
        result.append("\n  subject: ").append(subject);
    }
    if (this.subjectKeyIdentifier != null) {
        result.append("\n  subjectKeyIdentifier: ").append(Array.getBytesAsString(subjectKeyIdentifier));
    }
    if (this.authorityKeyIdentifier != null) {
        result.append("\n  authorityKeyIdentifier: ").append(Array.getBytesAsString(authorityKeyIdentifier));
    }
    if (this.certificateValid != null) {
        result.append("\n  certificateValid: ").append(certificateValid);
    }
    if (this.subjectPublicKeyAlgID != null) {
        result.append("\n  subjectPublicKeyAlgID: ").append(subjectPublicKeyAlgID);
    }
    if (this.privateKeyValid != null) {
        result.append("\n  privateKeyValid: ").append(privateKeyValid);
    }
    if (this.subjectPublicKey != null) {
        result.append("\n  subjectPublicKey: ").append(Array.getBytesAsString(subjectPublicKey));
    }
    if (this.keyUsage != null) {
        result.append("\n  keyUsage: \n  [");
        String[] kuNames = new String[] { "digitalSignature", "nonRepudiation", "keyEncipherment", "dataEncipherment", "keyAgreement", "keyCertSign", "cRLSign", "encipherOnly", "decipherOnly" };
        for (int i = 0; i < 9; i++) {
            if (keyUsage[i]) {
                result.append("\n    ").append(kuNames[i]);
            }
        }
        result.append("\n  ]");
    }
    if (this.extendedKeyUsage != null) {
        result.append("\n  extendedKeyUsage: ").append(extendedKeyUsage.toString());
    }
    result.append("\n  matchAllNames: ").append(matchAllNames);
    result.append("\n  pathLen: ").append(pathLen);
    if (this.subjectAltNames != null) {
        result.append("\n  subjectAltNames:  \n  [");
        for (int i = 0; i < 9; i++) {
            List<GeneralName> names = subjectAltNames[i];
            if (names != null) {
                int size = names.size();
                for (GeneralName generalName : names) {
                    result.append("\n    ").append(generalName.toString());
                }
            }
        }
        result.append("\n  ]");
    }
    if (this.nameConstraints != null) {
    }
    if (this.policies != null) {
        result.append("\n  policies: ").append(policies.toString());
    }
    if (this.pathToNames != null) {
        result.append("\n  pathToNames:  \n  [");
        for (GeneralName generalName : pathToNames) {
            result.append("\n    ").append(generalName.toString());
        }
    }
    result.append("\n]");
    return result.toString();
}
Also used : ASN1OctetString(org.apache.harmony.security.asn1.ASN1OctetString) GeneralName(org.apache.harmony.security.x509.GeneralName)

Aggregations

GeneralName (org.bouncycastle.asn1.x509.GeneralName)39 IOException (java.io.IOException)29 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)24 ArrayList (java.util.ArrayList)23 List (java.util.List)20 GeneralName (org.apache.harmony.security.x509.GeneralName)18 X509Certificate (java.security.cert.X509Certificate)16 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)16 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)15 X500Name (org.bouncycastle.asn1.x500.X500Name)10 GeneralName (sun.security.x509.GeneralName)10 GeneralSecurityException (java.security.GeneralSecurityException)9 CertPathValidatorException (java.security.cert.CertPathValidatorException)9 Date (java.util.Date)9 Enumeration (java.util.Enumeration)9 BasicConstraints (org.bouncycastle.asn1.x509.BasicConstraints)9 CertificateExpiredException (java.security.cert.CertificateExpiredException)8 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)8 X500Principal (javax.security.auth.x500.X500Principal)8 DERIA5String (org.bouncycastle.asn1.DERIA5String)8