public boolean isSessionValid(UserSession userSession, RequestContext request) {
    String remoteUser = null;

    Cookie SSOCookie = ControllerUtils.getCookie("JforumSSO"); // my app login cookie
    logger.info("DEBUG - CustomSSO - isSessionValid - Getting JForumSSO Cookie!");

    if (SSOCookie != null) remoteUser = SSOCookie.getValue(); //  jforum username

    if (remoteUser == null) {
      logger.info("DEBUG - CustomSSO - isSessionValid - JForumSSO Cookie is NULL!");
      JForumExecutionContext.setRedirect(SystemGlobals.getValue(ConfigKeys.SSO_REDIRECT));
      return false;

    } else if (remoteUser.equals("")) {
      logger.info("DEBUG - CustomSSO - isSessionValid - JForumSSO Cookie is empty!");
      JForumExecutionContext.setRedirect(SystemGlobals.getValue(ConfigKeys.SSO_REDIRECT));
      return false;
      // user has since logged in
    } else if (remoteUser != null
        && userSession.getUserId() == SystemGlobals.getIntValue(ConfigKeys.ANONYMOUS_USER_ID)) {
      logger.info("DEBUG - CustomSSO - isSessionValid - JForumSSO Cookie is Anonymous!");
      return false;
      // user has changed user
    } else if (remoteUser != null && !remoteUser.equals(userSession.getUsername())) {
      logger.info("DEBUG - CustomSSO - isSessionValid - JForumSSO Cookie User Mismatch");
      return false;
    }
    logger.info("DEBUG - CustomSSO - isSessionValid - Returning True");
    return true; // sso pool apps user and forum user the same
  }
  public String authenticateUser(RequestContext request) {
    Cookie cookie = ControllerUtils.getCookie("JForumSSO");
    logger.info("DEBUG - CustomSSO - authenticatUser - Getting JForumSSO Cookie!");

    String username = null;
    if (cookie == null) {
      logger.info("DEBUG - CustomSSO - authenticatUser - JForumSSO Cookie is NULL!");
      JForumExecutionContext.setRedirect(SystemGlobals.getValue(ConfigKeys.SSO_REDIRECT));

      return null;
    } else {
      username = (String) cookie.getValue();
      logger.info(
          "DEBUG - CustomSSO - authenticatUser - JForumSSO Cookie is contains username: "******"!");
      if (username.equals("")) {
        logger.info("DEBUG - CustomSSO - authenticatUser - JForumSSO Cookie is empty!");
        JForumExecutionContext.setRedirect(SystemGlobals.getValue(ConfigKeys.SSO_REDIRECT));
      }
    }
    logger.info(
        "DEBUG - CustomSSO - authenticatUser - JForumSSO is returning username: "******"!");
    return username;
  }
Exemple #3
0
  /**
   * Prepares the mail message for sending.
   *
   * @param subject the subject of the email
   * @param messageFile the path to the mail message template
   * @throws MailException
   */
  protected void prepareMessage(final String subject, final String messageFile)
      throws MailException {
    if (this.messageId != null) {
      this.message = new IdentifiableMimeMessage(session);
      ((IdentifiableMimeMessage) this.message).setMessageId(this.messageId);
    } else {
      this.message = new MimeMessage(session);
    }

    this.templateParams.put("forumName", SystemGlobals.getValue(ConfigKeys.FORUM_NAME));

    try {
      this.message.setSentDate(new Date());
      this.message.setFrom(new InternetAddress(SystemGlobals.getValue(ConfigKeys.MAIL_SENDER)));
      this.message.setSubject(subject, SystemGlobals.getValue(ConfigKeys.MAIL_CHARSET));

      if (this.inReplyTo != null) {
        this.message.addHeader("In-Reply-To", this.inReplyTo);
      }

      this.createTemplate(messageFile);
      this.needCustomization = this.isCustomizationNeeded();

      // If we don't need to customize any part of the message,
      // then build the generic text right now
      if (!this.needCustomization) {
        String text = this.processTemplate();
        this.defineMessageText(text);
      }
    } catch (Exception e) {
      throw new MailException(e);
    }
  }
  private void removePosts(List posts) {
    PreparedStatement post = null;
    PreparedStatement text = null;

    try {
      post =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("PostModel.deletePost"));

      text =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("PostModel.deletePostText"));

      for (Iterator iter = posts.iterator(); iter.hasNext(); ) {
        Post p = (Post) iter.next();

        post.setInt(1, p.getId());
        text.setInt(1, p.getId());

        text.executeUpdate();
        post.executeUpdate();

        SearchFacade.delete(p);
      }
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(post);
      DbUtils.close(text);
    }
  }
 /**
  * @see net.jforum.dao.security.SecurityDAO#addRole(int, net.jforum.security.Role,
  *     net.jforum.security.RoleValueCollection)
  */
 public void addRole(int id, Role role, RoleValueCollection roleValues) {
   this.setAutoGeneratedKeysQuery(SystemGlobals.getSql("PermissionControl.lastGeneratedRoleId"));
   SecurityCommon.executeAddRole(
       SystemGlobals.getSql("PermissionControl.addGroupRole"),
       id,
       role,
       roleValues,
       this.supportAutoGeneratedKeys(),
       this.getAutoGeneratedKeysQuery());
 }
Exemple #6
0
  protected Spammer() throws MailException {
    final boolean ssl = SystemGlobals.getBoolValue(ConfigKeys.MAIL_SMTP_SSL);

    final String hostProperty = this.hostProperty(ssl);
    final String portProperty = this.portProperty(ssl);
    final String authProperty = this.authProperty(ssl);
    final String localhostProperty = this.localhostProperty(ssl);

    mailProps.put(hostProperty, SystemGlobals.getValue(ConfigKeys.MAIL_SMTP_HOST));
    mailProps.put(portProperty, SystemGlobals.getValue(ConfigKeys.MAIL_SMTP_PORT));

    String localhost = SystemGlobals.getValue(ConfigKeys.MAIL_SMTP_LOCALHOST);

    if (StringUtils.isNotEmpty(localhost)) {
      LOGGER.debug("localhost=" + localhost);
      mailProps.put(localhostProperty, localhost);
    }

    mailProps.put("mail.mime.address.strict", "false");
    mailProps.put("mail.mime.charset", SystemGlobals.getValue(ConfigKeys.MAIL_CHARSET));
    mailProps.put(authProperty, SystemGlobals.getValue(ConfigKeys.MAIL_SMTP_AUTH));

    username = SystemGlobals.getValue(ConfigKeys.MAIL_SMTP_USERNAME);
    password = SystemGlobals.getValue(ConfigKeys.MAIL_SMTP_PASSWORD);

    messageFormat =
        SystemGlobals.getValue(ConfigKeys.MAIL_MESSSAGE_FORMAT).equals("html")
            ? MESSAGE_HTML
            : MESSAGE_TEXT;

    this.session = Session.getInstance(mailProps);
  }
Exemple #7
0
  private String getSql(String queryName) {
    String query = SystemGlobals.getSql(queryName);

    query =
        StringUtils.replace(query, "${phpbb}", SystemGlobals.getValue(ConfigKeys.DATABASE_PHPBB));
    query =
        StringUtils.replace(
            query, "${table.prefix}", SystemGlobals.getValue(ConfigKeys.PHPBB_TABLE_PREFIX));

    return query;
  }
  /**
   * Checks user credentials / automatic login.
   *
   * @param userSession The UserSession instance associated to the user's session
   * @return <code>true</code> if auto login was enabled and the user was sucessfuly logged in.
   * @throws DatabaseException
   */
  protected boolean checkAutoLogin(UserSession userSession) {

    LOG.trace("checkAutoLogin");
    String cookieName = SystemGlobals.getValue(ConfigKeys.COOKIE_NAME_DATA);

    Cookie cookie = this.getCookieTemplate(cookieName);
    Cookie hashCookie = this.getCookieTemplate(SystemGlobals.getValue(ConfigKeys.COOKIE_USER_HASH));
    Cookie autoLoginCookie =
        this.getCookieTemplate(SystemGlobals.getValue(ConfigKeys.COOKIE_AUTO_LOGIN));

    if (hashCookie != null
        && cookie != null
        && !cookie.getValue().equals(SystemGlobals.getValue(ConfigKeys.ANONYMOUS_USER_ID))
        && autoLoginCookie != null
        && "1".equals(autoLoginCookie.getValue())) {
      String uid = cookie.getValue();
      String uidHash = hashCookie.getValue();

      // Load the user-specific security hash from the database
      try {
        UserDAO userDao = DataAccessDriver.getInstance().newUserDAO();
        String userHash = userDao.getUserAuthHash(Integer.parseInt(uid));

        if (userHash == null || userHash.trim().length() == 0) {
          return false;
        }

        String securityHash = MD5.crypt(userHash);

        if (securityHash.equals(uidHash)) {
          int userId = Integer.parseInt(uid);
          userSession.setUserId(userId);

          User user = userDao.selectById(userId);

          if (user == null || user.getId() != userId || user.isDeleted()) {
            userSession.makeAnonymous();
            return false;
          }

          this.configureUserSession(userSession, user);

          return true;
        }
      } catch (Exception e) {
        throw new DatabaseException(e);
      }

      userSession.makeAnonymous();
    }

    return false;
  }
  public void init(ServletConfig config) throws ServletException {
    super.init(config);

    try {
      String appPath = config.getServletContext().getRealPath("");
      // 是否为开发mode
      debug = "true".equals(config.getInitParameter("development"));
      // 读取log4j.xml配置文件
      DOMConfigurator.configure(appPath + "/WEB-INF/log4j.xml");

      logger.info("Starting JForum. Debug mode is " + debug);
      //
      ConfigLoader.startSystemglobals(appPath);
      // 启动缓存引擎
      ConfigLoader.startCacheEngine();

      // Configure the template engine
      Configuration templateCfg = new Configuration();
      templateCfg.setTemplateUpdateDelay(2);
      templateCfg.setSetting("number_format", "#");
      templateCfg.setSharedVariable("startupTime", new Long(new Date().getTime()));

      // Create the default template loader
      String defaultPath = SystemGlobals.getApplicationPath() + "/templates";
      FileTemplateLoader defaultLoader = new FileTemplateLoader(new File(defaultPath));

      String extraTemplatePath = SystemGlobals.getValue(ConfigKeys.FREEMARKER_EXTRA_TEMPLATE_PATH);

      if (StringUtils.isNotBlank(extraTemplatePath)) {
        // An extra template path is configured, we need a MultiTemplateLoader
        FileTemplateLoader extraLoader = new FileTemplateLoader(new File(extraTemplatePath));
        TemplateLoader[] loaders = new TemplateLoader[] {extraLoader, defaultLoader};
        MultiTemplateLoader multiLoader = new MultiTemplateLoader(loaders);
        templateCfg.setTemplateLoader(multiLoader);
      } else {
        // An extra template path is not configured, we only need the default loader
        templateCfg.setTemplateLoader(defaultLoader);
      }
      // 载入模块
      ModulesRepository.init(SystemGlobals.getValue(ConfigKeys.CONFIG_DIR));

      this.loadConfigStuff();

      if (!this.debug) {
        templateCfg.setTemplateUpdateDelay(3600);
      }

      JForumExecutionContext.setTemplateConfig(templateCfg);
    } catch (Exception e) {
      throw new ForumStartupException("Error while starting JForum", e);
    }
  }
Exemple #10
0
  private String applyRegexToPostText(String text) {
    for (int i = 0; i < this.regexps.length; i++) {
      if (text == null) {
        text = "";
      } else {
        text =
            text.replaceAll(
                SystemGlobals.getValue(this.regexps[i][0]),
                SystemGlobals.getValue(this.regexps[i][1]));
      }
    }

    return text;
  }
Exemple #11
0
  /** @see net.jforum.dao.PostDAO#selectAllBytTopicByLimit(int, int, int) */
  public List selectAllByTopicByLimit(int topicId, int startFrom, int count) {
    List l = new ArrayList();

    String sql = SystemGlobals.getSql("PostModel.selectAllByTopicByLimit");

    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      p = JForumExecutionContext.getConnection().prepareStatement(sql);
      p.setInt(1, topicId);
      p.setInt(2, startFrom);
      p.setInt(3, count);

      rs = p.executeQuery();

      while (rs.next()) {
        l.add(this.makePost(rs));
      }

      return l;
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }
  }
  public void deleteForumRoles(int forumId) {
    PreparedStatement p = null;

    List roleIds = this.selectForumRoles(forumId);

    try {
      StringBuffer ids = new StringBuffer();

      for (Iterator iterator = roleIds.iterator(); iterator.hasNext(); ) {
        Integer id = (Integer) iterator.next();
        ids.append(id).append(',');
      }

      ids.append("-1");

      // Role values
      String sql = SystemGlobals.getSql("PermissionControl.deleteRoleValues");
      sql = StringUtils.replace(sql, "#IDS#", ids.toString());

      p = JForumExecutionContext.getConnection().prepareStatement(sql);
      p.setString(1, String.valueOf(forumId));
      p.executeUpdate();
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(p);
    }
  }
Exemple #13
0
  public int countUserPosts(int userId) {
    int total = 0;

    PreparedStatement p = null;
    ResultSet rs = null;
    try {
      p =
          JForumExecutionContext.getConnection()
              .prepareStatement(
                  SystemGlobals.getSql("PostModel.countUserPosts")
                      .replaceAll(":fids:", ForumRepository.getListAllowedForums()));
      p.setInt(1, userId);

      rs = p.executeQuery();

      if (rs.next()) {
        total = rs.getInt(1);
      }

      return total;
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }
  }
  protected RoleCollection loadRoles(int[] groupIds) {
    String sql = SystemGlobals.getSql("PermissionControl.loadGroupRoles");
    String groupIdAsString = SecurityCommon.groupIdAsString(groupIds);

    if ("".equals(groupIdAsString)) {
      // We suppose there is no "negative" group ids
      sql = sql.replaceAll("#IN#", "-1");
    } else {
      sql = sql.replaceAll("#IN#", groupIdAsString);
    }

    RoleCollection roles = new RoleCollection();

    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      p = JForumExecutionContext.getConnection().prepareStatement(sql);
      rs = p.executeQuery();

      roles = SecurityCommon.loadRoles(rs);
    } catch (Exception e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }

    return roles;
  }
Exemple #15
0
  /** @see net.jforum.model.PostModel#deleteByTopic(int) */
  public void deleteByTopic(int topicId) {
    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      p =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("PostModel.deleteByTopic"));
      p.setInt(1, topicId);
      rs = p.executeQuery();

      List posts = new ArrayList();

      while (rs.next()) {
        Post post = new Post();
        post.setId(rs.getInt("post_id"));
        post.setUserId(rs.getInt("user_id"));

        posts.add(post);
      }

      this.removePosts(posts);
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }
  }
Exemple #16
0
  /**
   * Gets the registration date of the user
   *
   * @return String value with the registration date
   */
  public String getRegistrationDate() {

    LOG.trace("getRegistrationDate");
    SimpleDateFormat df = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));

    return df.format(this.registrationDate);
  }
Exemple #17
0
  protected Post makePost(ResultSet rs) throws SQLException {
    Post post = new Post();
    post.setId(rs.getInt("post_id"));
    post.setTopicId(rs.getInt("topic_id"));
    post.setForumId(rs.getInt("forum_id"));
    post.setUserId(rs.getInt("user_id"));

    Timestamp postTime = rs.getTimestamp("post_time");
    post.setTime(new Date(postTime.getTime()));
    post.setUserIp(rs.getString("poster_ip"));
    post.setBbCodeEnabled(rs.getInt("enable_bbcode") > 0);
    post.setHtmlEnabled(rs.getInt("enable_html") > 0);
    post.setSmiliesEnabled(rs.getInt("enable_smilies") > 0);
    post.setSignatureEnabled(rs.getInt("enable_sig") > 0);
    post.setEditCount(rs.getInt("post_edit_count"));

    Timestamp editTime = rs.getTimestamp("post_edit_time");
    post.setEditTime(editTime != null ? new Date(editTime.getTime()) : null);

    post.setSubject(rs.getString("post_subject"));
    post.setText(this.getPostTextFromResultSet(rs));
    post.setPostUsername(rs.getString("username"));
    post.hasAttachments(rs.getInt("attach") > 0);
    post.setModerate(rs.getInt("need_moderate") == 1);

    SimpleDateFormat df = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
    post.setFormatedTime(df.format(postTime));

    post.setKarma(DataAccessDriver.getInstance().newKarmaDAO().getPostKarma(post.getId()));

    return post;
  }
Exemple #18
0
  public List selectHotForRSS(int limit) {
    List l = new ArrayList();

    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      p =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("PostModel.selectHotForRSS"));
      p.setInt(1, limit);

      rs = p.executeQuery();

      while (rs.next()) {
        Post post = this.buildPostForRSS(rs);
        l.add(post);
      }

    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }

    return l;
  }
Exemple #19
0
  /** @see net.jforum.model.PostModel#countPreviousPosts(int) */
  public int countPreviousPosts(int postId) {
    int total = 0;

    PreparedStatement p = null;
    ResultSet rs = null;
    try {
      p =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("PostModel.countPreviousPosts"));
      p.setInt(1, postId);
      p.setInt(2, postId);

      rs = p.executeQuery();

      if (rs.next()) {
        total = rs.getInt(1);
      }

      return total;
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }
  }
Exemple #20
0
  protected void addNewPost(Post post) {
    PreparedStatement p = null;
    try {
      p = this.getStatementForAutoKeys("PostModel.addNewPost");

      p.setInt(1, post.getTopicId());
      p.setInt(2, post.getForumId());
      p.setLong(3, post.getUserId());
      p.setTimestamp(4, new Timestamp(post.getTime().getTime()));
      p.setString(5, post.getUserIp());
      p.setInt(6, post.isBbCodeEnabled() ? 1 : 0);
      p.setInt(7, post.isHtmlEnabled() ? 1 : 0);
      p.setInt(8, post.isSmiliesEnabled() ? 1 : 0);
      p.setInt(9, post.isSignatureEnabled() ? 1 : 0);
      p.setInt(10, post.isModerationNeeded() ? 1 : 0);

      this.setAutoGeneratedKeysQuery(SystemGlobals.getSql("PostModel.lastGeneratedPostId"));
      int postId = this.executeAutoKeysQuery(p);
      post.setId(postId);
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(p);
    }
  }
  private List selectForumRoles(int forumId) {
    List l = new ArrayList();

    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      p =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("PermissionControl.selectForumRoles"));
      p.setString(1, String.valueOf(forumId));

      rs = p.executeQuery();

      while (rs.next()) {
        l.add(new Integer(rs.getInt("role_id")));
      }
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }

    return l;
  }
  /** Finishes the execution context */
  public static void finish() {
    Connection conn = JForumExecutionContext.getConnection(false);

    if (conn != null) {
      if (SystemGlobals.getBoolValue(ConfigKeys.DATABASE_USE_TRANSACTIONS)) {
        if (JForumExecutionContext.shouldRollback()) {
          try {
            conn.rollback();
          } catch (Exception e) {
            logger.error("Error while rolling back a transaction", e);
          }
        } else {
          try {
            conn.commit();
          } catch (Exception e) {
            logger.error("Error while commiting a transaction", e);
          }
        }
      }

      try {
        DBConnection.getImplementation().releaseConnection(conn);
      } catch (Exception e) {
        logger.error("Error while releasing the connection : " + e, e);
      }
    }

    userData.set(null);
  }
Exemple #23
0
  /** @see net.jforum.dao.PostDAO#selectByUserByLimit(int, int, int) */
  public List selectByUserByLimit(int userId, int startFrom, int count) {
    String sql = SystemGlobals.getSql("PostModel.selectByUserByLimit");
    sql = sql.replaceAll(":fids:", ForumRepository.getListAllowedForums());

    PreparedStatement p = null;
    ResultSet rs = null;
    try {
      p = JForumExecutionContext.getConnection().prepareStatement(sql);

      p.setInt(1, userId);
      p.setInt(2, startFrom);
      p.setInt(3, count);

      rs = p.executeQuery();
      List l = new ArrayList();

      while (rs.next()) {
        l.add(this.makePost(rs));
      }

      return l;
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }
  }
Exemple #24
0
  protected void updatePostsTable(Post post) {
    PreparedStatement p = null;

    try {
      p =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("PostModel.updatePost"));
      p.setInt(1, post.getTopicId());
      p.setInt(2, post.getForumId());
      p.setInt(3, post.isBbCodeEnabled() ? 1 : 0);
      p.setInt(4, post.isHtmlEnabled() ? 1 : 0);
      p.setInt(5, post.isSmiliesEnabled() ? 1 : 0);
      p.setInt(6, post.isSignatureEnabled() ? 1 : 0);
      p.setTimestamp(7, new Timestamp(System.currentTimeMillis()));
      p.setInt(8, post.getEditCount() + 1);
      p.setString(9, post.getUserIp());
      p.setInt(10, post.getId());

      p.executeUpdate();
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(p);
    }
  }
  /**
   * Do a refresh in the user's session. This method will update the last visit time for the current
   * user, as well checking for authentication if the session is new or the SSO user has changed
   */
  public void refreshSession() {

    LOG.trace("refreshSession");
    UserSession userSession = SessionFacade.getUserSession();
    RequestContext request = JForumExecutionContext.getRequest();

    if (userSession == null) {
      userSession = new UserSession();
      userSession.registerBasicInfo();
      userSession.setSessionId(request.getSessionContext().getId());
      userSession.setIp(request.getRemoteAddr());
      SessionFacade.makeUnlogged();

      if (!JForumExecutionContext.getForumContext().isBot()) {
        // Non-SSO authentications can use auto login
        if (!ConfigKeys.TYPE_SSO.equals(SystemGlobals.getValue(ConfigKeys.AUTHENTICATION_TYPE))) {
          if (SystemGlobals.getBoolValue(ConfigKeys.AUTO_LOGIN_ENABLED)) {
            this.checkAutoLogin(userSession);
          } else {
            userSession.makeAnonymous();
          }
        } else {
          this.checkSSO(userSession);
        }
      }

      SessionFacade.add(userSession);
    } else if (ConfigKeys.TYPE_SSO.equals(SystemGlobals.getValue(ConfigKeys.AUTHENTICATION_TYPE))) {
      SSO sso;

      try {
        sso =
            (SSO)
                Class.forName(SystemGlobals.getValue(ConfigKeys.SSO_IMPLEMENTATION)).newInstance();
      } catch (Exception e) {
        throw new ForumException(e);
      }

      // If SSO, then check if the session is valid
      if (!sso.isSessionValid(userSession, request)) {
        SessionFacade.remove(userSession.getSessionId());
        refreshSession();
      }
    } else {
      SessionFacade.getUserSession().updateSessionTime();
    }
  }
Exemple #26
0
  protected void loadConfigStuff() {
    ConfigLoader.loadUrlPatterns();
    I18n.load();
    Tpl.load(SystemGlobals.getValue(ConfigKeys.TEMPLATES_MAPPING));

    // BB Code
    BBCodeRepository.setBBCollection(new BBCodeHandler().parse());
  }
  /**
   * @see #getAllCategoriesAndForums(boolean)
   * @return List
   */
  public static List getAllCategoriesAndForums() {

    LOG.trace("getAllCategoriesAndForums");
    UserSession us = SessionFacade.getUserSession();
    boolean checkUnread =
        (us != null && us.getUserId() != SystemGlobals.getIntValue(ConfigKeys.ANONYMOUS_USER_ID));
    return getAllCategoriesAndForums(checkUnread);
  }
Exemple #28
0
  /** Load the default I18n file */
  public static synchronized void load() {
    baseDir =
        SystemGlobals.getApplicationResourceDir()
            + "/"
            + SystemGlobals.getValue(ConfigKeys.LOCALES_DIR);

    loadLocales();

    defaultName = SystemGlobals.getValue(ConfigKeys.I18N_DEFAULT_ADMIN);
    load(defaultName, null);

    String custom = SystemGlobals.getValue(ConfigKeys.I18N_DEFAULT);
    if (!custom.equals(defaultName)) {
      load(custom, defaultName);
      defaultName = custom;
    }
  }
  /**
   * @see #getAllCategoriesAndForums(UserSession, int, Map, boolean)
   * @return List
   * @param checkUnreadPosts boolean
   */
  public static List getAllCategoriesAndForums(boolean checkUnreadPosts) {

    LOG.trace("getAllCategoriesAndForums");
    return getAllCategoriesAndForums(
        SessionFacade.getUserSession(),
        SystemGlobals.getIntValue(ConfigKeys.ANONYMOUS_USER_ID),
        SessionFacade.getTopicsReadTime(),
        checkUnreadPosts);
  }
Exemple #30
0
  /**
   * Set the text contents of the email we're sending
   *
   * @param text the text to set
   * @throws MessagingException
   */
  private void defineMessageText(final String text) throws MessagingException {
    String charset = SystemGlobals.getValue(ConfigKeys.MAIL_CHARSET);

    if (messageFormat == MESSAGE_HTML) {
      this.message.setContent(text.replaceAll("\n", "<br>"), "text/html; charset=" + charset);
    } else {
      this.message.setText(text);
    }
  }