Examples of DistinguishedName


Examples of org.springframework.ldap.core.DistinguishedName

        addAuthorities(dn, user.getAuthorities());
    }

    public void updateUser(UserDetails user) {
        DistinguishedName dn = usernameMapper.buildDn(user.getUsername());

        logger.debug("Updating user '"+ user.getUsername() + "' with DN '" + dn + "'");

        List<GrantedAuthority> authorities = getUserAuthorities(dn, user.getUsername());
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

        removeAuthorities(dn, authorities);
        addAuthorities(dn, user.getAuthorities());
    }

    public void deleteUser(String username) {
        DistinguishedName dn = usernameMapper.buildDn(username);
        removeAuthorities(dn, getUserAuthorities(dn, username));
        template.unbind(dn);
    }
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

        removeAuthorities(dn, getUserAuthorities(dn, username));
        template.unbind(dn);
    }

    public boolean userExists(String username) {
        DistinguishedName dn = usernameMapper.buildDn(username);

        try {
            Object obj = template.lookup(dn);
            if (obj instanceof Context) {
                LdapUtils.closeContext((Context) obj);
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

     *
     * @param group the name of the group
     * @return the DN of the corresponding group, including the groupSearchBase
     */
    protected DistinguishedName buildGroupDn(String group) {
        DistinguishedName dn = new DistinguishedName(groupSearchBase);
        dn.add(groupRoleAttributeName, group.toLowerCase());

        return dn;
    }
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    private void modifyAuthorities(final DistinguishedName userDn, final Collection<? extends GrantedAuthority> authorities, final int modType) {
        template.executeReadWrite(new ContextExecutor() {
            public Object executeWithContext(DirContext ctx) throws NamingException {
                for(GrantedAuthority authority : authorities) {
                    String group = convertAuthorityToGroup(authority);
                    DistinguishedName fullDn = LdapUtils.getFullDn(userDn, ctx);
                    ModificationItem addGroup = new ModificationItem(modType,
                            new BasicAttribute(groupMemberAttributeName, fullDn.toUrl()));

                    ctx.modifyAttributes(buildGroupDn(group), new ModificationItem[] {addGroup});
                }
                return null;
            }
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

    public void setPasswordAttributeName(String passwordAttributeName) {
        this.passwordAttributeName = passwordAttributeName;
    }

    public void setGroupSearchBase(String groupSearchBase) {
        this.groupSearchBase = new DistinguishedName(groupSearchBase);
    }
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

        mapper.setRoleAttributes(new String[] {"userRole", "nonRetrievedAttribute"});

        BasicAttributes attrs = new BasicAttributes();
        attrs.put(new BasicAttribute("userRole", "x"));

        DirContextAdapter ctx = new DirContextAdapter(attrs, new DistinguishedName("cn=someName"));
        ctx.setAttributeValue("uid", "ani");

        LdapUserDetailsImpl user = (LdapUserDetailsImpl) mapper.mapUserFromContext(ctx, "ani", AuthorityUtils.NO_AUTHORITIES);

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

Examples of org.springframework.ldap.core.DistinguishedName

        mapper.setPasswordAttributeName("myappsPassword");
        BasicAttributes attrs = new BasicAttributes();
        attrs.put(new BasicAttribute("myappsPassword", "mypassword".getBytes()));

        DirContextAdapter ctx = new DirContextAdapter(attrs, new DistinguishedName("cn=someName"));
        ctx.setAttributeValue("uid", "ani");

        LdapUserDetails user = (LdapUserDetailsImpl) mapper.mapUserFromContext(ctx, "ani", AuthorityUtils.NO_AUTHORITIES);

        assertEquals("mypassword", user.getPassword());
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

        new LdapUserDetailsService(new MockUserSearch(), null);
    }

    @Test
    public void correctAuthoritiesAreReturned() {
        DirContextAdapter userData = new DirContextAdapter(new DistinguishedName("uid=joe"));

        LdapUserDetailsService service =
                new LdapUserDetailsService(new MockUserSearch(userData), new MockAuthoritiesPopulator());
        service.setUserDetailsMapper(new LdapUserDetailsMapper());
View Full Code Here

Examples of org.springframework.ldap.core.DistinguishedName

        assertTrue(authorities.contains("ROLE_FROM_POPULATOR"));
    }

    @Test
    public void nullPopulatorConstructorReturnsEmptyAuthoritiesList() throws Exception {
        DirContextAdapter userData = new DirContextAdapter(new DistinguishedName("uid=joe"));

        LdapUserDetailsService service = new LdapUserDetailsService(new MockUserSearch(userData));
        UserDetails user = service.loadUserByUsername("doesntmatterwegetjoeanyway");
        assertEquals(0, user.getAuthorities().size());
    }
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.