Search in sources :

Example 31 with DirContextOperations

use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.

the class PerunUserImpl method synchronizePrincipals.

@Override
public void synchronizePrincipals(User user, List<UserExtSource> extSources) {
    DirContextOperations entry = findByDN(buildDN(user));
    doSynchronizePrincipals(entry, extSources);
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations)

Example 32 with DirContextOperations

use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.

the class PerunUserImpl method removePrincipal.

@Override
public void removePrincipal(User user, String login) {
    DirContextOperations entry = findByDN(buildDN(user));
    if (isEppnEpuidLogin(login)) {
        entry.removeAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrEduPersonPrincipalNames, login);
    }
    entry.removeAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrUserIdentities, login);
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations)

Example 33 with DirContextOperations

use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.

the class PerunUserImpl method synchronizeAdminRoles.

@Override
public void synchronizeAdminRoles(User user, List<Group> admin_groups, List<Vo> admin_vos, List<Facility> admin_facilities) {
    DirContextOperations entry = findByDN(buildDN(user));
    doSynchronizeAdminRoles(entry, admin_groups, admin_vos, admin_facilities);
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations)

Example 34 with DirContextOperations

use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.

the class PerunGroupImpl method isMember.

public boolean isMember(Member member, Group group) {
    DirContextOperations groupEntry = findByDN(buildDN(group));
    Name userDN = addBaseDN(user.getEntryDN(String.valueOf(member.getUserId())));
    return isMember(groupEntry, userDN);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) Name(javax.naming.Name)

Example 35 with DirContextOperations

use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.

the class PerunGroupImpl method addAsFacilityAdmin.

@Override
public void addAsFacilityAdmin(Group group, Facility facility) {
    DirContextOperations entry = findByDN(buildDN(group));
    Name facilityDN = addBaseDN(perunFacility.getEntryDN(String.valueOf(facility.getId())));
    entry.addAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrAdminOfFacility, facilityDN.toString());
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) Name(javax.naming.Name)

Aggregations

DirContextOperations (org.springframework.ldap.core.DirContextOperations)89 Name (javax.naming.Name)20 Test (org.junit.jupiter.api.Test)13 Test (org.junit.Test)9 UserDetails (org.springframework.security.core.userdetails.UserDetails)9 HashSet (java.util.HashSet)8 DirContextAdapter (org.springframework.ldap.core.DirContextAdapter)8 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)8 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)7 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)7 FilterBasedLdapUserSearch (org.springframework.security.ldap.search.FilterBasedLdapUserSearch)7 LdapConfig (com.thoughtworks.go.config.LdapConfig)6 BaseConfig (com.thoughtworks.go.config.server.security.ldap.BaseConfig)6 BasesConfig (com.thoughtworks.go.config.server.security.ldap.BasesConfig)6 ArrayList (java.util.ArrayList)6 Set (java.util.Set)6 NameNotFoundException (org.springframework.ldap.NameNotFoundException)6 GrantedAuthority (org.springframework.security.core.GrantedAuthority)5 PerunAttribute (cz.metacentrum.perun.ldapc.model.PerunAttribute)4 List (java.util.List)4