Package sun.security.krb5

Examples of sun.security.krb5.EncryptedData


        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<Ticket> ();
            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);
        }
View Full Code Here


     * @exception IOException if an I/O error occurs while reading encoded data.
     */
    public KRBSafeBody(DerValue encoding) throws Asn1Exception, IOException {
        DerValue der;
        if (encoding.getTag() != DerValue.tag_Sequence) {
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
        }
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x00) {
            userData = der.getData().getOctetString();
        }
        else
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
        timestamp = KerberosTime.parse(encoding.getData(), (byte)0x01, true);
        if ((encoding.getData().peekByte() & 0x1F) == 0x02) {
            der = encoding.getData().getDerValue();
            usec = new Integer(der.getData().getBigInteger().intValue());
        }
        if ((encoding.getData().peekByte() & 0x1F) == 0x03) {
            der = encoding.getData().getDerValue();
            seqNumber = new Integer(der.getData().getBigInteger().intValue());
        }
        sAddress = HostAddress.parse(encoding.getData(), (byte)0x04, false);
        if (encoding.getData().available() > 0)
            rAddress = HostAddress.parse(encoding.getData(), (byte)0x05, true);
        if (encoding.getData().available() > 0)
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
View Full Code Here

    public static KRBSafeBody parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException {
        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 KRBSafeBody(subDer);
        }
    }
View Full Code Here

     * @exception IOException if an I/O error occurs while reading encoded data.
     */

    public TransitedEncoding(DerValue encoding) throws Asn1Exception, IOException {
        if (encoding.getTag() != DerValue.tag_Sequence) {
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
        }
        DerValue der;
        der = encoding.getData().getDerValue();
        if ((der.getTag() & 0x1F) == 0x00) {
            trType = der.getData().getBigInteger().intValue();
        }
        else
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
        der = encoding.getData().getDerValue();

        if ((der.getTag() & 0x1F) == 0x01) {
            contents = der.getData().getOctetString();
        }
        else
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
        if (der.getData().available() > 0)
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
View Full Code Here

    public static TransitedEncoding parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException {
        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 TransitedEncoding(subDer);
        }
View Full Code Here

        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 HostAddresses(subDer);
        }
    }
View Full Code Here

            clientPrincipal = (name.getKrb5PrincipalName()).getName();
            realm = (name.getKrb5PrincipalName()).getRealmAsString();
        } else {
            clientPrincipal = null;
            try {
                Config config = Config.getInstance();
                realm = config.getDefaultRealm();
            } catch (KrbException e) {
                GSSException ge =
                        new GSSException(GSSException.NO_CRED, -1,
                            "Attempt to obtain INITIATE credentials failed!" +
                            " (" + e.getMessage() + ")");
View Full Code Here

     */
    public static CksumType getInstance() throws KdcErrException {
        // this method provided for Kerberos applications.
        int cksumType = Checksum.CKSUMTYPE_RSA_MD5; // default
        try {
            Config c = Config.getInstance();
            if ((cksumType = (c.getType(c.getDefault("ap_req_checksum_type",
                                "libdefaults")))) == - 1) {
                if ((cksumType = c.getType(c.getDefault("checksum_type",
                                "libdefaults"))) == -1) {
                    cksumType = Checksum.CKSUMTYPE_RSA_MD5; // default
                }
            }
        } catch (KrbException e) {
View Full Code Here

     */

    private static String[] parseCapaths(String cRealm, String sRealm) throws KrbException {
        String[] retList = null;

        Config cfg = null;
        try {
            cfg = Config.getInstance();
        } catch (Exception exc) {
            if (DEBUG) {
                System.out.println ("Configuration information can not be " +
                                    "obtained " + exc.getMessage());
            }
            return null;
        }

        String intermediaries = cfg.getDefault(sRealm, cRealm);

        if (intermediaries == null) {
            if (DEBUG) {
                System.out.println(">>> Realm parseCapaths: no cfg entry");
            }
            return null;
        }

        String tempTarget = null, tempRealm = null;
        StringTokenizer strTok = null;
        Stack<String> iStack = new Stack<String> ();

        /*
         * I don't expect any more than a handful of intermediaries.
         */
        Vector<String> tempList = new Vector<String> (8, 8);

        /*
         * The initiator at first location.
         */
        tempList.add(cRealm);

        int count = 0; // For debug only
        if (DEBUG) {
            tempTarget = sRealm;
        }

        do {
            if (DEBUG) {
                count++;
                System.out.println(">>> Realm parseCapaths: loop " +
                                   count + ": target=" + tempTarget);
            }

            if (intermediaries != null &&
                !intermediaries.equals(PrincipalName.REALM_COMPONENT_SEPARATOR_STR))
            {
                if (DEBUG) {
                    System.out.println(">>> Realm parseCapaths: loop " +
                                       count + ": intermediaries=[" +
                                       intermediaries + "]");
                }

                /*
                 * We have one or more space-separated intermediary realms.
                 * Stack them.
                 */
                strTok = new StringTokenizer(intermediaries, " ");
                while (strTok.hasMoreTokens())
                {
                    tempRealm = strTok.nextToken();
                    if (!tempRealm.equals(PrincipalName.
                                          REALM_COMPONENT_SEPARATOR_STR) &&
                        !iStack.contains(tempRealm)) {
                        iStack.push(tempRealm);
                        if (DEBUG) {
                            System.out.println(">>> Realm parseCapaths: loop " +
                                               count +
                                               ": pushed realm on to stack: " +
                                               tempRealm);
                        }
                    } else if (DEBUG) {
                        System.out.println(">>> Realm parseCapaths: loop " +

                                           count +
                                           ": ignoring realm: [" +
                                           tempRealm + "]");
                    }
                }
            } else if (DEBUG) {
                System.out.println(">>> Realm parseCapaths: loop " +
                                   count +
                                   ": no intermediaries");
            }

            /*
             * Get next intermediary realm from the stack
             */

            try {
                tempTarget = iStack.pop();
            } catch (EmptyStackException exc) {
                tempTarget = null;
            }

            if (tempTarget == null) {
                /*
                 * No more intermediaries. We're done.
                 */
                break;
            }

            tempList.add(tempTarget);

            if (DEBUG) {
                System.out.println(">>> Realm parseCapaths: loop " + count +
                                   ": added intermediary to list: " +
                                   tempTarget);
            }

            intermediaries = cfg.getDefault(tempTarget, cRealm);

        } while (true);

        retList = new String[tempList.size()];
        try {
View Full Code Here

      return;
   
    String serviceName = "host/" + remoteHost.getHost();
    if (LOG.isDebugEnabled())
      LOG.debug("Fetching service ticket for host at: " + serviceName);
    Credentials serviceCred = null;
    try {
      PrincipalName principal = new PrincipalName(serviceName,
          PrincipalName.KRB_NT_SRV_HST);
      serviceCred = Credentials.acquireServiceCreds(principal
          .toString(), Krb5Util.ticketToCreds(getTgtFromSubject()));
View Full Code Here

TOP

Related Classes of sun.security.krb5.EncryptedData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.