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

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


                                String v = System
                                        .getProperty("java.security.krb5.realm"); //$NON-NLS-1$
                                if (v == null) {
                                    // look in config files
                                    KrbConfig config = null;
                                    try {
                                        config = KrbConfig.getSystemConfig();
                                    } catch (IOException e) {
                                        // ignore
                                    }
                                    if (config != null) {
                                        v = config.getValue("libdefaults", //$NON-NLS-1$
                                                "default_realm"); //$NON-NLS-1$
                                    }
                                }
                                return v;
                            }
View Full Code Here


    public void test_Ctor() throws IOException {

        File f = new File(Support_Resources
                .getAbsoluteResourcePath("KrbConfigTest.txt"));

        KrbConfig config = new KrbConfig(f);

        assertEquals("MY.REALM", config
                .getValue("libdefaults", "default_realm"));
        assertEquals("true", config.getValue("libdefaults", "dns_lookup_kdc"));

        assertEquals("SYSLOG:INFO", config.getValue("logging", "default"));
        assertEquals("FILE:/var/kdc.log", config.getValue("logging", "kdc"));
    }
View Full Code Here

        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

        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);

            return true; //FIXME
        } catch (Exception e) {
            LoginException ex = new LoginException();
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.