コード例 #1
0
  /** Gets all roles available. */
  public List<InfoGluePrincipalBean> getPrincipalsWithGroup(String groupName) {
    if (!ServerNodeController.getController().getIsIPAllowed(getRequest())) {
      logger.error(
          "A client with IP "
              + getRequest().getRemoteAddr()
              + " was denied access to the webservice. Could be a hack attempt or you have just not configured the allowed IP-addresses correct.");
      return null;
    }

    List<InfoGluePrincipalBean> users = new ArrayList<InfoGluePrincipalBean>();

    logger.info("***************************************");
    logger.info("Getting all principals through webservice..");
    logger.info("***************************************");

    try {
      List principalList = GroupControllerProxy.getController().getInfoGluePrincipals(groupName);

      Iterator principalListIterator = principalList.iterator();
      while (principalListIterator.hasNext()) {
        InfoGluePrincipal principal = (InfoGluePrincipal) principalListIterator.next();
        InfoGluePrincipalBean bean = new InfoGluePrincipalBean();
        bean.setName(principal.getName());
        bean.setDisplayName(principal.getDisplayName());
        bean.setEmail(principal.getEmail());
        bean.setFirstName(principal.getFirstName());
        bean.setLastName(principal.getLastName());
        bean.setAdministrator(false);
        bean.setMetaInformation(principal.getMetaInformation());

        List groups = new ArrayList();
        Iterator groupsListIterator = principal.getGroups().iterator();
        while (groupsListIterator.hasNext()) {
          InfoGlueGroup group = (InfoGlueGroup) groupsListIterator.next();
          InfoGlueGroupBean groupBean = new InfoGlueGroupBean();
          groupBean.setName(group.getName());
          groupBean.setDisplayName(group.getDisplayName());
          groupBean.setDescription(group.getDescription());
          groups.add(groupBean);
        }
        bean.setGroups(groups);

        List roles = new ArrayList();
        Iterator rolesListIterator = principal.getRoles().iterator();
        while (rolesListIterator.hasNext()) {
          InfoGlueRole role = (InfoGlueRole) rolesListIterator.next();
          InfoGlueRoleBean roleBean = new InfoGlueRoleBean();
          roleBean.setName(role.getName());
          roleBean.setDisplayName(role.getDisplayName());
          roleBean.setDescription(role.getDescription());
          roles.add(roleBean);
        }
        bean.setRoles(roles);

        users.add(bean);
      }
    } catch (Exception e) {
      logger.error(
          "En error occurred when we tried to create a new contentVersion:" + e.getMessage(), e);
    }

    return users;
  }
コード例 #2
0
  /** Gets a principal. */
  public InfoGluePrincipalBean getPrincipal(String userName) {
    if (!ServerNodeController.getController().getIsIPAllowed(getRequest())) {
      logger.error(
          "A client with IP "
              + getRequest().getRemoteAddr()
              + " was denied access to the webservice. Could be a hack attempt or you have just not configured the allowed IP-addresses correct.");
      return null;
    }

    InfoGluePrincipalBean bean = null;

    logger.info("***************************************");
    logger.info("Getting all principals through webservice..");
    logger.info("***************************************");

    try {
      InfoGluePrincipal principal = UserControllerProxy.getController().getUser(userName);

      if (principal != null) {
        bean = new InfoGluePrincipalBean();
        bean.setName(principal.getName());
        bean.setDisplayName(principal.getDisplayName());
        bean.setEmail(principal.getEmail());
        bean.setFirstName(principal.getFirstName());
        bean.setLastName(principal.getLastName());
        bean.setAdministrator(false);
        bean.setMetaInformation(principal.getMetaInformation());

        List groups = new ArrayList();
        Iterator groupsListIterator = principal.getGroups().iterator();
        while (groupsListIterator.hasNext()) {
          InfoGlueGroup group = (InfoGlueGroup) groupsListIterator.next();
          InfoGlueGroupBean groupBean = new InfoGlueGroupBean();
          groupBean.setName(group.getName());
          groupBean.setDisplayName(group.getDisplayName());
          groupBean.setDescription(group.getDescription());
          groups.add(groupBean);
        }
        bean.setGroups(groups);

        List roles = new ArrayList();
        Iterator rolesListIterator = principal.getRoles().iterator();
        while (rolesListIterator.hasNext()) {
          InfoGlueRole role = (InfoGlueRole) rolesListIterator.next();
          InfoGlueRoleBean roleBean = new InfoGlueRoleBean();
          roleBean.setName(role.getName());
          roleBean.setDisplayName(role.getDisplayName());
          roleBean.setDescription(role.getDescription());
          roles.add(roleBean);
        }
        bean.setRoles(roles);
      } else {
        logger.error("User asked for was not in the system:" + userName);
        bean = new InfoGluePrincipalBean();
        bean.setName(userName);
        bean.setDisplayName(userName);
        bean.setEmail("*****@*****.**");
        bean.setFirstName("Not valid user");
        bean.setLastName("");
        bean.setAdministrator(false);

        List groups = new ArrayList();
        bean.setGroups(groups);

        List roles = new ArrayList();
        bean.setRoles(roles);
      }
    } catch (Exception e) {
      logger.error(
          "En error occurred when we tried to create a new contentVersion:" + e.getMessage(), e);
    }

    return bean;
  }