Search in sources :

Example 1 with VaadinRequest

use of com.vaadin.server.VaadinRequest in project opennms by OpenNMS.

the class SSHWindowTest method setup.

@SuppressWarnings("serial")
@Before
public void setup() {
    app = new UI() {

        @Override
        public void init(VaadinRequest request) {
        }
    };
    sshWindow = new SSHWindow(null, 200, 200);
    client = SshClient.setUpDefaultClient();
    client.start();
    try {
        session = client.connect(testHost, testPort).await().getSession();
    } catch (Exception e) {
        fail("Could not connect to host");
    }
    sshWindow2 = new SSHWindow(session, 200, 200);
    app.addWindow(sshWindow);
    app.addWindow(sshWindow2);
}
Also used : UI(com.vaadin.ui.UI) VaadinRequest(com.vaadin.server.VaadinRequest) Before(org.junit.Before)

Example 2 with VaadinRequest

use of com.vaadin.server.VaadinRequest in project opennms by OpenNMS.

the class ResourceGraphsWindowTest method setUp.

@Before
public void setUp() throws Exception {
    Node testNode1 = new Node(9, "192.0.2.10", "Cartman");
    final URL url = new URL("http://localhost:8080/");
    window1 = new ResourceGraphsWindow(testNode1, url);
    window2 = new ResourceGraphsWindow(null, url);
    mainWindow = new Window();
    app = new // Empty Application
    UI() {

        private static final long serialVersionUID = -8945754438079223762L;

        @Override
        public void init(VaadinRequest request) {
        }
    };
}
Also used : Window(com.vaadin.ui.Window) VaadinRequest(com.vaadin.server.VaadinRequest) URL(java.net.URL) Before(org.junit.Before)

Example 3 with VaadinRequest

use of com.vaadin.server.VaadinRequest in project opennms by OpenNMS.

the class SSHTerminalTest method setUp.

@SuppressWarnings("serial")
@Before
public void setUp() throws Exception {
    app = new UI() {

        @Override
        public void init(VaadinRequest request) {
        }
    };
    mainWindow = new VerticalLayout();
    app.setContent(mainWindow);
    SSHWindow sshWindow = new SSHWindow(null, 200, 200);
    app.addWindow(sshWindow);
    SshClient client = SshClient.setUpDefaultClient();
    client.start();
    ClientSession session = null;
    try {
        session = client.connect(testHost, testPort).await().getSession();
    } catch (Exception e) {
        fail("Could not connect to host");
    }
    sshTerm = new SSHTerminal(sshWindow, session, 200, 200);
    sshWindow.setContent(sshTerm);
    UI.setCurrent(app);
}
Also used : UI(com.vaadin.ui.UI) SshClient(org.apache.sshd.SshClient) ClientSession(org.apache.sshd.ClientSession) VerticalLayout(com.vaadin.ui.VerticalLayout) VaadinRequest(com.vaadin.server.VaadinRequest) Before(org.junit.Before)

Example 4 with VaadinRequest

use of com.vaadin.server.VaadinRequest in project opennms by OpenNMS.

the class TopologyUI method init.

@Override
protected void init(final VaadinRequest request) {
    // Register a cleanup
    request.getService().addSessionDestroyListener((SessionDestroyListener) event -> m_widgetManager.removeUpdateListener(TopologyUI.this));
    try {
        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.setApplicationContext(m_applicationContext);
    createLayouts();
    // Set up an error handler for UI-level exceptions
    setupErrorHandler();
    // Add an auto refresh handler to the GraphContainer
    setupAutoRefresher();
    loadUserSettings();
    // If no Topology Provider was selected (due to loadUserSettings(), fallback to default
    if (Strings.isNullOrEmpty(m_graphContainer.getMetaTopologyId())) {
        CheckedOperation defaultTopologySelectorOperation = getDefaultTopologySelectorOperation(m_bundlecontext);
        // no default found, abort
        Objects.requireNonNull(defaultTopologySelectorOperation, "No default GraphProvider found.");
        defaultTopologySelectorOperation.execute(Lists.newArrayList(), new DefaultOperationContext(TopologyUI.this, m_graphContainer, DisplayLocation.MENUBAR));
    }
    // Add a request handler that parses incoming focusNode and szl query parameters
    TopologyUIRequestHandler handler = new TopologyUIRequestHandler();
    getSession().addRequestHandler(handler);
    // deal with those in init case
    handler.handleRequestParameter(request);
    // Add the default criteria if we do not have already a criteria set
    if (getWrappedVertexHopCriteria(m_graphContainer).isEmpty() && noAdditionalFocusCriteria()) {
        List<Criteria> defaultCriteriaList = m_graphContainer.getTopologyServiceClient().getDefaults().getCriteria();
        if (defaultCriteriaList != null) {
            // set default
            defaultCriteriaList.forEach(m_graphContainer::addCriteria);
        }
    }
    // We set the listeners at the end, to not fire them all the time when initializing the UI
    setupListeners();
    // We force a reload to trigger a fireGraphChanged()
    m_graphContainer.setDirty(true);
    m_graphContainer.redoLayout();
    // Trigger a selectionChanged
    m_selectionManager.selectionChanged(m_selectionManager);
}
Also used : HasExtraComponents(org.opennms.features.topology.api.HasExtraComponents) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) Alignment(com.vaadin.ui.Alignment) SelectionAwareTable(org.opennms.features.topology.api.browsers.SelectionAwareTable) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) VertexHopGraphProvider.getWrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.getWrappedVertexHopCriteria) CategoryHopCriteria(org.opennms.features.topology.app.internal.support.CategoryHopCriteria) Map(java.util.Map) ServiceReference(org.osgi.framework.ServiceReference) RedoLayoutOperation(org.opennms.features.topology.app.internal.operations.RedoLayoutOperation) VaadinResponse(com.vaadin.server.VaadinResponse) Property(com.vaadin.data.Property) HistoryManager(org.opennms.features.topology.api.HistoryManager) Set(java.util.Set) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) IconRepositoryManager(org.opennms.features.topology.app.internal.support.IconRepositoryManager) Criteria(org.opennms.features.topology.api.topo.Criteria) VaadinApplicationContextImpl(org.opennms.osgi.VaadinApplicationContextImpl) VertexRef(org.opennms.features.topology.api.topo.VertexRef) MenuUpdateListener(org.opennms.features.topology.app.internal.menu.MenuUpdateListener) DefaultErrorHandler(com.vaadin.server.DefaultErrorHandler) UriFragmentChangedListener(com.vaadin.server.Page.UriFragmentChangedListener) Title(com.vaadin.annotations.Title) VerticalLayout(com.vaadin.ui.VerticalLayout) TreeSet(java.util.TreeSet) VertexHopGraphProvider(org.opennms.features.topology.api.support.VertexHopGraphProvider) VertexUpdateListener(org.opennms.features.topology.app.internal.TopologyComponent.VertexUpdateListener) DefaultTopologyProviderInfo(org.opennms.features.topology.api.topo.DefaultTopologyProviderInfo) Strings(com.google.common.base.Strings) HttpServletRequest(javax.servlet.http.HttpServletRequest) Lists(com.google.common.collect.Lists) VaadinApplicationContextCreator(org.opennms.osgi.VaadinApplicationContextCreator) TopologyMenuBar(org.opennms.features.topology.app.internal.menu.TopologyMenuBar) OnmsHeaderProvider(org.opennms.web.api.OnmsHeaderProvider) InfoPanelItem(org.opennms.features.topology.api.info.item.InfoPanelItem) IOException(java.io.IOException) PreserveOnRefresh(com.vaadin.annotations.PreserveOnRefresh) Refresher(com.github.wolfie.refresher.Refresher) LayoutHintComponent(org.opennms.features.topology.app.internal.ui.LayoutHintComponent) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TopologyProviderInfo(org.opennms.features.topology.api.topo.TopologyProviderInfo) InfoPanelItemProvider(org.opennms.features.topology.api.info.InfoPanelItemProvider) OperationManager(org.opennms.features.topology.app.internal.menu.OperationManager) ContentType(org.opennms.features.topology.api.browsers.ContentType) EventConsumer(org.opennms.osgi.EventConsumer) GraphContainer(org.opennms.features.topology.api.GraphContainer) CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) ConfirmationDialog(org.opennms.netmgt.vaadin.core.ConfirmationDialog) RequestHandler(com.vaadin.server.RequestHandler) ToolbarPanel(org.opennms.features.topology.app.internal.ui.ToolbarPanel) LoggerFactory(org.slf4j.LoggerFactory) UI(com.vaadin.ui.UI) CheckedOperation(org.opennms.features.topology.api.CheckedOperation) Window(com.vaadin.ui.Window) VaadinRequest(com.vaadin.server.VaadinRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultInfoPanelItem(org.opennms.features.topology.api.info.item.DefaultInfoPanelItem) SelectionListener(org.opennms.features.topology.api.SelectionListener) VaadinApplicationContext(org.opennms.osgi.VaadinApplicationContext) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) Collection(java.util.Collection) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) Collectors(java.util.stream.Collectors) BundleContext(org.osgi.framework.BundleContext) Objects(java.util.Objects) List(java.util.List) Theme(com.vaadin.annotations.Theme) HudDisplay(org.opennms.features.topology.app.internal.ui.HudDisplay) TabSheet(com.vaadin.ui.TabSheet) TransactionOperations(org.springframework.transaction.support.TransactionOperations) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) TopologyContextMenu(org.opennms.features.topology.app.internal.menu.TopologyContextMenu) Optional(java.util.Optional) WidgetUpdateListener(org.opennms.features.topology.api.WidgetUpdateListener) IViewContribution(org.opennms.features.topology.api.IViewContribution) SessionDestroyListener(com.vaadin.server.SessionDestroyListener) VerticesUpdateManager(org.opennms.features.topology.api.VerticesUpdateManager) WidgetManager(org.opennms.features.topology.api.WidgetManager) LayoutManager(org.opennms.features.topology.app.internal.support.LayoutManager) TopologyLinkBuilder(org.opennms.features.topology.link.TopologyLinkBuilder) SelectionContext(org.opennms.features.topology.api.SelectionContext) Vertex(org.opennms.features.topology.api.topo.Vertex) MapViewManager(org.opennms.features.topology.api.MapViewManager) BreadcrumbComponent(org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent) CustomLayout(com.vaadin.ui.CustomLayout) SelectionNotifier(org.opennms.features.topology.api.SelectionNotifier) OnmsServiceManagerLocator(org.opennms.osgi.locator.OnmsServiceManagerLocator) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) WidgetContext(org.opennms.features.topology.api.WidgetContext) Logger(org.slf4j.Logger) SelectedTabChangeEvent(com.vaadin.ui.TabSheet.SelectedTabChangeEvent) DisplayLocation(org.opennms.features.topology.api.OperationContext.DisplayLocation) MapViewManagerListener(org.opennms.features.topology.api.MapViewManagerListener) InfoPanel(org.opennms.features.topology.app.internal.ui.InfoPanel) VaadinServletRequest(com.vaadin.server.VaadinServletRequest) SelectedTabChangeListener(com.vaadin.ui.TabSheet.SelectedTabChangeListener) UriFragmentChangedEvent(com.vaadin.server.Page.UriFragmentChangedEvent) VaadinSession(com.vaadin.server.VaadinSession) OperationContext(org.opennms.features.topology.api.OperationContext) ToolbarPanelController(org.opennms.features.topology.app.internal.ui.ToolbarPanelController) SelectionManager(org.opennms.features.topology.api.SelectionManager) NoSuchProviderException(org.opennms.features.topology.app.internal.service.NoSuchProviderException) NoContentAvailableWindow(org.opennms.features.topology.app.internal.ui.NoContentAvailableWindow) Collections(java.util.Collections) InputStream(java.io.InputStream) Component(com.vaadin.ui.Component) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) VaadinApplicationContextCreator(org.opennms.osgi.VaadinApplicationContextCreator) VaadinServletRequest(com.vaadin.server.VaadinServletRequest) VertexHopGraphProvider.getWrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.getWrappedVertexHopCriteria) CategoryHopCriteria(org.opennms.features.topology.app.internal.support.CategoryHopCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria) CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) IOException(java.io.IOException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) NoSuchProviderException(org.opennms.features.topology.app.internal.service.NoSuchProviderException) VaadinApplicationContextImpl(org.opennms.osgi.VaadinApplicationContextImpl) CheckedOperation(org.opennms.features.topology.api.CheckedOperation)

Example 5 with VaadinRequest

use of com.vaadin.server.VaadinRequest in project cuba by cuba-platform.

the class IdpLoginLifecycleManager method onAppStarted.

@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
@EventListener
protected void onAppStarted(AppStartedEvent event) throws LoginException {
    Connection connection = event.getApp().getConnection();
    // can be already authenticated by another event listener
    if (webIdpConfig.getIdpEnabled() && !connection.isAuthenticated()) {
        VaadinRequest currentRequest = VaadinService.getCurrentRequest();
        if (currentRequest != null) {
            Principal principal = currentRequest.getUserPrincipal();
            if (principal instanceof IdpSessionPrincipal) {
                IdpSession idpSession = ((IdpSessionPrincipal) principal).getIdpSession();
                Locale locale = event.getApp().getLocale();
                ExternalUserCredentials credentials = new ExternalUserCredentials(principal.getName(), locale);
                credentials.setSessionAttributes(ImmutableMap.of(IdpService.IDP_USER_SESSION_ATTRIBUTE, idpSession.getId()));
                connection.login(credentials);
            }
        }
    }
}
Also used : Locale(java.util.Locale) ExternalUserCredentials(com.haulmont.cuba.web.security.ExternalUserCredentials) Connection(com.haulmont.cuba.web.Connection) IdpSession(com.haulmont.cuba.security.global.IdpSession) VaadinRequest(com.vaadin.server.VaadinRequest) Principal(java.security.Principal) Order(org.springframework.core.annotation.Order) EventListener(org.springframework.context.event.EventListener)

Aggregations

VaadinRequest (com.vaadin.server.VaadinRequest)14 Before (org.junit.Before)6 UI (com.vaadin.ui.UI)5 Window (com.vaadin.ui.Window)5 VaadinSession (com.vaadin.server.VaadinSession)3 VerticalLayout (com.vaadin.ui.VerticalLayout)3 IdpSession (com.haulmont.cuba.security.global.IdpSession)2 Connection (com.haulmont.cuba.web.Connection)2 Theme (com.vaadin.annotations.Theme)2 WebBrowser (com.vaadin.server.WebBrowser)2 Notification (com.vaadin.ui.Notification)2 URL (java.net.URL)2 Refresher (com.github.wolfie.refresher.Refresher)1 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)1 AppUI (com.haulmont.cuba.web.AppUI)1 DefaultApp (com.haulmont.cuba.web.DefaultApp)1 ConnectionImpl (com.haulmont.cuba.web.security.ConnectionImpl)1 ExternalUserCredentials (com.haulmont.cuba.web.security.ExternalUserCredentials)1