List of usage examples for com.vaadin.server VaadinRequest getRemoteAddr
public String getRemoteAddr();
From source file:com.antonjohansson.lprs.ServiceServlet.java
License:Apache License
@Override protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException { VaadinServletService service = new VaadinServletService(this, deploymentConfiguration) { @Override//from w w w. j av a2s. c o m public void requestStart(VaadinRequest request, VaadinResponse response) { String remoteAddress = request.getRemoteAddr(); MDC.put(MDC_REMOTE_ADDRESS, remoteAddress); super.requestStart(request, response); } @Override public void requestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session) { super.requestEnd(request, response, session); MDC.remove(MDC_REMOTE_ADDRESS); } }; service.init(); return service; }
From source file:com.haulmont.cuba.web.security.ConnectionImpl.java
License:Apache License
@Nullable protected String getUserRemoteAddress() { VaadinRequest currentRequest = VaadinService.getCurrentRequest(); String userRemoteAddress = null; if (currentRequest != null) { String xForwardedFor = currentRequest.getHeader("X_FORWARDED_FOR"); if (StringUtils.isNotBlank(xForwardedFor)) { String[] strings = xForwardedFor.split(","); String userAddressFromHeader = StringUtils.trimToEmpty(strings[strings.length - 1]); if (StringUtils.isNotEmpty(userAddressFromHeader)) { userRemoteAddress = userAddressFromHeader; } else { userRemoteAddress = currentRequest.getRemoteAddr(); }//from w ww . ja v a2 s . co m } else { userRemoteAddress = currentRequest.getRemoteAddr(); } } return userRemoteAddress; }
From source file:com.mycollab.web.DesktopApplication.java
License:Open Source License
private String printRequest(VaadinRequest request) { StringBuilder requestInfo = new StringBuilder(); Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String attr = headerNames.nextElement(); requestInfo.append(attr + ": " + request.getHeader(attr)).append('\n'); }/*from w w w.j a v a 2 s .c o m*/ requestInfo.append("Subdomain: " + Utils.getSubDomain(request)).append('\n'); requestInfo.append("Remote address: " + request.getRemoteAddr()).append('\n'); requestInfo.append("Path info: " + request.getPathInfo()).append('\n'); requestInfo.append("Remote host: " + request.getRemoteHost()).append('\n'); return requestInfo.toString(); }
From source file:de.metas.procurement.webui.LoggingConfiguration.java
License:Open Source License
public void updateMDC() { ///*from w w w . ja va 2 s .c o m*/ // Remote address try { final VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) { final String remoteAddr = vaadinRequest.getRemoteAddr(); MDC.put(MDC_Param_RemoteAddr, remoteAddr); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_RemoteAddr, "?"); } // // LoggedUser try { final MFSession mfSession = MFProcurementUI.getCurrentMFSession(); if (mfSession != null) { final User user = mfSession.getUser(); if (user != null) { final String email = user.getEmail(); if (email != null) { MDC.put(MDC_Param_LoggedUser, email); } } } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_LoggedUser, "?"); } // // UserAgent try { final Page page = Page.getCurrent(); if (page != null) { final WebBrowser webBrowser = page.getWebBrowser(); if (webBrowser != null) { final String userAgent = webBrowser.getBrowserApplication(); MDC.put(MDC_Param_UserAgent, userAgent); } } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_UserAgent, "?"); } // // SessionId try { final VaadinSession session = VaadinSession.getCurrent(); if (session != null) { final int sessionId = System.identityHashCode(session); MDC.put(MDC_Param_SessionId, Integer.toString(sessionId)); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_SessionId, "?"); } // // UI Id try { final UI ui = UI.getCurrent(); if (ui != null) { final int uiId = ui.getUIId(); MDC.put(MDC_Param_UIId, Integer.toString(uiId)); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_UIId, "?"); } }
From source file:roart.client.MyVaadinUI.java
@Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); VerticalLayout searchTab = null, controlPanelTab = null; com.vaadin.server.Page.getCurrent().setTitle("Aether disk search engine by Roar Throns"); layout.setMargin(true);/*from w w w . j a v a 2s . c om*/ setContent(layout); getSession().setAttribute("addr", request.getRemoteAddr()); getSession().setAttribute(Constants.USER, Constants.NONE); initVars(); HorizontalLayout topLine = new HorizontalLayout(); Label topTitle = new Label("Aether disk search engine"); topTitle.setWidth("90%"); topLine.addComponent(topTitle); topLine.setHeight("10%"); topLine.setWidth("100%"); boolean doauthenticate = (boolean) getSession().getAttribute("authenticate"); statLabel = new Label("", ContentMode.PREFORMATTED); statLabel.setWidth("50%"); topLine.addComponent(statLabel); if (doauthenticate) { Button login = getLoginButton(); Button logout = getLogoutButton(); topLine.addComponent(login); topLine.addComponent(logout); getSession().setAttribute("login", login); getSession().setAttribute("logout", logout); } layout.addComponent(topLine); tabsheet = new TabSheet(); tabsheet.setHeight("80%"); layout.addComponent(tabsheet); // Create the first tab searchTab = getSearchTab(); getSession().setAttribute("search", searchTab); // This tab gets its caption from the component caption controlPanelTab = getControlPanelTab(); getSession().setAttribute("controlpanel", controlPanelTab); tabsheet.addTab(searchTab); // This tab gets its caption from the component caption tabsheet.addTab(controlPanelTab); //tabsheet.addTab(statTab); /* tabsheet.addTab(miscTab); tabsheet.addTab(comicsTab); tabsheet.addTab(trainingTab); */ HorizontalLayout bottomLine = new HorizontalLayout(); bottomLine.setHeight("10%"); bottomLine.setWidth("90%"); Label nodeLabel = new Label("Node " + ControlService.nodename); bottomLine.addComponent(nodeLabel); Label dbLabel = new Label("Db type " + roart.util.Prop.getProp().getProperty(ConfigConstants.DB)); //dbLabel.setWidth("30%"); bottomLine.addComponent(dbLabel); Label idxLabel = new Label("Index type " + roart.util.Prop.getProp().getProperty(ConfigConstants.INDEX)); //idxLabel.setWidth("30%"); bottomLine.addComponent(idxLabel); Label licenseLabel = new Label("Affero GPL"); //licenseLabel.setWidth("30%"); bottomLine.addComponent(licenseLabel); //bottomLine.setComponentAlignment(licenseLabel, Alignment.BOTTOM_RIGHT); layout.addComponent(bottomLine); setVisibilities(); }