Examples of IAuthorizationPrincipal


Examples of org.jasig.portal.security.IAuthorizationPrincipal

     */
  public IChannelDefinition[] getChildChannels(ChannelCategory parent,
      IPerson person) {

    EntityIdentifier ei = person.getEntityIdentifier();
      IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
     
        String parentKey = String.valueOf(parent.getId());
        IEntityGroup parentGroup = GroupService.findGroup(parentKey);
        Set<IChannelDefinition> channelDefs = new HashSet<IChannelDefinition>();
        Iterator<IGroupMember> iter = parentGroup.getMembers();
        while (iter.hasNext()) {
            IGroupMember gm = (IGroupMember)iter.next();
            if (gm.isEntity()) {
                int channelPublishId = Integer.parseInt(gm.getKey());
              if(ap.canSubscribe(channelPublishId)) {
                channelDefs.add(getChannelDefinition(channelPublishId));
              }
            }
        }
        return (IChannelDefinition[])channelDefs.toArray(new IChannelDefinition[channelDefs.size()]);
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

 
  public IChannelDefinition[] getManageableChildChannels(ChannelCategory parent,
      IPerson person) {

    EntityIdentifier ei = person.getEntityIdentifier();
      IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
     
        String parentKey = String.valueOf(parent.getId());
        IEntityGroup parentGroup = GroupService.findGroup(parentKey);
        Set<IChannelDefinition> channelDefs = new HashSet<IChannelDefinition>();
        Iterator<IGroupMember> iter = parentGroup.getMembers();
        while (iter.hasNext()) {
            IGroupMember gm = (IGroupMember)iter.next();
            if (gm.isEntity()) {
                int channelPublishId = Integer.parseInt(gm.getKey());
              if(ap.canManage(channelPublishId)) {
                channelDefs.add(getChannelDefinition(channelPublishId));
              }
            }
        }
        return (IChannelDefinition[])channelDefs.toArray(new IChannelDefinition[channelDefs.size()]);
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

   * @param person a IPerson instance
   * @return instance of the IAuthorizationPrincipal for the IPerson
   */
  public static IAuthorizationPrincipal getAuthorizationPrincipal( IPerson person ) {
    EntityIdentifier pid = person.getEntityIdentifier();
    IAuthorizationPrincipal ap = null;
    try
    {
      ap = AuthorizationService.instance().newPrincipal(pid.getKey(), pid.getType());
    }
    catch (AuthorizationException ae)
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

  public static Document getChannelRegistry(IPerson person) throws PortalException {
    Document channelRegistry = getChannelRegistry();

    // Filter the channel registry according to permissions
    EntityIdentifier ei = person.getEntityIdentifier();
    IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());

    // Cycle through all the channels, looking for restricted channels
    NodeList nl = channelRegistry.getElementsByTagName("channel");
    for (int i = (nl.getLength()-1); i >=0; i--) {
      Element channel = (Element)nl.item(i);
      String channelPublishId = channel.getAttribute("chanID");
      channelPublishId = channelPublishId.startsWith("chan") ? channelPublishId.substring(4) : channelPublishId;

      // Take out channels which user doesn't have access to
      if (!ap.canSubscribe(Integer.parseInt(channelPublishId)))
        channel.getParentNode().removeChild(channel);
    }

    return channelRegistry;
  }
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

  public static Document getManageableChannelRegistry(IPerson person) throws PortalException {
    Document channelRegistry = getChannelRegistry();

    // Filter the channel registry according to permissions
    EntityIdentifier ei = person.getEntityIdentifier();
    IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());

    // Cycle through all the channels, looking for restricted channels
    NodeList nl = channelRegistry.getElementsByTagName("channel");
    for (int i = (nl.getLength()-1); i >=0; i--) {
      Element channel = (Element)nl.item(i);
      String channelPublishId = channel.getAttribute("chanID");
      channelPublishId = channelPublishId.startsWith("chan") ? channelPublishId.substring(4) : channelPublishId;

      // Take out channels which user doesn't have access to
      if (!ap.canManage(Integer.parseInt(channelPublishId)))
        channel.getParentNode().removeChild(channel);
    }

    return channelRegistry;
  }
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

    return states;
  }
 
  public boolean hasLifecyclePermission(IPerson person, ChannelLifecycleState state, List<JsonEntityBean> categories) {
    EntityIdentifier ei = person.getEntityIdentifier();
      IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
     
        final String activity;
        switch (state) {
            case APPROVED: {
                activity = IPermission.CHANNEL_MANAGER_APPROVED_ACTIVITY;
                break;
            }
            case CREATED: {
                activity = IPermission.CHANNEL_MANAGER_CREATED_ACTIVITY;
                break;
            }
            case PUBLISHED: {
                activity = IPermission.CHANNEL_MANAGER_ACTIVITY;
                break;
            }
            case EXPIRED: {
                activity = IPermission.CHANNEL_MANAGER_EXPIRED_ACTIVITY;
                break;
            }
            default: {
                throw new IllegalArgumentException("");
            }
        }
        if (ap.hasPermission("UP_FRAMEWORK", activity, "ALL_CHANNELS")) {
            logger.debug("Found permission for category ALL_CHANNELS and lifecycle state " + state.toString());
            return true;
        }
     
    for (JsonEntityBean category : categories) {
      if (ap.canManage(state, category.getId())) {
        logger.debug("Found permission for category " + category.getName() + " and lifecycle state " + state.toString());
        return true;
      }
    }
    logger.debug("No permission for lifecycle state " + state.toString());
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

            if (IPortletAdaptor.CONFIG.equals(portletMode)) {
                final IPerson person = this.personManager.getPerson(httpServletRequest);
               
                final EntityIdentifier ei = person.getEntityIdentifier();
                final AuthorizationService authorizationService = AuthorizationService.instance();
                final IAuthorizationPrincipal ap = authorizationService.newPrincipal(ei.getKey(), ei.getType());
               
                final IPortletDefinition portletDefinition = this.portletEntityRegistry.getParentPortletDefinition(portletWindow.getPortletEntityId());
                final IChannelDefinition channelDefinition = portletDefinition.getChannelDefinition();
               
                if (!ap.canConfigure(channelDefinition.getId())) {
                    throw new AuthorizationException(person.getUserName() + " does not have permission to render '" + channelDefinition.getFName() + "' in " + portletMode + " PortletMode");
                }
            }
           
            portletWindow.setPortletMode(portletMode);
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

    if ( obj == this )
        return true;
    if ( ! ( obj instanceof IAuthorizationPrincipal))
        return false;

    IAuthorizationPrincipal otherAP = (IAuthorizationPrincipal) obj;
    return this.getKey().equals(otherAP.getKey()) &&
           this.getType() == otherAP.getType();
}
View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

    if (StringUtils.isBlank(entityId)) {
      return new ModelAndView("jsonView", "error", "No entityId specified.");
    }

    EntityIdentifier ei = person.getEntityIdentifier();
      IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
      if (!ap.hasPermission("org.jasig.portal.channels.groupsmanager.CGroupsManager", "VIEW", entityId)) {
      throw new AuthorizationException("User " + person.getUserName() +
          " does not have view permissions on entity " + entityId);
    }

View Full Code Here

Examples of org.jasig.portal.security.IAuthorizationPrincipal

    public boolean canRender(final String userName, final String channelFName) {
        if (userName == null || channelFName == null) {
            return false;
        }
       
        final IAuthorizationPrincipal userPrincipal = this.getUserPrincipal(userName);
        if (userPrincipal == null) {
            return false;
        }
       
        final int channelId;
        try {
            final IChannelDefinition channelDefinition = this.channelRegistryStore.getChannelDefinition(channelFName);
            if (channelDefinition == null) {
                if (this.logger.isInfoEnabled()) {
                    this.logger.info("No ChannelDefinition for fname='" + channelFName + "', returning false.");
                }

                return false;
            }
           
            channelId = channelDefinition.getId();
        }
        catch (Exception e) {
            this.logger.warn("Could not find ChannelDefinition for fname='" + channelFName + "' while checking if user '" + userName + "' can render it. Returning FALSE.", e);
            return false;
        }
       
        return userPrincipal.canRender(channelId);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.