Hi,
I am trying to implement this authorization in my application, using HttpServletRequestListener instead of TransactionListener, following this Vaadin Wiki Page:
Authenticating Vaadin-based applications
Here is the code for Application class methods authenticate() and loadProtectedResources():
public void authenticate(String login, String password) throws Exception
{
//Validation
if(login.equals("admin") && password.equals("admin")) {
currentUser = login;
loadProtectedResources();
return;
}
throw new Exception("Invalid username or password");
}
private void loadProtectedResources()
{
setMainWindow(new InitialView());
}
Login button listener:
public void buttonClick(ClickEvent event)
{
final Button source = event.getButton();
if(source == btnLogin) {
try {
App.getInstance().authenticate(login.getValue().toString(), password.getValue().toString());
open(new ExternalResource(App.getInstance().getURL()));
}
catch (Exception e) {
showNotification("Login error", "<br>" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
}
}
}
The problem occurs when the user clicks on the Login button: the page is refreshed with the same login page, instead of loading the InitialView class, which is created but is not shown, remaining in background…
Am I missing something?
Thanks in advance…