@Override
 public void showLoginPage(HttpServletRequest req, HttpServletResponse resp, String callback)
     throws IOException, ServletException {
   if (Strings.isNullOrEmpty(callback)) {
     callback = CoreConfiguration.getConfiguration().applicationUrl() + "/login.do";
   }
   super.showLoginPage(req, resp, callback);
 }
 @Override
 public void contextInitialized(ServletContextEvent sce) {
   if (CoreConfiguration.casConfig().isCasEnabled()) {
     PortalLoginServlet.setLoginStrategy(new FenixIstCasStrategy());
   } else {
     PortalLoginServlet.setLoginStrategy(new FenixIstLocalLoginStrategy());
   }
 }
 private void populateSiteInfo(
     final HttpServletRequest req, Page page, Site site, TemplateContext context) {
   context.put("request", makeRequestWrapper(req));
   context.put("app", makeAppWrapper());
   context.put("site", site.makeWrap());
   context.put("menus", makeMenuWrapper(site, page));
   context.put("staticDir", site.getStaticDirectory());
   context.put("devMode", CoreConfiguration.getConfiguration().developmentMode());
 }
 private Map<String, Object> makeAppWrapper() {
   HashMap<String, Object> result = new HashMap<String, Object>();
   PortalConfiguration configuration = PortalConfiguration.getInstance();
   result.put("title", configuration.getApplicationTitle());
   result.put("subtitle", configuration.getApplicationSubTitle());
   result.put("copyright", configuration.getApplicationCopyright());
   result.put("support", configuration.getSupportEmailAddress());
   result.put("locale", I18N.getLocale());
   result.put("supportedLocales", CoreConfiguration.supportedLocales());
   return result;
 }
  @Override
  protected User doAuthentication(ActionForm form, HttpServletRequest request) {
    final CasConfig casConfig = CoreConfiguration.casConfig();
    if (casConfig != null && casConfig.isCasEnabled()) {
      throw AuthorizationException.authenticationFailed();
    }

    final AuthenticationForm authenticationForm = (AuthenticationForm) form;
    final String username = authenticationForm.getUsername();
    final String password = authenticationForm.getPassword();

    return Authenticate.login(request.getSession(true), username, password);
  }
 private void handleLeadingSlash(final HttpServletRequest req, HttpServletResponse res, Site sites)
     throws PebbleException, IOException, ServletException {
   if (req.getMethod().equals("GET")) {
     res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
     res.setHeader("Location", rewritePageUrl(req));
     return;
   } else if (req.getMethod().equals("POST")) {
     if (CoreConfiguration.getConfiguration().developmentMode()) {
       PebbleEngine engine = new PebbleEngine(new StringLoader());
       engine.addExtension(new CMSExtensions());
       PebbleTemplate compiledTemplate =
           engine.getTemplate(
               "<html><head></head><body><h1>POST action with backslash</h1><b>You posting data with a URL with a backslash. Alter the form to post with the same URL without the backslash</body></html>");
       res.setStatus(500);
       res.setContentType("text/html");
       compiledTemplate.evaluate(res.getWriter());
     } else {
       errorPage(req, res, sites, 500);
     }
   }
 }
 @Override
 public void showLoginPage(HttpServletRequest req, HttpServletResponse resp, String callback)
     throws IOException, ServletException {
   if (Authenticate.isLogged()) {
     if (Strings.isNullOrEmpty(callback)) {
       resp.sendRedirect(req.getContextPath() + "/login.do");
     } else {
       resp.sendRedirect(callback);
     }
   } else {
     CasConfig casConfig = CoreConfiguration.casConfig();
     if (Strings.isNullOrEmpty(callback)) {
       callback = casConfig.getCasServiceUrl();
     }
     String casLoginUrl = casConfig.getCasLoginUrl(callback);
     if (FenixEduIstIntegrationConfiguration.barraLogin()) {
       casLoginUrl =
           FenixEduIstIntegrationConfiguration.getConfiguration().barraLoginUrl()
               + "?next="
               + casLoginUrl;
     }
     resp.sendRedirect(casLoginUrl);
   }
 }