Package sun.security.krb5

Examples of sun.security.krb5.PrincipalName


        if (pos != -1) {
            port = Integer.parseInt(kdc.substring(pos + 1));
            kdc = kdc.substring(0, pos);
        }

        PrincipalName cname = new PrincipalName(PrincipalName.NT_UNKNOWN, new String[] { name });

        PrincipalName krbtgt = new PrincipalName(PrincipalName.NT_SRV_XHST, new String[] {
                "krbtgt", realm }); //$NON-NLS-1$

        try {
            Ticket ticket = KrbClient.doAS(InetAddress.getByName(kdc), port, cname, realm,
                    krbtgt);
View Full Code Here


    private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {

        s.defaultReadObject();

        PrincipalName principalName = (PrincipalName) PrincipalName.ASN1.decode((byte[]) s
                .readObject());
        realm = (String) ASN1StringType.GENERALSTRING.decode((byte[]) s.readObject());

        String[] nameString = principalName.getName();
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < (nameString.length - 1); i++) {
            buf.append(nameString[i]);
            buf.append('/');
        }
        // append last name element
        buf.append(nameString[nameString.length - 1]);

        // append realm
        buf.append('@');
        buf.append(realm);

        name = buf.toString();

        type = principalName.getType();

        //FIXME: verify serialized values
    }
View Full Code Here

            for (int i = 0; i < nameString.length; i++) {
                nameString[i] = strTknzr.nextToken();
            }
        }

        byte[] enc = PrincipalName.ASN1.encode(new PrincipalName(type, nameString));
        s.writeObject(enc);

        enc = ASN1StringType.GENERALSTRING.encode(realm);
        s.writeObject(enc);
    }
View Full Code Here

        if (name == null) {
            throw new LoginException();//FIXME check params
        }

        PrincipalName cname = new PrincipalName(PrincipalName.NT_UNKNOWN,
                new String[] { name });

        try {
            // get client's password
            PasswordCallback callback = new PasswordCallback("Password for "
View Full Code Here

        KDCReply reply = (KDCReply) KDCReply.AS_REP_ASN1.decode(enc);

        assertEquals("msg-type", KDCReply.AS_REP, reply.getMsgtype());
        assertEquals("crealm", "MY.REALM", reply.getCrealm());
        assertEquals("cname", new PrincipalName(1, new String[] { "me" }),
                reply.getCname());

        // ticket
        Ticket ticket = reply.getTicket();
        assertEquals("ticket's realm", "MY.REALM", ticket.getRealm());
        assertEquals("ticket's sname", new PrincipalName(0, new String[] {
                "krbtgt", "MY.REALM" }), ticket.getSname());
       
        // enc-part
        EncryptedData encPart = reply.getEncPart();
        assertEquals("etype", 3, encPart.getEtype());
View Full Code Here

        assertEquals("susec", 65793, message.getSusec());

        assertEquals("error-code", 6, message.getErrorCode());

        assertEquals("crealm", "MY.REALM", message.getCrealm());
        assertEquals("cname", new PrincipalName(PrincipalName.NT_PRINCIPAL,
                new String[] { "no_such_user" }), message.getCname());

        assertEquals("realm", "MY.REALM", message.getRealm());
        assertEquals("sname", new PrincipalName(PrincipalName.NT_UNKNOWN,
                new String[] { "krbtgt", "MY.REALM" }), message.getSname());

        assertEquals("etext", "e_text_string", message.getEtext());
    }
View Full Code Here

                realm = KrbClient.getRealm();
            } catch (KerberosException e) {
                throw new IllegalArgumentException(e);
            }
        }
        this.name = new PrincipalName(type, name);
    }
View Full Code Here

        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 = Realm.parse(der.getData(), (byte)0x01, false);
        sname = PrincipalName.parse(der.getData(), (byte)0x02, false);
        encPart = EncryptedData.parse(der.getData(), (byte)0x03, false);
        if (der.getData().available() > 0)
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
View Full Code Here

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

     */

    public LastReq(DerValue encoding) throws Asn1Exception, IOException {
        Vector<LastReqEntry> v= new Vector<LastReqEntry> ();
        if (encoding.getTag() != DerValue.tag_Sequence) {
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
        }
        while (encoding.getData().available() > 0) {
            v.addElement(new LastReqEntry(encoding.getData().getDerValue()));
        }
        if (v.size() > 0) {
View Full Code Here

TOP

Related Classes of sun.security.krb5.PrincipalName

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.