Search in sources :

Example 26 with DirContextOperations

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

the class PerunResourceImpl method synchronizeGroups.

@Override
public void synchronizeGroups(Resource resource, List<Group> assignedGroups) {
    DirContextOperations entry = findByDN(buildDN(resource));
    doSynchronizeGroups(entry, assignedGroups);
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations)

Example 27 with DirContextOperations

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

the class PerunVOImpl method addMemberToVO.

@Override
public void addMemberToVO(int voId, Member member) {
    DirContextOperations voEntry = findById(String.valueOf(voId));
    Name memberDN = user.getEntryDN(String.valueOf(member.getUserId()));
    voEntry.addAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrUniqueMember, addBaseDN(memberDN).toString());
    ldapTemplate.modifyAttributes(voEntry);
    DirContextOperations userEntry = findByDN(memberDN);
    userEntry.addAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrMemberOfPerunVo, String.valueOf(voId));
    ldapTemplate.modifyAttributes(userEntry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) Name(javax.naming.Name)

Example 28 with DirContextOperations

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

the class PerunVOImpl method removeMemberFromVO.

@Override
public void removeMemberFromVO(int voId, Member member) {
    DirContextOperations voEntry = findById(String.valueOf(voId));
    Name memberDN = user.getEntryDN(String.valueOf(member.getUserId()));
    voEntry.removeAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrUniqueMember, addBaseDN(memberDN).toString());
    ldapTemplate.modifyAttributes(voEntry);
    DirContextOperations userEntry = findByDN(memberDN);
    userEntry.removeAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrMemberOfPerunVo, String.valueOf(voId));
    ldapTemplate.modifyAttributes(userEntry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) Name(javax.naming.Name)

Example 29 with DirContextOperations

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

the class PerunUserImpl method removeFromGroupAdmins.

@Override
public void removeFromGroupAdmins(User user, Group group) {
    DirContextOperations entry = findByDN(buildDN(user));
    Name groupDN = addBaseDN(perunGroup.getEntryDN(String.valueOf(group.getVoId()), String.valueOf(group.getId())));
    entry.removeAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrAdminOfGroup, groupDN.toString());
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) Name(javax.naming.Name)

Example 30 with DirContextOperations

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

the class PerunUserImpl method addPrincipal.

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

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