コード例 #1
0
ファイル: Border.java プロジェクト: edaniels/sipxecs
 public String getUserName() {
   UserSession userSession = getUserSession();
   if (!userSession.isLoggedIn()) {
     return StringUtils.EMPTY;
   }
   User user = userSession.getUser(getCoreContext());
   return user.getLabel();
 }
コード例 #2
0
ファイル: Border.java プロジェクト: edaniels/sipxecs
  public void pageValidate(PageEvent event) {

    if (ObjectUtils.equals(getPage().getRequestCycle().getPage(FirstUser.PAGE), getPage())
        || !isLoginRequired()) {
      return;
    }

    // If there are no users, and we are not on the FirstUser page then we need to create the first
    // user
    // Move to the FIrstUser page
    if (getCoreContext().getUsersCount() == 0) {
      throw new PageRedirectException(FirstUser.PAGE);
    }

    UserSession user = getUserSession();

    // XX-6132: prevent mixing session - store and check original session id against the
    // current one
    WebSession session = getRequest().getSession(false);
    if (session != null) {
      String initialSessionId = getInitialSessionId();
      String currentSessionId = session.getId();

      if (initialSessionId == null) {
        setInitialSessionId(currentSessionId);
      }

      if (!getInitialSessionId().equals(currentSessionId)) {
        if (user.isAdmin()) {
          throw new PageRedirectException(Home.PAGE);
        } else {
          setInitialSessionId(null);
          if (getFeatureManager().isFeatureEnabled(Ivr.FEATURE)) {
            throw new PageRedirectException(ManageVoicemail.PAGE);
          } else {
            throw new PageRedirectException(UserRegistrations.PAGE);
          }
        }
      }
    }

    // If there are users, but no one is logged in, then force a login
    if (!user.isLoggedIn()) {
      redirectToLogin(getPage(), event.getRequestCycle());
    }

    // If the logged-in user is not an admin, and this page is restricted, then
    // redirect the user to the home page since they are not worthy.
    // (We should probably use an error page instead of just tossing them home.)
    if (!user.isAdmin() && isRestricted()) {
      if (getFeatureManager().isFeatureEnabled(Ivr.FEATURE)) {
        throw new PageRedirectException(ManageVoicemail.PAGE);
      } else {
        throw new PageRedirectException(UserRegistrations.PAGE);
      }
    }
  }