I have a web application where I’m trying out various Java web technologies and now the turn has come to vaadin.
The “using-vaadin” branch of my web application currently contains a vaadin hello world application that has been transformed from a shiro-basic-authenticated primefaces web application: https://github.com/steinarb/ukelonn/tree/using-vaadin
My next step is to retrieve the shiro authentication information, but I have been unable to google up how to do this with vaadin 7. All examples and prior forum questions relate to vaadin 6.
How do I find the authenticated username? Is it somewhere in the session object? Do I need to create some kind of handler to listen to the http request? Where do I put it in the handler so that it is available in the UI.init() method?
Do my questions make sense when applied to vaadin…?
It turned out to be a lot simpler than the above example: The VaadinRequest argument to the init() method contains the necessary information:
public class UkelonnUI extends UI {
@Override
protected void init(VaadinRequest request) {
Principal currentUser = request.getUserPrincipal();
// Create the content root layout for the UI
VerticalLayout content = new VerticalLayout();
setContent(content);
// Display the greeting
Component greeting = new Label("Hello " + currentUser.getName());
greeting.setStyleName("h1");
content.addComponent(greeting);