Package com.simplicite.util
Class ScriptedPlatformHooks
- java.lang.Object
-
- com.simplicite.util.engine.PlatformHooksInterface
-
- com.simplicite.util.PlatformHooks
-
- com.simplicite.util.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.
-
-
Constructor Summary
Constructors Constructor Description ScriptedPlatformHooks()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canPreviewDocument(Grant g, DocumentDB doc)
Hook called before document previewboolean
changeScope(Grant g, View home)
This method is called when the user has changed its application scopeboolean
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 datajava.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 requestvoid
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 downloadjava.lang.String
event(Grant g, java.lang.String origin, java.lang.Object data)
Hook called when receiving asynchronous eventjava.lang.String
generatePassword(Grant g)
This method is called to generate a new password
The default implementation generates a random passwordjava.lang.String
getAuthTokenInfo(java.lang.String token)
This method is called to process a custom tokenvoid
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 menuvoid
logout(Grant g)
Hook called before the logoutjava.lang.String
parseAuth(Grant sys, SessionInfo info)
This method is called for session info to extract user login fromjava.lang.String
postAuth(Grant sys, java.lang.String provider, java.lang.String login, boolean success)
This method is called after processing internal authenticationvoid
postClearCache()
Hook called after clear cachevoid
postLoadGrant(Grant g)
This method is called after loading grantjava.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 eventsvoid
postLoadMenu(Grant g)
This method is called after loading user's menuvoid
postLoadProfile(Grant g)
This method is called after loading user profile datavoid
postLoadResponsibilities(Grant g)
This method is called after loading user's menujava.util.List<java.lang.String>
postLoadScope(Grant g, java.util.List<java.lang.String> views)
Hook to customize the available scopesvoid
postLoadSystemParams(Grant g)
This method is called after loading of system parametersjava.lang.String
postPlatformInit(Grant sys)
This method is called after platform initializationjava.util.List<SearchItem>
postSearchIndex(Grant g, java.util.List<SearchItem> rows)
Hook to change the result after the search in indexjava.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 indexjava.lang.String
preAuth(Grant sys, java.lang.String provider, java.lang.String login, java.lang.String password)
This method is called before processing internal authenticationvoid
preClearCache()
Hook called before a clear cachevoid
preLoadGrant(Grant g)
This method is called before loading grantvoid
preLoadHome(Grant g)
This method is called before loading home pagevoid
preLoadLogEvents(Grant g)
This method is called before loading log eventsvoid
preLoadMenu(Grant g)
This method is called before loading loading user's menuvoid
preLoadProfile(Grant g)
This method is called before loading user profile datavoid
preLoadResponsibilities(Grant g)
This method is called before loading loading user's responsibilitiesvoid
preLoadSystemParams(Grant g)
This method is called before loading of system parametersjava.lang.String
preSearchIndex(Grant g, java.lang.String search)
Hook to change the query before the search in indexjava.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 indexjava.lang.String
sendSMS(Grant g, java.lang.String to, java.lang.String msg)
This method is called to send SMS using a custom servicevoid
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 postjava.lang.String
unitTests()
Unit testsjava.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.PlatformHooks
clearCache, getInstance, init
-
-
-
-
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 classPlatformHooks
- Parameters:
request
- HTTP requestresponse
- 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 classPlatformHooks
- Parameters:
request
- HTTP requestresponse
- HTTP responseerror
- 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 classPlatformHooks
- Parameters:
request
- HTTP requestresponse
- 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 classcom.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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
request
- HTTP requestresponse
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
request
- HTTP requestresponse
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Grantto
- 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 classcom.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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
sys
- System admin grantinfo
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
sys
- System admin grantprovider
- Authentication providerlogin
- Authentication stringpassword
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
sys
- System admin grantprovider
- Authentication providerlogin
- Authentication stringsuccess
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Grant
-
postLoadGrant
public void postLoadGrant(Grant g)
This method is called after loading grant- Overrides:
postLoadGrant
in classcom.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 classcom.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 classcom.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 classcom.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 classcom.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 classcom.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 classcom.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 classcom.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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Grant
-
preLoadHome
public void preLoadHome(Grant g)
This method is called before loading home page- Overrides:
preLoadHome
in classcom.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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Granth
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Grant
-
postLoadLogEvents
public void postLoadLogEvents(Grant g)
This method is called after loading log events- Overrides:
postLoadLogEvents
in classcom.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 classcom.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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Grantpassword
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Grantparams
- Parameters
-
changeScope
public boolean changeScope(Grant g, View home)
This method is called when the user has changed its application scope- Overrides:
changeScope
in classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Granthome
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightsviews
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightsdomain
- Domain nameitem
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightssearch
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightssearch
- User queryobjects
- Optional list of objects to limit searchcontext
- Search contextparent
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightsrows
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightsrows
- search resultobjects
- Optional list of objects to limit searchcontext
- Search contextparent
- Optional parent context (OBJECT_REFSELECT)- Returns:
- Overridden result
-
canPreviewDocument
public boolean canPreviewDocument(Grant g, DocumentDB doc)
Hook called before document preview- Overrides:
canPreviewDocument
in classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightsdoc
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightsdoc
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- User rightsorigin
- Event origindata
- 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 classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- GrantpostId
- Social post row IDuserId
- Author row IDmessage
- Posted messagepub
- Public or private?target
- Optional object namerowId
- Optional object row IDlevel
- Optional level of audit poststatus
- Optional status of audit post
-
logout
public void logout(Grant g)
Hook called before the logout- Overrides:
logout
in classcom.simplicite.util.engine.PlatformHooksInterface
- Parameters:
g
- Grant
-
preClearCache
public void preClearCache()
Hook called before a clear cache- Overrides:
preClearCache
in classcom.simplicite.util.engine.PlatformHooksInterface
-
postClearCache
public void postClearCache()
Hook called after clear cache- Overrides:
postClearCache
in classcom.simplicite.util.engine.PlatformHooksInterface
-
unitTests
public java.lang.String unitTests()
Unit tests- Overrides:
unitTests
in classcom.simplicite.util.engine.PlatformHooksInterface
- Returns:
- Unit tests results
-
-