public class FormCredentialProvider extends AbstractCredentialProvider implements NonBlockingCredentialProvider, BlockingCredentialProvider, LogoutCapable, Contextualizable, Configurable, Serviceable
Modifier and Type | Field and Description |
---|---|
private static String |
__PARAM_DATASOURCE
Name of the parameter holder the datasource id
|
private static String |
__PARAM_SECURITY_LEVEL
Name of the parameter holding the security level
|
protected Collection<Pattern> |
_acceptedUrlPatterns
A list of accepted url patterns
|
protected Set<String> |
_acceptedUrlPrefixes
Set of accepted url prefixes (default : empty).
|
protected AuthenticationTokenManager |
_authenticationTokenManager
The token manager
|
protected String |
_captchaField
Name of the captcha answer html field
|
protected String |
_captchaKeyField
Name of the captcha key html field
|
protected Context |
_context
Context
|
protected boolean |
_cookieEnabled
Indicates if the user credentials must be saved by a cookie
|
protected long |
_cookieLifetime
Cookie duration in seconds, by default 1 week
|
protected String |
_cookieName
The name of the cookie
|
protected String |
_datasourceId
The datasource id
|
protected boolean |
_lazyInitialized
was lazy initialize done
|
protected String |
_passwordField
Name of the user password html field
|
protected String |
_rememberMeField
Name of the "remember me" html field
|
protected String |
_securityLevel
The security level
|
protected SourceResolver |
_sourceResolver
The avalon source resolver
|
protected String |
_usernameField
Name of the user name html field
|
protected UserPopulationDAO |
_userPopulationDAO
The user population DAO
|
static String |
AUTHENTICATION_BY_COOKIE
Password value in case of info retrieved from cookie
|
static int |
COOKIE_LIFETIME
Default cookie lifetime (15 days in seconds)
|
static Integer |
NB_CONNECTION_ATTEMPTS
Number of connection attempts allowed
|
static String |
SECURITY_LEVEL_HIGH
High security level
|
static String |
SECURITY_LEVEL_LOW
Low security level
|
protected static Integer |
TIME_ALLOWED
Duration in days a connection failure will last
|
Constructor and Description |
---|
FormCredentialProvider() |
Modifier and Type | Method and Description |
---|---|
protected void |
_deleteAllPastLoginFailedBDD()
Delete all past failed connections
|
protected void |
_deleteCookie()
Delete the cookie
|
protected void |
_deleteLoginFailedBDD(String login,
String populationId)
Delete the login from the table of the failed connection
|
protected String |
_getCookieValue()
Return the cookie value corresponding to the searched name
|
private UserPopulation |
_getPopulation(Request request) |
private UserIdentity |
_getUserIdentityFromRequest(Request request) |
protected void |
_insertLoginNbConnectBDD(String login,
String populationId)
Insert the login with one failed connection in the BDD
|
protected boolean |
_isCookieAlreadySet()
Checks if cookie already exists
|
protected Integer |
_setNbConnectBDD(String login,
String populationId)
Get the number of failed connections with this login
|
protected void |
_updateCookie(String value)
Update the cookie for client-side purpose
|
protected void |
_updateLoginNbConnectBDD(String login,
String populationId,
Integer nbConnect)
Update the number of failed connections of the login in the BDD
|
UserIdentity |
blockingGetUserIdentity(Redirector redirector)
Method called by AuthenticateAction each time a request need
authentication.
|
boolean |
blockingGrantAnonymousRequest()
Method called by AuthenticateAction before asking for credentials.
|
boolean |
blockingIsStillConnected(UserIdentity userIdentity,
Redirector redirector)
Validates that the user specify is still connected
|
void |
blockingUserAllowed(UserIdentity userConnected)
Method called by AuthenticateAction after authentication process succeeded
|
void |
blockingUserNotAllowed(Redirector redirector)
Method called by AuthenticateAction each a user could not get
authenticated.
|
void |
configure(Configuration configuration) |
void |
contextualize(Context context) |
protected Connection |
getSQLConnection()
Get the connection to the database
|
void |
init(String id,
String cpModelId,
Map<String,Object> paramValues,
String label)
Initialize the credential provider with given parameters' values.
|
void |
logout()
Logout a particular user.
|
UserIdentity |
nonBlockingGetUserIdentity(Redirector redirector)
Method called by AuthenticateAction each time a request need
authentication.
|
boolean |
nonBlockingGrantAnonymousRequest()
Method called by AuthenticateAction before asking for credentials.
|
boolean |
nonBlockingIsStillConnected(UserIdentity userIdentity,
Redirector redirector)
Validates that the user specify is still connected
|
void |
nonBlockingUserAllowed(UserIdentity userConnected)
Method called by AuthenticateAction after authentication process succeeded
|
void |
nonBlockingUserNotAllowed(Redirector redirector)
Method called by AuthenticateAction each a user could not get
authenticated.
|
Integer |
requestNbConnectBDD(String login,
String populationId)
Get the number of failed connections with this login
|
boolean |
requiresNewWindow()
Does this blocking credential provider requires a new window to process.
|
void |
service(ServiceManager manager) |
equals, getCredentialProviderModelId, getId, getLabel, getParameterValues, hashCode
getLogger, setLogger
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getCredentialProviderModelId, getId, getLabel, getParameterValues, getUserIdentity, grantAnonymousRequest, isStillConnected, userAllowed, userNotAllowed
public static final String AUTHENTICATION_BY_COOKIE
public static final String SECURITY_LEVEL_LOW
public static final String SECURITY_LEVEL_HIGH
public static final Integer NB_CONNECTION_ATTEMPTS
public static final int COOKIE_LIFETIME
protected static final Integer TIME_ALLOWED
private static final String __PARAM_DATASOURCE
private static final String __PARAM_SECURITY_LEVEL
protected String _usernameField
protected String _passwordField
protected String _rememberMeField
protected String _captchaField
protected String _captchaKeyField
protected boolean _cookieEnabled
protected String _cookieName
protected long _cookieLifetime
protected Set<String> _acceptedUrlPrefixes
protected Collection<Pattern> _acceptedUrlPatterns
protected String _securityLevel
protected UserPopulationDAO _userPopulationDAO
protected String _datasourceId
protected SourceResolver _sourceResolver
protected AuthenticationTokenManager _authenticationTokenManager
protected boolean _lazyInitialized
public FormCredentialProvider()
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void init(String id, String cpModelId, Map<String,Object> paramValues, String label)
CredentialProvider
init
in interface CredentialProvider
init
in class AbstractCredentialProvider
id
- The unique identifiercpModelId
- The id of credential provider extension pointparamValues
- The parameters' valueslabel
- The specific label of this instance. Can be nullpublic void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
protected Connection getSQLConnection()
public void logout()
LogoutCapable
logout
in interface LogoutCapable
public boolean nonBlockingIsStillConnected(UserIdentity userIdentity, Redirector redirector)
NonBlockingCredentialProvider
nonBlockingIsStillConnected
in interface NonBlockingCredentialProvider
userIdentity
- the user previously correctly identified with this credential providerredirector
- The cocoon redirectorpublic boolean blockingIsStillConnected(UserIdentity userIdentity, Redirector redirector)
BlockingCredentialProvider
blockingIsStillConnected
in interface BlockingCredentialProvider
userIdentity
- the user previously correctly identified with this credential providerredirector
- The cocoon redirectorpublic boolean blockingGrantAnonymousRequest()
BlockingCredentialProvider
blockingGrantAnonymousRequest
in interface BlockingCredentialProvider
public boolean nonBlockingGrantAnonymousRequest()
NonBlockingCredentialProvider
nonBlockingGrantAnonymousRequest
in interface NonBlockingCredentialProvider
public UserIdentity blockingGetUserIdentity(Redirector redirector) throws Exception
BlockingCredentialProvider
blockingGetUserIdentity
in interface BlockingCredentialProvider
redirector
- the cocoon redirector.UserIdentity
corresponding to the user (with or without population specified), or null if user could not get authenticated.Exception
- if something wrong occurspublic UserIdentity nonBlockingGetUserIdentity(Redirector redirector) throws Exception
NonBlockingCredentialProvider
nonBlockingGetUserIdentity
in interface NonBlockingCredentialProvider
redirector
- the cocoon redirector.UserIdentity
corresponding to the user (with or without population specified), or null if user could not get authenticated.Exception
- if something wrong occursprivate UserIdentity _getUserIdentityFromRequest(Request request) throws AccessDeniedException
AccessDeniedException
private UserPopulation _getPopulation(Request request)
public void blockingUserNotAllowed(Redirector redirector) throws Exception
BlockingCredentialProvider
blockingUserNotAllowed
in interface BlockingCredentialProvider
redirector
- the cocoon Redirector that can be used for redirecting response.Exception
- if something wrong occurspublic void nonBlockingUserNotAllowed(Redirector redirector) throws Exception
NonBlockingCredentialProvider
nonBlockingUserNotAllowed
in interface NonBlockingCredentialProvider
redirector
- the cocoon Redirector that can be used for redirecting response.Exception
- if something wrong occurspublic void blockingUserAllowed(UserIdentity userConnected)
BlockingCredentialProvider
blockingUserAllowed
in interface BlockingCredentialProvider
userConnected
- The user correctly connectedpublic void nonBlockingUserAllowed(UserIdentity userConnected)
NonBlockingCredentialProvider
nonBlockingUserAllowed
in interface NonBlockingCredentialProvider
userConnected
- The user correctly connectedpublic boolean requiresNewWindow()
BlockingCredentialProvider
requiresNewWindow
in interface BlockingCredentialProvider
protected void _deleteAllPastLoginFailedBDD()
public Integer requestNbConnectBDD(String login, String populationId)
login
- The login to requestpopulationId
- The user's populationprotected Integer _setNbConnectBDD(String login, String populationId)
login
- The login to setpopulationId
- The population id of the userprotected void _insertLoginNbConnectBDD(String login, String populationId)
login
- The login to insertpopulationId
- The population idprotected void _deleteLoginFailedBDD(String login, String populationId)
login
- The login to removepopulationId
- The populationId of the userprotected void _updateLoginNbConnectBDD(String login, String populationId, Integer nbConnect)
login
- The login to updatepopulationId
- The user's populationnbConnect
- The nb of connection to setprotected String _getCookieValue()
protected boolean _isCookieAlreadySet()
protected void _updateCookie(String value)
value
- the cookie valueprotected void _deleteCookie()