/** {@inheritDoc} */ @Override public Group deassign(Group group, String member) throws SecurityException { String methodName = "deassign"; assertContext(CLS_NM, methodName, group, GlobalErrIds.GROUP_NULL); checkAccess(CLS_NM, methodName); ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(); User user = reviewMgr.readUser(new User(member)); return GROUP_P.deassign(group, user.getDn()); }
private void loadUserDns(Group group) throws SecurityException { if (CollectionUtils.isNotEmpty(group.getMembers())) { ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(); List<String> userDns = new ArrayList<String>(); for (String member : group.getMembers()) { User user = reviewMgr.readUser(new User(member)); userDns.add(user.getDn()); } group.setMembers(userDns); } }
/** {@inheritDoc} */ @Override public Group deassign(Group group, String member) throws SecurityException { String methodName = "deassign"; assertContext(CLS_NM, methodName, group, GlobalErrIds.GROUP_NULL); checkAccess(CLS_NM, methodName); ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(this.contextId); String dn; if (group.getType() == Group.Type.ROLE) { Role role = reviewMgr.readRole(new Role(member)); dn = role.getDn(); } else { User user = reviewMgr.readUser(new User(member)); dn = user.getDn(); } return GROUP_P.deassign(group, dn); }
/** * @param user * @return * @throws org.apache.directory.fortress.core.FinderException */ List<Group> find(User user) throws FinderException { List<Group> groupList = new ArrayList<>(); LdapConnection ld = null; SearchCursor searchResults; String groupRoot = getRootDn(user.getContextId(), GlobalIds.GROUP_ROOT); String filter = null; try { encodeSafeText(user.getUserId(), GlobalIds.USERID_LEN); filter = GlobalIds.FILTER_PREFIX + GROUP_OBJECT_CLASS_IMPL + ")(" + SchemaConstants.MEMBER_AT + "=" + user.getDn() + "))"; ld = getAdminConnection(); searchResults = search( ld, groupRoot, SearchScope.ONELEVEL, filter, GROUP_ATRS, false, GlobalIds.BATCH_SIZE); long sequence = 0; while (searchResults.next()) { groupList.add(unloadLdapEntry(searchResults.getEntry(), sequence++)); } } catch (CursorException e) { String error = "find filter [" + filter + "] caught CursorException=" + e.getMessage(); throw new FinderException(GlobalErrIds.GROUP_SEARCH_FAILED, error, e); } catch (LdapException e) { String error = "find filter [" + filter + "] caught LDAPException=" + e.getMessage(); throw new FinderException(GlobalErrIds.GROUP_SEARCH_FAILED, error, e); } finally { closeAdminConnection(ld); } return groupList; }
/** {@inheritDoc} */ @Override public Group assign(Group group, String member) throws SecurityException { String methodName = "assign"; assertContext(CLS_NM, methodName, group, GlobalErrIds.GROUP_NULL); checkAccess(CLS_NM, methodName); ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(this.contextId); String dn; if (group.getType() == Group.Type.ROLE) { Role inRole = new Role(member); inRole.setContextId(group.getContextId()); Role role = reviewMgr.readRole(inRole); dn = role.getDn(); // Validate SSD constraints SDUtil.getInstance().validateSSD(group, role); } else { User inUser = new User(member); inUser.setContextId(group.getContextId()); User user = reviewMgr.readUser(inUser); dn = user.getDn(); } return GROUP_P.assign(group, dn); }
private void loadUserDn(User inUser) throws SecurityException { ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(); User outUser = reviewMgr.readUser(inUser); inUser.setDn(outUser.getDn()); }