Search in sources :

Example 6 with NamingException

use of org.springframework.ldap.NamingException in project kylo by Teradata.

the class LdapGroupList method getAllGroups.

public void getAllGroups(LdapTemplate ldapTemplate, String groupBaseDnPattern) {
    try {
        groupInfo = new ArrayList<>();
        LdapQuery query = query().base(groupBaseDnPattern);
        groupInfo = ldapTemplate.list(query.base());
    } catch (NamingException e) {
        log.error("Unable to Groups from LDAP " + e.getMessage());
        throw new RuntimeException(e);
    }
}
Also used : NamingException(org.springframework.ldap.NamingException) LdapQuery(org.springframework.ldap.query.LdapQuery)

Example 7 with NamingException

use of org.springframework.ldap.NamingException in project perun by CESNET.

the class GroupEventProcessor method processMemberValidated.

public void processMemberValidated(String msg, MessageBeans beans) {
    if (beans.getMember() == null) {
        return;
    }
    List<Group> memberGroups = new ArrayList<Group>();
    Perun perun = ldapcManager.getPerunBl();
    try {
        log.debug("Getting list of groups for member {}", beans.getMember().getId());
        // memberGroups = Rpc.GroupsManager.getAllMemberGroups(ldapcManager.getRpcCaller(), beans.getMember());
        memberGroups = perun.getGroupsManager().getAllGroupsWhereMemberIsActive(ldapcManager.getPerunSession(), beans.getMember());
        for (Group g : memberGroups) {
            log.debug("Adding validated member {} to group {}", beans.getMember(), g);
            perunGroup.addMemberToGroup(beans.getMember(), g);
        }
    } catch (MemberNotExistsException e) {
    // IMPORTANT this is not problem, if member not exist, we expected that will be deleted in some message after that, in DB is deleted
    } catch (PrivilegeException e) {
        log.warn("There are no privileges for getting member's groups", e);
    } catch (NamingException | InternalErrorException e) {
        log.error("Error adding validated member to group", e);
    }
}
Also used : Perun(cz.metacentrum.perun.core.api.Perun) Group(cz.metacentrum.perun.core.api.Group) MemberNotExistsException(cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException) ArrayList(java.util.ArrayList) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) NamingException(org.springframework.ldap.NamingException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Example 8 with NamingException

use of org.springframework.ldap.NamingException in project perun by CESNET.

the class ResourceAttributeProcessor method processVirtualAttributeChanged.

public void processVirtualAttributeChanged(String msg, MessageBeans beans) {
    PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
    if (beans.getAttribute() == null || beans.getResource() == null) {
        return;
    }
    try {
        Attribute virtAttr = perun.getAttributesManagerBl().getAttribute(ldapcManager.getPerunSession(), beans.getResource(), beans.getAttribute().getName());
        log.debug("Changing virtual attribute {} for resource {}", virtAttr, beans.getResource());
        perunResource.modifyEntry(beans.getResource(), virtAttr);
    } catch (InternalErrorException | AttributeNotExistsException | WrongAttributeAssignmentException | NamingException e) {
        log.error("Error changing virtual attribute:", e);
    }
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) NamingException(org.springframework.ldap.NamingException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Example 9 with NamingException

use of org.springframework.ldap.NamingException in project perun by CESNET.

the class UserAttributeProcessor method processAdminAdded.

public void processAdminAdded(String msg, MessageBeans beans) {
    if (beans.getUser() == null) {
        return;
    }
    PerunBean admined = null;
    try {
        if (beans.getVo() != null) {
            admined = beans.getVo();
            perunUser.addAsVoAdmin(beans.getUser(), beans.getVo());
        } else if (beans.getGroup() != null) {
            admined = beans.getGroup();
            perunUser.addAsGroupAdmin(beans.getUser(), beans.getGroup());
        } else if (beans.getFacility() != null) {
            admined = beans.getFacility();
            perunUser.addAsFacilityAdmin(beans.getUser(), beans.getFacility());
        }
    } catch (NamingException | InternalErrorException e) {
        log.error("Error adding user {} as admin of {}: {}", beans.getUser().getId(), admined.getId(), ((InvalidAttributeValueException) e).getExplanation(), e);
    }
}
Also used : PerunBean(cz.metacentrum.perun.core.api.PerunBean) NamingException(org.springframework.ldap.NamingException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) InvalidAttributeValueException(org.springframework.ldap.InvalidAttributeValueException)

Example 10 with NamingException

use of org.springframework.ldap.NamingException in project perun by CESNET.

the class UserAttributeProcessor method processAdminRemoved.

public void processAdminRemoved(String msg, MessageBeans beans) {
    if (beans.getUser() == null) {
        return;
    }
    PerunBean admined = null;
    try {
        if (beans.getVo() != null) {
            admined = beans.getVo();
            perunUser.removeFromVoAdmins(beans.getUser(), beans.getVo());
        } else if (beans.getGroup() != null) {
            admined = beans.getGroup();
            perunUser.removeFromGroupAdmins(beans.getUser(), beans.getGroup());
        } else if (beans.getFacility() != null) {
            admined = beans.getFacility();
            perunUser.removeFromFacilityAdmins(beans.getUser(), beans.getFacility());
        }
    } catch (NamingException | InternalErrorException e) {
        log.error("Error removing user {} from admins of {}: {}", beans.getUser().getId(), admined.getId(), e);
    }
}
Also used : PerunBean(cz.metacentrum.perun.core.api.PerunBean) NamingException(org.springframework.ldap.NamingException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Aggregations

NamingException (org.springframework.ldap.NamingException)10 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)8 PerunBean (cz.metacentrum.perun.core.api.PerunBean)4 Attribute (cz.metacentrum.perun.core.api.Attribute)2 Group (cz.metacentrum.perun.core.api.Group)2 Perun (cz.metacentrum.perun.core.api.Perun)2 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)2 MemberNotExistsException (cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException)2 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)2 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)2 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)2 ArrayList (java.util.ArrayList)2 DirContext (javax.naming.directory.DirContext)1 InvalidAttributeValueException (org.springframework.ldap.InvalidAttributeValueException)1 DirContextAdapter (org.springframework.ldap.core.DirContextAdapter)1 DistinguishedName (org.springframework.ldap.core.DistinguishedName)1 BaseLdapPathContextSource (org.springframework.ldap.core.support.BaseLdapPathContextSource)1 LdapQuery (org.springframework.ldap.query.LdapQuery)1 PasswordPolicyControl (org.springframework.security.ldap.ppolicy.PasswordPolicyControl)1