Search in sources :

Example 66 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class AuthorizationManager method addUserAuthorization.

@Override
public void addUserAuthorization(String username, String groupName, String roleName) throws ApsSystemException {
    try {
        Group group = (null != groupName) ? this.getGroupManager().getGroup(groupName) : null;
        if (null != groupName && null == group) {
            _logger.warn("invalid authorization -  invalid referenced group name");
            return;
        }
        Role role = (null != roleName) ? this.getRoleManager().getRole(roleName) : null;
        if (null != roleName && null == role) {
            _logger.warn("invalid authorization -  invalid referenced role name");
            return;
        }
        Authorization authorization = new Authorization(group, role);
        this.addUserAuthorization(username, authorization);
    } catch (Throwable t) {
        _logger.error("Error adding user authorization for user '{}'", username, t);
        throw new ApsSystemException("Error adding user authorization for user " + username, t);
    }
}
Also used : Role(com.agiletec.aps.system.services.role.Role) Group(com.agiletec.aps.system.services.group.Group) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 67 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class AuthorizationManager method getUserAuthorizations.

@Override
public List<Authorization> getUserAuthorizations(String username) throws ApsSystemException {
    List<Authorization> authorizations = null;
    try {
        Map<String, Group> groups = (Map<String, Group>) this.getAuthorityMap(this.getGroupManager().getGroups());
        Map<String, Role> roles = (Map<String, Role>) this.getAuthorityMap(this.getRoleManager().getRoles());
        authorizations = this.getAuthorizationDAO().getUserAuthorizations(username, groups, roles);
    } catch (Throwable t) {
        _logger.error("Error extracting user authorizations for user '{}'", username, t);
        throw new ApsSystemException("Error extracting user authorizations for user " + username, t);
    }
    return authorizations;
}
Also used : Role(com.agiletec.aps.system.services.role.Role) Group(com.agiletec.aps.system.services.group.Group) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 68 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class GroupManagerCacheWrapper method initCache.

@Override
public void initCache(IGroupDAO groupDAO) throws ApsSystemException {
    try {
        Cache cache = this.getCache();
        this.releaseCachedObjects(cache);
        Map<String, Group> groups = groupDAO.loadGroups();
        this.insertObjectsOnCache(cache, groups);
    } catch (Throwable t) {
        _logger.error("Error loading groups", t);
        throw new ApsSystemException("Error loading groups", t);
    }
}
Also used : Group(com.agiletec.aps.system.services.group.Group) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Cache(org.springframework.cache.Cache)

Aggregations

Group (com.agiletec.aps.system.services.group.Group)68 UserDetails (com.agiletec.aps.system.services.user.UserDetails)15 Role (com.agiletec.aps.system.services.role.Role)13 ArrayList (java.util.ArrayList)13 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)7 BeanComparator (org.apache.commons.beanutils.BeanComparator)5 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)4 HashSet (java.util.HashSet)4 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)4 RestServerError (org.entando.entando.aps.system.exception.RestServerError)4 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3 AttributeRole (com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)2 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)2 Authorization (com.agiletec.aps.system.services.authorization.Authorization)2 IAuthorizationManager (com.agiletec.aps.system.services.authorization.IAuthorizationManager)2 ExtendedResourceAction (com.agiletec.plugins.jacms.apsadmin.content.attribute.action.resource.ExtendedResourceAction)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2