예제 #1
0
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    final ServletContext context = sce.getServletContext();

    LOGGER = LumifyLoggerFactory.getLogger(ApplicationBootstrap.class);

    LOGGER.info("Servlet context initialized...");
    try {
      if (context != null) {
        final Configuration config = fetchApplicationConfiguration(context);
        LOGGER.info("Running application with configuration:\n%s", config);

        InjectHelper.inject(this, LumifyBootstrap.bootstrapModuleMaker(config));

        // Store the injector in the context for a servlet to access later
        context.setAttribute(Injector.class.getName(), InjectHelper.getInjector());
        if (!config.get(Configuration.MODEL_PROVIDER).equals(Configuration.UNKNOWN_STRING)) {
          FrameworkUtils.initializeFramework(
              InjectHelper.getInjector(), userRepository.getSystemUser());
        }

        InjectHelper.getInjector().getInstance(OntologyRepository.class);

        LOGGER.warn(
            "JavaScript / Less modifications will not be reflected on server. Run `grunt watch` from webapp directory in development");
      } else {
        LOGGER.error("Servlet context could not be acquired!");
      }
    } catch (Exception ex) {
      LOGGER.error("Failed to initialize context", ex);
      throw new RuntimeException("Failed to initialize context", ex);
    }
  }
예제 #2
0
  @Override
  public void init(WebApp app, ServletContext servletContext, Handler authenticationHandler) {
    StaticResourceHandler jsHandler =
        new StaticResourceHandler(
            this.getClass(), "/ldap-x509/authentication.js", "application/javascript");
    StaticResourceHandler loginTemplateHandler =
        new StaticResourceHandler(this.getClass(), "/ldap-x509/templates/login.hbs", "text/plain");
    StaticResourceHandler lessHandler =
        new StaticResourceHandler(this.getClass(), "/ldap-x509/less/login.less", "text/plain");

    app.registerJavaScript("/ldap-x509/logout.js");

    app.get(
        "/logout.html",
        new StaticResourceHandler(this.getClass(), "/ldap-x509/logout.html", "text/html"));
    app.get(
        "/jsc/configuration/plugins/authentication/css/logout.css",
        new StaticResourceHandler(this.getClass(), "/ldap-x509/css/logout.css", "text/css"));
    app.get("/jsc/configuration/plugins/authentication/authentication.js", jsHandler);
    app.get("/jsc/configuration/plugins/authentication/templates/login.hbs", loginTemplateHandler);
    app.get("/jsc/configuration/plugins/authentication/less/login.less", lessHandler);

    app.post(
        AuthenticationHandler.LOGIN_PATH,
        InjectHelper.getInstance(LdapX509AuthenticationHandler.class));
  }