NIHVIVO-736 transitioning from LoginFormBean to LoginStatusBean.

This commit is contained in:
jeb228 2010-10-13 15:54:11 +00:00
parent 4dbf19c9c0
commit 02e32428bd
6 changed files with 30 additions and 106 deletions

View file

@ -7,19 +7,10 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.*"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.*"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginStatusBean" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<% <%
/**
* @version 1.00
* @author Jon Corson-Rikert
* UPDATES:
* 2006-01-04 bdc removed <head> and <body> tags and moved from <table> to <div>
* 2005-07-07 JCR included LoginFormBean so can substitute filterbrowse for portalbrowse for authorized users
*/
final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.themes.default.footer.jsp"); final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.themes.default.footer.jsp");
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
@ -28,14 +19,8 @@
if (portal==null) { if (portal==null) {
log.error("portal from vreq.getPortal() null in themes/default/footer.jsp"); log.error("portal from vreq.getPortal() null in themes/default/footer.jsp");
} }
HttpSession currentSession = request.getSession();
boolean authorized = false; boolean isEditor = LoginStatusBean.getBean(request).isLoggedInAtLeast(LoginStatusBean.EDITOR);
if (loginHandler.getLoginStatus().equals("authenticated")) /* test if session is still valid */
if (currentSession.getId().equals(loginHandler.getSessionId()))
if (request.getRemoteAddr().equals(
loginHandler.getLoginRemoteAddr()))
authorized = true;
%> %>
<c:set var="currentYear" value="<%= Calendar.getInstance().get(Calendar.YEAR) %>" /> <c:set var="currentYear" value="<%= Calendar.getInstance().get(Calendar.YEAR) %>" />
<div class='footer'><div class='footerLinks'> <div class='footer'><div class='footerLinks'>
@ -43,14 +28,14 @@
if (rootBreadCrumb != null && rootBreadCrumb.length()>0) { %> if (rootBreadCrumb != null && rootBreadCrumb.length()>0) { %>
<%=rootBreadCrumb%> | <%=rootBreadCrumb%> |
<% } %> <% } %>
<a href="<%=(authorized?"browsecontroller":"browsecontroller")%>?home=<%=portal.getPortalId()%>">Index</a> <a href="browsecontroller?home=<%=portal.getPortalId()%>">Index</a>
| <a href="comments?home=<%=portal.getPortalId()%>">Contact Us</a> | <a href="comments?home=<%=portal.getPortalId()%>">Contact Us</a>
<c:if test="${sessionScope.loginHandler.loginStatus == 'authenticated' && sessionScope.loginHandler.loginRole > 3 }"> <% if (isEditor) { %>
| admin [ | admin [
<a href="http://validator.w3.org/check?uri=referer">validate xhtml</a> <a href="http://validator.w3.org/check?uri=referer">validate xhtml</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">validate css</a> <a href="http://jigsaw.w3.org/css-validator/check/referer">validate css</a>
] ]
</c:if> <% } %>
</div> </div>
<% if (portal.getCopyrightAnchor() != null && portal.getCopyrightAnchor().length()>0) { %> <% if (portal.getCopyrightAnchor() != null && portal.getCopyrightAnchor().length()>0) { %>
<div class='copyright'> <div class='copyright'>

View file

@ -6,47 +6,21 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginStatusBean" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%><%/* this odd thing points to something in web.xml */ %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%><%/* this odd thing points to something in web.xml */ %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.PortalWebUtil" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.PortalWebUtil" %>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<% <%
/**
*
* @version 1.00
* @author Jon Corson-Rikert, Brian Caruso, and Brian Lowe
*
* UPDATES:
* 2007-09-27 BJL moved VIVO and CALS-specific markup to VIVO clone
* 2006-01-31 BJL edited to remove deprecated markup
* 2005-11-06 JCR put styling on extra search selection box
* 2005-10-25 JCR changed local ALL CALS RESEARCH constant to appBean.getSharedPortalFlagNumeric()
* 2005-10-11 JCR tweaks to VIVO search label spacing in header
* 2005-09-15 JCR,BDC converted to use revised ApplicationBean and PortalBean
* 2005-08-16 JCR added CALS_IMPACT contant and modified code to use CALS display for that portal
* 2005-08-01 JCR changed ordering of other portals being displayed to displayRank instead of appName (affects SGER, CALS portals)
* 2005-07-05 JCR retrieving ONLY_CURRENT and ONLY_PUBLIC from database and setting in ApplicationBean
* 2005-06-20 JCR enabling a common CALS research portal via ALL CALS RESEARCH
* 2005-06-20 JCR removed MIN_STATUS_ID and minstatus parameter from search -- has been changed to interactive-only maxstatus parameter
* JCR 2005-06-14 : added isInitialized() test for appBean and portalBean
*/
// application variables not stored in application bean // application variables not stored in application bean
final int CALS_IMPACT = 6; final int CALS_IMPACT = 6;
final int FILTER_SECURITY_LEVEL = 4;
final int CALS_SEARCHBOX_SIZE = 25; final int CALS_SEARCHBOX_SIZE = 25;
final int VIVO_SEARCHBOX_SIZE = 20; final int VIVO_SEARCHBOX_SIZE = 20;
HttpSession currentSession = request.getSession(); LoginStatusBean loginBean = LoginStatusBean.getBean(request);
String currentSessionIdStr = currentSession.getId(); boolean isEditor = loginBean.isLoggedInAtLeast(LoginStatusBean.EDITOR);
int securityLevel = -1; String loginName = loginBean.getUsername();
String loginName = null;
if (loginHandler.testSessionLevel(request) > -1) {
securityLevel = Integer.parseInt(loginHandler.getLoginRole());
loginName = loginHandler.getLoginName();
}
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
ApplicationBean appBean = vreq.getAppBean(); ApplicationBean appBean = vreq.getAppBean();
@ -106,7 +80,7 @@
<label for="search">Search </label> <label for="search">Search </label>
</td> </td>
<td> <td>
<% if (securityLevel>=FILTER_SECURITY_LEVEL && appBean.isFlag1Active()) { %> <% if (isEditor && appBean.isFlag1Active()) { %>
<select id="select" name="flag1" class="form-item" > <select id="select" name="flag1" class="form-item" >
<option value="nofiltering" selected="selected">entire database (<%=loginName%>)</option> <option value="nofiltering" selected="selected">entire database (<%=loginName%>)</option>
<option value="<%=portal.getPortalId()%>"><%=portal.getShortHand()%></option> <option value="<%=portal.getPortalId()%>"><%=portal.getShortHand()%></option>

View file

@ -8,10 +8,9 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginStatusBean" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<% <%
/*********************************************** /***********************************************
Make the Tab menu div, nothing else. Make the Tab menu div, nothing else.
@ -19,14 +18,9 @@
bdc34 2006-01-03 created bdc34 2006-01-03 created
**********************************************/ **********************************************/
HttpSession currentSession = request.getSession(); LoginStatusBean loginBean = LoginStatusBean.getBean(request);
String currentSessionIdStr = currentSession.getId(); boolean isLoggedIn = loginBean.isLoggedIn();
int securityLevel = -1; String loginName = loginBean.getUsername();
String loginName = null;
if (loginHandler.testSessionLevel(request) > -1) {
securityLevel = Integer.parseInt(loginHandler.getLoginRole());
loginName = loginHandler.getLoginName();
}
final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.menu.jsp"); final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.menu.jsp");
@ -51,7 +45,7 @@
<ul id="otherMenu"> <ul id="otherMenu">
<%-- A user is logged in --%> <%-- A user is logged in --%>
<% if (securityLevel > 0) { %> <% if (isLoggedIn) { %>
<c:url var="logoutHref" value="<%= Controllers.LOGOUT_JSP %>"> <c:url var="logoutHref" value="<%= Controllers.LOGOUT_JSP %>">
<c:param name="home" value="${currentPortal}" /> <c:param name="home" value="${currentPortal}" />

View file

@ -12,16 +12,7 @@
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<% <%
/**
* @version 1.00
* @author Jon Corson-Rikert
* UPDATES:
* 2006-01-04 bdc removed <head> and <body> tags and moved from <table> to <div>
* 2005-07-07 JCR included LoginFormBean so can substitute filterbrowse for portalbrowse for authorized users
*/
final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.themes.enhanced.footer.jsp"); final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.themes.enhanced.footer.jsp");
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
@ -30,14 +21,6 @@
if (portal==null) { if (portal==null) {
log.error("portal from vreq.getPortal() null in themes/enhanced/footer.jsp"); log.error("portal from vreq.getPortal() null in themes/enhanced/footer.jsp");
} }
HttpSession currentSession = request.getSession();
boolean authorized = false;
if (loginHandler.getLoginStatus().equals("authenticated")) /* test if session is still valid */
if (currentSession.getId().equals(loginHandler.getSessionId()))
if (request.getRemoteAddr().equals(
loginHandler.getLoginRemoteAddr()))
authorized = true;
%> %>
<c:set var="currentYear" value="<%= Calendar.getInstance().get(Calendar.YEAR) %>" /> <c:set var="currentYear" value="<%= Calendar.getInstance().get(Calendar.YEAR) %>" />
<c:set var='context' value="<%=vreq.getContextPath()%>" /> <c:set var='context' value="<%=vreq.getContextPath()%>" />

View file

@ -10,20 +10,15 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginStatusBean" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<% <%
HttpSession currentSession = request.getSession(); LoginStatusBean loginBean = LoginStatusBean.getBean(request);
String currentSessionIdStr = currentSession.getId(); boolean isLoggedIn = loginBean.isLoggedIn();
int securityLevel = -1; String loginName = loginBean.getUsername();
String loginName = null;
if (loginHandler.testSessionLevel(request) > -1) {
securityLevel = Integer.parseInt(loginHandler.getLoginRole());
loginName = loginHandler.getLoginName();
}
// VITRO FILE // VITRO FILE
final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.menu.jsp"); final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.menu.jsp");
@ -74,7 +69,7 @@ portal.getRootBreadCrumbURL() : request.getContextPath()+"/";
<ul id="otherMenu"> <ul id="otherMenu">
<%-- A user is logged in --%> <%-- A user is logged in --%>
<% if (securityLevel > 0) { %> <% if (isLoggedIn) { %>
<c:url var="logoutHref" value="<%= Controllers.LOGOUT_JSP %>"> <c:url var="logoutHref" value="<%= Controllers.LOGOUT_JSP %>">
<c:param name="home" value="${currentPortal}" /> <c:param name="home" value="${currentPortal}" />

View file

@ -10,12 +10,12 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.PortalWebUtil" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.PortalWebUtil" %>
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginStatusBean" %>
<%@ page import="java.util.List"%> <%@ page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<% <%
/*********************************************** /***********************************************
Make the Tab menu list and search block Make the Tab menu list and search block
@ -57,22 +57,15 @@
// application variables not stored in application bean // application variables not stored in application bean
final String DEFAULT_SEARCH_METHOD = "fulltext"; final String DEFAULT_SEARCH_METHOD = "fulltext";
final int FILTER_SECURITY_LEVEL = 4;
final int VIVO_SEARCHBOX_SIZE = 20; final int VIVO_SEARCHBOX_SIZE = 20;
ApplicationBean appBean = vreq.getAppBean(); ApplicationBean appBean = vreq.getAppBean();
PortalWebUtil.populateSearchOptions(portal, appBean, vreq.getWebappDaoFactory().getPortalDao()); PortalWebUtil.populateSearchOptions(portal, appBean, vreq.getWebappDaoFactory().getPortalDao());
PortalWebUtil.populateNavigationChoices(portal, request, appBean, vreq.getWebappDaoFactory().getPortalDao()); PortalWebUtil.populateNavigationChoices(portal, request, appBean, vreq.getWebappDaoFactory().getPortalDao());
HttpSession currentSession = request.getSession(); LoginStatusBean loginBean = LoginStatusBean.getBean(request);
String currentSessionIdStr = currentSession.getId(); boolean isEditor = loginBean.isLoggedInAtLeast(LoginStatusBean.EDITOR);
int securityLevel = -1; String loginName = loginBean.getUsername();
String loginName = null;
if (loginHandler.testSessionLevel(request) > -1) {
securityLevel = Integer.parseInt(loginHandler.getLoginRole());
loginName = loginHandler.getLoginName();
}
%> %>
<c:url var="themePath" value="/${themeDir}" /> <c:url var="themePath" value="/${themeDir}" />
@ -118,7 +111,7 @@
<div id="searchBlock"> <div id="searchBlock">
<form id="searchForm" action="${searchURL}" > <form id="searchForm" action="${searchURL}" >
<label for="search">Search </label> <label for="search">Search </label>
<% if (securityLevel>=FILTER_SECURITY_LEVEL && appBean.isFlag1Active()) { %> <% if (isEditor && appBean.isFlag1Active()) { %>
<select id="search-form-modifier" name="flag1" class="form-item" > <select id="search-form-modifier" name="flag1" class="form-item" >
<option value="nofiltering" selected="selected">entire database (<%=loginName%>)</option> <option value="nofiltering" selected="selected">entire database (<%=loginName%>)</option>
<option value="${currentPortal}"><%=portal.getShortHand()%></option> <option value="${currentPortal}"><%=portal.getShortHand()%></option>