Package org.jasig.portal.layout.dlm.remoting

Examples of org.jasig.portal.layout.dlm.remoting.JsonEntityBean


         
          // create a JsonEntityBean for each current category and add it
          // to our form bean's category list
          ChannelCategory[] categories = channelRegistryStore.getParentCategories(def);
          for (ChannelCategory cat : categories) {
            form.addCategory(new JsonEntityBean(cat));
          }

      try {
                IPermissionManager pm = AuthorizationService.instance().newPermissionManager(IChannelPublishingService.FRAMEWORK_OWNER);
                IAuthorizationPrincipal[] prins = pm.getAuthorizedPrincipals(IChannelPublishingService.SUBSCRIBER_ACTIVITY,
                        "CHAN_ID." + String.valueOf(form.getId()));
                for (int mp = 0; mp < prins.length; mp++) {
                  JsonEntityBean bean;
                 
                  // first assume this is a group
                  IEntityGroup group = GroupService.findGroup(prins[mp].getKey());
                  if (group != null) {
                      bean = new JsonEntityBean(group, EntityEnum.GROUP.toString());
                  }
                 
                  // if a matching group can't be found, try to find a matching
                  // non-group entity
                  else {
                      IGroupMember member = AuthorizationService.instance().getGroupMember(prins[mp]);
                      bean = new JsonEntityBean(member, EntityEnum.PERSON.toString());
                      String name = groupListHelper.lookupEntityName(bean);
                      bean.setName(name);
                  }
                 
                    form.addGroup(bean);
                }
      } catch (GroupsException e) {
        e.printStackTrace();
      }
    }
       
        // otherwise, if this is a new channel, pre-populate the categories
        // and groups with some reasonable defaults
        else {
         
      // pre-populate with top-level category
      IEntityGroup channelCategoriesGroup = GroupService.getDistinguishedGroup(GroupService.CHANNEL_CATEGORIES);
      form.addCategory(new JsonEntityBean(channelCategoriesGroup, groupListHelper.getEntityType(channelCategoriesGroup)));

      // pre-populate with top-level group
      IEntityGroup everyoneGroup = GroupService.getDistinguishedGroup(GroupService.EVERYONE);
      form.addGroup(new JsonEntityBean(everyoneGroup, groupListHelper.getEntityType(everyoneGroup)));
    }

    return form;
  }
View Full Code Here


      IPerson publisher) throws Exception {
   
    // create the group array from the form's group list
    IGroupMember[] groupMembers = new IGroupMember[form.getGroups().size()];
    for (int i = 0; i < groupMembers.length; i++) {
      JsonEntityBean bean = form.getGroups().get(i);
      EntityEnum entityEnum = EntityEnum.getEntityEnum(bean.getEntityType());
      if (entityEnum.isGroup()) {
        groupMembers[i] = GroupService.findGroup(bean.getId());
      } else {
              groupMembers[i] = GroupService.getGroupMember(bean.getId(), entityEnum.getClazz());
       
      }
    }
   
        // create the category array from the form's category list
View Full Code Here

          // create a JsonEntityBean for each current category and add it
          // to our form bean's category list
          Set<PortletCategory> categories = portletCategoryRegistry.getParentCategories(def);
          for (PortletCategory cat : categories) {
            form.addCategory(new JsonEntityBean(cat));
          }

      try {
                IPermissionManager pm = AuthorizationService.instance().newPermissionManager(IPortletPublishingService.FRAMEWORK_OWNER);
                IAuthorizationPrincipal[] prins =
                        pm.getAuthorizedPrincipals(IPortletPublishingService.SUBSCRIBER_ACTIVITY,
                        PermissionHelper.permissionTargetIdForPortletDefinition(def));
                for (int mp = 0; mp < prins.length; mp++) {
                  JsonEntityBean bean;

                  // first assume this is a group
                  IEntityGroup group = GroupService.findGroup(prins[mp].getKey());
                  if (group != null) {
                      bean = new JsonEntityBean(group, EntityEnum.GROUP);
                  }

                  // if a matching group can't be found, try to find a matching
                  // non-group entity
                  else {
                      IGroupMember member = AuthorizationService.instance().getGroupMember(prins[mp]);
                      bean = new JsonEntityBean(member, EntityEnum.PERSON);
                      String name = groupListHelper.lookupEntityName(bean);
                      bean.setName(name);
                  }

                    form.addGroup(bean);
                }
      } catch (GroupsException e) {
        e.printStackTrace();
      }
    }

        // otherwise, if this is a new portlet, pre-populate the categories
        // and groups with some reasonable defaults
        else {

      // pre-populate with top-level category
      IEntityGroup portletCategoriesGroup = GroupService.getDistinguishedGroup(GroupService.PORTLET_CATEGORIES);
      form.addCategory(new JsonEntityBean(portletCategoriesGroup, groupListHelper.getEntityType(portletCategoriesGroup)));

      // pre-populate with top-level group
      IEntityGroup everyoneGroup = GroupService.getDistinguishedGroup(GroupService.EVERYONE);
      form.addGroup(new JsonEntityBean(everyoneGroup, groupListHelper.getEntityType(everyoneGroup)));

    }

        /* TODO:  Service-Layer Security Reboot (great need of refactoring with a community-approved plan in place) */
        // User must have SOME FORM of lifecycle permission over AT LEAST ONE
View Full Code Here

            // in AT LEAST ONE previous category as well
            IPortletDefinition def = this.portletDefinitionRegistry.getPortletDefinition(form.getId());
            Set<PortletCategory> categories = portletCategoryRegistry.getParentCategories(def);
            List<JsonEntityBean> categoryBeans = new ArrayList<JsonEntityBean>();
            for (PortletCategory cat : categories) {
                categoryBeans.add(new JsonEntityBean(cat));
            }
            if (!hasLifecyclePermission(publisher, def.getLifecycleState(), categoryBeans)) {
                logger.warn("User '" + publisher.getUserName() +
                        "' attempted to save the following portlet without the previous MANAGE permission:  " + form);
                throw new SecurityException("Not Authorized");
            }
        }

        if (form.isNew() || portletDefinitionRegistry.getPortletDefinition(form.getId()).getType().getId() != form.getTypeId()) {
            // User must have access to the selected CPD if s/he selected it in this interaction
            final int selectedTypeId = form.getTypeId();
            final PortletPublishingDefinition cpd = portletPublishingDefinitionDao.getChannelPublishingDefinition(selectedTypeId);
            final Map<IPortletType, PortletPublishingDefinition> allowableCpds = this.getAllowableChannelPublishingDefinitions(publisher);
            if (!allowableCpds.containsValue(cpd)) {
                logger.warn("User '" + publisher.getUserName() +
                        "' attempted to administer the following portlet without the selected " +
                        IPermission.PORTLET_MANAGER_SELECT_PORTLET_TYPE + " permission:  " + form);
                throw new SecurityException("Not Authorized");
            }
        }

    // create the group array from the form's group list
    IGroupMember[] groupMembers = new IGroupMember[form.getGroups().size()];
    for (int i = 0; i < groupMembers.length; i++) {
      JsonEntityBean bean = form.getGroups().get(i);
      EntityEnum entityEnum = EntityEnum.getEntityEnum(bean.getEntityTypeAsString());
      if (entityEnum.isGroup()) {
        groupMembers[i] = GroupService.findGroup(bean.getId());
      } else {
              groupMembers[i] = GroupService.getGroupMember(bean.getId(), entityEnum.getClazz());
       
      }
    }

        // create the category array from the form's category list
View Full Code Here

                !permissionAdministrationHelper.canViewPermission(currentUser, target)) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
            return null;
        }

        JsonEntityBean bean = groupListHelper.getEntityForPrincipal(principal);

        if (bean != null) {
           
            IAuthorizationPrincipal p = groupListHelper.getPrincipalForEntity(bean);
           
            IPermission[] directPermissions = permissionStore.select(owner, p.getPrincipalString(), activity, target, null);
            this.authorizationService.removePermissions(directPermissions);
           
            assignment = assignment.toUpperCase();
            if (assignment.equals(Assignment.Type.GRANT.toString()) || assignment.equals(Assignment.Type.DENY.toString())) {
                IPermission permission = new PermissionImpl(owner);
                permission.setActivity(activity);
                permission.setPrincipal(bean.getPrincipalString());
                permission.setTarget(target);
                permission.setType(assignment);
                this.authorizationService.addPermissions(new IPermission[]{ permission });
            }
           
View Full Code Here

       
        // Build the set of existing assignments
        List<Assignment> flatAssignmentsList = new ArrayList<Assignment>();
        for (String principal : principals) {
           
            JsonEntityBean bean = groupListHelper.getEntityForPrincipal(principal);

            if (bean != null) {
               
                IAuthorizationPrincipal p = groupListHelper.getPrincipalForEntity(bean);
               
View Full Code Here

            while (it.hasNext()) {
                IEntityGroup group = (IEntityGroup) it.next();

                EntityEnum beanType = EntityEnum.getEntityEnum(group.getEntityType(), true);

                JsonEntityBean bean = new JsonEntityBean(group, beanType);
                Assignment parent = null;
                for (Assignment root : hierarchy) {
                    parent = root.findDecendentOrSelfIfExists(bean);
                    if (parent != null) {
                        // We found one...
View Full Code Here

            throw new IllegalArgumentException(msg);
        }
       
        List<Map<String,String>> rslt = new ArrayList<Map<String,String>>(data.length);
        for (IPermission p : data) {
            JsonEntityBean bean = getEntityBean(p.getPrincipal());

            Map<String,String> entry = new HashMap<String,String>();
            entry.put("owner", p.getOwner());
            entry.put("principalType", bean.getEntityTypeAsString());
            entry.put("principalName", bean.getName());
            entry.put("principalKey", p.getPrincipal());
            entry.put("activity", p.getActivity());
            entry.put("target", p.getTarget());
            entry.put("permissionType", p.getType());
           
View Full Code Here

        if (IEntityGroup.class.isAssignableFrom(type)) {
            entityType = "group";
        }

        // get the JsonEntityBean for this type and key
        JsonEntityBean bean = groupListHelper.getEntity(entityType, key, false);
        return bean;
    }
View Full Code Here

       
        Set<JsonEntityBean> entities = new HashSet<JsonEntityBean>();
       
        // add a permission for each member of the principals collection
        for (String principal : principals) {
            JsonEntityBean entity = groupListHelper.getEntityForPrincipal(principal);
            entities.add(entity);
        }

        return entities;
    }
View Full Code Here

TOP

Related Classes of org.jasig.portal.layout.dlm.remoting.JsonEntityBean

Copyright © 2018 www.massapicom. 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.