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

The following examples show how to use sun.security.krb5.internal.util.KerberosString. These examples are extracted from open source projects. 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 Project: dragonwell8_jdk   Source File: ETypeInfo.java    License: 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 Project: TencentKona-8   Source File: PrincipalName.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes a <code>PrincipalName</code> object. Note that only the type and
 * names are encoded. To encode the realm, call getRealm().asn1Encode().
 * @return the byte array of the encoded PrncipalName object.
 * @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 byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();
    BigInteger bint = BigInteger.valueOf(this.nameType);
    temp.putInteger(bint);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
    temp = new DerOutputStream();
    DerValue der[] = new DerValue[nameStrings.length];
    for (int i = 0; i < nameStrings.length; i++) {
        der[i] = new KerberosString(nameStrings[i]).toDerValue();
    }
    temp.putSequence(der);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 3
Source Project: jdk8u_jdk   Source File: PrincipalName.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes a <code>PrincipalName</code> object. Note that only the type and
 * names are encoded. To encode the realm, call getRealm().asn1Encode().
 * @return the byte array of the encoded PrncipalName object.
 * @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 byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();
    BigInteger bint = BigInteger.valueOf(this.nameType);
    temp.putInteger(bint);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
    temp = new DerOutputStream();
    DerValue der[] = new DerValue[nameStrings.length];
    for (int i = 0; i < nameStrings.length; i++) {
        der[i] = new KerberosString(nameStrings[i]).toDerValue();
    }
    temp.putSequence(der);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 4
Source Project: jdk8u60   Source File: ETypeInfo.java    License: 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 Project: openjdk-jdk8u   Source File: ETypeInfo.java    License: 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
/**
 * Encodes a <code>PrincipalName</code> object. Note that only the type and
 * names are encoded. To encode the realm, call getRealm().asn1Encode().
 * @return the byte array of the encoded PrncipalName object.
 * @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 byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();
    BigInteger bint = BigInteger.valueOf(this.nameType);
    temp.putInteger(bint);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
    temp = new DerOutputStream();
    DerValue der[] = new DerValue[nameStrings.length];
    for (int i = 0; i < nameStrings.length; i++) {
        der[i] = new KerberosString(nameStrings[i]).toDerValue();
    }
    temp.putSequence(der);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 7
Source Project: openjdk-jdk8u   Source File: PrincipalName.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes a <code>PrincipalName</code> object. Note that only the type and
 * names are encoded. To encode the realm, call getRealm().asn1Encode().
 * @return the byte array of the encoded PrncipalName object.
 * @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 byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();
    BigInteger bint = BigInteger.valueOf(this.nameType);
    temp.putInteger(bint);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
    temp = new DerOutputStream();
    DerValue der[] = new DerValue[nameStrings.length];
    for (int i = 0; i < nameStrings.length; i++) {
        der[i] = new KerberosString(nameStrings[i]).toDerValue();
    }
    temp.putSequence(der);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 8
Source Project: openjdk-8-source   Source File: ETypeInfo.java    License: 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 Project: openjdk-8   Source File: PrincipalName.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes a <code>PrincipalName</code> object. Note that only the type and
 * names are encoded. To encode the realm, call getRealm().asn1Encode().
 * @return the byte array of the encoded PrncipalName object.
 * @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 byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();
    BigInteger bint = BigInteger.valueOf(this.nameType);
    temp.putInteger(bint);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
    temp = new DerOutputStream();
    DerValue der[] = new DerValue[nameStrings.length];
    for (int i = 0; i < nameStrings.length; i++) {
        der[i] = new KerberosString(nameStrings[i]).toDerValue();
    }
    temp.putSequence(der);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 10
Source Project: jdk8u_jdk   Source File: ETypeInfo.java    License: 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 Project: jdk8u-jdk   Source File: ETypeInfo.java    License: 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 Project: jdk8u-jdk   Source File: PrincipalName.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes a <code>PrincipalName</code> object. Note that only the type and
 * names are encoded. To encode the realm, call getRealm().asn1Encode().
 * @return the byte array of the encoded PrncipalName object.
 * @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 byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();
    BigInteger bint = BigInteger.valueOf(this.nameType);
    temp.putInteger(bint);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
    temp = new DerOutputStream();
    DerValue der[] = new DerValue[nameStrings.length];
    for (int i = 0; i < nameStrings.length; i++) {
        der[i] = new KerberosString(nameStrings[i]).toDerValue();
    }
    temp.putSequence(der);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 13
Source Project: openjdk-8   Source File: ETypeInfo.java    License: 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 14
Source Project: hottub   Source File: ETypeInfo.java    License: 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 15
Source Project: hottub   Source File: PrincipalName.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Encodes a <code>PrincipalName</code> object. Note that only the type and
 * names are encoded. To encode the realm, call getRealm().asn1Encode().
 * @return the byte array of the encoded PrncipalName object.
 * @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 byte[] asn1Encode() throws Asn1Exception, IOException {
    DerOutputStream bytes = new DerOutputStream();
    DerOutputStream temp = new DerOutputStream();
    BigInteger bint = BigInteger.valueOf(this.nameType);
    temp.putInteger(bint);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
    temp = new DerOutputStream();
    DerValue der[] = new DerValue[nameStrings.length];
    for (int i = 0; i < nameStrings.length; i++) {
        der[i] = new KerberosString(nameStrings[i]).toDerValue();
    }
    temp.putSequence(der);
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 16
Source Project: openjdk-8-source   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 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 (saltStr != null) {
        temp = new DerOutputStream();
        temp.putDerValue(new KerberosString(saltStr).toDerValue());
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE1), temp);
    }
    if (s2kparams != null) {
        temp = new DerOutputStream();
        temp.putOctetString(s2kparams);
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE2), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 17
Source Project: dragonwell8_jdk   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 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 (saltStr != null) {
        temp = new DerOutputStream();
        temp.putDerValue(new KerberosString(saltStr).toDerValue());
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE1), temp);
    }
    if (s2kparams != null) {
        temp = new DerOutputStream();
        temp.putOctetString(s2kparams);
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE2), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 18
Source Project: TencentKona-8   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 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 (saltStr != null) {
        temp = new DerOutputStream();
        temp.putDerValue(new KerberosString(saltStr).toDerValue());
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE1), temp);
    }
    if (s2kparams != null) {
        temp = new DerOutputStream();
        temp.putOctetString(s2kparams);
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE2), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 19
Source Project: openjdk-8   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 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 (saltStr != null) {
        temp = new DerOutputStream();
        temp.putDerValue(new KerberosString(saltStr).toDerValue());
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE1), temp);
    }
    if (s2kparams != null) {
        temp = new DerOutputStream();
        temp.putOctetString(s2kparams);
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE2), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 20
Source Project: jdk8u60   Source File: Realm.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Realm 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.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */
public Realm(DerValue encoding)
    throws Asn1Exception, RealmException, IOException {
    if (encoding == null) {
        throw new IllegalArgumentException("encoding can not be null");
    }
    realm = new KerberosString(encoding).toString();
    if (realm == null || realm.length() == 0)
        throw new RealmException(Krb5.REALM_NULL);
    if (!isValidRealmString(realm))
        throw new RealmException(Krb5.REALM_ILLCHAR);
}
 
Example 21
Source Project: jdk8u60   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a ETypeInfo2 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 ETypeInfo2(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) {
        if ((encoding.getData().peekByte() & 0x1F) == 0x01) {
            der = encoding.getData().getDerValue();
            this.saltStr = new KerberosString(
                    der.getData().getDerValue()).toString();
        }
    }

    // s2kparams
    if (encoding.getData().available() > 0) {
        if ((encoding.getData().peekByte() & 0x1F) == 0x02) {
            der = encoding.getData().getDerValue();
            this.s2kparams = der.getData().getOctetString();
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 22
Source Project: jdk8u60   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 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 (saltStr != null) {
        temp = new DerOutputStream();
        temp.putDerValue(new KerberosString(saltStr).toDerValue());
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE1), temp);
    }
    if (s2kparams != null) {
        temp = new DerOutputStream();
        temp.putOctetString(s2kparams);
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE2), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 23
Source Project: openjdk-jdk8u   Source File: Realm.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Realm 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.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */
public Realm(DerValue encoding)
    throws Asn1Exception, RealmException, IOException {
    if (encoding == null) {
        throw new IllegalArgumentException("encoding can not be null");
    }
    realm = new KerberosString(encoding).toString();
    if (realm == null || realm.length() == 0)
        throw new RealmException(Krb5.REALM_NULL);
    if (!isValidRealmString(realm))
        throw new RealmException(Krb5.REALM_ILLCHAR);
}
 
Example 24
Source Project: openjdk-jdk8u   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a ETypeInfo2 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 ETypeInfo2(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) {
        if ((encoding.getData().peekByte() & 0x1F) == 0x01) {
            der = encoding.getData().getDerValue();
            this.saltStr = new KerberosString(
                    der.getData().getDerValue()).toString();
        }
    }

    // s2kparams
    if (encoding.getData().available() > 0) {
        if ((encoding.getData().peekByte() & 0x1F) == 0x02) {
            der = encoding.getData().getDerValue();
            this.s2kparams = der.getData().getOctetString();
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 25
Source Project: openjdk-jdk8u   Source File: ETypeInfo2.java    License: GNU General Public License v2.0 5 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 (saltStr != null) {
        temp = new DerOutputStream();
        temp.putDerValue(new KerberosString(saltStr).toDerValue());
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE1), temp);
    }
    if (s2kparams != null) {
        temp = new DerOutputStream();
        temp.putOctetString(s2kparams);
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE2), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 26
Source Project: openjdk-jdk8u-backup   Source File: Realm.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Realm 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.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */
public Realm(DerValue encoding)
    throws Asn1Exception, RealmException, IOException {
    if (encoding == null) {
        throw new IllegalArgumentException("encoding can not be null");
    }
    realm = new KerberosString(encoding).toString();
    if (realm == null || realm.length() == 0)
        throw new RealmException(Krb5.REALM_NULL);
    if (!isValidRealmString(realm))
        throw new RealmException(Krb5.REALM_ILLCHAR);
}
 
Example 27
/**
 * Constructs a ETypeInfo2 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 ETypeInfo2(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) {
        if ((encoding.getData().peekByte() & 0x1F) == 0x01) {
            der = encoding.getData().getDerValue();
            this.saltStr = new KerberosString(
                    der.getData().getDerValue()).toString();
        }
    }

    // s2kparams
    if (encoding.getData().available() > 0) {
        if ((encoding.getData().peekByte() & 0x1F) == 0x02) {
            der = encoding.getData().getDerValue();
            this.s2kparams = der.getData().getOctetString();
        }
    }

    if (encoding.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example 28
/**
 * 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 (saltStr != null) {
        temp = new DerOutputStream();
        temp.putDerValue(new KerberosString(saltStr).toDerValue());
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE1), temp);
    }
    if (s2kparams != null) {
        temp = new DerOutputStream();
        temp.putOctetString(s2kparams);
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
                                    TAG_VALUE2), temp);
    }

    temp = new DerOutputStream();
    temp.write(DerValue.tag_Sequence, bytes);
    return temp.toByteArray();
}
 
Example 29
Source Project: openjdk-8-source   Source File: Realm.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Realm 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.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */
public Realm(DerValue encoding)
    throws Asn1Exception, RealmException, IOException {
    if (encoding == null) {
        throw new IllegalArgumentException("encoding can not be null");
    }
    realm = new KerberosString(encoding).toString();
    if (realm == null || realm.length() == 0)
        throw new RealmException(Krb5.REALM_NULL);
    if (!isValidRealmString(realm))
        throw new RealmException(Krb5.REALM_ILLCHAR);
}
 
Example 30
Source Project: openjdk-jdk9   Source File: Realm.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Realm 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.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */
public Realm(DerValue encoding)
    throws Asn1Exception, RealmException, IOException {
    if (encoding == null) {
        throw new IllegalArgumentException("encoding can not be null");
    }
    realm = new KerberosString(encoding).toString();
    if (realm == null || realm.length() == 0)
        throw new RealmException(Krb5.REALM_NULL);
    if (!isValidRealmString(realm))
        throw new RealmException(Krb5.REALM_ILLCHAR);
}