List of usage examples for com.vaadin.server VaadinRequest getWrappedSession
public WrappedSession getWrappedSession();
From source file:fi.csc.pathway.TutkaUI.java
License:Creative Commons License
private String getPortletContextName(VaadinRequest request) { WrappedPortletSession wrappedPortletSession = (WrappedPortletSession) request.getWrappedSession(); PortletSession portletSession = wrappedPortletSession.getPortletSession(); final PortletContext context = portletSession.getPortletContext(); final String portletContextName = context.getPortletContextName(); File f = new File("/opt/avaa/liferay-portal/tomcat/shared/radar.properties"); Properties prop = new Properties(); // voisi parsia mys suoraan tomcatin configista FileInputStream in = null;//from w w w .j a v a 2 s. co m try { in = new FileInputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } try { prop.load(in); } catch (IOException e) { e.printStackTrace(); } String portti = prop.getProperty("portti"); if (null == portti) { portti = "8181"; // tomcat log.error("Konfiguraation lukuvirhe: portiksi asetettu 8181"); } //palvelu on kytss ulkopuolle mys portissa 80 (apache) String parvo = portti + "/" + portletContextName; return parvo; }
From source file:me.uni.emuseo.EMuseoUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { WrappedSession session = request.getWrappedSession(); HttpSession httpSession = ((WrappedHttpSession) session).getHttpSession(); ServletContext servletContext = httpSession.getServletContext(); applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); securityContext = SecurityContextHolder.getContext(); authenticationManager = applicationContext.getBean(AuthManager.class); getPage().setTitle(PAGE_TITLE);//from ww w . ja va 2s . co m Responsive.makeResponsive(this); addStyleName(ValoTheme.UI_WITH_MENU); navigator = new EMuseoNavigator(this, this, authenticationManager); navigator.addView(Permissions.LOGIN_VIEW, LoginView.class); navigator.addView(Permissions.MENU_VIEW, MenuView.class); }
From source file:org.opencms.ui.login.CmsLoginUI.java
License:Open Source License
/** * Returns the bootstrap html fragment required to display the login dialog.<p> * * @param cms the cms context//from ww w.java 2 s .c o m * @param request the request * * @return the html fragment * * @throws IOException in case reading the html template fails */ public static String generateLoginHtmlFragment(CmsObject cms, VaadinRequest request) throws IOException { LoginParameters parameters = CmsLoginHelper.getLoginParameters(cms, (HttpServletRequest) request, true); request.getWrappedSession().setAttribute(CmsLoginUI.INIT_DATA_SESSION_ATTR, parameters); byte[] pageBytes; pageBytes = CmsFileUtil.readFully(Thread.currentThread().getContextClassLoader() .getResourceAsStream("org/opencms/ui/login/login-fragment.html")); String html = new String(pageBytes, "UTF-8"); String autocomplete = ((parameters.getPcType() == null) || parameters.getPcType().equals(CmsLoginHelper.PCTYPE_PRIVATE)) ? "on" : "off"; CmsMacroResolver resolver = new CmsMacroResolver(); resolver.addMacro("autocompplete", autocomplete); if ((parameters.getPcType() == null) || parameters.getPcType().equals(CmsLoginHelper.PCTYPE_PRIVATE)) { resolver.addMacro("hiddenPasswordField", " <input type=\"password\" id=\"hidden-password\" name=\"ocPword\" autocomplete=\"%(autocomplete)\" >"); } if (parameters.getUsername() != null) { resolver.addMacro("predefUser", "value=\"" + CmsEncoder.escapeXml(parameters.getUsername()) + "\""); } html = resolver.resolveMacros(html); return html; }
From source file:org.opencms.ui.login.CmsLoginUI.java
License:Open Source License
/** * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest) *///from w w w.ja v a 2 s . co m @Override protected void init(VaadinRequest request) { addStyleName("login-dialog"); LoginParameters params = (LoginParameters) (request.getWrappedSession() .getAttribute(INIT_DATA_SESSION_ATTR)); if (params == null) { params = CmsLoginHelper.getLoginParameters(getCmsObject(), (HttpServletRequest) request, true); request.getWrappedSession().setAttribute(CmsLoginUI.INIT_DATA_SESSION_ATTR, params); } VaadinSession.getCurrent().setErrorHandler(new CmsVaadinErrorHandler()); m_controller = new CmsLoginController(m_adminCms, params); m_controller.setUi(this); setLocale(params.getLocale()); m_loginForm = new CmsLoginForm(m_controller, params.getLocale()); m_controller.onInit(); getPage().setTitle(CmsAppWorkplaceUi.WINDOW_TITLE_PREFIX + CmsVaadinUtils.getMessageText(org.opencms.workplace.Messages.GUI_LOGIN_HEADLINE_0)); }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
@Override protected void init(final VaadinRequest request) { // Register a cleanup request.getService().addSessionDestroyListener( (SessionDestroyListener) event -> m_widgetManager.removeUpdateListener(TopologyUI.this)); try {/*w w w . j a va 2 s.co m*/ m_headerHtml = getHeader(((VaadinServletRequest) request).getHttpServletRequest()); } catch (final Exception e) { LOG.error("failed to get header HTML for request " + request.getPathInfo(), e.getCause()); } //create VaadinApplicationContext m_applicationContext = m_serviceManager.createApplicationContext(new VaadinApplicationContextCreator() { @Override public VaadinApplicationContext create(OnmsServiceManager manager) { VaadinApplicationContextImpl context = new VaadinApplicationContextImpl(); context.setSessionId(request.getWrappedSession().getId()); context.setUiId(getUIId()); context.setUsername(request.getRemoteUser()); return context; } }); m_verticesUpdateManager = new OsgiVerticesUpdateManager(m_serviceManager, m_applicationContext); m_serviceManager.getEventRegistry().addPossibleEventConsumer(this, m_applicationContext); // Set the algorithm last so that the criteria and SZLs are // in place before we run the layout algorithm. m_graphContainer.setSessionId(m_applicationContext.getSessionId()); m_graphContainer.setLayoutAlgorithm(new TopoFRLayoutAlgorithm()); createLayouts(); setupErrorHandler(); // Set up an error handler for UI-level exceptions setupAutoRefresher(); // Add an auto refresh handler to the GraphContainer loadUserSettings(); // the layout must be created BEFORE loading the hop criteria and the semantic zoom level TopologyUIRequestHandler handler = new TopologyUIRequestHandler(); getSession().addRequestHandler(handler); // Add a request handler that parses incoming focusNode and szl query parameters handler.handleRequestParameter(request); // deal with those in init case // Add the default criteria if we do not have already a criteria set if (getWrappedVertexHopCriteria(m_graphContainer).isEmpty() && noAdditionalFocusCriteria()) { m_graphContainer.addCriteria(m_graphContainer.getBaseTopology().getDefaultCriteria()); // set default } // If no Topology Provider was selected (due to loadUserSettings(), fallback to default if (m_graphContainer.getBaseTopology() == null || m_graphContainer.getBaseTopology() == MergingGraphProvider.NULL_PROVIDER) { TopologySelectorOperation defaultTopologySelectorOperation = createOperationForDefaultGraphProvider( m_bundlecontext, "(|(label=Enhanced Linkd)(label=Linkd))"); Objects.requireNonNull(defaultTopologySelectorOperation, "No default GraphProvider found."); // no default found, abort defaultTopologySelectorOperation.execute(m_graphContainer); } // We set the listeners at the end, to not fire them all the time when initializing the UI setupListeners(); // We force a reload of the topology provider as it may not have been initialized m_graphContainer.getBaseTopology().refresh(); // We force a reload to trigger a fireGraphChanged() m_graphContainer.setDirty(true); m_graphContainer.redoLayout(); // Trigger a selectionChanged m_selectionManager.selectionChanged(m_selectionManager); }
From source file:org.vaadin.spring.security.managed.DefaultVaadinManagedSecurity.java
License:Apache License
/** * Clears the session of all attributes except some internal Vaadin attributes and reinitializes it. If Websocket * Push is used, the session will never be reinitialized since this throws errors on at least * Tomcat 8./*from www .j a v a 2 s. com*/ */ protected void clearAndReinitializeSession() { final VaadinRequest currentRequest = VaadinService.getCurrentRequest(); final UI currentUI = UI.getCurrent(); if (currentUI != null) { final Transport transport = currentUI.getPushConfiguration().getTransport(); if (Transport.WEBSOCKET.equals(transport) || Transport.WEBSOCKET_XHR.equals(transport)) { LOGGER.warn( "Clearing and reinitializing the session is currently not supported when using Websocket Push."); return; } } if (currentRequest != null) { LOGGER.debug("Clearing the session"); final WrappedSession session = currentRequest.getWrappedSession(); final String serviceName = VaadinService.getCurrent().getServiceName(); final Set<String> attributesToSpare = new HashSet<String>(); attributesToSpare.add(serviceName + ".lock"); attributesToSpare.add(VaadinSession.class.getName() + "." + serviceName); for (String s : currentRequest.getWrappedSession().getAttributeNames()) { if (!attributesToSpare.contains(s)) { LOGGER.trace("Removing attribute {} from session", s); session.removeAttribute(s); } } LOGGER.debug("Reinitializing the session {}", session.getId()); VaadinService.reinitializeSession(currentRequest); LOGGER.debug("Session reinitialized, new ID is {}", VaadinService.getCurrentRequest().getWrappedSession().getId()); } else { LOGGER.warn( "No VaadinRequest bound to current thread, could NOT clear/reinitialize the session after login"); } }