protected void onBeforeRender()
{
// logged in already?
if (isSignedIn() == false)
{
IAuthenticationStrategy authenticationStrategy = getApplication().getSecuritySettings()
.getAuthenticationStrategy();
// get username and password from persistence store
String[] data = authenticationStrategy.load();
if ((data != null) && (data.length > 1))
{
// try to sign in the user
if (signIn(data[0], data[1]))
{
username = data[0];
password = data[1];
// logon successful. Continue to the original destination
if (!continueToOriginalDestination())
{
// Ups, no original destination. Go to the home page
throw new RestartResponseException(getApplication().getSessionSettings()
.getPageFactory()
.newPage(getApplication().getHomePage()));
}
}
else
{
// the loaded credentials are wrong. erase them.
authenticationStrategy.remove();
}
}
}
// don't forget