Search in sources :

Example 16 with ObjectIdentifier

use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.

the class SubjectInfoAccessExtension method decodeThis.

private void decodeThis() throws IOException {
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Sequence) {
        throw new IOException("Invalid encoding of AuthInfoAccess extension");
    }
    while (val.data.available() != 0) {
        DerValue seq = val.data.getDerValue();
        ObjectIdentifier method = seq.data.getDerValue().getOID();
        GeneralName gn = new GeneralName(seq.data.getDerValue());
        addAccessDescription(method, gn);
    }
}
Also used : DerValue(org.mozilla.jss.netscape.security.util.DerValue) IOException(java.io.IOException) GeneralName(org.mozilla.jss.netscape.security.x509.GeneralName) ObjectIdentifier(org.mozilla.jss.netscape.security.util.ObjectIdentifier)

Example 17 with ObjectIdentifier

use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.

the class GenericASN1Extension method encode.

/**
 * Write the extension to the DerOutputStream.
 *
 * @param out the DerOutputStream to write the extension to.
 * @exception IOException on encoding errors.
 */
@Override
public void encode(OutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    try {
        if (this.extensionValue == null) {
            this.extensionId = new ObjectIdentifier(OID);
            this.critical = true;
            encodeThis();
        }
    } catch (ParseException e) {
    }
    super.encode(tmp);
    out.write(tmp.toByteArray());
}
Also used : DerOutputStream(org.mozilla.jss.netscape.security.util.DerOutputStream) ParseException(java.text.ParseException) ObjectIdentifier(org.mozilla.jss.netscape.security.util.ObjectIdentifier)

Example 18 with ObjectIdentifier

use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.

the class AuthInfoAccessExtension method decodeThis.

private void decodeThis() throws IOException {
    DerValue val = new DerValue(this.extensionValue);
    if (val.tag != DerValue.tag_Sequence) {
        throw new IOException("Invalid encoding of AuthInfoAccess extension");
    }
    while (val.data.available() != 0) {
        DerValue seq = val.data.getDerValue();
        ObjectIdentifier method = seq.data.getDerValue().getOID();
        GeneralName gn = new GeneralName(seq.data.getDerValue());
        addAccessDescription(method, gn);
    }
}
Also used : DerValue(org.mozilla.jss.netscape.security.util.DerValue) IOException(java.io.IOException) GeneralName(org.mozilla.jss.netscape.security.x509.GeneralName) ObjectIdentifier(org.mozilla.jss.netscape.security.util.ObjectIdentifier)

Example 19 with ObjectIdentifier

use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.

the class X509CRLImpl method getExtensionValue.

/**
 * Gets the DER encoded OCTET string for the extension value
 * (<code>extnValue</code>) identified by the passed in oid String.
 * The <code>oid</code> string is
 * represented by a set of positive whole number separated
 * by ".", that means,<br>
 * &lt;positive whole number&gt;.&lt;positive whole number&gt;.&lt;...&gt;
 *
 * @param oid the Object Identifier value for the extension.
 * @return the der encoded octet string of the extension value.
 */
@Override
public byte[] getExtensionValue(String oid) {
    if (extensions == null)
        return null;
    try (DerOutputStream out = new DerOutputStream()) {
        String extAlias = OIDMap.getName(new ObjectIdentifier(oid));
        Extension crlExt = null;
        if (extAlias == null) {
            // may be unknown
            ObjectIdentifier findOID = new ObjectIdentifier(oid);
            Extension ex = null;
            ObjectIdentifier inCertOID;
            for (Enumeration<Extension> e = extensions.getElements(); e.hasMoreElements(); ) {
                ex = e.nextElement();
                inCertOID = ex.getExtensionId();
                if (inCertOID.equals(findOID)) {
                    crlExt = ex;
                    break;
                }
            }
        } else
            crlExt = extensions.get(extAlias);
        if (crlExt == null)
            return null;
        byte[] extData = crlExt.getExtensionValue();
        if (extData == null)
            return null;
        out.putOctetString(extData);
        return out.toByteArray();
    } catch (Exception e) {
        return null;
    }
}
Also used : DerOutputStream(org.mozilla.jss.netscape.security.util.DerOutputStream) SignatureException(java.security.SignatureException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) CRLException(java.security.cert.CRLException) NoSuchProviderException(java.security.NoSuchProviderException) ObjectIdentifier(org.mozilla.jss.netscape.security.util.ObjectIdentifier)

Example 20 with ObjectIdentifier

use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.

the class LdapV3DNStrConverter method parseAVAKeyword.

/**
 * Converts a AVA keyword from a Ldap DN string to an ObjectIdentifier
 * from the attribute map or, if this keyword is an OID not
 * in the attribute map, create a new ObjectIdentifier for the keyword
 * if acceptUnknownOids is true.
 *
 * @param avaKeyword AVA keyword from a Ldap DN string.
 *
 * @return a ObjectIdentifier object
 * @exception IOException if the keyword is an OID not in the attribute
 *                map and acceptUnknownOids is false, or
 *                if an error occurs during conversion.
 */
public ObjectIdentifier parseAVAKeyword(String avaKeyword) throws IOException {
    String keyword = avaKeyword.toUpperCase().trim();
    String oid_str = null;
    ObjectIdentifier oid, new_oid;
    if (Character.digit(keyword.charAt(0), 10) != -1) {
        // value is an oid string of 1.2.3.4
        oid_str = keyword;
    } else if (keyword.startsWith("oid.") || keyword.startsWith("OID.")) {
        // value is an oid string of oid.1.2.3.4 or OID.1.2...
        oid_str = keyword.substring(4);
    }
    if (oid_str != null) {
        // value is an oid string of 1.2.3.4 or oid.1.2.3.4 or OID.1.2...
        new_oid = new ObjectIdentifier(oid_str);
        oid = attrMap.getOid(new_oid);
        if (oid == null) {
            if (!acceptUnknownOids)
                throw new IOException("Unknown AVA OID.");
            oid = new_oid;
        }
    } else {
        oid = attrMap.getOid(keyword);
        if (oid == null)
            throw new IOException("Unknown AVA keyword '" + keyword + "'.");
    }
    return oid;
}
Also used : IOException(java.io.IOException) ObjectIdentifier(org.mozilla.jss.netscape.security.util.ObjectIdentifier)

Aggregations

ObjectIdentifier (org.mozilla.jss.netscape.security.util.ObjectIdentifier)27 IOException (java.io.IOException)21 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)8 CertificateException (java.security.cert.CertificateException)8 DerOutputStream (org.mozilla.jss.netscape.security.util.DerOutputStream)8 DerValue (org.mozilla.jss.netscape.security.util.DerValue)8 InvalidKeyException (java.security.InvalidKeyException)7 NoSuchProviderException (java.security.NoSuchProviderException)7 SignatureException (java.security.SignatureException)7 CertificateEncodingException (java.security.cert.CertificateEncodingException)5 CertificateExpiredException (java.security.cert.CertificateExpiredException)5 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)5 CertificateParsingException (java.security.cert.CertificateParsingException)5 DerInputStream (org.mozilla.jss.netscape.security.util.DerInputStream)5 GeneralName (org.mozilla.jss.netscape.security.x509.GeneralName)3 CRLException (java.security.cert.CRLException)2 CertificateExtensions (org.mozilla.jss.netscape.security.x509.CertificateExtensions)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 CharArrayWriter (java.io.CharArrayWriter)1 File (java.io.File)1