Search in sources :

Example 61 with IAuthorizationPrincipal

use of org.apereo.portal.security.IAuthorizationPrincipal in project uPortal by Jasig.

the class GroupAdministrationHelper method canDeleteGroup.

public boolean canDeleteGroup(IPerson currentUser, String target) {
    EntityIdentifier ei = currentUser.getEntityIdentifier();
    IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
    return (ap.hasPermission(IPermission.PORTAL_GROUPS, IPermission.DELETE_GROUP_ACTIVITY, target));
}
Also used : IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 62 with IAuthorizationPrincipal

use of org.apereo.portal.security.IAuthorizationPrincipal in project uPortal by Jasig.

the class GroupAdministrationHelper method canCreateMemberGroup.

public boolean canCreateMemberGroup(IPerson currentUser, String target) {
    EntityIdentifier ei = currentUser.getEntityIdentifier();
    IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
    return (ap.hasPermission(IPermission.PORTAL_GROUPS, IPermission.CREATE_GROUP_ACTIVITY, target));
}
Also used : IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 63 with IAuthorizationPrincipal

use of org.apereo.portal.security.IAuthorizationPrincipal in project uPortal by Jasig.

the class PersonLookupHelperImpl method findPerson.

/* (non-Javadoc)
     * @see org.apereo.portal.portlets.lookup.IPersonLookupHelper#findPerson(org.apereo.portal.security.IPerson, java.lang.String)
     */
@Override
public IPersonAttributes findPerson(final IPerson searcher, final String username) {
    // get the IAuthorizationPrincipal for the searching user
    final IAuthorizationPrincipal principal = getPrincipalForUser(searcher);
    // build a set of all possible user attributes the current user has
    // permission to view
    final Set<String> permittedAttributes = getPermittedAttributes(principal);
    // get the set of people matching the search query
    final IPersonAttributes person = this.personAttributeDao.getPerson(username);
    if (person == null) {
        logger.info("No user found with username matching " + username);
        return null;
    }
    // searcher has permissions to view
    return getVisiblePerson(principal, person, permittedAttributes);
}
Also used : IPersonAttributes(org.apereo.services.persondir.IPersonAttributes) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal)

Example 64 with IAuthorizationPrincipal

use of org.apereo.portal.security.IAuthorizationPrincipal in project uPortal by Jasig.

the class EntityService method getEntity.

public Entity getEntity(String entityType, String entityId, boolean populateChildren) {
    // get the EntityEnum for the specified entity type
    if (StringUtils.isBlank(entityType) && StringUtils.isBlank(entityId)) {
        return null;
    }
    EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
    // to locate it
    if (entityEnum.isGroup()) {
        // attempt to find the entity
        IEntityGroup entityGroup = GroupService.findGroup(entityId);
        if (entityGroup == null) {
            return null;
        } else {
            Entity entity = EntityFactory.createEntity(entityGroup, entityEnum);
            if (populateChildren) {
                Iterator<IGroupMember> members = entityGroup.getChildren().iterator();
                entity = populateChildren(entity, members);
            }
            IAuthorizationPrincipal authP = getPrincipalForEntity(entity);
            Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
            entity.setPrincipal(principal);
            return entity;
        }
    } else // otherwise use the getGroupMember method
    {
        IGroupMember groupMember = GroupService.getGroupMember(entityId, entityEnum.getClazz());
        if (groupMember == null || groupMember instanceof IEntityGroup) {
            return null;
        }
        Entity entity = EntityFactory.createEntity(groupMember, entityEnum);
        // the group member interface doesn't include the entity name, so
        // we'll need to look that up manually
        entity.setName(lookupEntityName(entity));
        if (EntityEnum.GROUP.toString().equals(entity.getEntityType()) || EntityEnum.PERSON.toString().equals(entity.getEntityType())) {
            IAuthorizationPrincipal authP = getPrincipalForEntity(entity);
            Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
            entity.setPrincipal(principal);
        }
        return entity;
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) EntityEnum(org.apereo.portal.portlets.groupselector.EntityEnum) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) Principal(org.apereo.portal.api.Principal) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PrincipalImpl(org.apereo.portal.api.PrincipalImpl)

Example 65 with IAuthorizationPrincipal

use of org.apereo.portal.security.IAuthorizationPrincipal in project uPortal by Jasig.

the class EntityService method getEntity.

public Entity getEntity(IGroupMember member) {
    if (member == null) {
        return null;
    }
    // get the type of this member entity
    EntityEnum entityEnum = getEntityType(member);
    // construct a new entity bean for this entity
    Entity entity;
    if (entityEnum.isGroup()) {
        entity = EntityFactory.createEntity((IEntityGroup) member, entityEnum);
    } else {
        entity = EntityFactory.createEntity(member, entityEnum);
    }
    // if the name hasn't been set yet, look up the entity name
    if (entity.getName() == null) {
        entity.setName(lookupEntityName(entity));
    }
    if (EntityEnum.GROUP.toString().equals(entity.getEntityType()) || EntityEnum.PERSON.toString().equals(entity.getEntityType())) {
        IAuthorizationPrincipal authP = getPrincipalForEntity(entity);
        Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
        entity.setPrincipal(principal);
    }
    return entity;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) EntityEnum(org.apereo.portal.portlets.groupselector.EntityEnum) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) Principal(org.apereo.portal.api.Principal) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PrincipalImpl(org.apereo.portal.api.PrincipalImpl)

Aggregations

IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)87 EntityIdentifier (org.apereo.portal.EntityIdentifier)31 IPerson (org.apereo.portal.security.IPerson)21 ArrayList (java.util.ArrayList)19 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)17 IEntityGroup (org.apereo.portal.groups.IEntityGroup)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 IGroupMember (org.apereo.portal.groups.IGroupMember)14 IPermission (org.apereo.portal.security.IPermission)14 HashSet (java.util.HashSet)12 JsonEntityBean (org.apereo.portal.layout.dlm.remoting.JsonEntityBean)9 ModelAndView (org.springframework.web.servlet.ModelAndView)9 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)8 AuthorizationServiceFacade (org.apereo.portal.services.AuthorizationServiceFacade)8 EntityEnum (org.apereo.portal.portlets.groupselector.EntityEnum)7 HashMap (java.util.HashMap)6 IUserInstance (org.apereo.portal.user.IUserInstance)5 Locale (java.util.Locale)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)4