use of org.apereo.portal.security.IPerson 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.security.IPerson in project uPortal by Jasig.
the class PortletEntityRegistryImpl method getOrCreateDefaultPortletEntity.
@Override
public IPortletEntity getOrCreateDefaultPortletEntity(HttpServletRequest request, IPortletDefinitionId portletDefinitionId) {
Validate.notNull(request, "HttpServletRequest cannot be null");
Validate.notNull(portletDefinitionId, "portletDefinitionId cannot be null");
final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionId);
if (portletDefinition == null) {
throw new IllegalArgumentException("No portlet definition found for id '" + portletDefinitionId + "'.");
}
// Determine the appropriate portlet window ID for the definition
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
// Determine the subscribe ID
final String portletFName = portletDefinition.getFName();
final String layoutNodeId = userLayoutManager.getSubscribeId(portletFName);
if (layoutNodeId == null) {
throw new IllegalArgumentException("No layout node ID found for fname '" + portletFName + "'.");
}
this.logger.trace("Found layout node {} for portlet definition {}", layoutNodeId, portletFName);
final IPerson person = userInstance.getPerson();
final int personId = person.getID();
return this.getOrCreatePortletEntity(request, portletDefinitionId, layoutNodeId, personId);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PortletEntityRegistryImpl method getOrCreateDelegatePortletEntity.
@Override
public IPortletEntity getOrCreateDelegatePortletEntity(HttpServletRequest request, IPortletWindowId parentPortletWindowId, IPortletDefinitionId delegatePortletDefinitionId) {
// Create a special synthetic layout node ID for the delegate entity
final String layoutNodeId = PortletWindowIdStringUtils.convertToDelegateLayoutNodeId(parentPortletWindowId.toString());
// Grab the current user
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPerson person = userInstance.getPerson();
final int userId = person.getID();
// Use the general API, the only thing special is the layout node id
return getOrCreatePortletEntity(request, delegatePortletDefinitionId, layoutNodeId, userId);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PortletEntityRegistryImpl method getOrCreatePortletEntity.
@Override
public IPortletEntity getOrCreatePortletEntity(HttpServletRequest request, IUserInstance userInstance, String layoutNodeId) {
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
// Find the channel and portlet definitions
final IUserLayoutChannelDescription channelNode = (IUserLayoutChannelDescription) userLayoutManager.getNode(layoutNodeId);
if (channelNode == null) {
this.logger.warn("No layout node exists for id " + layoutNodeId + ", no portlet entity will be returned.");
return null;
}
final String channelPublishId = channelNode.getChannelPublishId();
final IPortletDefinition portletDefinition = this.getPortletDefinition(request, userInstance, channelPublishId);
if (portletDefinition != null) {
final IPerson person = userInstance.getPerson();
return this.getOrCreatePortletEntity(request, portletDefinition.getPortletDefinitionId(), layoutNodeId, person.getID());
}
// No permission to see the portlet
return null;
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PortletWindowRegistryImpl method storePortletWindow.
@Override
public void storePortletWindow(HttpServletRequest request, IPortletWindow portletWindow) {
if (isDisablePersistentWindowStates(request)) {
return;
}
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPerson person = userInstance.getPerson();
if (person.isGuest()) {
// Never persist things for the guest user, just rely on in-memory storage
return;
}
final IStylesheetDescriptor themeStylesheetDescriptor = this.getThemeStylesheetDescriptor(request);
final WindowState windowState = portletWindow.getWindowState();
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final WindowState entityWindowState = portletEntity.getWindowState(themeStylesheetDescriptor);
// If the window and entity states are different
if (windowState != entityWindowState && !windowState.equals(entityWindowState)) {
final WindowState defaultWindowState = this.getDefaultWindowState(themeStylesheetDescriptor);
// If a window state is set and is one of the persistent states set it on the entity
if (!defaultWindowState.equals(windowState) && persistentWindowStates.contains(windowState)) {
portletEntity.setWindowState(themeStylesheetDescriptor, windowState);
} else // If not remove the state from the entity
if (entityWindowState != null) {
portletEntity.setWindowState(themeStylesheetDescriptor, null);
}
// Persist the modified entity
this.portletEntityRegistry.storePortletEntity(request, portletEntity);
}
}
Aggregations