Search in sources :

Example 46 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class PortletEntityRegistryImpl method checkPortletDefinitionRenderPermissions.

private IPortletDefinition checkPortletDefinitionRenderPermissions(IUserInstance userInstance, final IPortletDefinition portletDefinition) {
    if (portletDefinition == null) {
        return null;
    }
    final IPerson person = userInstance.getPerson();
    final EntityIdentifier ei = person.getEntityIdentifier();
    final IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
    if (ap.canRender(portletDefinition.getPortletDefinitionId().getStringId())) {
        return portletDefinition;
    }
    return null;
}
Also used : IPerson(org.apereo.portal.security.IPerson) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 47 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class UserGroupSkinMappingTransformerConfigurationSource method getSkinName.

@Override
protected String getSkinName(HttpServletRequest request) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IPerson person = userInstance.getPerson();
    final EntityIdentifier personIdentifier = person.getEntityIdentifier();
    final IGroupMember groupMember = GroupService.getGroupMember(personIdentifier);
    final Map<IGroupMember, String> groupMemberToSkinMapping = groupMemberToSkinMappingCreator.get();
    for (final Entry<IGroupMember, String> groupToSkinEntry : groupMemberToSkinMapping.entrySet()) {
        final IGroupMember group = groupToSkinEntry.getKey();
        if (group.isGroup() && groupMember.isDeepMemberOf(group.asGroup())) {
            final String skin = groupToSkinEntry.getValue();
            getLogger().debug("Setting skin override {} for {} because they are a member of {}", new Object[] { skin, person.getUserName(), group });
            // Cache the resolution
            return skin;
        }
    }
    getLogger().debug("No user {} is not a member of any configured groups, no skin override will be done", person.getUserName());
    return null;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) IGroupMember(org.apereo.portal.groups.IGroupMember) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 48 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class PortalWebFlowUtilsImpl method getCurrentPrincipal.

/* (non-Javadoc)
     * @see org.apereo.portal.spring.web.flow.IPortalWebFlowUtils#getCurrentPrincipal(org.springframework.webflow.context.ExternalContext)
     */
@Override
public IAuthorizationPrincipal getCurrentPrincipal(final ExternalContext externalContext) {
    final IPerson person = getCurrentPerson(externalContext);
    final EntityIdentifier ei = person.getEntityIdentifier();
    return AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
}
Also used : IPerson(org.apereo.portal.security.IPerson) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 49 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class PortalHttpServletRequestWrapper method isUserInRole.

/**
 * Determines whether or not the user is in the given role. The wrapped request is consulted
 * first then the {@link GroupService} is used to determine if a group exists for the specified
 * role and if the user is a member of it.
 *
 * <p>Role is case sensitive.
 *
 * @see
 *     org.apereo.portal.utils.web.AbstractHttpServletRequestWrapper#isUserInRole(java.lang.String)
 */
@Override
public boolean isUserInRole(String role) {
    if (super.getSession(false) == null) {
        return super.isUserInRole(role);
    }
    // Check the wrapped request first
    final boolean isUserInRole = super.isUserInRole(role);
    if (isUserInRole) {
        return true;
    }
    // Find the group for the role, if not found return false
    IEntityGroup groupForRole = GroupService.findGroup(role);
    if (groupForRole == null) {
        final EntityIdentifier[] results = GroupService.searchForGroups(role, GroupService.SearchMethod.DISCRETE, IPerson.class);
        if (results == null || results.length == 0) {
            return false;
        }
        if (results.length > 1) {
            this.logger.warn(results.length + " groups were found for role '" + role + "'. The first result will be used.");
        }
        IGroupMember member = GroupService.getGroupMember(results[0]);
        if (member == null || !member.isGroup()) {
            return false;
        }
        groupForRole = member.asGroup();
    }
    // Load the group information about the current user
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(this.getWrappedRequest());
    final IPerson person = userInstance.getPerson();
    final EntityIdentifier personEntityId = person.getEntityIdentifier();
    final IGroupMember personGroupMember = GroupService.getGroupMember(personEntityId);
    final boolean rslt = personGroupMember.isDeepMemberOf(groupForRole);
    logger.trace("Answering {} for isUserInRole where user='{}', role='{}', and groupForRole='{}'", rslt, person.getUserName(), role, groupForRole.getName());
    return rslt;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IUserInstance(org.apereo.portal.user.IUserInstance) IGroupMember(org.apereo.portal.groups.IGroupMember) IPerson(org.apereo.portal.security.IPerson) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 50 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class AbstractEntityCachingService method add.

/* (non-Javadoc)
     * @see org.apereo.portal.concurrency.IEntityCachingService#add(org.apereo.portal.IBasicEntity)
     */
@Override
public void add(IBasicEntity entity) throws CachingException {
    final EntityIdentifier entityIdentifier = entity.getEntityIdentifier();
    final Class<? extends IBasicEntity> entityType = entityIdentifier.getType();
    final IEntityCache entityCache = this.getCache(entityType);
    entityCache.add(entity);
}
Also used : IEntityCache(org.apereo.portal.concurrency.IEntityCache) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Aggregations

EntityIdentifier (org.apereo.portal.EntityIdentifier)93 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)31 HashSet (java.util.HashSet)25 ArrayList (java.util.ArrayList)24 IPerson (org.apereo.portal.security.IPerson)17 GroupsException (org.apereo.portal.groups.GroupsException)16 IEntityGroup (org.apereo.portal.groups.IEntityGroup)16 Set (java.util.Set)14 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)13 Iterator (java.util.Iterator)12 IGroupMember (org.apereo.portal.groups.IGroupMember)12 List (java.util.List)6 Element (net.sf.ehcache.Element)6 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)6 HashMap (java.util.HashMap)5 InvalidNameException (javax.naming.InvalidNameException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 GcFindGroups (edu.internet2.middleware.grouperClient.api.GcFindGroups)2