/*\r
- * Copyright 1999,2004 The Apache Software Foundation.\r
+ * Copyright 1999,2004-2006 The Apache Software Foundation.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* @author Craig R. McClanahan\r
* @author Carson McDonald\r
* @author Ignacio Ortega\r
-* @version $Revision: 373023 $\r
+* @version $Revision: 394121 $\r
*/\r
\r
public class DataSourceRealm\r
/**\r
* The generated string for the roles PreparedStatement\r
*/\r
- private StringBuffer preparedRoles = null;\r
+ private String preparedRoles = null;\r
\r
\r
/**\r
* The generated string for the credentials PreparedStatement\r
*/\r
- private StringBuffer preparedCredentials = null;\r
+ private String preparedCredentials = null;\r
\r
\r
/**\r
throws SQLException {\r
\r
PreparedStatement credentials =\r
- dbConnection.prepareStatement(preparedCredentials.toString());\r
+ dbConnection.prepareStatement(preparedCredentials);\r
\r
credentials.setString(1, username);\r
return (credentials);\r
throws SQLException {\r
\r
PreparedStatement roles = \r
- dbConnection.prepareStatement(preparedRoles.toString());\r
+ dbConnection.prepareStatement(preparedRoles);\r
\r
roles.setString(1, username);\r
return (roles);\r
super.start();\r
\r
// Create the roles PreparedStatement string\r
- preparedRoles = new StringBuffer("SELECT ");\r
- preparedRoles.append(roleNameCol);\r
- preparedRoles.append(" FROM ");\r
- preparedRoles.append(userRoleTable);\r
- preparedRoles.append(" WHERE ");\r
- preparedRoles.append(userNameCol);\r
- preparedRoles.append(" = ?");\r
+ StringBuffer temp = new StringBuffer("SELECT ");\r
+ temp.append(roleNameCol);\r
+ temp.append(" FROM ");\r
+ temp.append(userRoleTable);\r
+ temp.append(" WHERE ");\r
+ temp.append(userNameCol);\r
+ temp.append(" = ?");\r
+ preparedRoles = temp.toString();\r
\r
// Create the credentials PreparedStatement string\r
- preparedCredentials = new StringBuffer("SELECT ");\r
- preparedCredentials.append(userCredCol);\r
- preparedCredentials.append(" FROM ");\r
- preparedCredentials.append(userTable);\r
- preparedCredentials.append(" WHERE ");\r
- preparedCredentials.append(userNameCol);\r
- preparedCredentials.append(" = ?");\r
-\r
+ temp = new StringBuffer("SELECT ");\r
+ temp.append(userCredCol);\r
+ temp.append(" FROM ");\r
+ temp.append(userTable);\r
+ temp.append(" WHERE ");\r
+ temp.append(userNameCol);\r
+ temp.append(" = ?");\r
+ preparedCredentials = temp.toString();\r
}\r
\r
\r
/**\r
* Set of attribute names which are not allowed to be persisted.\r
*/\r
- private static final String[] excludedAttributes = {\r
+ protected static final String[] excludedAttributes = {\r
Globals.SUBJECT_ATTR\r
};\r
\r
*/\r
public long getLastAccessedTime() {\r
\r
- if ( !isValid() ) {\r
+ if (!isValidInternal()) {\r
throw new IllegalStateException\r
- (sm.getString("standardSession.getId.ise"));\r
+ (sm.getString("standardSession.getId.ise"));\r
}\r
\r
return (this.lastAccessedTime);\r
return true;\r
}\r
\r
- if (!this.isValid ) {\r
+ if (!this.isValid) {\r
return false;\r
}\r
\r
*/\r
public long getCreationTime() {\r
\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.getCreationTime.ise"));\r
\r
*/\r
public Object getAttribute(String name) {\r
\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.getAttribute.ise"));\r
\r
*/\r
public Enumeration getAttributeNames() {\r
\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.getAttributeNames.ise"));\r
\r
*/\r
public String[] getValueNames() {\r
\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.getValueNames.ise"));\r
\r
*/\r
public void invalidate() {\r
\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.invalidate.ise"));\r
\r
*/\r
public boolean isNew() {\r
\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.isNew.ise"));\r
\r
public void removeAttribute(String name, boolean notify) {\r
\r
// Validate our current state\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.removeAttribute.ise"));\r
\r
}\r
\r
// Validate our current state\r
- if (!isValid())\r
+ if (!isValidInternal())\r
throw new IllegalStateException\r
(sm.getString("standardSession.setAttribute.ise"));\r
if ((manager != null) && manager.getDistributable() &&\r
\r
\r
/**\r
+ * Return the <code>isValid</code> flag for this session without any expiration\r
+ * check.\r
+ */\r
+ protected boolean isValidInternal() {\r
+ return (this.isValid || this.expiring);\r
+ }\r
+\r
+\r
+ /**\r
* Read a serialized version of this session object from the specified\r
* object input stream.\r
* <p>\r
* @exception ClassNotFoundException if an unknown class is specified\r
* @exception IOException if an input/output error occurs\r
*/\r
- private void readObject(ObjectInputStream stream)\r
+ protected void readObject(ObjectInputStream stream)\r
throws ClassNotFoundException, IOException {\r
\r
// Deserialize the scalar instance variables (except Manager)\r
*\r
* @exception IOException if an input/output error occurs\r
*/\r
- private void writeObject(ObjectOutputStream stream) throws IOException {\r
+ protected void writeObject(ObjectOutputStream stream) throws IOException {\r
\r
// Write the scalar instance variables (except Manager)\r
stream.writeObject(new Long(creationTime));\r
* To use, copy into the server/classes directory of the Tomcat installation\r
* and configure in server.xml as:\r
* <pre>\r
- * <Valve className="AccessLogDBValve"\r
+ * <Valve className="org.apache.catalina.valves.JDBCAccessLogValve"\r
* driverName="<i>your_jdbc_driver</i>"\r
* connectionURL="<i>your_jdbc_url</i>"\r
* pattern="combined" resolveHosts="false"\r
* id INT UNSIGNED AUTO_INCREMENT NOT NULL,\r
* ts TIMESTAMP NOT NULL,\r
* remoteHost CHAR(15) NOT NULL,\r
- * user CHAR(15),\r
+ * userName CHAR(15),\r
* timestamp TIMESTAMP NOT NULL,\r
* virtualHost VARCHAR(64) NOT NULL,\r
* method VARCHAR(8) NOT NULL,\r
* connectionURL = null;\r
* tableName = "access";\r
* remoteHostField = "remoteHost";\r
- * userField = "user";\r
+ * userField = "userName";\r
* timestampField = "timestamp";\r
* virtualHostField = "virtualHost";\r
* methodField = "method";\r
connectionURL = null;\r
tableName = "access";\r
remoteHostField = "remoteHost";\r
- userField = "user";\r
+ userField = "userName";\r
timestampField = "timestamp";\r
virtualHostField = "virtualHost";\r
methodField = "method";\r
* The descriptive information about this implementation.\r
*/\r
protected static String info = \r
- "org.apache.catalina.valves.JDBCAccessLogValve/1.0";\r
+ "org.apache.catalina.valves.JDBCAccessLogValve/1.1";\r
\r
\r
/**\r
out.printin("if (");\r
out.print(tagEvalVar);\r
out\r
- .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)");\r
+ .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");\r
out.pushIndent();\r
out.printil("out = _jspx_page_context.popBody();");\r
if (n.implementsTryCatchFinally()) {\r
out.println("[0]--;");\r
}\r
out.popIndent();\r
+ out.printil("}");\r
}\r
\r
out.popIndent(); // EVAL_BODY\r