Java Code Examples for sun.security.krb5.RealmException

The following examples show how to use sun.security.krb5.RealmException. 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: openjdk-jdk8u   Author: AdoptOpenJDK   File: Ticket.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initializes a Ticket object.
 * @param encoding a single DER-encoded value.
 * @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 KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */

private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der;
    DerValue subDer;
    if (((encoding.getTag() & (byte)0x1F) != Krb5.KRB_TKT)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) != (byte)0x00)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    tkt_vno = subDer.getData().getBigInteger().intValue();
    if (tkt_vno != Krb5.TICKET_VNO)
        throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    Realm srealm = Realm.parse(der.getData(), (byte)0x01, false);
    sname = PrincipalName.parse(der.getData(), (byte)0x02, false, srealm);
    encPart = EncryptedData.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #2
Source Project: dragonwell8_jdk   Author: alibaba   File: Ticket.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initializes a Ticket object.
 * @param encoding a single DER-encoded value.
 * @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 KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */

private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der;
    DerValue subDer;
    if (((encoding.getTag() & (byte)0x1F) != Krb5.KRB_TKT)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) != (byte)0x00)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    tkt_vno = subDer.getData().getBigInteger().intValue();
    if (tkt_vno != Krb5.TICKET_VNO)
        throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    Realm srealm = Realm.parse(der.getData(), (byte)0x01, false);
    sname = PrincipalName.parse(der.getData(), (byte)0x02, false, srealm);
    encPart = EncryptedData.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #3
Source Project: TencentKona-8   Author: Tencent   File: Ticket.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initializes a Ticket object.
 * @param encoding a single DER-encoded value.
 * @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 KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */

private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der;
    DerValue subDer;
    if (((encoding.getTag() & (byte)0x1F) != Krb5.KRB_TKT)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) != (byte)0x00)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    tkt_vno = subDer.getData().getBigInteger().intValue();
    if (tkt_vno != Krb5.TICKET_VNO)
        throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    Realm srealm = Realm.parse(der.getData(), (byte)0x01, false);
    sname = PrincipalName.parse(der.getData(), (byte)0x02, false, srealm);
    encPart = EncryptedData.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #4
Source Project: jdk8u60   Author: chenghanpeng   File: Ticket.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initializes a Ticket object.
 * @param encoding a single DER-encoded value.
 * @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 KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */

private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der;
    DerValue subDer;
    if (((encoding.getTag() & (byte)0x1F) != Krb5.KRB_TKT)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) != (byte)0x00)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    tkt_vno = subDer.getData().getBigInteger().intValue();
    if (tkt_vno != Krb5.TICKET_VNO)
        throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    Realm srealm = Realm.parse(der.getData(), (byte)0x01, false);
    sname = PrincipalName.parse(der.getData(), (byte)0x02, false, srealm);
    encPart = EncryptedData.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #5
Source Project: dragonwell8_jdk   Author: alibaba   File: KRBSafe.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes an KRBSafe object.
 * @param encoding a single DER-encoded value.
 * @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.
 * @exception KrbApErrException if the value read from the DER-encoded data
 *  stream does not match the pre-defined value.
 */
private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der, subDer;
    if (((encoding.getTag() & (byte)0x1F) != (byte)0x14)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x00) {
        pvno = subDer.getData().getBigInteger().intValue();
        if (pvno != Krb5.PVNO)
            throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x01) {
        msgType = subDer.getData().getBigInteger().intValue();
        if (msgType != Krb5.KRB_SAFE)
            throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE);
    }

    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    safeBody = KRBSafeBody.parse(der.getData(), (byte)0x02, false);
    cksum = Checksum.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #6
Source Project: dragonwell8_jdk   Author: alibaba   File: Ticket.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parse (unmarshal) a Ticket from a DER input stream.  This form
 * parsing might be used when expanding a value which is part of
 * a constructed sequence and uses explicitly tagged type.
 *
 * @exception Asn1Exception on error.
 * @param data the Der input stream value, which contains one or more marshaled value.
 * @param explicitTag tag number.
 * @param optional indicate if this data field is optional
 * @return an instance of Ticket.
 */
public static Ticket parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException, RealmException, KrbApErrException {
    if ((optional) && (((byte)data.peekByte() & (byte)0x1F)!= explicitTag))
        return null;
    DerValue der = data.getDerValue();
    if (explicitTag != (der.getTag() & (byte)0x1F))  {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    else {
        DerValue subDer = der.getData().getDerValue();
        return new Ticket(subDer);
    }
}
 
Example #7
Source Project: TencentKona-8   Author: Tencent   File: KRBSafe.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes an KRBSafe object.
 * @param encoding a single DER-encoded value.
 * @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.
 * @exception KrbApErrException if the value read from the DER-encoded data
 *  stream does not match the pre-defined value.
 */
private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der, subDer;
    if (((encoding.getTag() & (byte)0x1F) != (byte)0x14)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x00) {
        pvno = subDer.getData().getBigInteger().intValue();
        if (pvno != Krb5.PVNO)
            throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x01) {
        msgType = subDer.getData().getBigInteger().intValue();
        if (msgType != Krb5.KRB_SAFE)
            throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE);
    }

    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    safeBody = KRBSafeBody.parse(der.getData(), (byte)0x02, false);
    cksum = Checksum.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #8
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: KRBSafe.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes an KRBSafe object.
 * @param encoding a single DER-encoded value.
 * @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.
 * @exception KrbApErrException if the value read from the DER-encoded data
 *  stream does not match the pre-defined value.
 */
private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der, subDer;
    if (((encoding.getTag() & (byte)0x1F) != (byte)0x14)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x00) {
        pvno = subDer.getData().getBigInteger().intValue();
        if (pvno != Krb5.PVNO)
            throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    }
    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x01) {
        msgType = subDer.getData().getBigInteger().intValue();
        if (msgType != Krb5.KRB_SAFE)
            throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE);
    }

    else
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    safeBody = KRBSafeBody.parse(der.getData(), (byte)0x02, false);
    cksum = Checksum.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #9
Source Project: TencentKona-8   Author: Tencent   File: Ticket.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parse (unmarshal) a Ticket from a DER input stream.  This form
 * parsing might be used when expanding a value which is part of
 * a constructed sequence and uses explicitly tagged type.
 *
 * @exception Asn1Exception on error.
 * @param data the Der input stream value, which contains one or more marshaled value.
 * @param explicitTag tag number.
 * @param optional indicate if this data field is optional
 * @return an instance of Ticket.
 */
public static Ticket parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException, RealmException, KrbApErrException {
    if ((optional) && (((byte)data.peekByte() & (byte)0x1F)!= explicitTag))
        return null;
    DerValue der = data.getDerValue();
    if (explicitTag != (der.getTag() & (byte)0x1F))  {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    else {
        DerValue subDer = der.getData().getDerValue();
        return new Ticket(subDer);
    }
}
 
Example #10
Source Project: jdk8u60   Author: chenghanpeng   File: Ticket.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parse (unmarshal) a Ticket from a DER input stream.  This form
 * parsing might be used when expanding a value which is part of
 * a constructed sequence and uses explicitly tagged type.
 *
 * @exception Asn1Exception on error.
 * @param data the Der input stream value, which contains one or more marshaled value.
 * @param explicitTag tag number.
 * @param optional indicate if this data field is optional
 * @return an instance of Ticket.
 */
public static Ticket parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException, RealmException, KrbApErrException {
    if ((optional) && (((byte)data.peekByte() & (byte)0x1F)!= explicitTag))
        return null;
    DerValue der = data.getDerValue();
    if (explicitTag != (der.getTag() & (byte)0x1F))  {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    else {
        DerValue subDer = der.getData().getDerValue();
        return new Ticket(subDer);
    }
}
 
Example #11
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Ticket.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parse (unmarshal) a Ticket from a DER input stream.  This form
 * parsing might be used when expanding a value which is part of
 * a constructed sequence and uses explicitly tagged type.
 *
 * @exception Asn1Exception on error.
 * @param data the Der input stream value, which contains one or more marshaled value.
 * @param explicitTag tag number.
 * @param optional indicate if this data field is optional
 * @return an instance of Ticket.
 */
public static Ticket parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException, RealmException, KrbApErrException {
    if ((optional) && (((byte)data.peekByte() & (byte)0x1F)!= explicitTag))
        return null;
    DerValue der = data.getDerValue();
    if (explicitTag != (der.getTag() & (byte)0x1F))  {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    else {
        DerValue subDer = der.getData().getDerValue();
        return new Ticket(subDer);
    }
}
 
Example #12
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: KeyTab.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns fresh keys for the given Kerberos principal.
 * <p>
 * Implementation of this method should make sure the returned keys match
 * the latest content of the keytab file. The result is a newly created
 * copy that can be modified by the caller without modifying the keytab
 * object. The caller should {@link KerberosKey#destroy() destroy} the
 * result keys after they are used.
 * <p>
 * Please note that the keytab file can be created after the
 * {@code KeyTab} object is instantiated and its content may change over
 * time. Therefore, an application should call this method only when it
 * needs to use the keys. Any previous result from an earlier invocation
 * could potentially be expired.
 * <p>
 * If there is any error (say, I/O error or format error)
 * during the reading process of the KeyTab file, a saved result should be
 * returned. If there is no saved result (say, this is the first time this
 * method is called, or, all previous read attempts failed), an empty array
 * should be returned. This can make sure the result is not drastically
 * changed during the (probably slow) update of the keytab file.
 * <p>
 * Each time this method is called and the reading of the file succeeds
 * with no exception (say, I/O error or file format error),
 * the result should be saved for {@code principal}. The implementation can
 * also save keys for other principals having keys in the same keytab object
 * if convenient.
 * <p>
 * Any unsupported key read from the keytab is ignored and not included
 * in the result.
 * <p>
 * If this keytab is bound to a specific principal, calling this method on
 * another principal will return an empty array.
 *
 * @param principal the Kerberos principal, must not be null.
 * @return the keys (never null, may be empty)
 * @throws NullPointerException if the {@code principal}
 * argument is null
 * @throws SecurityException if a security manager exists and the read
 * access to the keytab file is not permitted
 */
public KerberosKey[] getKeys(KerberosPrincipal principal) {
    try {
        if (princ != null && !principal.equals(princ)) {
            return new KerberosKey[0];
        }
        PrincipalName pn = new PrincipalName(principal.getName());
        EncryptionKey[] keys = takeSnapshot().readServiceKeys(pn);
        KerberosKey[] kks = new KerberosKey[keys.length];
        for (int i=0; i<kks.length; i++) {
            Integer tmp = keys[i].getKeyVersionNumber();
            kks[i] = new KerberosKey(
                    principal,
                    keys[i].getBytes(),
                    keys[i].getEType(),
                    tmp == null ? 0 : tmp.intValue());
            keys[i].destroy();
        }
        return kks;
    } catch (RealmException re) {
        return new KerberosKey[0];
    }
}
 
Example #13
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: EncKrbCredPart.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EncKrbCredPart(byte[] data) throws Asn1Exception,
        IOException, RealmException {
    init(new DerValue(data));
}
 
Example #14
Source Project: dragonwell8_jdk   Author: alibaba   File: TGSRep.java    License: GNU General Public License v2.0 4 votes vote down vote up
public TGSRep(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    init(encoding);
}
 
Example #15
Source Project: dragonwell8_jdk   Author: alibaba   File: TGSRep.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    init(encoding, Krb5.KRB_TGS_REP);
}
 
Example #16
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ASRep.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ASRep(byte[] data) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    init(new DerValue(data));
}
 
Example #17
Source Project: dragonwell8_jdk   Author: alibaba   File: KRBSafe.java    License: GNU General Public License v2.0 4 votes vote down vote up
public KRBSafe(byte[] data) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    init(new DerValue(data));
}
 
Example #18
Source Project: dragonwell8_jdk   Author: alibaba   File: KRBSafe.java    License: GNU General Public License v2.0 4 votes vote down vote up
public KRBSafe(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    init(encoding);
}
 
Example #19
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: KRBCred.java    License: GNU General Public License v2.0 4 votes vote down vote up
public KRBCred(DerValue encoding) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    init(encoding);
}
 
Example #20
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: KRBCred.java    License: GNU General Public License v2.0 4 votes vote down vote up
public KRBCred(byte[] data) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    init(new DerValue(data));
}
 
Example #21
Source Project: dragonwell8_jdk   Author: alibaba   File: KRBError.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initializes a KRBError 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 KrbApErrException if the value read from the DER-encoded data
 *  stream does not match the pre-defined value.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */
private void init(DerValue encoding) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    DerValue der, subDer;
    if (((encoding.getTag() & (byte)0x1F) != (byte)0x1E)
            || (encoding.isApplication() != true)
            || (encoding.isConstructed() != true)) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) == (byte)0x00) {

        pvno = subDer.getData().getBigInteger().intValue();
        if (pvno != Krb5.PVNO)
            throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    } else {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) == (byte)0x01) {
        msgType = subDer.getData().getBigInteger().intValue();
        if (msgType != Krb5.KRB_ERROR) {
            throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE);
        }
    } else {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }

    cTime = KerberosTime.parse(der.getData(), (byte)0x02, true);
    if ((der.getData().peekByte() & 0x1F) == 0x03) {
        subDer = der.getData().getDerValue();
        cuSec = new Integer(subDer.getData().getBigInteger().intValue());
    }
    else cuSec = null;
    sTime = KerberosTime.parse(der.getData(), (byte)0x04, false);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) == (byte)0x05) {
        suSec = new Integer (subDer.getData().getBigInteger().intValue());
    }
    else  throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) == (byte)0x06) {
        errorCode = subDer.getData().getBigInteger().intValue();
    }
    else  throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    crealm = Realm.parse(der.getData(), (byte)0x07, true);
    cname = PrincipalName.parse(der.getData(), (byte)0x08, true, crealm);
    Realm realm = Realm.parse(der.getData(), (byte)0x09, false);
    sname = PrincipalName.parse(der.getData(), (byte)0x0A, false, realm);
    eText = null;
    eData = null;
    eCksum = null;
    if (der.getData().available() >0) {
        if ((der.getData().peekByte() & 0x1F) == 0x0B) {
            subDer = der.getData().getDerValue();
            eText = new KerberosString(subDer.getData().getDerValue())
                    .toString();
        }
    }
    if (der.getData().available() >0) {
        if ((der.getData().peekByte() & 0x1F) == 0x0C) {
            subDer = der.getData().getDerValue();
            eData = subDer.getData().getOctetString();
        }
    }
    if (der.getData().available() >0) {
        eCksum = Checksum.parse(der.getData(), (byte)0x0D, true);
    }
    if (der.getData().available() >0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
Example #22
Source Project: dragonwell8_jdk   Author: alibaba   File: EncKrbCredPart.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EncKrbCredPart(byte[] data) throws Asn1Exception,
        IOException, RealmException {
    init(new DerValue(data));
}
 
Example #23
Source Project: dragonwell8_jdk   Author: alibaba   File: EncKrbCredPart.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EncKrbCredPart(DerValue encoding) throws Asn1Exception,
        IOException, RealmException {
    init(encoding);
}
 
Example #24
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Ticket.java    License: GNU General Public License v2.0 4 votes vote down vote up
public Ticket(byte[] data) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    init(new DerValue(data));
}
 
Example #25
Source Project: dragonwell8_jdk   Author: alibaba   File: KRBCred.java    License: GNU General Public License v2.0 4 votes vote down vote up
public KRBCred(DerValue encoding) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    init(encoding);
}
 
Example #26
Source Project: dragonwell8_jdk   Author: alibaba   File: KRBCred.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initializes an KRBCred object.
 * @param encoding a single DER-encoded value.
 * @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 KrbApErrException if the value read from the DER-encoded data
 *  stream does not match the pre-defined value.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */
private void init(DerValue encoding) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    if (((encoding.getTag() & (byte) 0x1F) != (byte) 0x16)
            || (encoding.isApplication() != true)
            || (encoding.isConstructed() != true)) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    DerValue der, subDer;
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x00) {
        pvno = subDer.getData().getBigInteger().intValue();
        if (pvno != Krb5.PVNO) {
            throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
        }
    } else {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x01) {
        msgType = subDer.getData().getBigInteger().intValue();
        if (msgType != Krb5.KRB_CRED) {
            throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE);
        }
    } else {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & 0x1F) == 0x02) {
        DerValue subsubDer = subDer.getData().getDerValue();
        if (subsubDer.getTag() != DerValue.tag_SequenceOf) {
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
        }
        Vector<Ticket> v = new Vector<>();
        while (subsubDer.getData().available() > 0) {
            v.addElement(new Ticket(subsubDer.getData().getDerValue()));
        }
        if (v.size() > 0) {
            tickets = new Ticket[v.size()];
            v.copyInto(tickets);
        }
    } else {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    encPart = EncryptedData.parse(der.getData(), (byte) 0x03, false);

    if (der.getData().available() > 0) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
}
 
Example #27
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ASRep.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void init(DerValue encoding) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    init(encoding, Krb5.KRB_AS_REP);
}
 
Example #28
Source Project: dragonwell8_jdk   Author: alibaba   File: ASRep.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ASRep(DerValue encoding) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    init(encoding);
}
 
Example #29
Source Project: dragonwell8_jdk   Author: alibaba   File: ASRep.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void init(DerValue encoding) throws Asn1Exception,
        RealmException, KrbApErrException, IOException {
    init(encoding, Krb5.KRB_AS_REP);
}
 
Example #30
Source Project: dragonwell8_jdk   Author: alibaba   File: Ticket.java    License: GNU General Public License v2.0 4 votes vote down vote up
public Ticket(byte[] data) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    init(new DerValue(data));
}