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

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


        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 testEqualsWithDisimilarObjects()
    {
        UsernamePrincipal wrappedPrincipal = new UsernamePrincipal("user1");
        AuthenticatedPrincipal authenticatedPrincipal = new AuthenticatedPrincipal(wrappedPrincipal);

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

        else
        {
            Set<Principal> principals = new HashSet<Principal>();
            for (String user : users)
            {
                principals.add(new UsernamePrincipal(user));
            }
            return principals;
        }
    }
View Full Code Here

    }

    public void testAddRejected()
    {
        final GroupPrincipal principal = new GroupPrincipal("group");
        final UsernamePrincipal user = new UsernamePrincipal("name");

        try
        {
            principal.addMember(user);
            fail("Exception not thrown");
View Full Code Here

    }

    public void testInequalityNonGroupPrincipal()
    {
        GroupPrincipal principal = new GroupPrincipal("string");
        assertFalse(principal.equals(new UsernamePrincipal("string")));
    }
View Full Code Here

        setVirtualHost(virtualHost);
    }

    private void setTestAuthorizedSubject()
    {
        Principal principal = new AuthenticatedPrincipal(new UsernamePrincipal("InternalTestProtocolSession"));
        Subject authorizedSubject = new Subject(
                true,
                Collections.singleton(principal),
                Collections.emptySet(),
                Collections.emptySet());
View Full Code Here

    public void testAuthenticateWithUsernameBasedOnCNAndDC() throws Exception
    {
        X500Principal principal;
        SaslServer saslServer;
        AuthenticationResult result;
        UsernamePrincipal expectedPrincipal;

        // DN contains only CN
        principal = new X500Principal("CN=person");
        expectedPrincipal = new UsernamePrincipal("person");
        saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

        result = _manager.authenticate(saslServer, new byte[0]);
        assertNotNull(result);
        assertEquals("Expected authentication to be successful",
                     AuthenticationResult.AuthenticationStatus.SUCCESS,
                     result.getStatus());
        assertOnlyContainsWrapped(expectedPrincipal, result.getPrincipals());

        // Null princial
        saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", null);
        result = _manager.authenticate(saslServer, new byte[0]);

        assertNotNull(result);
        assertEquals("Expected authentication to be unsuccessful",
                AuthenticationResult.AuthenticationStatus.ERROR,
                result.getStatus());

        // DN doesn't contain CN
        principal = new X500Principal("DC=example, DC=com, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
        saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);
        result = _manager.authenticate(saslServer, new byte[0]);

        assertNotNull(result);
        assertEquals("Expected authentication to be unsuccessful",
                AuthenticationResult.AuthenticationStatus.ERROR,
                result.getStatus());

        // DN contains empty CN
        principal = new X500Principal("CN=, DC=example, DC=com, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
        saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);
        result = _manager.authenticate(saslServer, new byte[0]);

        assertNotNull(result);
        assertEquals("Expected authentication to be unsuccessful",
                AuthenticationResult.AuthenticationStatus.ERROR,
                result.getStatus());

        // DN contains CN and DC
        principal = new X500Principal("CN=person, DC=example, DC=com");
        expectedPrincipal = new UsernamePrincipal("person@example.com");
        saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

        result = _manager.authenticate(saslServer, new byte[0]);
        assertNotNull(result);
        assertEquals("Expected authentication to be successful",
                AuthenticationResult.AuthenticationStatus.SUCCESS,
                result.getStatus());
        assertOnlyContainsWrapped(expectedPrincipal, result.getPrincipals());

        // DN contains CN and DC and other components
        principal = new X500Principal("CN=person, DC=example, DC=com, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
        expectedPrincipal = new UsernamePrincipal("person@example.com");
        saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

        result = _manager.authenticate(saslServer, new byte[0]);
        assertNotNull(result);
        assertEquals("Expected authentication to be successful",
                AuthenticationResult.AuthenticationStatus.SUCCESS,
                result.getStatus());
        assertOnlyContainsWrapped(expectedPrincipal, result.getPrincipals());

        // DN contains CN and DC and other components
        principal = new X500Principal("CN=person, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB");
        expectedPrincipal = new UsernamePrincipal("person");
        saslServer = _manager.createSaslServer("EXTERNAL", "example.example.com", principal);

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

                    String username;
                    String dn = ((X500Principal) principal).getName(X500Principal.RFC2253);


                    username = SSLUtil.getIdFromSubjectDN(dn);
                    principal = new  UsernamePrincipal(username);
                }

                subject = subjectCreator.createSubjectWithGroups(new AuthenticatedPrincipal(principal));
            }
        }
View Full Code Here

            }

            @Override
            public Principal getAuthenticatedPrincipal(SaslServer server)
            {
                return new UsernamePrincipal(server.getAuthorizationID());
            }
        };
    }
View Full Code Here

                    String username;
                    String dn = ((X500Principal) principal).getName(X500Principal.RFC2253);


                    username = SSLUtil.getIdFromSubjectDN(dn);
                    principal = new  UsernamePrincipal(username);
                }

                subject = subjectCreator.createSubjectWithGroups(new AuthenticatedPrincipal(principal));
            }
        }
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.