Example usage for com.vaadin.server WebBrowser getAddress

List of usage examples for com.vaadin.server WebBrowser getAddress

Introduction

In this page you can find the example usage for com.vaadin.server WebBrowser getAddress.

Prototype

public String getAddress() 

Source Link

Document

Gets the IP-address of the web browser.

Usage

From source file:com.hack23.cia.web.impl.ui.application.util.WebBrowserUtil.java

License:Apache License

/**
 * Gets the ip information.//from ww w  .j av  a  2 s  . c o  m
 *
 * @param webBrowser
 *            the web browser
 * @return the ip information
 */
public static String getIpInformation(final WebBrowser webBrowser) {
    String ipInformation = webBrowser.getAddress();

    final HttpServletRequest httpRequest = ((ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes()).getRequest();
    final String xForwardedForHeader = httpRequest.getHeader(X_FORWARDED_FOR);
    if (xForwardedForHeader != null) {
        final String[] split = xForwardedForHeader.split(",");
        if (split.length != 0) {
            ipInformation = split[0];
        }
    }
    return ipInformation;
}

From source file:com.haulmont.cuba.web.config.WebDeviceInfoProvider.java

License:Apache License

@Nullable
@Override//  w w w  .ja  v  a  2s. c  o m
public DeviceInfo getDeviceInfo() {
    // per request cache
    HttpServletRequest currentServletRequest = VaadinServletService.getCurrentServletRequest();
    if (currentServletRequest == null) {
        return null;
    }

    DeviceInfo deviceInfo = (DeviceInfo) currentServletRequest.getAttribute(DeviceInfoProvider.NAME);
    if (deviceInfo != null) {
        return deviceInfo;
    }

    Page page = Page.getCurrent();

    if (page == null) {
        return null;
    }

    WebBrowser webBrowser = page.getWebBrowser();

    DeviceInfo di = new DeviceInfo();

    di.setAddress(webBrowser.getAddress());
    di.setBrowserApplication(webBrowser.getBrowserApplication());
    di.setBrowserMajorVersion(webBrowser.getBrowserMajorVersion());
    di.setBrowserMinorVersion(webBrowser.getBrowserMinorVersion());

    di.setChrome(webBrowser.isChrome());
    di.setChromeFrame(webBrowser.isChromeFrame());
    di.setChromeFrameCapable(webBrowser.isChromeFrameCapable());
    di.setEdge(webBrowser.isEdge());
    di.setFirefox(webBrowser.isFirefox());
    di.setOpera(webBrowser.isOpera());
    di.setIE(webBrowser.isIE());

    if (webBrowser.isWindows()) {
        di.setOperatingSystem(OperatingSystem.WINDOWS);
    } else if (webBrowser.isAndroid()) {
        di.setOperatingSystem(OperatingSystem.ANDROID);
    } else if (webBrowser.isIOS()) {
        di.setOperatingSystem(OperatingSystem.IOS);
    } else if (webBrowser.isMacOSX()) {
        di.setOperatingSystem(OperatingSystem.MACOSX);
    } else if (webBrowser.isLinux()) {
        di.setOperatingSystem(OperatingSystem.LINUX);
    }

    di.setIPad(webBrowser.isIPad());
    di.setIPhone(webBrowser.isIPhone());
    di.setWindowsPhone(webBrowser.isWindowsPhone());

    di.setSecureConnection(webBrowser.isSecureConnection());
    di.setLocale(webBrowser.getLocale());

    di.setScreenHeight(webBrowser.getScreenHeight());
    di.setScreenWidth(webBrowser.getScreenWidth());

    currentServletRequest.setAttribute(DeviceInfoProvider.NAME, di);

    return di;
}

From source file:edu.nps.moves.mmowgli.MmowgliSessionGlobals.java

License:Open Source License

private void deriveBrowserBooleans(WebBrowser webBr) {
    browserApp = webBr.getBrowserApplication();
    browserMiniType = returnBrowserType(webBr);
    browserOS = returnBrowserOS(webBr);/*w w  w  . j a  v  a2  s  .  co  m*/
    browserMajVersion = webBr.getBrowserMajorVersion();
    browserMajVersionString = "" + browserMajVersion;
    browserMinVersion = webBr.getBrowserMinorVersion();
    browserAddress = webBr.getAddress();

    if (browserApp.contains("MSIE 7.0")) {
        internetExplorer = true;
        if (browserMajVersion <= 7)
            internetExplorer7 = true;
    }
}

From source file:fr.univlorraine.mondossierweb.photo.PhotoUnivLorraineImpl.java

License:Apache License

/**
 * @return l'adresse ip de l'utilisateur
 *///from  w w w  .  j a va2 s .  c  o  m
public String getRemoteAdresse() {
    WebBrowser browser;
    //String ip =  getIpAddr();
    String ip = GenericUI.getCurrent().getIpClient();
    LOG.debug("IP client via VaadinService Headers : " + ip);

    //Recuperation de l'IP pour info
    if (GenericUI.getCurrent() instanceof MainUI) {
        MainUI mainUI = MainUI.getCurrent();
        browser = mainUI.getPage().getWebBrowser();
        LOG.debug("browser IP client MainUI : " + browser.getAddress());

    }
    if (GenericUI.getCurrent() instanceof MdwTouchkitUI) {
        MdwTouchkitUI mdwTouchkitUI = MdwTouchkitUI.getCurrent();
        browser = mdwTouchkitUI.getPage().getWebBrowser();
        LOG.debug("browser IP client MdwTouchkitUI : " + browser.getAddress());

    }

    if (ip != null) {
        ip = ip.trim();
    }
    return ip;
}