Calendar example worked (with page import java.util.Calendar) :)
This is the Pam.java class the class compiles to
WEB-INF/classes/net/digitalassembly/auth/Pam.class
package net.digitalassembly.auth;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;
import net.digitalassembly.auth.PamModule;
import net.digitalassembly.auth.PamHibernateModule; // May need to have this in
the config file to make it plugable
public class Pam {
/* Pam has a list of modules that it can support
* There is a interface called PamModule that allows
* other "modules" to interact with Pam
* Pam should be a singleton
* Does PAM ONLY allow one mechanism? I think Not
*/
private static Pam instance = new Pam();
private String pamConfigFile = "pam.conf"; // Static file for all
modules
private List<PamModule> pamModules = new ArrayList();
private Properties pamProperties = new Properties();
private Pam() {
try {
pamProperties.load(new FileInputStream(pamConfigFile));
} catch (IOException ioe) {
System.out.println("File not found");
this.instance = null;
}
System.out.println(pamProperties.getProperty("pam.hibernate.plugin"));
if
(pamProperties.getProperty("pam.hibernate.plugin").equalsIgnoreCase("true")) {
pamModules.add(PamHibernateModule.getInstance());
}
if
(pamProperties.getProperty("pam.db.plugin").equalsIgnoreCase("true")) {
pamModules.add(PamHibernateModule.getInstance());
}
if
(pamProperties.getProperty("pam.ldap.plugin").equalsIgnoreCase("true")) {
pamModules.add(PamHibernateModule.getInstance());
}
if
(pamProperties.getProperty("pam.file.plugin").equalsIgnoreCase("true")) {
pamModules.add(PamHibernateModule.getInstance());
}
}
public boolean authenticate(String username, String password) {
System.out.println("Running Authenticate");
for (PamModule module: pamModules) {
System.out.println(module);
boolean pass = false;
pass = module.authenticate(username,password);
if (pass == true) {
return true;
}
}
return false;
}
public static Pam getInstance() {
return instance;
}
}
The file that is trying to use it is authenticate.jsp which contains the
following:
<%@ page import="net.digitalassembly.auth.Pam" %>
<%
Pam pam = Pam.getInstance();
if (pam != null) {
if
(pam.authenticate(request.getParameter("username"),request.getParameter("password")))
{
session.setAttribute("validUser",request.getParameter("username"));
}
response.sendRedirect("/CharacterForge/forge/index.jsp");
} else {
out.println("Pam failed to initialize");
}
%>
*
The error I get is:*
org.apache.jasper.JasperException: Exception in JSP: /authenticate.jsp:3
1: <%@ page import="net.digitalassembly.auth.Pam" %>
2: <%
3: Pam pam = Pam.getInstance();
4: if (pam != null) {
5: if
(pam.authenticate(request.getParameter("username"),request.getParameter("password")))
{
6:
session.setAttribute("validUser",request.getParameter("username"));
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
*root cause*
javax.servlet.ServletException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.authenticate_jsp._jspService(authenticate_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
*root cause*
java.lang.NoClassDefFoundError
org.apache.jsp.authenticate_jsp._jspService(authenticate_jsp.java:46)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Any help would be appreciated. I have other classes (not implementing
singleton pattern) that don't have any issues.
Hence why I was thinking it was a singleton/tomcat issue I was causing.
Thanks
Thomas
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]