use of org.springframework.ldap.core.DistinguishedName in project trainning by fernandotomasio.
the class LDAPNetworkGroupDAO method findOrganization.
@Override
public NetworkGroupDTO findOrganization(String uid) throws DAOException {
NetworkGroupDTO group = null;
try {
DistinguishedName dn = new DistinguishedName();
dn.add("ou", "groups");
dn.add("ou", APPLICATION_GROUP_BRANCH);
dn.add("ou", ORGANIZATIONS_GROUP_BRANCH);
dn.add("cn", uid);
group = (NetworkGroupDTO) ldapTemplate.lookup(dn, getGroupContextMapper());
} catch (AuthenticationException e) {
Logger.getLogger(this.getClass().getName()).log(Level.INFO, null, e);
throw new DAOException(MessageHelper.getMessage("systemUsers.find.error"));
} catch (org.springframework.ldap.NameNotFoundException e) {
Logger.getLogger(this.getClass().getName()).log(Level.INFO, null, e);
}
return group;
}
use of org.springframework.ldap.core.DistinguishedName in project trainning by fernandotomasio.
the class LDAPNetworkGroupDAO method buildOrganizationsGroupDn.
private Name buildOrganizationsGroupDn(final NetworkGroupDTO group) {
DistinguishedName dn = new DistinguishedName();
dn.add("ou", "groups");
dn.add("ou", APPLICATION_GROUP_BRANCH);
dn.add("ou", ORGANIZATIONS_GROUP_BRANCH);
dn.add("cn", group.getNome());
return dn;
}
use of org.springframework.ldap.core.DistinguishedName in project trainning by fernandotomasio.
the class LDAPNetworkUserDAO method buildDn.
private Name buildDn(final NetworkUserDTO user) {
DistinguishedName dn = new DistinguishedName();
dn.add("ou", "people");
dn.add("uid", user.getLogin());
return dn;
}
use of org.springframework.ldap.core.DistinguishedName in project spring-security by spring-projects.
the class SpringSecurityAuthenticationSourceTests method expectedPrincipalIsReturned.
@Test
public void expectedPrincipalIsReturned() {
LdapUserDetailsImpl.Essence user = new LdapUserDetailsImpl.Essence();
user.setUsername("joe");
user.setDn(new DistinguishedName("uid=joe,ou=users"));
AuthenticationSource source = new SpringSecurityAuthenticationSource();
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(user.createUserDetails(), null));
assertThat(source.getPrincipal()).isEqualTo("uid=joe,ou=users");
}
use of org.springframework.ldap.core.DistinguishedName in project spring-security by spring-projects.
the class DefaultLdapAuthoritiesPopulatorTests method defaultRoleIsAssignedWhenSet.
@Test
public void defaultRoleIsAssignedWhenSet() {
this.populator.setDefaultRole("ROLE_USER");
assertThat(this.populator.getContextSource()).isSameAs(this.contextSource);
DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("cn=notfound"));
Collection<GrantedAuthority> authorities = this.populator.getGrantedAuthorities(ctx, "notfound");
assertThat(authorities).hasSize(1);
assertThat(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER")).isTrue();
}
Aggregations