Package org.apache.harmony.auth.internal.kerberos.v5

Examples of org.apache.harmony.auth.internal.kerberos.v5.PrincipalName


        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());
        assertEquals("kvno", 1, encPart.getKvno());
        assertTrue("cipher", Arrays.equals(new byte[] { 0x0f }, encPart
                .getCipher()));
    }
View Full Code Here


        if (destroyed) {
            throw new IOException(Messages.getString("auth.48")); //$NON-NLS-1$
        }
        s.defaultWriteObject();

        byte[] enc = EncryptionKey.ASN1.encode(new EncryptionKey(keyType,
                keyBytes));
        s.writeObject(enc);
    }
View Full Code Here

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

        s.defaultReadObject();

        EncryptionKey ekey = (EncryptionKey) EncryptionKey.ASN1
                .decode((byte[]) s.readObject());

        keyType = ekey.getType();
        keyBytes = ekey.getValue();
    }
View Full Code Here

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

        s.defaultReadObject();

        EncryptionKey ekey = (EncryptionKey) EncryptionKey.ASN1
                .decode((byte[]) s.readObject());

        keyType = ekey.getType();
        keyBytes = ekey.getValue();
    }
View Full Code Here

        if (destroyed) {
            throw new IOException(Messages.getString("auth.48")); //$NON-NLS-1$
        }
        s.defaultWriteObject();

        byte[] enc = EncryptionKey.ASN1.encode(new EncryptionKey(keyType,
                keyBytes));
        s.writeObject(enc);
    }
View Full Code Here

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

        s.defaultReadObject();

        EncryptionKey ekey = (EncryptionKey) EncryptionKey.ASN1
                .decode((byte[]) s.readObject());

        keyType = ekey.getType();
        keyBytes = ekey.getValue();
    }
View Full Code Here

        if (destroyed) {
            throw new IOException(Messages.getString("auth.48")); //$NON-NLS-1$
        }
        s.defaultWriteObject();

        byte[] enc = EncryptionKey.ASN1.encode(new EncryptionKey(keyType,
                keyBytes));
        s.writeObject(enc);
    }
View Full Code Here

            // get client's password
            PasswordCallback callback = new PasswordCallback("Password for "
                    + name, false);
            callbackHandler.handle(new Callback[] { callback });

            KDCReply reply = KrbClient.doAS(cname, callback.getPassword());

            // add principal to subject
            String[] pName = reply.getCname().getName();
            StringBuilder buf = new StringBuilder();
            for (int i = 0; i < pName.length - 1; i++) {
                buf.append(pName[i]);
                buf.append('/');
            }
            buf.append(pName[pName.length - 1]);
            buf.append('@');
            buf.append(reply.getCrealm());

            client = new KerberosPrincipal(buf.toString(), reply.getCname()
                    .getType());

            // add ticket to private credentials
            byte[] ticket = reply.getTicket().getEncoded();

            String[] sName = reply.getSname().getName();
            buf = new StringBuilder();
            for (int i = 0; i < sName.length - 1; i++) {
                buf.append(sName[i]);
                buf.append('/');
            }
            buf.append(sName[sName.length - 1]);
            buf.append('@');
            buf.append(reply.getSrealm());

            KerberosPrincipal server = new KerberosPrincipal(buf.toString(),
                    reply.getSname().getType());

            int keyType = reply.getKey().getType();
            byte[] sessionKey = reply.getKey().getValue();

            boolean[] flags = reply.getFlags().toBooleanArray();

            krbTicket = new KerberosTicket(ticket, client, server, sessionKey,
                    keyType, flags, reply.getAuthtime(), reply.getStarttime(),
                    reply.getEndtime(), reply.getRenewtill(),
                    //TODO InetAddress[] clientAddresses
                    null);

            return true; //FIXME
        } catch (Exception e) {
View Full Code Here

public class KDCReplyTest extends TestCase {

    public void test_Ctor() throws IOException {

        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());
        assertEquals("kvno", 1, encPart.getKvno());
        assertTrue("cipher", Arrays.equals(new byte[] { 0x0f }, encPart
                .getCipher()));
    }
View Full Code Here

public class KerberosErrorMessageTest extends TestCase {

    public void test_Ctor() throws IOException {

        KerberosErrorMessage message = KerberosErrorMessage
                .decode(new DerInputStream(err_resp));

        assertEquals("ctime", new Date(1000), message.getCtime());
        assertEquals("cusec", 65536, message.getCusec());

        assertEquals("stime", new Date(0), message.getStime());
        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

TOP

Related Classes of org.apache.harmony.auth.internal.kerberos.v5.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.