List of usage examples for com.vaadin.server VaadinRequest getRemoteUser
public String getRemoteUser();
From source file:annis.libgui.AnnisBaseUI.java
License:Apache License
private static void checkIfRemoteLoggedIn(VaadinRequest request) { // check if we are logged in using an external authentification mechanism // like Schibboleth String remoteUser = request.getRemoteUser(); if (remoteUser != null) { Helper.setUser(new AnnisUser(remoteUser, null, true)); }/* w ww . j a v a 2s . c o m*/ }
From source file:de.unioninvestment.eai.portal.portlet.crud.domain.model.user.CurrentUser.java
License:Apache License
protected User currentUser() { VaadinRequest currentRequest = VaadinService.getCurrentRequest(); if (currentRequest != null) { String remoteUser = currentRequest.getRemoteUser(); if (remoteUser != null) { if (cachedUser == null || !cachedUser.getName().equals(remoteUser)) { cachedUser = new NamedUser(remoteUser, portalRoles); }//from w w w .ja v a2 s . c o m return cachedUser; } } else { LOG.warn("No portlet request found - that's ok for unit testing. Returning anonymous user"); } return ANONYMOUS_USER; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.presenters.configuration.PortletConfigurationPresenter.java
License:Apache License
/** * /*from ww w . j a v a 2s.c o m*/ * @param portletConfigurationView * die View * @param configurationService * Service Bean fr die Portletkonfiguration. * @param eventBus * fr applikationsweites Eventhandler. * @param settings */ public PortletConfigurationPresenter(PortletConfigurationView portletConfigurationView, ConfigurationService configurationService, EventBus eventBus, Settings settings) { super(portletConfigurationView); this.configurationService = configurationService; this.eventBus = eventBus; this.settings = settings; this.receiver = new ConfigurationReceiver(); getView().getUpload().setReceiver(receiver); getView().getUpload().addFinishedListener(new ConfigUploadFinishedListener()); getView().getUploadVcsButton().addClickListener(new ConfigUploadVcsFinishedListener()); LiferayUI app = LiferayUI.getCurrent(); VaadinRequest request = VaadinPortletService.getCurrentRequest(); portletId = app.getPortletId(); communityId = app.getCommunityId(); currentUsername = request.getRemoteUser(); initStatus(); }
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 {/*from w ww . ja va2s. com*/ 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.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java
License:Open Source License
@Override protected void init(final VaadinRequest vaadinRequest) { m_request = vaadinRequest;// ww w .ja v a2 s .co m LOG.debug("initializing"); final VaadinApplicationContextImpl context = new VaadinApplicationContextImpl(); final UI currentUI = UI.getCurrent(); context.setSessionId(currentUI.getSession().getSession().getId()); context.setUiId(currentUI.getUIId()); context.setUsername(vaadinRequest.getRemoteUser()); Assert.notNull(m_alarmTable); Assert.notNull(m_nodeTable); final String searchString = vaadinRequest.getParameter("search"); final Integer maxClusterRadius = Integer.getInteger("gwt.maxClusterRadius", 350); LOG.info("Starting search string: {}, max cluster radius: {}", searchString, maxClusterRadius); m_alarmTable.setVaadinApplicationContext(context); final EventProxy eventProxy = new EventProxy() { @Override public <T> void fireEvent(final T eventObject) { LOG.debug("got event: {}", eventObject); if (eventObject instanceof VerticesUpdateEvent) { final VerticesUpdateEvent event = (VerticesUpdateEvent) eventObject; final List<Integer> nodeIds = new ArrayList<Integer>(); for (final VertexRef ref : event.getVertexRefs()) { if ("nodes".equals(ref.getNamespace()) && ref.getId() != null) { nodeIds.add(Integer.valueOf(ref.getId())); } } m_mapWidgetComponent.setSelectedNodes(nodeIds); return; } LOG.warn("Unsure how to deal with event: {}", eventObject); } @Override public <T> void addPossibleEventConsumer(final T possibleEventConsumer) { LOG.debug("(ignoring) add consumer: {}", possibleEventConsumer); /* throw new UnsupportedOperationException("Not yet implemented!"); */ } }; m_alarmTable.setEventProxy(eventProxy); m_nodeTable.setEventProxy(eventProxy); createMapPanel(searchString, maxClusterRadius); createRootLayout(); addRefresher(); // Notify the user if no tileserver url or options are set if (!NodeMapConfiguration.isValid()) { new InvalidConfigurationWindow().open(); } // Schedule refresh of node data m_executor.scheduleWithFixedDelay(() -> m_mapWidgetComponent.refreshNodeData(), 0, 5, TimeUnit.MINUTES); // If we do not shutdown the executor, the scheduler keeps refreshing the node data, even if the // UI may already been detached, resulting at one point in a OutOfMemory. See NMS-8589. vaadinRequest.getService().addSessionDestroyListener(new SessionDestroyListener() { @Override public void sessionDestroy(SessionDestroyEvent event) { m_executor.shutdown(); } }); }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewsUI.java
License:Open Source License
/** * {@inheritDoc}// w w w . j a v a 2s . c o m */ @Override protected void init(VaadinRequest request) { /** * Force the reload of the configuration */ SurveillanceViewProvider.getInstance().load(); /** * create a layout */ VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSpacing(true); /** * check query parameters for viewName, dashboard */ String viewName = request.getParameter("viewName"); boolean dashboard = request.getParameter("dashboard") != null && "true".equals(request.getParameter("dashboard")); /** * retrieve the username */ String username = request.getRemoteUser(); /** * now select the right view */ View view; if (viewName == null) { view = m_surveillanceViewService.selectDefaultViewForUsername(username); } else { view = SurveillanceViewProvider.getInstance().getView(viewName); } /** * set the poll interval */ setPollInterval(1000); /** * check for dashboard role */ boolean isDashboardRole = true; SecurityContext context = SecurityContextHolder.getContext(); if ((context != null) && !(context.toString().contains(org.opennms.web.api.Authentication.ROLE_DASHBOARD))) { isDashboardRole = false; } LOG.debug("User {} is in dashboard role? {}", username, isDashboardRole); /** * now construct the surveillance view/dashboard */ rootLayout.addComponent(new SurveillanceView(view, m_surveillanceViewService, dashboard, !isDashboardRole)); setContent(rootLayout); Page.getCurrent().getJavaScript().execute("function receiveMessage(event){\n" + "if(event.origin !== window.location.origin){ return; }\n" + "\n" + "event.source.postMessage( (document.getElementById('surveillance-window').offsetHeight + 17) + 'px', window.location.origin )\n" + "}\n" + "window.addEventListener(\"message\", receiveMessage, false);"); }