* committed to osgi bundle.

* remove ejb, created md5 filter to provide http way of retrieving md5 for report file
This commit is contained in:
Heng Sin Low 2010-07-14 11:41:52 +08:00
parent 4c28952212
commit e7407a390b
23 changed files with 338 additions and 662 deletions

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/JasperReports"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry combineaccessrules="false" kind="src" path="/JasperReportsTools"/> <classpathentry kind="output" path="build"/>
<classpathentry kind="output" path="build"/> </classpath>
</classpath>

View File

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.adempiere.JasperReports.webapp
Bundle-SymbolicName: org.adempiere.JasperReports.webapp;singleton:=true
Bundle-Version: 0.0.0.1
Require-Bundle: org.eclipse.osgi.services;bundle-version="3.1.100",
org.eclipse.core.runtime;bundle-version="3.5.0",
com.springsource.javax.servlet;bundle-version="2.5.0",
com.springsource.javax.servlet.jsp;bundle-version="2.1.0",
org.adempiere.base;bundle-version="0.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Web-ContextPath: jasperreports
Bundle-ClassPath: .

View File

@ -30,14 +30,14 @@
<servlet-class> <servlet-class>
org.compiere.web.GetMD5FileServlet org.compiere.web.GetMD5FileServlet
</servlet-class> </servlet-class>
<init-param>
<param-name>A parameter</param-name>
<param-value>A value</param-value>
</init-param>
</servlet> </servlet>
<filter>
<filter-name>MD5Filter</filter-name>
<filter-class>
org.compiere.web.MD5Filter
</filter-class>
</filter>
<!-- <!--
To use non XDoclet servlets, create a servlets.xml file that To use non XDoclet servlets, create a servlets.xml file that
contains the additional servlets (eg Struts) and place it in your contains the additional servlets (eg Struts) and place it in your
@ -51,17 +51,21 @@
<url-pattern>/GetMD5File</url-pattern> <url-pattern>/GetMD5File</url-pattern>
</servlet-mapping> </servlet-mapping>
<filter-mapping>
<filter-name>MD5Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- <!--
To specify mime mappings, create a file named mime-mappings.xml, put it in your project's mergedir. To specify mime mappings, create a file named mime-mappings.xml, put it in your project's mergedir.
Organize mime-mappings.xml following this DTD slice: Organize mime-mappings.xml following this DTD slice:
<!ELEMENT mime-mapping (extension, mime-type)> <!ELEMENT mime-mapping (extension, mime-type)>
--> -->
<!-- <!--
To specify error pages, create a file named error-pages.xml, put it in your project's mergedir. To specify error pages, create a file named error-pages.xml, put it in your project's mergedir.
Organize error-pages.xml following this DTD slice: Organize error-pages.xml following this DTD slice:
<!ELEMENT error-page ((error-code | exception-type), location)> <!ELEMENT error-page ((error-code | exception-type), location)>
--> -->
@ -73,7 +77,7 @@
<!-- <!--
To set up security settings for your web app, create a file named web-security.xml, put it in your project's mergedir. To set up security settings for your web app, create a file named web-security.xml, put it in your project's mergedir.
Organize web-security.xml following this DTD slice: Organize web-security.xml following this DTD slice:
<!ELEMENT security-constraint (display-name?, web-resource-collection+, auth-constraint?, user-data-constraint?)> <!ELEMENT security-constraint (display-name?, web-resource-collection+, auth-constraint?, user-data-constraint?)>
<!ELEMENT web-resource-collection (web-resource-name, description?, url-pattern*, http-method*)> <!ELEMENT web-resource-collection (web-resource-name, description?, url-pattern*, http-method*)>
<!ELEMENT web-resource-name (#PCDATA)> <!ELEMENT web-resource-name (#PCDATA)>
@ -81,7 +85,7 @@
<!ELEMENT http-method (#PCDATA)> <!ELEMENT http-method (#PCDATA)>
<!ELEMENT user-data-constraint (description?, transport-guarantee)> <!ELEMENT user-data-constraint (description?, transport-guarantee)>
<!ELEMENT transport-guarantee (#PCDATA)> <!ELEMENT transport-guarantee (#PCDATA)>
<!ELEMENT login-config (auth-method?, realm-name?, form-login-config?)> <!ELEMENT login-config (auth-method?, realm-name?, form-login-config?)>
<!ELEMENT auth-method (#PCDATA)> <!ELEMENT auth-method (#PCDATA)>
<!ELEMENT realm-name (#PCDATA)> <!ELEMENT realm-name (#PCDATA)>
@ -90,9 +94,4 @@
<!ELEMENT form-error-page (#PCDATA)> <!ELEMENT form-error-page (#PCDATA)>
--> -->
<ejb-ref>
<ejb-ref-name>ejb/compiere/MD5</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
</ejb-ref>
</web-app> </web-app>

View File

@ -0,0 +1,10 @@
bin.includes = META-INF/,\
.,\
standalone.jrxml
bin.excludes = src/**,\
.settings/**,\
.classpath,\
.project,\
build.properties,\
build.xml
source.. = src/

View File

@ -1,59 +1,32 @@
<?xml version="1.0"?>
<!-- ============================================= --> <!-- ============================================= -->
<!-- webApp --> <!-- Adempiere Server Root -->
<!-- ============================================= --> <!-- ============================================= -->
<!-- $Header: /cvs/adempiere/serverRoot/build.xml,v 1.4 2006/06/10 21:58:02 jjanke Exp $-->
<project name="webApp" default="main" basedir="."> <project name="JasperReportsWebApp" default="plugin" basedir=".">
<description>
Build the UI subproject within the Compiere project.
</description>
<!-- set global properties for this build -->
<property name="src" value="src"/>
<property name="build.dir" value="build"/>
<property name="dist.dir" value="."/>
<!--<property environment="env"/>--> <!--<property environment="env"/>-->
<import file="../utils_dev/properties.xml"/> <import file="../utils_dev/properties.xml"/>
<!-- set path to include the necessary jar files for javac --> <target name="init">
<path id="project.class.path"> <echo message="=========== Build JasperReports WebApp Bundle"/>
<pathelement path="${classpath}"/>
<fileset dir="../jboss/client" includes="*.jar"/>
<pathelement location="../JasperReports/CompiereJasper.jar" />
<pathelement location="../base/Base.jar" />
</path>
<target name="compile">
<echo>------ Compiling webApp</echo>
<mkdir dir="${build.dir}"/>
<javac target="1.6" srcdir="${src}" destdir="${build.dir}" deprecation="on" debug="on">
<classpath refid="project.class.path"/>
</javac>
</target> </target>
<target name="packaging"> <target name="clean" description="delete class directory">
<echo>------ packaging</echo> <delete>
<ant inheritall="false" antfile="packaging-build.xml"/> <fileset dir="../lib/plugins">
</target> <include name="org.adempiere.JasperReports.webapp*.jar"/>
</fileset>
<target name="deploy-interface"> </delete>
<echo>------ deploying interfaces to JasperReports</echo> </target>
<copy todir="../JasperReports/src">
<fileset dir="src" includes="org/compiere/interfaces/*.java"/>
</copy>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete file="webApp.war" failonerror="false"/>
<delete file="webApp.ear" failonerror="false"/>
<delete file="webAppEJB.jar" failonerror="false"/>
<delete file="webEJB-client.jar" failonerror="false"/>
</target>
<target name="main" depends="compile, packaging, deploy-interface" description="initialization target">
</target>
<target name="plugin">
<buildPlugin workspaceDirectory="${workspace}"
projectName="JasperReportsWebApp"
targetPlatformId="target.platform"
destination="../lib"
buildSourceJar="false"
clean="no"/>
</target>
</project> </project>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
version="5">
<display-name>Web App</display-name>
<module>
<ejb>webAppEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>webApp.war</web-uri>
<context-root>/webApp</context-root>
</web>
</module>
</application>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 4.2//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>compiereMD5</ejb-name>
<jndi-name>ejb/compiere/MD5</jndi-name>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss>

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
<jboss-web>
<!-- Resource Environment References -->
<!--
For additional resouce-env-ref tags add a merge file called jbossweb-resource-env-ref.xml
-->
<!-- Resource references -->
<!--
For additional resouce-ref tags add a merge file called jbossweb-resource-ref.xml
-->
<!-- EJB References -->
<!--
For additional ejb-ref tags add a merge file called jbossweb-ejb-ref.xml
-->
<ejb-ref>
<ejb-ref-name>ejb/compiere/MD5</ejb-ref-name>
<jndi-name>ejb/compiere/MD5</jndi-name>
</ejb-ref>
<!-- EJB Local References -->
</jboss-web>

View File

@ -1,98 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app >
<distributable/>
<!--
To use non XDoclet filters, create a filters.xml file that
contains the additional filters (eg Sitemesh) and place it in your
project's merge dir. Don't include filter-mappings in this file,
include them in a file called filter-mappings.xml and put that in
the same directory.
-->
<!--
To use non XDoclet filter-mappings, create a filter-mappings.xml file that
contains the additional filter-mappings and place it in your
project's merge dir.
-->
<!--
To use non XDoclet listeners, create a listeners.xml file that
contains the additional listeners and place it in your
project's merge dir.
-->
<!--
To use non XDoclet servlets, create a servlets.xml file that
contains the additional servlets (eg Struts) and place it in your
project's merge dir. Don't include servlet-mappings in this file,
include them in a file called servlet-mappings.xml and put that in
the same directory.
-->
<servlet>
<servlet-name>GetMD5File</servlet-name>
<display-name>Name for GetMD5File</display-name>
<description><![CDATA[Description for GetMD5File]]></description>
<servlet-class>org.compiere.web.GetMD5FileServlet</servlet-class>
<init-param>
<param-name>A parameter</param-name>
<param-value>A value</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>GetMD5File</servlet-name>
<url-pattern>/GetMD5File</url-pattern>
</servlet-mapping>
<!--
To specify mime mappings, create a file named mime-mappings.xml, put it in your project's mergedir.
Organize mime-mappings.xml following this DTD slice:
<!ELEMENT mime-mapping (extension, mime-type)>
-->
<!--
To specify error pages, create a file named error-pages.xml, put it in your project's mergedir.
Organize error-pages.xml following this DTD slice:
<!ELEMENT error-page ((error-code | exception-type), location)>
-->
<!--
To add taglibs by xml, create a file called taglibs.xml and place it
in your merge dir.
-->
<!--
To set up security settings for your web app, create a file named web-security.xml, put it in your project's mergedir.
Organize web-security.xml following this DTD slice:
<!ELEMENT security-constraint (display-name?, web-resource-collection+, auth-constraint?, user-data-constraint?)>
<!ELEMENT web-resource-collection (web-resource-name, description?, url-pattern*, http-method*)>
<!ELEMENT web-resource-name (#PCDATA)>
<!ELEMENT url-pattern (#PCDATA)>
<!ELEMENT http-method (#PCDATA)>
<!ELEMENT user-data-constraint (description?, transport-guarantee)>
<!ELEMENT transport-guarantee (#PCDATA)>
<!ELEMENT login-config (auth-method?, realm-name?, form-login-config?)>
<!ELEMENT auth-method (#PCDATA)>
<!ELEMENT realm-name (#PCDATA)>
<!ELEMENT form-login-config (form-login-page, form-error-page)>
<!ELEMENT form-login-page (#PCDATA)>
<!ELEMENT form-error-page (#PCDATA)>
-->
<ejb-ref >
<ejb-ref-name>ejb/compiere/MD5</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>org.compiere.interfaces.MD5</remote>
</ejb-ref>
</web-app>

View File

@ -1,37 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Compiere Jasper integration</title>
<meta name = "DC.Title"
content = "Compiere ERP CRM and JasperReports Integration"/>
<meta name = "DC.Subject"
content = "Compiere distribution fully integrated with JasperReports Open Source GPL"/>
<meta name = "DC.Date.Created"
content = "2005-03-23"/>
<meta name = "DC.Type"
scheme = "DCMIType"
content = "Software"/>
<meta name = "DC.Language"
content = "en"/>
</head>
<body bgcolor="#FFFFFF">
<a href="http://sourceforge.net"> <img src="http://sourceforge.net/sflogo.php?group_id=133118&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a>
<center><h1>Compiere Jasper Integration</h1><br/>
<h2>under construction</h2><h2>web designer wanted!</h2><br/>
Please visite the sourceforge project page <a href="http://sourceforge.net/projects/compierejaper/">here</a><br/>
If you want to join the project don't hesitate to contact<br/>Developers, web designer and testers are welcomed<br/><br/>
Access directly to latest files <a href="http://sourceforge.net/project/showfiles.php?group_id=133118">here</a><br/>and the documentation <a href="/doc/Compiere_with_JasperReports.pdf">here</a><br/>
Browse the JavaDoc <a href="/doc">here</a><br/><br/>Don't hesitate to use the <a href="http://sourceforge.net/forum/?group_id=133118">forums</a> it is the best place for any help<br/>
<h6>License information: the Open software presented here is under GPL license, but you must agree each license of each specific part included (ie: Compiere,jasperreports,iText, ant,..) each Trademark is propritary of its owner </h6>
</center>
</body>
</html>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
version="5">
<display-name>JasperReport Web App</display-name>
<module>
<ejb>webAppEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>webApp.war</web-uri>
<context-root>/webApp</context-root>
</web>
</module>
</application>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 4.2//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>compiereMD5</ejb-name>
<jndi-name>ejb/compiere/MD5</jndi-name>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss>

View File

@ -1,30 +0,0 @@
/*
* Generated file - Do not edit!
*/
package org.compiere.interfaces;
import javax.ejb.Remote;
/**
* Remote interface for compiere/MD5.
*/
@Remote
public interface MD5
{
public final static String JNDI_NAME = "ejb/compiere/MD5";
public final static String EJB_NAME = "compiereMD5";
/**
* Business method
* @param Filename
* @return AbsolutePath on server */
public java.lang.String getFileAsolutePath( java.lang.String Filename );
/**
* Business method
* @param FileName
* @return hash base64 encoded */
public java.lang.String getFileMD5( java.lang.String FileName );
}

View File

@ -1,95 +0,0 @@
/*
* Créé le 26 mars 2005
*
* TODO Pour changer le modčle de ce fichier généré, allez ŕ :
* Fenętre - Préférences - Java - Style de code - Modčles de code
*/
package org.compiere.utils;
import java.net.InetAddress;
import java.util.Hashtable;
import javax.naming.InitialContext;
import org.compiere.interfaces.MD5;
/**
* @author rlemeill
*/
public class MD5EjbTest {
/**************************************************************************
* constructor
* @param serverName
* @param context
* @param Filename
*/
public MD5EjbTest (String serverName,String Filename)
{
Hashtable env = new Hashtable();
env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
env.put(InitialContext.PROVIDER_URL, serverName);
System.out.println ("Creating context ...");
System.out.println (" " + env);
InitialContext context = null;
try
{
context = new InitialContext(env);
}
catch (Exception e)
{
System.err.println("ERROR: Could not create context: " + e);
return;
}
testEjb(serverName,context,Filename);
}
/**************************************************************************
* testing entry point
* @param serverName
* @param context
* @param Filename
*/
public static void testEjb(String serverName, InitialContext context, String Filename)
{
try{
System.out.println("MD5 Creation at: "+MD5.JNDI_NAME);
MD5 md5 = (MD5) context.lookup(MD5.JNDI_NAME);
System.out.println("Creation OK");
System.out.println("MD5 for " + Filename + " is " +md5.getFileMD5(Filename));
}
catch(Exception e)
{
}
}
/**************************************************************************
* Start Method
* @param args serverName Filename
*/
public static void main(String[] args)
{
String serverName = null;
String Filename = null;
if (args.length > 0)
serverName = args[0];
if (args.length > 1)
Filename = args[1];
if (serverName == null || serverName.length() == 0)
{
try
{
serverName = InetAddress.getLocalHost().getHostName();
}
catch (Exception e)
{
e.printStackTrace();
}
}
MD5EjbTest myMD5EjbTest = new MD5EjbTest(serverName,Filename);
}
}

View File

@ -4,30 +4,21 @@
* TODO Pour changer le modčle de ce fichier généré, allez ŕ : * TODO Pour changer le modčle de ce fichier généré, allez ŕ :
* Fenętre - Préférences - Java - Style de code - Modčles de code * Fenętre - Préférences - Java - Style de code - Modčles de code
*/ */
package org.compiere.ejb; package org.compiere.utils;
import java.net.URL; import java.net.URL;
import javax.ejb.Stateless;
import org.compiere.interfaces.MD5;
import org.compiere.util.CLogger;
import org.compiere.utils.DigestOfFile; import org.compiere.utils.DigestOfFile;
/** public class MD5Impl {
* @ejb:ejb-ref ejb-name="compiere/MD5"
* ref-name="compiere/MD5"
*/
@Stateless(mappedName=MD5.JNDI_NAME, name=MD5.EJB_NAME)
public class MD5Bean implements MD5 {
/** /**
* *
*/ */
private CLogger log = null; private CLogger log = null;
public MD5Bean() { public MD5Impl() {
super(); super();
log = CLogger.getCLogger(MD5Bean.class); log = CLogger.getCLogger(MD5Impl.class);
} }
/** /**
@ -56,23 +47,23 @@ public class MD5Bean implements MD5 {
{ {
absoluteFilename = FileName; absoluteFilename = FileName;
} }
if (absoluteFilename != null) if (absoluteFilename != null)
{ {
DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); DigestOfFile md5DigestAgent = new DigestOfFile("MD5");
hash = md5DigestAgent.digestAsBase64(new java.io.File(absoluteFilename)); hash = md5DigestAgent.digestAsBase64(new java.io.File(absoluteFilename));
} }
} }
catch(Exception e) catch(Exception e)
{ {
log.severe(e.getMessage()); log.severe(e.getMessage());
return null; return null;
} }
return hash; return hash;
} }
/** /**
* Business method * Business method
* @param Filename * @param Filename

View File

@ -9,8 +9,6 @@ package org.compiere.web;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletConfig; import javax.servlet.ServletConfig;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@ -19,39 +17,32 @@ import javax.servlet.http.HttpServletResponse;
import org.compiere.interfaces.MD5; import org.compiere.interfaces.MD5;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.compiere.utils.MD5Impl;
/** /**
* Servlet Class * Servlet Class
* *
* @author Michael Judd BF [2728388] - fix potential CSS vulnerability * @author Michael Judd BF [2728388] - fix potential CSS vulnerability
*/ */
public class GetMD5FileServlet extends HttpServlet { public class GetMD5FileServlet extends HttpServlet {
/** /**
* *
*/ */
private static final long serialVersionUID = -2625917637549702574L; private static final long serialVersionUID = -2625917637549702574L;
/** /**
* *
*/ */
private MD5 md5; private MD5Impl md5;
public GetMD5FileServlet() { public GetMD5FileServlet() {
super(); super();
// TODO Raccord de constructeur auto-généré // TODO Raccord de constructeur auto-généré
} }
public void init(ServletConfig config) throws ServletException { public void init(ServletConfig config) throws ServletException {
super.init(config); super.init(config);
try md5 = new MD5Impl();
{
Context context = new InitialContext();
md5 = (MD5) context.lookup("java:/comp/env/ejb/compiere/MD5");
}
catch(Exception e)
{
throw new ServletException("Error getting EJB: java:/comp/env/ejb/compiere/MD5");
}
} }
protected void doGet(HttpServletRequest req, HttpServletResponse resp) protected void doGet(HttpServletRequest req, HttpServletResponse resp)
@ -59,11 +50,21 @@ public class GetMD5FileServlet extends HttpServlet {
IOException { IOException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
String file = Util.maskHTML(req.getParameter("File")); String file = Util.maskHTML(req.getParameter("File"));
PrintWriter out = resp.getWriter(); String output = req.getParameter("output");
out.println("<HTML><HEAD><TITLE>MD5 Hash</TITLE></HEAD><BODY>"); if ("text".equalsIgnoreCase(output))
out.println("File is: "+ file + "<BR>MD5 : "+ md5.getFileMD5(file)+"<BR>"); {
//out.println(md5.getFileAsolutePath(file)); resp.setContextType("text/plain");
out.println("</BODY></HTML>"); PrintWriter out = resp.getWriter();
out.print(md5.getFileMD5(file));
}
else
{
PrintWriter out = resp.getWriter();
out.println("<HTML><HEAD><TITLE>MD5 Hash</TITLE></HEAD><BODY>");
out.println("File is: "+ file + "<BR>MD5 : "+ md5.getFileMD5(file)+"<BR>");
//out.println(md5.getFileAsolutePath(file));
out.println("</BODY></HTML>");
}
} }
} }

View File

@ -0,0 +1,111 @@
package org.compiere.web;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Implementation of <code>javax.servlet.Filter</code> used to compress
* the ServletResponse if it is bigger than a threshold.
*
* @author Amy Roh
* @author Dmitri Valdin
* @version $Revision: 1.2 $, $Date: 2004/03/18 16:40:33 $
*/
public class MD5Filter implements Filter{
/**
* The filter configuration object we are associated with. If this value
* is null, this filter instance is not currently configured.
*/
private FilterConfig config = null;
/**
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) {
config = filterConfig;
}
/**
* Take this filter out of service.
*/
public void destroy() {
this.config = null;
}
/**
* The <code>doFilter</code> method of the Filter is called by the container
* each time a request/response pair is passed through the chain due
* to a client request for a resource at the end of the chain.
* The FilterChain passed into this method allows the Filter to pass on the
* request and response to the next entity in the chain.<p>
* This method first examines the request to check whether the client support
* compression. <br>
* It simply just pass the request and response if there is no support for
* compression.<br>
* If the compression support is available, it creates a
* CompressionServletResponseWrapper object which compresses the content and
* modifies the header if the content length is big enough.
* It then invokes the next entity in the chain using the FilterChain object
* (<code>chain.doFilter()</code>), <br>
**/
public void doFilter ( ServletRequest request, ServletResponse response,
FilterChain chain ) throws IOException, ServletException {
if (request instanceof HttpServletRequest) {
// is md5 request
String s = (String) ((HttpServletRequest)request).getParameter("md5");
if (!"true".equals(s)) {
chain.doFilter(request, response);
return;
}
}
if (response instanceof HttpServletResponse) {
MD5ResponseWrapper wrappedResponse =
new MD5ResponseWrapper((HttpServletResponse)response);
try {
chain.doFilter(request, wrappedResponse);
} finally {
wrappedResponse.finishResponse();
}
return;
}
}
/**
* Set filter config
* This function is equivalent to init. Required by Weblogic 6.1
*
* @param filterConfig The filter configuration object
*/
public void setFilterConfig(FilterConfig filterConfig) {
init(filterConfig);
}
/**
* Return filter config
* Required by Weblogic 6.1
*/
public FilterConfig getFilterConfig() {
return config;
}
}

View File

@ -0,0 +1,53 @@
/**
*
*/
package org.compiere.web;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import javax.servlet.ServletOutputStream;
import sun.misc.BASE64Encoder;
/**
* @author hengsin
*
*/
public class MD5OutputStream extends ServletOutputStream {
private MessageDigest digestAgent;
/**
*
*/
public MD5OutputStream() {
try {
digestAgent = MessageDigest.getInstance("MD5", "SUN");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
e.printStackTrace();
}
}
/**
* @see java.io.OutputStream#write(int)
*/
@Override
public void write(int b) throws IOException {
digestAgent.update((byte) b);
}
/**
* @return md5 hash
*/
public String getMD5Hash() {
byte[] digest = digestAgent.digest();
BASE64Encoder base64Encoder = new BASE64Encoder();
String digestAsBase64 = base64Encoder.encode(digest);
return digestAsBase64;
}
}

View File

@ -0,0 +1,75 @@
/**
*
*/
package org.compiere.web;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
/**
* @author hengsin
*
*/
public class MD5ResponseWrapper extends HttpServletResponseWrapper {
private ServletOutputStream stream = null;
private PrintWriter writer = null;
private HttpServletResponse origResponse;
/**
* @param response
*/
public MD5ResponseWrapper(HttpServletResponse response) {
super(response);
origResponse = response;
}
public void finishResponse() {
if (stream != null) {
String digest = ((MD5OutputStream)stream).getMD5Hash();
origResponse.setContentType("text/plain");
origResponse.setContentLength(digest.getBytes().length);
try {
origResponse.getOutputStream().write(digest.getBytes());
origResponse.getOutputStream().flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public ServletOutputStream getOutputStream() throws IOException {
if (writer != null)
throw new IllegalStateException("getWriter() has already been called for this response");
if (stream == null)
stream = createOutputStream();
return (stream);
}
@Override
public PrintWriter getWriter() throws IOException {
if (writer != null)
return (writer);
if (stream != null)
throw new IllegalStateException("getOutputStream() has already been called for this response");
stream = createOutputStream();
writer = new PrintWriter(stream);
return writer;
}
private ServletOutputStream createOutputStream() {
stream = new MD5OutputStream();
return stream;
}
}

View File

@ -1,37 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Compiere Jasper integration</title>
<meta name = "DC.Title"
content = "Compiere ERP CRM and JasperReports Integration"/>
<meta name = "DC.Subject"
content = "Compiere distribution fully integrated with JasperReports Open Source GPL"/>
<meta name = "DC.Date.Created"
content = "2005-03-23"/>
<meta name = "DC.Type"
scheme = "DCMIType"
content = "Software"/>
<meta name = "DC.Language"
content = "en"/>
</head>
<body bgcolor="#FFFFFF">
<a href="http://sourceforge.net"> <img src="http://sourceforge.net/sflogo.php?group_id=133118&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a>
<center><h1>Compiere Jasper Integration</h1><br/>
<h2>under construction</h2><h2>web designer wanted!</h2><br/>
Please visite the sourceforge project page <a href="http://sourceforge.net/projects/compierejaper/">here</a><br/>
If you want to join the project don't hesitate to contact<br/>Developers, web designer and testers are welcomed<br/><br/>
Access directly to latest files <a href="http://sourceforge.net/project/showfiles.php?group_id=133118">here</a><br/>and the documentation <a href="/doc/Compiere_with_JasperReports.pdf">here</a><br/>
Browse the JavaDoc <a href="/doc">here</a><br/><br/>Don't hesitate to use the <a href="http://sourceforge.net/forum/?group_id=133118">forums</a> it is the best place for any help<br/>
<h6>License information: the Open software presented here is under GPL license, but you must agree each license of each specific part included (ie: Compiere,jasperreports,iText, ant,..) each Trademark is propritary of its owner </h6>
</center>
</body>
</html>

View File

@ -1,152 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created using an evaluation version of JasperAssistant (http://www.jasperassistant.com) -->
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="standalone" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">
<title>
<band height="782">
<staticText>
<reportElement x="0" y="50" width="150" height="40"/>
<textElement/>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="50" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="50" width="150" height="40"/><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="100" width="150" height="40"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="100" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="100" width="150" height="40"/><textElement><font size="14"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="150" width="150" height="40"/>
<textElement>
<font fontName="serif" size="12" pdfFontName="Times-Roman"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="150" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="150" width="150" height="40"/><textElement><font fontName="serif" size="12" pdfFontName="Times-Roman"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="200" width="150" height="40"/>
<textElement>
<font fontName="serif" size="12" isBold="true" isItalic="true" pdfFontName="Times-BoldItalic"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="200" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="200" width="150" height="40"/><textElement><font fontName="serif" size="12" isBold="true" isItalic="true" pdfFontName="Times-BoldItalic"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="250" width="150" height="40"/>
<textElement>
<font fontName="Comic Sans MS" size="12" isBold="false" pdfFontName="COMIC.TTF"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="250" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="250" width="150" height="40"/><textElement><font fontName="Comic Sans MS" size="12" isBold="false" pdfFontName="COMIC.TTF"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="300" width="150" height="40"/>
<textElement>
<font fontName="Comic Sans MS" size="12" isBold="true" pdfFontName="COMICBD.TTF"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="300" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="300" width="150" height="40"/><textElement><font fontName="Comic Sans MS" size="12" isBold="true" pdfFontName="COMICBD.TTF"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="350" width="150" height="40"/>
<textElement>
<font fontName="monospaced" size="12" isItalic="true" isUnderline="true" pdfFontName="Courier-Oblique"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="350" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="350" width="150" height="40"/><textElement><font fontName="monospaced" size="12" isItalic="true" isUnderline="true" pdfFontName="Courier-Oblique"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="400" width="150" height="40"/>
<textElement>
<font fontName="monospaced" size="12" isBold="true" isStrikeThrough="true" pdfFontName="Courier-Bold"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="400" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="400" width="150" height="40"/><textElement><font fontName="monospaced" size="12" isBold="true" isStrikeThrough="true" pdfFontName="Courier-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement x="0" y="450" width="150" height="40" forecolor="#ff0000"/>
<textElement>
<font size="14"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="450" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="450" width="150" height="40" forecolor="red"/><textElement><font size="14"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="0" y="500" width="150" height="40" forecolor="#ff00" backcolor="#ffff00"/>
<textElement>
<font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="500" width="390" height="40"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="500" width="150" height="40" forecolor="green" backcolor="#FFFF00" mode="Opaque"/><textElement><font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="0" y="550" width="150" height="90" forecolor="#ff" backcolor="#ffdd99"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="550" width="390" height="90"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="550" width="150" height="90" forecolor="blue" backcolor="#FFDD99" mode="Opaque"/><textElement textAlignment="Center" verticalAlignment="Middle"><font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="0" y="650" width="150" height="90" forecolor="#ff0000" backcolor="#99ddff"/>
<textElement textAlignment="Right" verticalAlignment="Bottom">
<font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/>
</textElement>
<text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text>
</staticText>
<staticText>
<reportElement x="160" y="650" width="390" height="90"/>
<textElement/>
<text><![CDATA[<staticText><reportElement x="0" y="650" width="150" height="90" forecolor="red" backcolor="#99DDFF" mode="Opaque"/><textElement textAlignment="Right" verticalAlignment="Bottom"><font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text>
</staticText>
</band>
</title>
</jasperReport>