Example usage for com.vaadin.server VaadinServletRequest getParameter

List of usage examples for com.vaadin.server VaadinServletRequest getParameter

Introduction

In this page you can find the example usage for com.vaadin.server VaadinServletRequest getParameter.

Prototype

public String getParameter(String parameter);

Source Link

Document

Gets the named request parameter This is typically a HTTP GET or POST parameter, though other request types might have other ways of representing parameters.

Usage

From source file:org.lucidj.vaadinui.BaseVaadinUI.java

License:Apache License

private void init_desktop(VaadinRequest vaadinRequest) {
    Responsive.makeResponsive(this);
    setLocale(vaadinRequest.getLocale());

    if (vaadinRequest instanceof VaadinServletRequest) {
        VaadinServletRequest vsr = (VaadinServletRequest) vaadinRequest;
        InetAddress remote_addr = null;

        // TODO: USE AUTOMATIC KEY AUTHENTICATION FOR SINGLE MODE
        try {/*  w  w w.jav  a2s.c o  m*/
            remote_addr = InetAddress.getByName(vsr.getRemoteAddr());
        } catch (UnknownHostException ignore) {
        }
        ;

        // Login tokens may be used only when browsing from the same machine
        if (remote_addr != null && remote_addr.isLoopbackAddress()
                && Login.isValidLoginToken(vsr.getParameter("token"))) {
            // Autologin into System when browsing from localhost
            log.warn("Automatic login from localhost using login token");
            security.createSystemSubject();

            // Erase the token from URL
            getPage().getJavaScript().execute("window.lucidj_vaadin_helper.clearUrl ()");
        }
    }

    if (!security.getSubject().isAuthenticated()) {
        setContent(new Login(security, new Login.LoginListener() {
            @Override
            public void loginSuccessful() {
                show_desktop();
            }
        }));
    } else {
        show_desktop();
    }
}