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;
}
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;
}
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());
}
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;
}
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);
}
Aggregations