Search in sources :

Example 71 with DirContextOperations

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

the class PerunUserImpl method removeFromVoAdmins.

@Override
public void removeFromVoAdmins(User user, Vo vo) {
    DirContextOperations entry = findByDN(buildDN(user));
    Name voDN = addBaseDN(perunVO.getEntryDN(String.valueOf(vo.getId())));
    entry.removeAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrAdminOfVo, voDN.toString());
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) Name(javax.naming.Name)

Example 72 with DirContextOperations

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

the class PerunUserImpl method synchronizeMembership.

@Override
public void synchronizeMembership(User user, Set<Integer> voIds, List<Group> groups) {
    DirContextOperations entry = findByDN(buildDN(user));
    doSynchronizeMembership(entry, voIds, groups);
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations)

Example 73 with DirContextOperations

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

the class AbstractPerunEntry method beginSynchronizeEntry.

@Override
public SyncOperation beginSynchronizeEntry(T bean, Iterable<Attribute> attrs) {
    DirContextOperations entry;
    boolean newEntry = false;
    try {
        entry = findByDN(buildDN(bean));
    } catch (NameNotFoundException e) {
        newEntry = true;
        entry = new DirContextAdapter(buildDN(bean));
    }
    mapToContext(bean, entry);
    for (Attribute attribute : attrs) {
        for (PerunAttribute<T> attributeDesc : findAttributeDescriptionsByPerunAttr(attributeDescriptions, attribute)) {
            mapToContext(bean, entry, attributeDesc, attribute);
        }
    }
    /*
		if(newEntry) {
			ldapTemplate.bind(entry);
		} else {
			ldapTemplate.modifyAttributes(entry);
		}
		*/
    return new SyncOperationImpl(entry, newEntry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) NameNotFoundException(org.springframework.ldap.NameNotFoundException) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunAttribute(cz.metacentrum.perun.ldapc.model.PerunAttribute) DirContextAdapter(org.springframework.ldap.core.DirContextAdapter)

Example 74 with DirContextOperations

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

the class PerunGroupImpl method removeFromVoAdmins.

@Override
public void removeFromVoAdmins(Group group, Vo vo) {
    DirContextOperations entry = findByDN(buildDN(group));
    Name voDN = addBaseDN(perunVO.getEntryDN(String.valueOf(vo.getId())));
    entry.removeAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrAdminOfVo, voDN.toString());
    ldapTemplate.modifyAttributes(entry);
}
Also used : DirContextOperations(org.springframework.ldap.core.DirContextOperations) Name(javax.naming.Name)

Example 75 with DirContextOperations

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

the class PerunGroupImpl method addAsGroupAdmin.

@Override
public void addAsGroupAdmin(Group group, Group group2) {
    DirContextOperations entry = findByDN(buildDN(group));
    Name groupDN = addBaseDN(getEntryDN(String.valueOf(group2.getVoId()), String.valueOf(group2.getId())));
    entry.addAttributeValue(PerunAttribute.PerunAttributeNames.ldapAttrAdminOfGroup, groupDN.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