You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/07/12 14:12:43 UTC
svn commit: r1502525 - in /manifoldcf/branches/CONNECTORS-737/framework:
core/src/main/java/org/apache/manifoldcf/core/system/
crawler-ui/src/main/webapp/
ui-core/src/main/java/org/apache/manifoldcf/ui/beans/
ui-core/src/main/native2ascii/org/apache/ma...
Author: kwright
Date: Fri Jul 12 12:12:42 2013
New Revision: 1502525
URL: http://svn.apache.org/r1502525
Log:
Turn on requirement to login when session expires.
Added:
manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/login.jsp (with props)
manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/logout.jsp (with props)
Removed:
manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/checkAdminLogin.jsp
Modified:
manifoldcf/branches/CONNECTORS-737/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/index.jsp
manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/navigation.jsp
manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/setupAdminProfile.jsp
manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/java/org/apache/manifoldcf/ui/beans/AdminProfile.java
manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_en_US.properties
manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_ja_JP.properties
Modified: manifoldcf/branches/CONNECTORS-737/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java Fri Jul 12 12:12:42 2013
@@ -81,6 +81,8 @@ public class ManifoldCF
protected static Integer initializeFlagLock = new Integer(0);
// Local member variables
+ protected static String loginUserName = null;
+ protected static String loginPassword = null;
protected static String masterDatabaseName = null;
protected static String masterDatabaseUsername = null;
protected static String masterDatabasePassword = null;
@@ -96,6 +98,12 @@ public class ManifoldCF
// System property/config file property names
+ // Admin properties
+ /** UI login user name */
+ public static final String loginUserNameProperty = "org.apache.manifoldcf.login.name";
+ /** UI login password */
+ public static final String loginPasswordProperty = "org.apache.manifoldcf.login.password";
+
// Database access properties
/** Database name property */
public static final String masterDatabaseNameProperty = "org.apache.manifoldcf.database.name";
@@ -142,6 +150,8 @@ public class ManifoldCF
{
// Clean up the system doing the same thing the shutdown thread would have if the process was killed
cleanUpEnvironment();
+ loginUserName = null;
+ loginPassword = null;
masterDatabaseName = null;
masterDatabaseUsername = null;
masterDatabasePassword = null;
@@ -208,6 +218,13 @@ public class ManifoldCF
Logging.initializeLoggers();
Logging.setLogLevels();
+ loginUserName = getProperty(loginUserNameProperty);
+ if (loginUserName == null)
+ loginUserName = "admin";
+ loginPassword = getProperty(loginPasswordProperty);
+ if (loginPassword == null)
+ loginPassword = "admin";
+
masterDatabaseName = getProperty(masterDatabaseNameProperty);
if (masterDatabaseName == null)
masterDatabaseName = "dbname";
@@ -552,6 +569,25 @@ public class ManifoldCF
}
}
+ /** Verify login.
+ */
+ public static boolean verifyLogin(IThreadContext threadContext, String userID, String userPassword)
+ throws ManifoldCFException
+ {
+ if (userID != null && userPassword != null)
+ {
+ /*
+ IDBInterface database = DBInterfaceFactory.make(threadContext,
+ ManifoldCF.getMasterDatabaseName(),
+ ManifoldCF.getMasterDatabaseUsername(),
+ ManifoldCF.getMasterDatabasePassword());
+ */
+ // MHL to use a database table, when we get that sophisticated
+ return userID.equals(loginUserName) && userPassword.equals(loginPassword);
+ }
+ return false;
+ }
+
/** Perform standard one-way encryption of a string.
*@param input is the string to encrypt.
*@return the encrypted string.
Modified: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/adminHeaders.jsp?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/adminHeaders.jsp (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/adminHeaders.jsp Fri Jul 12 12:12:42 2013
@@ -46,6 +46,12 @@ response.setContentType("text/html;chars
<%
+ if (adminprofile.getLoggedOn() == false)
+ {
+ response.sendRedirect("login.jsp");
+ return;
+ }
+
IThreadContext threadContext = thread.getThreadContext();
org.apache.manifoldcf.ui.multipart.MultipartWrapper variableContext = (org.apache.manifoldcf.ui.multipart.MultipartWrapper)threadContext.get("__WRAPPER__");
if (variableContext == null)
@@ -54,5 +60,3 @@ response.setContentType("text/html;chars
threadContext.save("__WRAPPER__",variableContext);
}
%>
-
-<%@ include file="checkAdminLogin.jsp" %>
Modified: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/index.jsp?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/index.jsp (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/index.jsp Fri Jul 12 12:12:42 2013
@@ -29,7 +29,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="StyleSheet" href="style.css" type="text/css" media="screen"/>
<title>
- Apache ManifoldCF
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"index.ApacheManifoldCF")%>
</title>
</head>
@@ -39,7 +39,7 @@
<tr><td colspan="2" class="banner"><jsp:include page="banner.jsp" flush="true"/></td></tr>
<tr><td class="navigation"><jsp:include page="navigation.jsp" flush="true"/></td>
<td class="window">
- <p class="windowtitle"><%=Messages.getString(pageContext.getRequest().getLocale(),"index.WelcomeToApacheManifoldFC")%></p>
+ <p class="windowtitle"><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"index.WelcomeToApacheManifoldFC")%></p>
</td>
</tr>
</table>
Added: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/login.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/login.jsp?rev=1502525&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/login.jsp (added)
+++ manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/login.jsp Fri Jul 12 12:12:42 2013
@@ -0,0 +1,84 @@
+<%@ include file="adminDefaults.jsp" %>
+
+<%
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+%>
+<?xml version="1.0" encoding="utf-8"?>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <link rel="StyleSheet" href="style.css" type="text/css" media="screen"/>
+ <title>
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"index.ApacheManifoldCFLogin")%>
+ </title>
+ <script type="text/javascript">
+ <!--
+ function login()
+ {
+ document.loginform.submit();
+ }
+ //-->
+ </script>
+ </head>
+ <body class="standardbody">
+ <table class="page">
+ <tr><td colspan="2" class="banner"><jsp:include page="banner.jsp" flush="true"/></td></tr>
+ <tr>
+ <td colspan="2" class="window">
+
+ <form class="standardform" name="loginform" action="setupAdminProfile.jsp" method="POST">
+ <table class="displaytable">
+<%
+String value = variableContext.getParameter("loginfailed");
+if (value != null && value.equals("true"))
+{
+%>
+ <tr><td class="message" colspan="2"><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"index.LoginFailed")%></td></tr>
+ <tr><td class="separator" colspan="2"><hr/></td></tr>
+<%
+}
+%>
+ <tr>
+ <td class="description"><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"index.UserIDColon")%></td>
+ <td class="value">
+ <input name="userID" type="text" size="32" value=""/>
+ </td>
+ </tr>
+ <tr>
+ <td class="description"><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"index.PasswordColon")%></td>
+ <td class="value">
+ <input name="password" type="password" size="32" value=""/>
+ </td>
+ </tr>
+ <tr><td class="separator" colspan="2"><hr/></td></tr>
+ <tr>
+ <td class="message" colspan="2">
+ <input type="button" onclick='Javascript:login();' value='<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"index.Login")%>'/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
+
Propchange: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/login.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/login.jsp
------------------------------------------------------------------------------
svn:keywords = Id
Added: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/logout.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/logout.jsp?rev=1502525&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/logout.jsp (added)
+++ manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/logout.jsp Fri Jul 12 12:12:42 2013
@@ -0,0 +1,28 @@
+<%@ include file="adminDefaults.jsp" %>
+
+<%
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+%>
+
+<%
+adminprofile.logout();
+response.sendRedirect("login.jsp");
+%>
+
Propchange: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/logout.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/logout.jsp
------------------------------------------------------------------------------
svn:keywords = Id
Modified: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/navigation.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/navigation.jsp?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/navigation.jsp (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/navigation.jsp Fri Jul 12 12:12:42 2013
@@ -90,4 +90,7 @@
<li class="menuitem">
<nobr><a class="menulink" href='<%="http://manifoldcf.apache.org/release/trunk/"+Messages.getBodyString(pageContext.getRequest().getLocale(),"navigation.Locale")+"/end-user-documentation.html"%>' alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"navigation.Help")%>"><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"navigation.Help")%></a></nobr>
</li>
+ <li class="menuitem">
+ <nobr><a class="menulink" href="logout.jsp" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"navigation.LogOut")%>"><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"navigation.LogOut")%></a></nobr>
+ </li>
</ul>
Modified: manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/setupAdminProfile.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/setupAdminProfile.jsp?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/setupAdminProfile.jsp (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/crawler-ui/src/main/webapp/setupAdminProfile.jsp Fri Jul 12 12:12:42 2013
@@ -1,5 +1,6 @@
-<%
+<%@ include file="adminDefaults.jsp" %>
+<%
/* $Id$ */
/**
@@ -20,28 +21,20 @@
*/
%>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-
-<jsp:useBean id="adminprofile" class="org.apache.manifoldcf.ui.beans.AdminProfile" scope="session"/>
-
-<c:catch var="error">
- <c:if test="${param.valid=='true'}">
- <c:set value="${param.login}" target="${adminprofile}" property="userID"/>
- <c:set value="${param.password}" target="${adminprofile}" property="password"/>
- </c:if>
-
- <c:if test="${param.valid=='false'}">
- <c:set value="null" target="${adminprofile}" property="userID"/>
- </c:if>
-</c:catch>
-
-<c:if test="${error!=null}">
- <c:set target="${logger}" property="msg" value="Profile error!!!! ${error}"/>
- <c:set value="null" target="${adminprofile}" property="userID"/>
-</c:if>
-
-
-
-
+<%
+String userID = variableContext.getParameter("userID");
+String password = variableContext.getParameter("password");
+if (userID == null)
+ userID = "";
+if (password == null)
+ password = "";
+
+adminprofile.login(threadContext,userID,password);
+if (adminprofile.getLoggedOn())
+ response.sendRedirect("index.jsp");
+else
+{
+ // Go back to login page, but with signal that login failed
+ response.sendRedirect("login.jsp?loginfailed=true");
+}
+%>
Modified: manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/java/org/apache/manifoldcf/ui/beans/AdminProfile.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/java/org/apache/manifoldcf/ui/beans/AdminProfile.java?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/java/org/apache/manifoldcf/ui/beans/AdminProfile.java (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/java/org/apache/manifoldcf/ui/beans/AdminProfile.java Fri Jul 12 12:12:42 2013
@@ -34,16 +34,17 @@ public class AdminProfile implements Htt
public static final String _rcsid = "@(#)$Id: AdminProfile.java 988245 2010-08-23 18:39:35Z kwright $";
/** Time of login */
- private long loginTime = 0;
+ private long loginTime = -1L;
/** Logged in user */
private String userID = null;
- /** Session identifier */
- private String sessionIdentifier = null;
/** Set to "true" if user is logged in. */
private boolean isLoggedIn = false;
/** Set to "true" if user can manage users. */
private boolean manageUsers = false;
+ /** Session identifier */
+ private String sessionIdentifier = null;
+
/** Constructor.
*/
public AdminProfile()
@@ -61,15 +62,6 @@ public class AdminProfile implements Htt
return sessionIdentifier;
}
- /** Set the admin user id.
- *@param userID is the ID of the admin user to log in.
- */
- public void setUserID(String userID)
- {
- sessionCleanup(); // nuke existing stuff (i.e. log out)
- this.userID = userID;
- }
-
/** Get the admin user id.
*@return the last login user id.
*/
@@ -86,35 +78,35 @@ public class AdminProfile implements Htt
return manageUsers;
}
+ /** Log out the current user.
+ */
+ public void logout()
+ {
+ sessionCleanup();
+ }
+
/** Log on the user, with the already-set user id and company
* description.
*@param userPassword is the login password for the user.
*/
- public void setPassword(String userPassword)
+ public void login(IThreadContext threadContext,
+ String userID, String userPassword)
{
sessionCleanup();
try
{
// Check if everything is in place.
- IThreadContext threadContext = ThreadContextFactory.make();
- if (userID != null)
+ if (ManifoldCF.verifyLogin(threadContext,userID,userPassword))
{
- IDBInterface database = DBInterfaceFactory.make(threadContext,
- ManifoldCF.getMasterDatabaseName(),
- ManifoldCF.getMasterDatabaseUsername(),
- ManifoldCF.getMasterDatabasePassword());
- // MHL to actually log in (when we figure out what to use as an authority)
- if (userID.equals("admin") && userPassword.equals("admin"))
- {
- isLoggedIn = true;
- loginTime = System.currentTimeMillis();
- manageUsers = false;
- }
+ isLoggedIn = true;
+ loginTime = System.currentTimeMillis();
+ this.userID = userID;
+ manageUsers = false;
}
}
catch (ManifoldCFException e)
{
- Logging.misc.fatal("Exception logging in!",e);
+ Logging.misc.fatal("Exception logging in: "+e.getMessage(),e);
}
}
@@ -149,6 +141,9 @@ public class AdminProfile implements Htt
{
// Un-log-in the user
isLoggedIn = false;
+ userID = null;
+ manageUsers = false;
+ loginTime = -1L;
}
Modified: manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_en_US.properties?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_en_US.properties (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_en_US.properties Fri Jul 12 12:12:42 2013
@@ -32,10 +32,17 @@ editjob.HopFilters=Hop Filters
editjob.am=am
editjob.pm=pm
+index.ApacheManifoldCF=Apache ManifoldCF
index.WelcomeToApacheManifoldFC=Welcome to Apache ManifoldCF
+index.ApacheManifoldCFLogin=Apache ManifoldCF Login
+index.UserIDColon=User ID:
+index.PasswordColon=Password:
+index.Login=Login
+index.LoginFailed=Login failed!
banner.DocumentIngestion=Document Ingestion
+navigation.LogOut=Log Out
navigation.Outputs=Outputs
navigation.ListOutputConnections=List Output Connections
navigation.UserMappings=User Mappings
Modified: manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_ja_JP.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_ja_JP.properties?rev=1502525&r1=1502524&r2=1502525&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_ja_JP.properties (original)
+++ manifoldcf/branches/CONNECTORS-737/framework/ui-core/src/main/native2ascii/org/apache/manifoldcf/ui/i18n/common_ja_JP.properties Fri Jul 12 12:12:42 2013
@@ -32,10 +32,17 @@ editjob.HopFilters=ãããã�
editjob.am=åå
editjob.pm=åå¾
+index.ApacheManifoldCF=Apache ManifoldCF
index.WelcomeToApacheManifoldFC=Apache ManifoldCFã¸ãããã
+index.ApacheManifoldCFLogin=Apache ManifoldCF Login
+index.UserIDColon=User ID:
+index.PasswordColon=Password:
+index.Login=Login
+index.LoginFailed=Login failed!
banner.DocumentIngestion=ã³ã³ãã³ãã®èªè¾¼ã¿
+navigation.LogOut=Log Out
navigation.Outputs=åºå
navigation.ListOutputConnections=åºåã³ãã¯ã·ã§ã³ä¸è¦§
navigation.UserMappings=User Mappings