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; }
// œr private ’ protected protected void init(IWContext iwc) { this.form = new Form(); this.searchString = iwc.getParameter(this.PARAMETER_SEARCH); this.iwrb = iwc.getIWMainApplication() .getBundle(BuilderConstants.STANDARD_IW_BUNDLE_IDENTIFIER) .getResourceBundle(iwc); this.showAll = iwc.isParameterSet(this.PARAMETER_VIEW_ALL); if (iwc.isParameterSet(this.PARAMETER_CURRENT_PAGE)) { this.currentPage = Integer.parseInt(iwc.getParameter(this.PARAMETER_CURRENT_PAGE)); } // int start = currentPage * USERS_PER_PAGE; try { String useUserPks = (String) iwc.getSessionAttribute(USING_AVAILABLE_USER_PKS_SESSION_PARAMETER); if (useUserPks != null) { this.usingUserPks = true; } Collection availableUserPks = (Collection) iwc.getSessionAttribute(AVAILABLE_USER_PKS_SESSION_PARAMETER); String[] userIds = null; if (this.usingUserPks && availableUserPks != null) { userIds = new String[availableUserPks.size()]; Iterator iter = availableUserPks.iterator(); int counter = 0; while (iter.hasNext()) { Object i = iter.next(); userIds[counter++] = i.toString(); } } if (this.usingUserPks && this.searchString == null) { this.showAll = true; } UserHome uHome = (UserHome) IDOLookup.getHome(User.class); if (this.showAll) { if (this.usingUserPks && userIds != null) { this.users = uHome.findUsers(userIds); } else { this.users = uHome.findAllUsersOrderedByFirstName(); } } else if (this.searchString != null) { this.users = uHome.findUsersBySearchCondition(this.searchString, userIds, false); } } catch (Exception e) { e.printStackTrace(System.err); } }
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; }
private boolean isAllowAction(IWContext iwc) { Object allowValue = iwc.getRequest().getAttribute(OpenIDConstants.PARAMETER_ALLOWED); if (allowValue != null) { return true; } else { String paramValue = iwc.getParameter(OpenIDConstants.PARAMETER_ALLOWED); String sessionValue = (String) iwc.getSessionAttribute(OpenIDConstants.PARAMETER_ALLOWED); iwc.removeSessionAttribute(OpenIDConstants.PARAMETER_ALLOWED); if (paramValue != null && paramValue.equals(sessionValue)) { iwc.getRequest().setAttribute(OpenIDConstants.PARAMETER_ALLOWED, "true"); return true; } } return false; }