/** * Returns <code>true</code> if a user is member of the given group.<p> * * @param dbc the current database context * @param username the name of the user to check * @param groupname the name of the group to check * @param readRoles if to read roles or groups * * @return <code>true</code>, if the user is in the group, <code>false</code> otherwise * * @throws CmsException if something goes wrong */ public boolean userInGroup(CmsDbContext dbc, String username, String groupname, boolean readRoles) throws CmsException { List<CmsGroup> groups = getGroupsOfUser(dbc, username, readRoles); for (int i = 0; i < groups.size(); i++) { CmsGroup group = groups.get(i); if (groupname.equals(group.getName()) || groupname.substring(1).equals(group.getName())) { return true; } } return false; }
/** * Returns <code>true</code> if a user is member of the given group.<p> * * @param dbc the current database context * @param username the name of the user to check * @param groupname the name of the group to check * @param readRoles if to read roles or groups * * @return <code>true</code>, if the user is in the group, <code>false</code> otherwise * * @throws CmsException if something goes wrong */ public boolean userInGroup(CmsDbContext dbc, String username, String groupname, boolean readRoles) throws CmsException { List groups = getGroupsOfUser(dbc, username, readRoles); for (int i = 0; i < groups.size(); i++) { CmsGroup group = (CmsGroup)groups.get(i); if (groupname.equals(group.getName()) || groupname.substring(1).equals(group.getName())) { return true; } } return false; }
/** * Returns the groups of an user filtered by the specified IP address.<p> * * @param dbc the current database context * @param username the name of the user * @param readRoles if to read roles or groups * * @return the groups of the given user, as a list of {@link CmsGroup} objects * * @throws CmsException if something goes wrong */ public List<CmsGroup> getGroupsOfUser(CmsDbContext dbc, String username, boolean readRoles) throws CmsException { return getGroupsOfUser(dbc, username, "", true, readRoles, false, dbc.getRequestContext().getRemoteAddress()); }
/** * Returns the groups of an user filtered by the specified IP address.<p> * * @param dbc the current database context * @param username the name of the user * @param readRoles if to read roles or groups * * @return the groups of the given user, as a list of {@link CmsGroup} objects * * @throws CmsException if something goes wrong */ public List getGroupsOfUser(CmsDbContext dbc, String username, boolean readRoles) throws CmsException { return getGroupsOfUser(dbc, username, "", true, readRoles, false, dbc.getRequestContext().getRemoteAddress()); }
getGroupsOfUser(dbc, user.getName(), "", true, true, false, dbc.getRequestContext().getRemoteAddress()));
/** * Returns the set of permissions of the current user for a given resource.<p> * * @param dbc the current database context * @param resource the resource * @param user the user * * @return bit set with allowed permissions * * @throws CmsException if something goes wrong */ public CmsPermissionSetCustom getPermissions(CmsDbContext dbc, CmsResource resource, CmsUser user) throws CmsException { CmsAccessControlList acList = getAccessControlList(dbc, resource, false); return acList.getPermissions(user, getGroupsOfUser(dbc, user.getName(), false), getRolesForUser(dbc, user)); }
/** * Returns the set of permissions of the current user for a given resource.<p> * * @param dbc the current database context * @param resource the resource * @param user the user * * @return bit set with allowed permissions * * @throws CmsException if something goes wrong */ public CmsPermissionSetCustom getPermissions(CmsDbContext dbc, CmsResource resource, CmsUser user) throws CmsException { CmsAccessControlList acList = getAccessControlList(dbc, resource, false); return acList.getPermissions(user, getGroupsOfUser(dbc, user.getName(), false), getRolesForUser(dbc, user)); }
List roles = new ArrayList(getGroupsOfUser( dbc, user.getName(),
List roles = new ArrayList(getGroupsOfUser( dbc, user.getName(),
getGroupsOfUser( dbc, user.getName(),
roles = m_driverManager.getGroupsOfUser( dbc, user.getName(),
Iterator itGroups = getGroupsOfUser(dbc, dbc.currentUser().getName(), false).iterator(); while (itGroups.hasNext()) { CmsGroup group = (CmsGroup)itGroups.next();
} else { boolean found = false; Iterator itGroups = getGroupsOfUser(dbc, dbc.currentUser().getName(), false).iterator(); while (itGroups.hasNext()) { CmsGroup group = (CmsGroup)itGroups.next();
} else { boolean found = false; Iterator<CmsGroup> itGroups = getGroupsOfUser(dbc, dbc.currentUser().getName(), false).iterator(); while (itGroups.hasNext()) { CmsGroup group = itGroups.next();
/** * Moves an user to the given organizational unit.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to move the user to * @param user the user that is to be moved to the organizational unit * * @throws CmsException if something goes wrong * * @see org.opencms.security.CmsOrgUnitManager#setUsersOrganizationalUnit(CmsObject, String, String) */ public void setUsersOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsUser user) throws CmsException { if (!getGroupsOfUser(dbc, user.getName(), false).isEmpty()) { throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_ORGUNIT_MOVE_USER_2, orgUnit.getName(), user.getName())); } // move the principal m_userDriver.setUsersOrganizationalUnit(dbc, orgUnit, user); // remove the principal from cache m_monitor.clearUserCache(user); // fire user modified event Map eventData = new HashMap(); eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString()); eventData.put(I_CmsEventListener.KEY_OU_NAME, user.getOuFqn()); eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_SET_OU); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData)); }
roles = m_driverManager.getGroupsOfUser( dbc, user.getName(),
throws CmsException { if (!getGroupsOfUser(dbc, user.getName(), false).isEmpty()) { throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ORGUNIT_MOVE_USER_2, orgUnit.getName(), user.getName()));
List result = null; try { result = m_driverManager.getGroupsOfUser( dbc, CmsOrganizationalUnit.removeLeadingSeparator(username),
List<CmsGroup> result = null; try { result = m_driverManager.getGroupsOfUser( dbc, CmsOrganizationalUnit.removeLeadingSeparator(username),
Iterator<CmsGroup> itGroups = getGroupsOfUser( dbc, username,