Class ScriptedPlatformHooks


  • public class ScriptedPlatformHooks
    extends PlatformHooks
    Scripted platform hooks
    Execute the platform and the grant hooks' common server script or dynamic Java class.
    PlatformHooks is used but GrantHooks is loaded as fallback for backward compatibility.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canPreviewDocument​(Grant g, DocumentDB doc)
      Hook called before document preview
      boolean changeScope​(Grant g, View home)
      This method is called when the user has changed its application scope
      boolean checkMFA​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      This method is called to check multi-factor authentication (MFA)
      void clear()
      Clear script data
      java.lang.String customAuth​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      This method is called before any standard authentication mechanism
      It can be used to return a custom authentication string from the incoming request
      void customAuthPage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String error)
      This method is called to generate a custom authentication page response.
      void customStartPage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      This method is called to generate a custom start page response.
      void downloadDocument​(Grant g, DocumentDB doc)
      Hook called after allowing document for download
      java.lang.String event​(Grant g, java.lang.String origin, java.lang.Object data)
      Hook called when receiving asynchronous event
      java.lang.String generatePassword​(Grant g)
      This method is called to generate a new password
      The default implementation generates a random password
      java.lang.String getAuthTokenInfo​(java.lang.String token)
      This method is called to process a custom token
      void init​(Grant g, Parameters params)
      This method is dedicated to be called when initializing presentation layers (in particular it is called by generic web UI main page display)
      boolean initMFA​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      This method is called to initialize multi-factor authentication (MFA)
      boolean isMenuEnable​(Grant g, java.lang.String domain, java.lang.String item)
      Hook to limit access to menu
      void logout​(Grant g)
      Hook called before the logout
      java.lang.String parseAuth​(Grant sys, SessionInfo info)
      This method is called for session info to extract user login from
      java.lang.String postAuth​(Grant sys, java.lang.String provider, java.lang.String login, boolean success)
      This method is called after processing internal authentication
      void postClearCache()
      Hook called after clear cache
      void postLoadGrant​(Grant g)
      This method is called after loading grant
      java.lang.String postLoadHome​(Grant g, java.lang.String h)
      This method is called after loading home page (and before assigning it)
      void postLoadLogEvents​(Grant g)
      This method is called after loading log events
      void postLoadMenu​(Grant g)
      This method is called after loading user's menu
      void postLoadProfile​(Grant g)
      This method is called after loading user profile data
      void postLoadResponsibilities​(Grant g)
      This method is called after loading user's menu
      java.util.List<java.lang.String> postLoadScope​(Grant g, java.util.List<java.lang.String> views)
      Hook to customize the available scopes
      void postLoadSystemParams​(Grant g)
      This method is called after loading of system parameters
      java.lang.String postPlatformInit​(Grant sys)
      This method is called after platform initialization
      java.util.List<SearchItem> postSearchIndex​(Grant g, java.util.List<SearchItem> rows)
      Hook to change the result after the search in index
      java.util.List<SearchItem> postSearchIndex​(Grant g, java.util.List<SearchItem> rows, java.util.List<java.lang.String> objects, int context, ObjectDB parent)
      Hook (extended) to change the result after the search in index
      java.lang.String preAuth​(Grant sys, java.lang.String provider, java.lang.String login, java.lang.String password)
      This method is called before processing internal authentication
      void preClearCache()
      Hook called before a clear cache
      void preLoadGrant​(Grant g)
      This method is called before loading grant
      void preLoadHome​(Grant g)
      This method is called before loading home page
      void preLoadLogEvents​(Grant g)
      This method is called before loading log events
      void preLoadMenu​(Grant g)
      This method is called before loading loading user's menu
      void preLoadProfile​(Grant g)
      This method is called before loading user profile data
      void preLoadResponsibilities​(Grant g)
      This method is called before loading loading user's responsibilities
      void preLoadSystemParams​(Grant g)
      This method is called before loading of system parameters
      java.lang.String preSearchIndex​(Grant g, java.lang.String search)
      Hook to change the query before the search in index
      java.lang.String preSearchIndex​(Grant g, java.lang.String search, java.util.List<java.lang.String> objects, int context, ObjectDB parent, java.util.Map<java.lang.String,​java.lang.String> filters)
      Hook (extended) to change the query before the search in index
      java.lang.String sendSMS​(Grant g, java.lang.String to, java.lang.String msg)
      This method is called to send SMS using a custom service
      void socialPost​(Grant g, java.lang.String postId, java.lang.String userId, java.lang.String message, boolean pub, java.lang.String target, java.lang.String rowId, java.lang.String level, java.lang.String status)
      Hook called on social post
      java.lang.String unitTests()
      Unit tests
      java.util.List<java.lang.String> validatePassword​(Grant g, java.lang.String password)
      This method is called before updating the password
      • Methods inherited from class com.simplicite.util.engine.PlatformHooksInterface

        postAuth, preAuth, socialPost
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScriptedPlatformHooks

        public ScriptedPlatformHooks()
    • Method Detail

      • clear

        public void clear()
        Clear script data
      • customStartPage

        public void customStartPage​(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response)
        This method is called to generate a custom start page response.
        Overrides:
        customStartPage in class PlatformHooks
        Parameters:
        request - HTTP request
        response - HTTP response
      • customAuthPage

        public void customAuthPage​(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response,
                                   java.lang.String error)
                            throws java.lang.Exception
        This method is called to generate a custom authentication page response.
        Overrides:
        customAuthPage in class PlatformHooks
        Parameters:
        request - HTTP request
        response - HTTP response
        error - Optional error message
        Throws:
        java.lang.Exception
      • customAuth

        public java.lang.String customAuth​(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
                                    throws java.lang.Exception
        This method is called before any standard authentication mechanism
        It can be used to return a custom authentication string from the incoming request
        Overrides:
        customAuth in class PlatformHooks
        Parameters:
        request - HTTP request
        response - HTTP response
        Returns:
        Login or null
        Throws:
        java.lang.Exception
      • getAuthTokenInfo

        public java.lang.String getAuthTokenInfo​(java.lang.String token)
        This method is called to process a custom token
        Overrides:
        getAuthTokenInfo in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        token - Token to process
        Returns:
        Token info : JSONObject as String object i.e. : {'login':'tokenLogin', 'expiry':exp_date, 'valid':true}
      • initMFA

        public boolean initMFA​(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws java.lang.Exception
        This method is called to initialize multi-factor authentication (MFA)
        Overrides:
        initMFA in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        request - HTTP request
        response - HTTP response
        Returns:
        True if MAF initialization is successful
        Throws:
        java.lang.Exception
      • checkMFA

        public boolean checkMFA​(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws java.lang.Exception
        This method is called to check multi-factor authentication (MFA)
        Overrides:
        checkMFA in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        request - HTTP request
        response - HTTP response
        Returns:
        True if MFA check is successful
        Throws:
        java.lang.Exception
      • sendSMS

        public java.lang.String sendSMS​(Grant g,
                                        java.lang.String to,
                                        java.lang.String msg)
                                 throws java.lang.Exception
        This method is called to send SMS using a custom service
        Overrides:
        sendSMS in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
        to - To phone number (e.g. +33144556677)
        msg - Message (160 characters max)
        Returns:
        SMS ID or null if there was an error
        Throws:
        java.lang.Exception - in case of unexpected error
      • postPlatformInit

        public java.lang.String postPlatformInit​(Grant sys)
        This method is called after platform initialization
        Overrides:
        postPlatformInit in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        sys - System admin grant
      • parseAuth

        public java.lang.String parseAuth​(Grant sys,
                                          SessionInfo info)
        This method is called for session info to extract user login from
        Overrides:
        parseAuth in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        sys - System admin grant
        info - Session info
        Returns:
        Login
      • preAuth

        public java.lang.String preAuth​(Grant sys,
                                        java.lang.String provider,
                                        java.lang.String login,
                                        java.lang.String password)
        This method is called before processing internal authentication
        Overrides:
        preAuth in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        sys - System admin grant
        provider - Authentication provider
        login - Authentication string
        password - Authentication password
        Returns:
        Error message to cancel the authentication or null
      • postAuth

        public java.lang.String postAuth​(Grant sys,
                                         java.lang.String provider,
                                         java.lang.String login,
                                         boolean success)
        This method is called after processing internal authentication
        Overrides:
        postAuth in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        sys - System admin grant
        provider - Authentication provider
        login - Authentication string
        success - Authentication success?
        Returns:
        Error message to cancel the authentication or null
      • preLoadGrant

        public void preLoadGrant​(Grant g)
        This method is called before loading grant
        Overrides:
        preLoadGrant in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • postLoadGrant

        public void postLoadGrant​(Grant g)
        This method is called after loading grant
        Overrides:
        postLoadGrant in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • preLoadSystemParams

        public void preLoadSystemParams​(Grant g)
        This method is called before loading of system parameters
        Overrides:
        preLoadSystemParams in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • postLoadSystemParams

        public void postLoadSystemParams​(Grant g)

        This method is called after loading of system parameters

        Overrides:
        postLoadSystemParams in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • preLoadProfile

        public void preLoadProfile​(Grant g)
        This method is called before loading user profile data
        Overrides:
        preLoadProfile in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • postLoadProfile

        public void postLoadProfile​(Grant g)
        This method is called after loading user profile data
        Overrides:
        postLoadProfile in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • preLoadResponsibilities

        public void preLoadResponsibilities​(Grant g)
        This method is called before loading loading user's responsibilities
        Overrides:
        preLoadResponsibilities in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • postLoadResponsibilities

        public void postLoadResponsibilities​(Grant g)
        This method is called after loading user's menu
        Overrides:
        postLoadResponsibilities in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • preLoadMenu

        public void preLoadMenu​(Grant g)
        This method is called before loading loading user's menu
        Overrides:
        preLoadMenu in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • postLoadMenu

        public void postLoadMenu​(Grant g)
        This method is called after loading user's menu
        Overrides:
        postLoadMenu in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • preLoadHome

        public void preLoadHome​(Grant g)
        This method is called before loading home page
        Overrides:
        preLoadHome in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • postLoadHome

        public java.lang.String postLoadHome​(Grant g,
                                             java.lang.String h)
        This method is called after loading home page (and before assigning it)
        Overrides:
        postLoadHome in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
        h - Home page name
        Returns:
        New home page name or null if no home page
      • preLoadLogEvents

        public void preLoadLogEvents​(Grant g)
        This method is called before loading log events
        Overrides:
        preLoadLogEvents in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • postLoadLogEvents

        public void postLoadLogEvents​(Grant g)
        This method is called after loading log events
        Overrides:
        postLoadLogEvents in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • generatePassword

        public java.lang.String generatePassword​(Grant g)
        This method is called to generate a new password
        The default implementation generates a random password
        Overrides:
        generatePassword in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • validatePassword

        public java.util.List<java.lang.String> validatePassword​(Grant g,
                                                                 java.lang.String password)
        This method is called before updating the password
        Overrides:
        validatePassword in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
        password - Password
      • init

        public void init​(Grant g,
                         Parameters params)
        This method is dedicated to be called when initializing presentation layers (in particular it is called by generic web UI main page display)
        Overrides:
        init in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
        params - Parameters
      • changeScope

        public boolean changeScope​(Grant g,
                                   View home)
        This method is called when the user has changed its application scope
        Overrides:
        changeScope in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
        home - new home page
        Returns:
        true on success
      • postLoadScope

        public java.util.List<java.lang.String> postLoadScope​(Grant g,
                                                              java.util.List<java.lang.String> views)
        Hook to customize the available scopes
        Overrides:
        postLoadScope in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        views - List of home pages based on user rights
        Returns:
        Available views
      • isMenuEnable

        public boolean isMenuEnable​(Grant g,
                                    java.lang.String domain,
                                    java.lang.String item)
        Hook to limit access to menu
        Overrides:
        isMenuEnable in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        domain - Domain name
        item - Optional Object or Process name
        Returns:
        true when menu item can be displayed
      • preSearchIndex

        public java.lang.String preSearchIndex​(Grant g,
                                               java.lang.String search)
        Hook to change the query before the search in index
        Overrides:
        preSearchIndex in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        search - User query
        Returns:
        Overridden query
      • preSearchIndex

        public java.lang.String preSearchIndex​(Grant g,
                                               java.lang.String search,
                                               java.util.List<java.lang.String> objects,
                                               int context,
                                               ObjectDB parent,
                                               java.util.Map<java.lang.String,​java.lang.String> filters)
        Hook (extended) to change the query before the search in index
        Overrides:
        preSearchIndex in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        search - User query
        objects - Optional list of objects to limit search
        context - Search context
        parent - Optional parent context (OBJECT_REFSELECT)
        filters - Optional field filters on objects
        Returns:
        Overridden query
      • postSearchIndex

        public java.util.List<SearchItem> postSearchIndex​(Grant g,
                                                          java.util.List<SearchItem> rows)
        Hook to change the result after the search in index
        Overrides:
        postSearchIndex in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        rows - search result
        Returns:
        Overridden result
      • postSearchIndex

        public java.util.List<SearchItem> postSearchIndex​(Grant g,
                                                          java.util.List<SearchItem> rows,
                                                          java.util.List<java.lang.String> objects,
                                                          int context,
                                                          ObjectDB parent)
        Hook (extended) to change the result after the search in index
        Overrides:
        postSearchIndex in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        rows - search result
        objects - Optional list of objects to limit search
        context - Search context
        parent - Optional parent context (OBJECT_REFSELECT)
        Returns:
        Overridden result
      • canPreviewDocument

        public boolean canPreviewDocument​(Grant g,
                                          DocumentDB doc)
        Hook called before document preview
        Overrides:
        canPreviewDocument in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        doc - Document
        Returns:
        true if preview is permitted
      • downloadDocument

        public void downloadDocument​(Grant g,
                                     DocumentDB doc)
        Hook called after allowing document for download
        Overrides:
        downloadDocument in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        doc - Document
      • event

        public java.lang.String event​(Grant g,
                                      java.lang.String origin,
                                      java.lang.Object data)
                               throws java.lang.Exception
        Hook called when receiving asynchronous event
        Overrides:
        event in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - User rights
        origin - Event origin
        data - Event data
        Returns:
        data Event data
        Throws:
        java.lang.Exception
      • socialPost

        public void socialPost​(Grant g,
                               java.lang.String postId,
                               java.lang.String userId,
                               java.lang.String message,
                               boolean pub,
                               java.lang.String target,
                               java.lang.String rowId,
                               java.lang.String level,
                               java.lang.String status)
        Hook called on social post
        Overrides:
        socialPost in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
        postId - Social post row ID
        userId - Author row ID
        message - Posted message
        pub - Public or private?
        target - Optional object name
        rowId - Optional object row ID
        level - Optional level of audit post
        status - Optional status of audit post
      • logout

        public void logout​(Grant g)
        Hook called before the logout
        Overrides:
        logout in class com.simplicite.util.engine.PlatformHooksInterface
        Parameters:
        g - Grant
      • preClearCache

        public void preClearCache()
        Hook called before a clear cache
        Overrides:
        preClearCache in class com.simplicite.util.engine.PlatformHooksInterface
      • postClearCache

        public void postClearCache()
        Hook called after clear cache
        Overrides:
        postClearCache in class com.simplicite.util.engine.PlatformHooksInterface
      • unitTests

        public java.lang.String unitTests()
        Unit tests
        Overrides:
        unitTests in class com.simplicite.util.engine.PlatformHooksInterface
        Returns:
        Unit tests results