lastPort = port.getPort();
connector.setPort(port.getPort());
server.addConnector(connector);
}
ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
root.setContextPath("/");
server.setHandler(root);
// set servlet context attributes for broker and configuration
root.getServletContext().setAttribute(HttpManagementUtil.ATTR_BROKER, getBroker());
root.getServletContext().setAttribute(HttpManagementUtil.ATTR_MANAGEMENT_CONFIGURATION, this);
FilterHolder restAuthorizationFilter = new FilterHolder(new ForbiddingAuthorisationFilter());
restAuthorizationFilter.setInitParameter(ForbiddingAuthorisationFilter.INIT_PARAM_ALLOWED, "/rest/sasl");
root.addFilter(restAuthorizationFilter, "/rest/*", EnumSet.of(DispatcherType.REQUEST));
root.addFilter(new FilterHolder(new RedirectingAuthorisationFilter()), HttpManagementUtil.ENTRY_POINT_PATH, EnumSet.of(DispatcherType.REQUEST));
root.addFilter(new FilterHolder(new RedirectingAuthorisationFilter()), "/index.html", EnumSet.of(DispatcherType.REQUEST));
root.addFilter(new FilterHolder(new RedirectingAuthorisationFilter()), "/", EnumSet.of(DispatcherType.REQUEST));
addRestServlet(root, "broker");
addRestServlet(root, "virtualhost", VirtualHost.class);
addRestServlet(root, "authenticationprovider", AuthenticationProvider.class);
addRestServlet(root, "accesscontrolprovider", AccessControlProvider.class);
addRestServlet(root, "user", AuthenticationProvider.class, User.class);
addRestServlet(root, "groupprovider", GroupProvider.class);
addRestServlet(root, "group", GroupProvider.class, Group.class);
addRestServlet(root, "groupmember", GroupProvider.class, Group.class, GroupMember.class);
addRestServlet(root, "exchange", VirtualHost.class, Exchange.class);
addRestServlet(root, "queue", VirtualHost.class, Queue.class);
addRestServlet(root, "connection", VirtualHost.class, Connection.class);
addRestServlet(root, "binding", VirtualHost.class, Exchange.class, Queue.class, Binding.class);
addRestServlet(root, "port", Port.class);
addRestServlet(root, "session", VirtualHost.class, Connection.class, Session.class);
addRestServlet(root, "keystore", KeyStore.class);
addRestServlet(root, "truststore", TrustStore.class);
addRestServlet(root, "plugin", Plugin.class);
addRestServlet(root, "preferencesprovider", AuthenticationProvider.class, PreferencesProvider.class);
root.addServlet(new ServletHolder(new UserPreferencesServlet()), "/rest/userpreferences/*");
root.addServlet(new ServletHolder(new LoggedOnUserPreferencesServlet()), "/rest/preferences");
root.addServlet(new ServletHolder(new StructureServlet()), "/rest/structure");
root.addServlet(new ServletHolder(new MessageServlet()), "/rest/message/*");
root.addServlet(new ServletHolder(new MessageContentServlet()), "/rest/message-content/*");
root.addServlet(new ServletHolder(new LogRecordsServlet()), "/rest/logrecords");
root.addServlet(new ServletHolder(new SaslServlet()), "/rest/sasl");
root.addServlet(new ServletHolder(new DefinedFileServlet("index.html")), HttpManagementUtil.ENTRY_POINT_PATH);
root.addServlet(new ServletHolder(new DefinedFileServlet("index.html")), "/");
root.addServlet(new ServletHolder(new LogoutServlet()), "/logout");
root.addServlet(new ServletHolder(new FileServlet(DojoHelper.getDojoPath(), true)), "/dojo/dojo/*");
root.addServlet(new ServletHolder(new FileServlet(DojoHelper.getDijitPath(), true)), "/dojo/dijit/*");
root.addServlet(new ServletHolder(new FileServlet(DojoHelper.getDojoxPath(), true)), "/dojo/dojox/*");
root.addServlet(new ServletHolder(new FileServlet()), "*.js");
root.addServlet(new ServletHolder(new FileServlet()), "*.css");
root.addServlet(new ServletHolder(new FileServlet()), "*.html");
root.addServlet(new ServletHolder(new FileServlet()), "*.png");
root.addServlet(new ServletHolder(new FileServlet()), "*.gif");
root.addServlet(new ServletHolder(new FileServlet()), "*.jpg");
root.addServlet(new ServletHolder(new FileServlet()), "*.jpeg");
root.addServlet(new ServletHolder(new FileServlet()), "*.json");
root.addServlet(new ServletHolder(new FileServlet()), "*.txt");
root.addServlet(new ServletHolder(new FileServlet()), "*.xsl");
root.addServlet(new ServletHolder(new HelperServlet()), "/rest/helper");
root.addServlet(new ServletHolder(new LogFileListingServlet()), "/rest/logfilenames");
root.addServlet(new ServletHolder(new LogFileServlet()), "/rest/logfile");
final SessionManager sessionManager = root.getSessionHandler().getSessionManager();
sessionManager.setSessionCookie(JSESSIONID_COOKIE_PREFIX + lastPort);
sessionManager.setMaxInactiveInterval((Integer)getAttribute(TIME_OUT));
return server;
}