Java Code Examples for sun.security.krb5.internal.util.KerberosString#MSNAME

The following examples show how to use sun.security.krb5.internal.util.KerberosString#MSNAME . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ETypeInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 2
Source File: ETypeInfo.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 3
Source File: ETypeInfo.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 4
Source File: ETypeInfo.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 5
Source File: ETypeInfo.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 6
Source File: ETypeInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 7
Source File: ETypeInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 8
Source File: ETypeInfo.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 9
Source File: ETypeInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 10
Source File: ETypeInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 11
Source File: ETypeInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes this object to an OutputStream.
 *
 * @return byte array of the encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception Asn1Exception on encoding errors.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {

    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();

    temp.putInteger(etype);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_TYPE), temp);

    if (salt != null) {
        temp = new DerOutputStream();
        if (KerberosString.MSNAME) {
            temp.putOctetString(salt.getBytes("UTF8"));
        } else {
            temp.putOctetString(salt.getBytes());
        }
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 12
Source File: ETypeInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 13
Source File: ETypeInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 14
Source File: ETypeInfo.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 15
Source File: ETypeInfo.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 16
Source File: ETypeInfo.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 17
Source File: ETypeInfo.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 18
Source File: ETypeInfo.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 19
Source File: ETypeInfo.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 20
Source File: ETypeInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ETypeInfo object.
 * @param encoding a DER-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an
 *            ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public ETypeInfo(DerValue encoding) throws Asn1Exception, IOException {
    DerValue der = null;

    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    // etype
    der = encoding.getData().getDerValue();
    if ((der.getTag() & 0x1F) == 0x00) {
        this.etype = der.getData().getBigInteger().intValue();
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);

    // salt
    if (encoding.getData().available() > 0) {
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x01) {
            byte[] saltBytes = der.getData().getOctetString();

            // Although salt is defined as an OCTET STRING, it's the
            // encoding from of a string. As RFC 4120 says:
            //
            // "The salt, ..., is also completely unspecified with respect
            // to character set and is probably locale-specific".
            //
            // It's known that this field is using the same encoding as
            // KerberosString in most implementations.

            if (KerberosString.MSNAME) {
                this.salt = new String(saltBytes, "UTF8");
            } else {
                this.salt = new String(saltBytes);
            }
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}