Package org.springframework.security.ldap.userdetails

Examples of org.springframework.security.ldap.userdetails.LdapUserDetails


    }

    private User getCurrentUser(Authentication auth, UserManager userManager) {
        User currentUser;
        if (auth.getPrincipal() instanceof LdapUserDetails) {
            LdapUserDetails ldapDetails = (LdapUserDetails) auth.getPrincipal();
            String username = ldapDetails.getUsername();
            currentUser = userManager.getUserByUsername(username);
        } else if (auth.getPrincipal() instanceof UserDetails) {
            currentUser = (User) auth.getPrincipal();
        } else if (auth.getDetails() instanceof UserDetails) {
            currentUser = (User) auth.getDetails();
View Full Code Here


        }

        Object principal = authentication.getPrincipal();

        if (principal instanceof LdapUserDetails) {
            LdapUserDetails details = (LdapUserDetails) principal;
            return details.getDn();
        } else if (authentication instanceof AnonymousAuthenticationToken) {
            if (log.isDebugEnabled()) {
                log.debug("Anonymous Authentication, returning empty String as Principal");
            }
            return "";
View Full Code Here

    @Test
    public void testLoadUserByUsernameReturnsCorrectData() {
        mgr.setUsernameMapper(new DefaultLdapUsernameToDnMapper("ou=people","uid"));
        mgr.setGroupSearchBase("ou=groups");
        LdapUserDetails bob = (LdapUserDetails) mgr.loadUserByUsername("bob");
        assertEquals("bob", bob.getUsername());
        assertEquals("uid=bob,ou=people,dc=springframework,dc=org", bob.getDn());
        assertEquals("bobspassword", bob.getPassword());

        assertEquals(1, bob.getAuthorities().size());
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.ldap.userdetails.LdapUserDetails

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.