Examples of DistinguishedName


Examples of org.springframework.ldap.core.DistinguishedName

    @Test
    public void mappingBackToContextMatchesOriginalData() {
        DirContextAdapter ctx1 = createUserContext();
        DirContextAdapter ctx2 = new DirContextAdapter();
        ctx1.setAttributeValues("objectclass", new String[] {"top", "person", "organizationalPerson", "inetOrgPerson"});
        ctx2.setDn(new DistinguishedName("ignored=ignored"));
        InetOrgPerson p = (InetOrgPerson) (new InetOrgPerson.Essence(ctx1)).createUserDetails();
        p.populateContext(ctx2);

        assertEquals(ctx1, ctx2);
    }
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    @Test
    public void copyMatchesOriginalData() {
        DirContextAdapter ctx1 = createUserContext();
        DirContextAdapter ctx2 = new DirContextAdapter();
        ctx2.setDn(new DistinguishedName("ignored=ignored"));
        ctx1.setAttributeValues("objectclass", new String[] {"top", "person", "organizationalPerson", "inetOrgPerson"});
        InetOrgPerson p = (InetOrgPerson) (new InetOrgPerson.Essence(ctx1)).createUserDetails();
        InetOrgPerson p2 = (InetOrgPerson) new InetOrgPerson.Essence(p).createUserDetails();
        p2.populateContext(ctx2);
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    }

    private DirContextAdapter createUserContext() {
        DirContextAdapter ctx = new DirContextAdapter();

        ctx.setDn(new DistinguishedName("ignored=ignored"));
        ctx.setAttributeValue("uid", "ghengis");
        ctx.setAttributeValue("userPassword", "pillage");
        ctx.setAttributeValue("carLicense", "HORS1");
        ctx.setAttributeValue("cn", "Ghengis Khan");
        ctx.setAttributeValue("description", "Scary");
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    @Test
    public void defaultRoleIsAssignedWhenSet() {
        populator.setDefaultRole("ROLE_USER");
        assertSame(getContextSource(), populator.getContextSource());

        DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("cn=notfound"));

        Collection<GrantedAuthority> authorities = populator.getGrantedAuthorities(ctx, "notfound");
        assertEquals(1, authorities.size());
        assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER"));
    }
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    public void nullSearchBaseIsAccepted() throws Exception {
        populator = new DefaultLdapAuthoritiesPopulator(getContextSource(), null);
        populator.setDefaultRole("ROLE_USER");

        Collection<GrantedAuthority> authorities = populator.getGrantedAuthorities(
                new DirContextAdapter(new DistinguishedName("cn=notused")), "notused");
        assertEquals(1, authorities.size());
        assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER"));
    }
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

        populator.setSearchSubtree(true);
        populator.setSearchSubtree(false);
        populator.setConvertToUpperCase(true);
        populator.setGroupSearchFilter("(member={0})");

        DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org"));

        Set<String> authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "ben"));

        assertEquals("Should have 2 roles", 2, authorities.size());
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    public void useOfUsernameParameterReturnsExpectedRoles() {
        populator.setGroupRoleAttribute("ou");
        populator.setConvertToUpperCase(true);
        populator.setGroupSearchFilter("(ou={1})");

        DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org"));

        Set<String> authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "manager"));

        assertEquals("Should have 1 role", 1, authorities.size());
        assertTrue(authorities.contains("ROLE_MANAGER"));
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    @Test
    public void subGroupRolesAreNotFoundByDefault() {
        populator.setGroupRoleAttribute("ou");
        populator.setConvertToUpperCase(true);

        DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org"));

        Set<String> authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "manager"));

        assertEquals("Should have 2 roles", 2, authorities.size());
        assertTrue(authorities.contains("ROLE_MANAGER"));
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    public void subGroupRolesAreFoundWhenSubtreeSearchIsEnabled() {
        populator.setGroupRoleAttribute("ou");
        populator.setConvertToUpperCase(true);
        populator.setSearchSubtree(true);

        DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org"));

        Set<String> authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "manager"));

        assertEquals("Should have 3 roles", 3, authorities.size());
        assertTrue(authorities.contains("ROLE_MANAGER"));
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

                return new HashSet<GrantedAuthority>(AuthorityUtils.createAuthorityList("ROLE_EXTRA"));
            }
        };

        Collection<GrantedAuthority> authorities = populator.getGrantedAuthorities(
                new DirContextAdapter(new DistinguishedName("cn=notused")), "notused");
        assertEquals(1, authorities.size());
        assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_EXTRA"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.