⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standardservice.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }

    /**
    * Deletion method of the <i>JBTop</i> business object.
    *
    * @param jbTop  Business object to delete.
    * @param userContext  Context of the user.
    *
    * @throws ServiceException - if an error occurs,
    * or the connected user has insufficient access rights.
    */
    public static void delete(JBTop jbTop, UserContext userContext)
                       throws ServiceException
    {
        if (!AclsService.isDeletionEnabled(jbTop, userContext))
        {
            // have no rights to do this
            throw new InsufficientAccessRights(MessageUtil.formatMessage("MSG_INSUFFICIENT_ACCESS_RIGHTS",
                                                                         SERVICE_NAME
                                                                        )
                                              );
        }

        try
        {
            // trigger pre-op
            TriggersService.launchPreOp(TriggersService.TYPE_DELETE, jbTop,
                                        userContext
                                       );
            PersistenceLDAP.delete(jbTop, userContext);

            // trigger post-op
            TriggersService.launchPostOp(TriggersService.TYPE_DELETE, jbTop,
                                         userContext
                                        );
        }
        catch (Exception pe)
        {
            _logger.error(pe.getMessage());
            _logger.debug("Trace", pe);

            throw new ServiceException(pe.getMessage(), pe);
        }
    }

    /**
    * Creation method of the <i>JBTop</i> business object.
    *
    * @param jbTop  Business object to create.
    * @param userContext  Context of the user.
    *
    * @throws ServiceException - if an error occurs,
    * or the connected user has insufficient access rights.
    */
    public static void create(JBTop jbTop, UserContext userContext)
                       throws ServiceException
    {
        if (!AclsService.isCreationEnabled(jbTop, userContext))
        {
            // have no rights to do this
            throw new InsufficientAccessRights(MessageUtil.formatMessage("MSG_INSUFFICIENT_ACCESS_RIGHTS",
                                                                         SERVICE_NAME
                                                                        )
                                              );
        }

        try
        {
            // trigger pre-op
            TriggersService.launchPreOp(TriggersService.TYPE_CREATE, jbTop,
                                        userContext
                                       );
            PersistenceLDAP.create(jbTop, userContext);

            // trigger post-op
            TriggersService.launchPostOp(TriggersService.TYPE_CREATE, jbTop,
                                         userContext
                                        );
        }
        catch (Exception pe)
        {
            _logger.error(pe.getMessage());
            _logger.debug("Trace", pe);

            throw new ServiceException(pe.getMessage(), pe);
        }
    }

    /**
     * Search method.
     * The first argument is a set of <i>opiam.admin.faare.service.javabeans.SearchArgument</i> class objects.
     * This argument is made by the  getSearchArgument() method of the StrutsService service.<br>
     * If there are several search arguments, the method does an union between the results
     * corresponding to every searchs.
     *
     * @param arguments    SearchArguments list.
     * @param userContext  Context of the user.
     *
     * @return The result of the search.
     *
     * @throws ServiceException  if an error occurs.
     */
    public static SearchResult search(List arguments, UserContext userContext)
                               throws ServiceException
    {
        try
        {
            List resultList = new ArrayList();
            SearchResult tmpResult =
                PersistenceLDAP.search(arguments, userContext);

            Iterator it = tmpResult.getLResults().iterator();
            JBTop jbTop = null;

            while (it.hasNext())
            {
                jbTop = (JBTop) it.next();

                if (AclsService.isVisualisationEnabled(jbTop, userContext))
                {
                    resultList.add(jbTop);
                }
            }

            return new SearchResult(resultList, tmpResult.isSizeLimit());
        }
        catch (PersistenceException e)
        {
            _logger.info("error in StandardService.search" + e.getMessage());
            throw new ServiceException("error in StandardService.search" +
                                       e.getMessage()
                                      );
        }
    }

    //DW/2584/BeginPatch
    //DW/2595 : sortField devient un tableau

    /**
     * Search method.
     *
     * @param arguments   SearchArguments list
     * @param userContext Context of the user.
     * @param sortFields  Sorting attributes.
     *
     * @return The result of the search.
     *
     * @see search(List arguments, UserContext userContext).
     *
     * @throws ServiceException  if an error occurs.
     */
    public static SearchResult search(List arguments, UserContext userContext,
                                      String[] sortFields
                                     ) throws ServiceException
    {
        try
        {
            List resultList = new ArrayList();
            SearchResult tmpResult;

            if (userContext.getLdapConfig().isServerSortEnabled())
            {
                tmpResult =
                    PersistenceLDAP.search(arguments, userContext, sortFields);
            }
            else
            {
                tmpResult = PersistenceLDAP.search(arguments, userContext);

                if ((tmpResult != null) && (tmpResult.getLResults() != null) &&
                        (tmpResult.getLResults().size() > 0)
                   )
                {
                    Object obj = tmpResult.getLResults().get(0);
                    SortService.sort(tmpResult.getLResults(), obj.getClass(),
                                     sortFields, userContext
                                    );
                }
            }

            Iterator it = tmpResult.getLResults().iterator();
            JBTop jbTop = null;

            while (it.hasNext())
            {
                jbTop = (JBTop) it.next();

                if (AclsService.isVisualisationEnabled(jbTop, userContext))
                {
                    resultList.add(jbTop);
                }
            }

            return new SearchResult(resultList, tmpResult.isSizeLimit());
        }
        catch (PersistenceException e)
        {
            _logger.info("error in StandardService.search" + e.getMessage());
            throw new ServiceException("error in StandardService.search" +
                                       e.getMessage()
                                      );
        }
    }

    //DW/2584/EndPatch

    /**
     * This method tries to set up a connection for the user account which the context is given in argument.<br>
     * The login is the attribute defined in the profiles_config.xml by the <i>logon</i> resource name.
     *
     * @param login  Login of the user.
     * @param pwd    Password of the user.
     * @param userContext Context of the user.
     *
     * @throws ServiceException - if an error occurs or if one of the arguments is null.
     */
    public static void logon(String login, String pwd, UserContext userContext)
                      throws ServiceException
    {
        _logger.debug("logon, pour login : " + login);

        //Attention cette m閠hode doit renvoyer un dn et non pas un JBTop
        _logger.debug("Logon");

        if (login == null)
        {
            throw new ServiceException(MessageUtil.formatMessage("MSG_ARGUMENT_NULL"));
        }

        if ((pwd == null) || (pwd.trim().compareToIgnoreCase("") == 0))
        {
            throw new ServiceException(MessageUtil.formatMessage("MSG_ARGUMENT_NULL"));
        }

        if (userContext == null)
        {
            throw new ServiceException(MessageUtil.formatMessage("MSG_ARGUMENT_NULL"));
        }

        logon(login, pwd, null, userContext);
    }

    /**
     * This method tries to set up a connection for the user account
     * which the context is given in argument.<br>
     *
     * @param login  Login of the user.
     * @param pwd    Password of the user.
     * @param ldapConfig  Ldap Directory access configuration.
     * @param userContext Context of the user.
     *
     * @throws ServiceException  if error occurs or if one of the arguments is null.<br>
     * AuthenticationFailureException if the authentication fails.
     */
    public static void logon(String login, String pwd, JBLdapConfig ldapConfig,
                             UserContext userContext
                            ) throws ServiceException
    {
        _logger.debug("logon JBLdapConfig, pour login : " + login);

        //Attention cette m閠hode doit renvoyer un dn et non pas un JBTop
        _logger.debug("Logon JBLdapConfig");

        if (login == null)
        {
            throw new ServiceException(MessageUtil.formatMessage("MSG_ARGUMENT_NULL"));
        }

        if ((pwd == null) || (pwd.trim().compareToIgnoreCase("") == 0))
        {
            throw new ServiceException(MessageUtil.formatMessage("MSG_ARGUMENT_NULL"));
        }

        if (userContext == null)
        {
            throw new ServiceException(MessageUtil.formatMessage("MSG_ARGUMENT_NULL"));
        }

        userContext.setLoggedIn(false);
        userContext.setLogin(login);
        userContext.setPwd(pwd);

        try
        {
            //les connections anonymes doivent 阾re rejett閑s auparavant
            // increment the logon Counter (in session only), which means
            // if the user kills the browser and redo the logon, the counter
            // will start at 0.
            userContext.incrementLogonCounter();

            //On se connecte avec le dn r閏up閞

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -