protected boolean doRedirectToLoginPage(
      ServerManager manager, ParameterList requestParameters, IWContext iwc, String realm) {
    boolean goToLogin = true;
    // Log user out if this is an authentication request for a new association
    // (i.e. another Relying Party or an expired association) or if this is a new request
    // after a completed successful one (loginExpireTime is removed on successful login)
    String loginExpireHandle =
        requestParameters.hasParameter(OpenIDConstants.PARAMETER_ASSOCIATE_HANDLE)
            ? "openid-login-"
                + requestParameters.getParameterValue(OpenIDConstants.PARAMETER_ASSOCIATE_HANDLE)
            : null;
    Date currentTime = new Date();
    if (loginExpireHandle == null) {
      String simpleRegHandle = "openid-simpleRegHandle-" + realm;
      Date loginExpirationTime = (Date) iwc.getSessionAttribute(simpleRegHandle);

      if (loginExpirationTime == null || currentTime.after(loginExpirationTime)) {
        if (iwc.isLoggedOn()) {
          // Make user log in again
          LoginBusinessBean loginBusiness = getLoginBusiness(iwc.getRequest());
          loginBusiness.logOutUser(iwc);
        }
        int expireInMilliSeconds = manager.getExpireIn() * 1000;
        iwc.setSessionAttribute(
            simpleRegHandle, new Date(currentTime.getTime() + expireInMilliSeconds));
        goToLogin = true;
      } else {
        // coming here again in the same request/association
        goToLogin = !iwc.isLoggedOn();
      }
    } else {
      Date loginExpirationTime = (Date) iwc.getSessionAttribute(loginExpireHandle);

      if (loginExpirationTime == null || currentTime.after(loginExpirationTime)) {
        if (iwc.isLoggedOn()) {
          // Make user log in again
          LoginBusinessBean loginBusiness = getLoginBusiness(iwc.getRequest());
          loginBusiness.logOutUser(iwc);
        }
        int expireInMilliSeconds = manager.getExpireIn() * 1000;
        iwc.setSessionAttribute(
            loginExpireHandle, new Date(currentTime.getTime() + expireInMilliSeconds));
        goToLogin = true;
      } else {
        // coming here again in the same request/association
        goToLogin = !iwc.isLoggedOn();
      }
    }
    return goToLogin;
  }
 public School getProvider(IWContext iwc) {
   School _provider = null;
   try {
     if (iwc.isParameterSet(SchoolUserChooser.PARAMETER_SCHOOL_ID)) {
       _provider =
           getSchoolBusiness(iwc)
               .getSchool(iwc.getParameter(SchoolUserChooser.PARAMETER_SCHOOL_ID));
       if (iwc.getSessionAttribute(SchoolUserChooser.PARAMETER_SCHOOL_ID) == null) {
         iwc.setSessionAttribute(SchoolUserChooser.PARAMETER_SCHOOL_ID, _provider);
       }
     } else {
       _provider = (School) iwc.getSessionAttribute(SchoolUserChooser.PARAMETER_SCHOOL_ID);
     }
   } catch (RemoteException ex) {
     ex.printStackTrace();
   }
   return _provider;
 }