public static Customization of(Req req) { assert inValidContext(req); return req != null ? req.custom() : My.custom(); }
@Override public void cleanUp() { My.reset(); App.resetGlobalState(); On.changes().ignore(); Setups.clear(); Env.reset(); }
private void registerRolesProvider() { My.rolesProvider((req, username) -> { try { User user = userDao.getUser(username); if (!user.isEnabled()) { req.response().code(HttpStatus.FORBIDDEN); return null; } if (user.isAdmin()) { return U.set(Role.ADMINISTRATOR); } return U.set(Role.ANYBODY); } catch (Exception e) { logger.error("Got exception while getting user roles! setting to ANYBODY", e); return U.set(Role.ANYBODY); } }); } }
private void registerLoginProvider() { My.loginProvider((req, username, password) -> { User requestedUser = userDao.getUser(username); if (requestedUser == null) { req.response().code(HttpStatus.UNAUTHORIZED); return false; } if (!requestedUser.isEnabled()) { req.response().code(HttpStatus.FORBIDDEN); return false; } if (PasswordManager.checkPassword(password, requestedUser.getHashedPassword())) { return true; } else { req.response().code(HttpStatus.UNAUTHORIZED); return false; } }); }
public static Setup create(String name) { IoCContext ioc = IoC.createContext().name(name); Config config = Conf.section(name); Customization customization = new Customization(name, My.custom(), config); HttpRoutesImpl routes = new HttpRoutesImpl(name, customization); Screen gui = new ScreenBean(); FastHttp http = new FastHttp(routes, config, gui); Setup setup = new SetupImpl(name, "main", http, ioc, config, customization, routes, gui, false); instances.add(setup); return setup; }
@Override public void cleanUp() { JPAUtil.reset(); // FIXME JPA module My.reset(); App.resetGlobalState(); On.changes().ignore(); SetupUtil.cleanUp(); Env.reset(); }
DefaultSetup() { Customization customization = new Customization("main", My.custom(), Conf.ROOT); HttpRoutesImpl routes = new HttpRoutesImpl("main", customization); FastHttp http = new FastHttp(routes, MAIN_CFG, gui); main = new SetupImpl("main", MAIN_ZONE, http, IoC.defaultContext(), MAIN_CFG, customization, routes, gui, true); Setups.register(main); initDefaults(); }
public static Customization of(Req req) { assert inValidContext(req); return req != null ? req.custom() : My.custom(); }
DefaultSetup() { boolean onSameServer = Setup.appAndAdminOnSameServer(); Customization appCustomization = new Customization("main", My.custom(), Conf.ROOT); Customization adminCustomization = onSameServer ? appCustomization : new Customization("admin", My.custom(), Conf.ROOT); HttpRoutesImpl appRoutes = new HttpRoutesImpl("main", appCustomization); HttpRoutesImpl adminRoutes = onSameServer ? appRoutes : new HttpRoutesImpl("admin", adminCustomization); on = new Setup("main", MAIN_ZONE, IoC.defaultContext(), Setup.MAIN_CFG, appCustomization, appRoutes); admin = new Setup("admin", ADMIN_ZONE, IoC.defaultContext(), Setup.ADMIN_CFG, adminCustomization, adminRoutes); Setup.instances.add(on); Setup.instances.add(admin); initDefaults(); }
public static Setup create(String name) { IoCContext ioc = IoC.createContext().name(name); Config config = Conf.section(name); Customization customization = new Customization(name, My.custom(), config); HttpRoutesImpl routes = new HttpRoutesImpl(name, customization); Setup setup = new Setup(name, "main", ioc, config, customization, routes); instances.add(setup); return setup; }