Search in sources :

Example 46 with ObjectIdentifier

use of sun.security.util.ObjectIdentifier in project Payara by payara.

the class GSSUtils method getOID.

/*
     * Return the OID corresponding to an OID represented in DER format as follows: 0x06 -- Tag for
     * OBJECT IDENTIFIER derOID.length -- length in octets of OID DER value of OID -- written as
     * specified byte the DER representation for an ObjectIdentifier.
     */
public static ObjectIdentifier getOID(byte[] derOID) throws IOException {
    DerInputStream dis = new DerInputStream(derOID);
    ObjectIdentifier oid = dis.getOID();
    /*
         * Note: getOID() method call generates an IOException if derOID contains any malformed data
         */
    return oid;
}
Also used : DerInputStream(sun.security.util.DerInputStream) ObjectIdentifier(sun.security.util.ObjectIdentifier)

Example 47 with ObjectIdentifier

use of sun.security.util.ObjectIdentifier in project Payara by payara.

the class GSSUtils method verifyMechOID.

/* verify if exportedName is of object ObjectIdentifier. */
public static boolean verifyMechOID(ObjectIdentifier oid, byte[] externalName) throws IOException {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Attempting to verify mechanism independent name");
        _logger.log(Level.FINE, dumpHex(externalName));
    }
    IOException e = new IOException("Invalid Name");
    if (externalName[0] != 0x04)
        throw e;
    if (externalName[1] != 0x01)
        throw e;
    int mechoidlen = ((externalName[2]) << 8) + (externalName[3] & 0xff);
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Mech OID length = " + mechoidlen);
    }
    if (externalName.length < (4 + mechoidlen + 4))
        throw e;
    /*
         * get the mechanism OID and verify it is the same as oid passed as an argument.
         */
    byte[] deroid = new byte[mechoidlen];
    System.arraycopy(externalName, 4, deroid, 0, mechoidlen);
    ObjectIdentifier oid1 = getOID(deroid);
    if (!oid1.equals(oid))
        return false;
    else
        return true;
}
Also used : IOException(java.io.IOException) ObjectIdentifier(sun.security.util.ObjectIdentifier)

Aggregations

ObjectIdentifier (sun.security.util.ObjectIdentifier)47 IOException (java.io.IOException)15 DerInputStream (sun.security.util.DerInputStream)11 DerValue (sun.security.util.DerValue)11 CertificateException (java.security.cert.CertificateException)7 KeyStoreException (java.security.KeyStoreException)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 X509Certificate (java.security.cert.X509Certificate)6 DerOutputStream (sun.security.util.DerOutputStream)6 AlgorithmId (sun.security.x509.AlgorithmId)6 AlgorithmParameters (java.security.AlgorithmParameters)5 UnrecoverableEntryException (java.security.UnrecoverableEntryException)5 UnrecoverableKeyException (java.security.UnrecoverableKeyException)5 Date (java.util.Date)5 SecretKey (javax.crypto.SecretKey)5 Cipher (javax.crypto.Cipher)4 DestroyFailedException (javax.security.auth.DestroyFailedException)4 EncryptedPrivateKeyInfo (sun.security.pkcs.EncryptedPrivateKeyInfo)4 PrivateKey (java.security.PrivateKey)3 PublicKey (java.security.PublicKey)3