Examples of ServletContainer


Examples of org.gatein.wci.ServletContainer

   }
  
   @Test
   public void testListenerError()
   {
     ServletContainer container = new DefaultServletContainer();
     ServletContainerContextImpl scc = new ServletContainerContextImpl();
     WebAppRegistry registry = new WebAppRegistry();

     //
     final SynchronizedBoolean called = new SynchronizedBoolean(false);
     container.register(scc);
     container.addWebAppListener(registry);
     container.addWebAppListener(new WebAppListener()
     {
       public void onEvent(WebAppEvent event)
       {
         called.set(true);
         throw new Error("Expected Error: don't freak out");
View Full Code Here

Examples of org.gatein.wci.ServletContainer

        //
        int status;
        if (req.getRemoteUser() == null) {
            if (username != null && password != null) {
                Credentials credentials = new Credentials(username, password);
                ServletContainer container = ServletContainerFactory.getServletContainer();

                // This will login or send an AuthenticationException
                try {
                    container.login(req, resp, credentials);
                } catch (AuthenticationException e) {
                    log.debug("User authentication failed");
                    if (log.isTraceEnabled()) {
                        log.trace(e.getMessage(), e);
                    }
View Full Code Here

Examples of org.gatein.wci.ServletContainer

        //
        int status;
        if (req.getRemoteUser() == null) {
            if (username != null && password != null) {
                Credentials credentials = new Credentials(username, password);
                ServletContainer container = ServletContainerFactory.getServletContainer();

                // This will login or send an AuthenticationException
                try {
                    container.login(req, resp, credentials);
                } catch (AuthenticationException e) {
                    log.debug("User authentication failed");
                    if (log.isTraceEnabled()) {
                        log.trace(e.getMessage(), e);
                    }
View Full Code Here

Examples of org.gatein.wci.ServletContainer

            if (token != null) {
                ExoContainer container = getContainer();
                CookieTokenService tokenservice = container.getComponentInstanceOfType(CookieTokenService.class);
                Credentials credentials = tokenservice.validateToken(token, false);
                if (credentials != null) {
                    ServletContainer servletContainer = ServletContainerFactory.getServletContainer();
                    try {
                        servletContainer.login(req, resp, credentials);
                    } catch (Exception e) {
                        // Could not authenticate
                    }
                }
            }

            // Clear token cookie if we did not authenticate
            if (req.getRemoteUser() == null) {
                Cookie cookie = new Cookie(LoginServlet.COOKIE_NAME, "");
                cookie.setPath(req.getContextPath());
                cookie.setMaxAge(0);
                resp.addCookie(cookie);
            }
        }

        //Process oauth rememberMe
        if(req.getRemoteUser() == null) {
            String token = LoginServlet.getOauthRememberMeTokenCookie(req);
            if(token != null) {
                ExoContainer container = getContainer();
                CookieTokenService tokenService = container.getComponentInstanceOfType(CookieTokenService.class);
                Credentials credentials = tokenService.validateToken(token, false);
                AuthenticationRegistry authRegistry = container.getComponentInstanceOfType(AuthenticationRegistry.class);
                OrganizationService orgService = container.getComponentInstanceOfType(OrganizationService.class);

                if (credentials != null) {
                    ServletContainer servletContainer = ServletContainerFactory.getServletContainer();
                    try {
                        String username = credentials.getUsername();

                        User portalUser = orgService.getUserHandler().findUserByName(username, UserStatus.ENABLED);
                        if(portalUser != null) {
                            authRegistry.setAttributeOfClient(req, ATTRIBUTE_AUTHENTICATED_PORTAL_USER_FOR_JAAS, portalUser);

                            servletContainer.login(req, resp, credentials);
                        }
                    } catch (Exception e) {
                        // Could not authenticate
                    }
                }
View Full Code Here

Examples of org.glassfish.jersey.servlet.ServletContainer

        return new HalfpipeJerseyApplciation();
    }

    @Bean
    public ServletRegistrationBean jerseyServlet() {
        ServletContainer servletContainer = new ServletContainer(jerseyConfig());
        String prefix = applicationProperties.getPrefix();
        ServletRegistrationBean bean = new ServletRegistrationBean(servletContainer, toUrlMapping(prefix));
        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return bean;
    }
View Full Code Here

Examples of org.glassfish.jersey.servlet.ServletContainer

        ResourceConfig resourceConfig = new ResourceConfig();
        resourceConfig.register(JacksonFeature.class);

        resourceConfig.register(new ApiResource());

        return new ServletContainer(resourceConfig);
    }
View Full Code Here

Examples of org.glassfish.jersey.servlet.ServletContainer

  }

  @Bean
  public ServletRegistrationBean jerseyRegistrationBean() {
    ServletRegistrationBean reg = new ServletRegistrationBean(
        new ServletContainer(new Api1()), Api1.PATH + "*");
    reg.setName(Api1.class.getSimpleName());
    reg.setAsyncSupported(true);
    reg.setEnabled(true);
    reg.setOrder(1);
    return reg;
View Full Code Here

Examples of org.glassfish.jersey.servlet.ServletContainer

        if (appReg != null && appReg.getClassName() == null) {
            final Set<Class<?>> appClasses = getRootResourceAndProviderClasses(classes);
            final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(ResourceConfig.class, appClasses)
                    .addProperties(getInitParams(appReg))
                    .addProperties(WebComponent.getContextParams(sc));
            final ServletContainer s = new ServletContainer(resourceConfig);
            appReg = sc.addServlet(appReg.getName(), s);
            ((ServletRegistration.Dynamic) appReg).setLoadOnStartup(1);

            if (appReg.getMappings().isEmpty()) {
                // Error
View Full Code Here

Examples of org.glassfish.jersey.servlet.ServletContainer

                                                  final Set<Class<?>> classes) throws ServletException {
        final ApplicationPath ap = a.getAnnotation(ApplicationPath.class);
        if (ap != null) {
            // App is annotated with ApplicationPath
            final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(a, classes);
            final ServletContainer s = new ServletContainer(resourceConfig);
            final ServletRegistration.Dynamic dsr = sc.addServlet(a.getName(), s);
            dsr.setAsyncSupported(true);
            dsr.setLoadOnStartup(1);

            final String mapping = createMappingPath(ap);
View Full Code Here

Examples of org.glassfish.jersey.servlet.ServletContainer

        if (sr.getClassName() == null) {
            // create a new servlet container for a given app.
            final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(a, classes)
                    .addProperties(getInitParams(sr))
                    .addProperties(WebComponent.getContextParams(sc));
            final ServletContainer s = new ServletContainer(resourceConfig);
            final ServletRegistration.Dynamic dsr = sc.addServlet(a.getName(), s);
            dsr.setAsyncSupported(true);
            dsr.setLoadOnStartup(1);

            if (dsr.getMappings().isEmpty()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.