Class SecurityService
java.lang.Object
fr.paris.lutece.portal.service.security.SecurityService
This class provides a security service to register and check user authentication
-
Method Summary
Modifier and TypeMethodDescriptionReturns the access controled templateReturns the access denied templateGets the actual authentication implementationReturns the DoLogin URL of the Authentication ServiceReturns the DoLogout URL of the Authentication Servicestatic SecurityServiceGet the unique instance of the Security ServiceReturns the Login page URL of the Authentication ServiceReturns the lost password URL of the Authentication ServiceReturns the new account page URL of the Authentication ServicegetRegisteredUser(jakarta.servlet.http.HttpServletRequest request) Gets the Lutece user registered in the Http sessiongetRemoteUser(jakarta.servlet.http.HttpServletRequest request) Gets the LuteceUser attached to the current Http sessionString[]getRolesByUser(LuteceUser user) get all roles for this user : - user's roles - user's groups rolesReturns user managed by the authentication service if this feature is available.getUserPrincipal(jakarta.servlet.http.HttpServletRequest request) Returns the user's principalgetUsers()Returns all users managed by the authentication service if this feature is available.Returns the view account page URL of the Authentication Servicestatic voidinit()Initialize servicestatic booleanReturns the authentication's activation : enable or disablebooleanReturns the authentication type : External or Lutece portal basedbooleanisLoginUrl(jakarta.servlet.http.HttpServletRequest request) Return true if the requested url is equal to LoginUrlbooleantrue when the service provides multi authentication supportbooleanReturns whether or not the portal needs authenticationbooleanisUserInAnyRole(jakarta.servlet.http.HttpServletRequest request, List<String> listRoles) Checks if the user is associated to a at least a rolebooleanisUserInRole(jakarta.servlet.http.HttpServletRequest request, String strRole) Checks if the user is associated to a given rolevoidChecks user's login with the Authentication service.voidlogoutUser(jakarta.servlet.http.HttpServletRequest request) Logout the uservoidregisterUser(jakarta.servlet.http.HttpServletRequest request, LuteceUser user) Register the user in the Http sessionremoteLoginUser(jakarta.servlet.http.HttpServletRequest request, String strUserName, String strPassword) Checks user's login with the Authentication service.voidunregisterUser(jakarta.servlet.http.HttpServletRequest request) Unregister the user in the Http session
-
Method Details
-
init
Initialize service- Throws:
LuteceInitException- if an error occurs
-
getInstance
Get the unique instance of the Security Service- Returns:
- The instance
-
isAuthenticationEnable
public static boolean isAuthenticationEnable()Returns the authentication's activation : enable or disable- Returns:
- true if the authentication is active, false otherwise
-
getRemoteUser
public LuteceUser getRemoteUser(jakarta.servlet.http.HttpServletRequest request) throws UserNotSignedException Gets the LuteceUser attached to the current Http session- Parameters:
request- The Http request- Returns:
- A LuteceUser object if found
- Throws:
UserNotSignedException- If there is no current user
-
getUserPrincipal
public Principal getUserPrincipal(jakarta.servlet.http.HttpServletRequest request) throws UserNotSignedException Returns the user's principal- Parameters:
request- The HTTP request- Returns:
- The user's principal
- Throws:
UserNotSignedException- The UserNotSignedException
-
isUserInRole
Checks if the user is associated to a given role- Parameters:
request- The Http requeststrRole- The Role name- Returns:
- Returns true if the user is associated to the given role
-
isUserInAnyRole
public boolean isUserInAnyRole(jakarta.servlet.http.HttpServletRequest request, List<String> listRoles) Checks if the user is associated to a at least a role- Parameters:
request- The Http requestlistRoles- The Role list- Returns:
- Returns true if the user is associated to any role
-
getRolesByUser
get all roles for this user : - user's roles - user's groups roles- Parameters:
user- The user- Returns:
- Array of roles
-
loginUser
public void loginUser(jakarta.servlet.http.HttpServletRequest request, String strUserName, String strPassword) throws LoginException, LoginRedirectException Checks user's login with the Authentication service.- Parameters:
request- The Http requeststrUserName- The user's loginstrPassword- The user's password- Throws:
LoginException- The LoginExceptionLoginRedirectException- if redirect exception
-
logoutUser
public void logoutUser(jakarta.servlet.http.HttpServletRequest request) Logout the user- Parameters:
request- The HTTP request
-
registerUser
Register the user in the Http session- Parameters:
request- The Http requestuser- The current user
-
unregisterUser
public void unregisterUser(jakarta.servlet.http.HttpServletRequest request) Unregister the user in the Http session- Parameters:
request- The Http request
-
getRegisteredUser
Gets the Lutece user registered in the Http session- Parameters:
request- The HTTP request- Returns:
- The User registered or null if the user has not been registered
-
isExternalAuthentication
public boolean isExternalAuthentication()Returns the authentication type : External or Lutece portal based- Returns:
- true if the user is already authenticated or false if it needs to login.
-
getLoginPageUrl
Returns the Login page URL of the Authentication Service- Returns:
- The URL
-
getDoLoginUrl
Returns the DoLogin URL of the Authentication Service- Returns:
- The URL
-
getDoLogoutUrl
Returns the DoLogout URL of the Authentication Service- Returns:
- The URL
-
getNewAccountPageUrl
Returns the new account page URL of the Authentication Service- Returns:
- The URL
-
getViewAccountPageUrl
Returns the view account page URL of the Authentication Service- Returns:
- The URL
-
getLostPasswordPageUrl
Returns the lost password URL of the Authentication Service- Returns:
- The URL
-
getAccessDeniedTemplate
Returns the access denied template- Returns:
- The template
-
getAccessControledTemplate
Returns the access controled template- Returns:
- The template
-
isPortalAuthenticationRequired
public boolean isPortalAuthenticationRequired()Returns whether or not the portal needs authentication- Returns:
- true if the access needs authentication, otherwise
- Since:
- 1.3.1
-
remoteLoginUser
public LuteceUser remoteLoginUser(jakarta.servlet.http.HttpServletRequest request, String strUserName, String strPassword) throws LoginException, LoginRedirectException Checks user's login with the Authentication service. Used during remote authentication validation We don't have to put user informations in session, since it is only used in external applications- Parameters:
request- the requeststrUserName- The user's loginstrPassword- The user's password- Returns:
- user's informations
- Throws:
LoginException- The LoginExceptionLoginRedirectException- The redirect exception
-
isLoginUrl
public boolean isLoginUrl(jakarta.servlet.http.HttpServletRequest request) Return true if the requested url is equal to LoginUrl- Parameters:
request- The Http servlet request- Returns:
- True if the requested url is equal to LoginUrl, false else.
-
getUsers
Returns all users managed by the authentication service if this feature is available.- Returns:
- A collection of Lutece users or null if the service doesn't provide a users list
-
getUser
Returns user managed by the authentication service if this feature is available.- Parameters:
strUserLogin- the user login- Returns:
- A Lutece user or null if the service doesn't provide LuteceUser
-
isMultiAuthenticationSupported
public boolean isMultiAuthenticationSupported()true when the service provides multi authentication support- Returns:
trueif multi authentication is supported,falseotherwise.
-
getAuthenticationService
Gets the actual authentication implementation- Returns:
LuteceAuthenticationimplementation
-