Package org.apache.qpid.server.security.auth

Examples of org.apache.qpid.server.security.auth.UsernamePrincipal


    }

    public void testTooManyAuthenticatedPrincipalsInSubject()
    {
        final Subject subject = new Subject();
        subject.getPrincipals().add(new AuthenticatedPrincipal(new UsernamePrincipal("name1")));
        subject.getPrincipals().add(new AuthenticatedPrincipal(new UsernamePrincipal("name2")));

        try
        {
            AuthenticatedPrincipal.getAuthenticatedPrincipalFromSubject(subject);
            fail("Exception not thrown");
View Full Code Here


        return subject;
    }

    public void testEqualsAndHashcode()
    {
        AuthenticatedPrincipal user1principal1 = new AuthenticatedPrincipal(new UsernamePrincipal("user1"));
        AuthenticatedPrincipal user1principal2 = new AuthenticatedPrincipal(new UsernamePrincipal("user1"));

        assertTrue(user1principal1.equals(user1principal1));
        assertTrue(user1principal1.equals(user1principal2));
        assertTrue(user1principal2.equals(user1principal1));
View Full Code Here

        assertEquals(user1principal1.hashCode(), user1principal2.hashCode());
    }

    public void testEqualsAndHashcodeWithSameWrappedObject()
    {
        UsernamePrincipal wrappedPrincipal = new UsernamePrincipal("user1");
        AuthenticatedPrincipal user1principal1 = new AuthenticatedPrincipal(wrappedPrincipal);
        AuthenticatedPrincipal user1principal2 = new AuthenticatedPrincipal(wrappedPrincipal);

        assertTrue(user1principal1.equals(user1principal1));
        assertTrue(user1principal1.equals(user1principal2));
View Full Code Here

        assertEquals(user1principal1.hashCode(), user1principal2.hashCode());
    }

    public void testEqualsWithDifferentUsernames()
    {
        AuthenticatedPrincipal user1principal1 = new AuthenticatedPrincipal(new UsernamePrincipal("user1"));
        AuthenticatedPrincipal user1principal2 = new AuthenticatedPrincipal(new UsernamePrincipal("user2"));

        assertFalse(user1principal1.equals(user1principal2));
        assertFalse(user1principal2.equals(user1principal1));
    }
View Full Code Here

        assertFalse(user1principal2.equals(user1principal1));
    }

    public void testEqualsWithDissimilarObjects()
    {
        UsernamePrincipal wrappedPrincipal = new UsernamePrincipal("user1");
        AuthenticatedPrincipal authenticatedPrincipal = new AuthenticatedPrincipal(wrappedPrincipal);

        assertFalse(authenticatedPrincipal.equals(wrappedPrincipal));
        assertFalse(wrappedPrincipal.equals(authenticatedPrincipal));
    }
View Full Code Here

    }

    public void testAuthenticatePrincipalCnOnly() throws Exception
    {
        X500Principal principal = new X500Principal("CN=person");
        UsernamePrincipal expectedPrincipal = new UsernamePrincipal("person");
        SaslServer saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

        AuthenticationResult result = _manager.authenticate(saslServer, new byte[0]);
        assertNotNull(result);
        assertEquals("Expected authentication to be successful",
View Full Code Here

    }

    public void testAuthenticatePrincipalCnAndDc() throws Exception
    {
        X500Principal principal = new X500Principal("CN=person, DC=example, DC=com");
        UsernamePrincipal expectedPrincipal = new UsernamePrincipal("person@example.com");
        SaslServer saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

        AuthenticationResult result = _manager.authenticate(saslServer, new byte[0]);
        assertNotNull(result);
        assertEquals("Expected authentication to be successful",
View Full Code Here

    }

    public void testAuthenticatePrincipalCnDc_OtherComponentsIgnored() throws Exception
    {
        X500Principal principal = new X500Principal("CN=person, DC=example, DC=com, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
        UsernamePrincipal expectedPrincipal = new UsernamePrincipal("person@example.com");
        SaslServer saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

        AuthenticationResult result = _manager.authenticate(saslServer, new byte[0]);
        assertNotNull(result);
        assertEquals("Expected authentication to be successful",
View Full Code Here

    }

    public void testAuthenticatePrincipalCn_OtherComponentsIgnored() throws Exception
    {
        X500Principal principal = new X500Principal("CN=person, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
        UsernamePrincipal expectedPrincipal = new UsernamePrincipal("person");
        SaslServer saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

        AuthenticationResult result = _manager.authenticate(saslServer, new byte[0]);
        assertNotNull(result);
        assertEquals("Expected authentication to be successful",
View Full Code Here

                if (_logger.isDebugEnabled())
                {
                    _logger.debug("Authenticated as " + authorizationID);
                }

                return new AuthenticationResult(new UsernamePrincipal(authorizationID));
            }
            else
            {
                return new AuthenticationResult(challenge, AuthenticationResult.AuthenticationStatus.CONTINUE);
            }
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.security.auth.UsernamePrincipal

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.