|
|
|
|
|
|
Embedded server version
1 Foreword *
2 Parameters *
2.1 cachePath *
2.2 toTrace *
2.3 toStat *
2.4 ID *
2.5 logfile *
2.6 remoteLocations *
2.7 expiration *
2.8 contextPath *
2.9 useBundleSpace *
2.10 allPermissionPolicy *
2.11 defaultPolicy *
2.12 keystore *
2.13 keystorePassword *
2.14 CAURL *
2.15 CRLURL *
2.16 CALDAPuser *
2.17 CALDAPpasswd *
2.18 CRLLDAPuser *
2.19 CRLLDAPpasswd *
2.20 CRLperiod *
3 Statistics and troubleshooting *
4 Notes on implementation *
4.1 Dynamic update *
4.1.1 Definition section *
4.1.2 Loaded/defined section *
4.2 Resource handling *
5 Special cases *
5.1 RequestDispatcher *
5.2 Use of SSL *
5.3 Load test *
5.4 Functional tests *
5.4.1 Update *
5.4.2 Security *
5.4.3 Misc *
6 Limitations *
7 Differences between Application Server and JES 2 version *
8 Miscellaneous *
8.1 License *
8.2 Deliveries *
TABLE OF FIGURES
Figure 1: Statistics using ServletStat *
Figure 2: log using ServletLog *
Figure 3: ServletUpdate definition *
Figure 4: ServletUpdate list *
This document describes the Java Embedded Server 2 (JES2) version
of JSPservletPkg.
JSPservletPkg is a complete implementation for servlets and JSP handling from a remote repository and with dynamic update.
The document doesn’t refer to the Application Server version but when we describe the differences between both versions.
This version is designed to be deployed in JES2 bundles. So its archive must have a Manifest like this:
Bundle-Name: JSPservlet
Bundle-Description: JSPservlet
Bundle-Vendor: Alexis Grandemange (GNU GPL 2).
Bundle-Version: 1.0.1
Bundle-DocURL: http://java.sun.com/products/embeddedserver
Bundle-ContactAddress: alexis.grandemange@pagebox.net
Bundle-Activator: JSPservletPkg.JSPhandler
Import-Package: org.osgi.service.http,
javax.servlet; specification-version=2.1.1,
javax.servlet.http; specification-version=2.1.1,
com.sun.jes.service.http.auth.basic
Import-Service: com.sun.jes.service.http.auth.basic.BasicSchemeHandler
There is no limitation to the number of bundles, which can be configured, in a given Application Server.
Its configuration is specified by a property file named Bundle-Name.properties where Bundle-Name is the name you gave to the bundle in the manifest. Here is an example of configuration:
cachePath=/jdjThis file acts as the web.xml of Application Servers’ version.
We bolded the parameters that doesn’t exist in web.xml version.
The package must contain:
JSPservlet.properties
JSPservletPkg
CRLchecker.class
JSPhandler$ClassEntry$ServletInfo.class
JSPhandler$ClassEntry$Stat.class
JSPhandler$ClassEntry.class
JSPhandler$Log.class
JSPhandler$Scanner.class
JSPhandler.class
JSPloader$ClassInfo.class
JSPloader$ProtectionDomainInfo.class
JSPloader$ResourceEntry.class
JSPloader.class
JSPloaderException.class
JSPresourceServlet.class
JSPresourceServlet.class
PageBoxAPI.class
ServletLog.class
ServletStat.class
ServletUpdate.class
We detail below JSPservlet.properties parameters.
cachePathcachePath is the location where jars are locally stored after been retrieved from remote location.
Default value: C:/temp.
Tells if the tool must write diagnostic messages.
Default value: false.
Tells if the tool must record statistics.
Default value: false.
If true, statistics are recorded per archive in a file cachePath/archive.stat, which is a property file, for instance:
#Sun Nov 19 23:20:32 CET 2000
TestServlet/FileAccess=3
helloImg=8
TestServlet/OtherServlet=2
SnoopJSP=3
TestServlet/ForwardingServlet=4
SnoopServlet=2
Allows the deployer to specify a unique identifier.
PageBoxAPI allows retrieving this ID.
Application: deployment of a large number of instances.
No default value.
Tells where the tool must write diagnostic messages.
Default value: $CachePath/log.txt.
Location of a property file containing jar names and associated URLs.
Default value: $CachePath/$ContextPath.properties where ContextPath indicated the name the war file is deployed with.
JSPupdate updates this file. It is OK to modify it manually but don’t expect to retrieve your comments.
You can set this parameter to minimize the round trip number between the browser and the server.
JSPservlet sets the Expire header field of static content (content with an extension different of class). It computes the Expire as current_time + expiration.
expiration unit is second.
Default value: 5 seconds.
contextPath is the equivalent of the name you give to the JSPservletPkg Web Archive in Application Servers configuration.
Consider you configure JES2 http server to handle requests toward http://myserver:8080, you will invoke a servlet defined in archive myarchive.jar in mypath/myservlet with
http://myserver:8080/contextPath/myarchive/mypath/myservlet.
Default: none. Must be specified.
Boolean. If true, uses JES 2 BundleContext’s getDataFile to create File objects in the persistent storage area provided for the bundle by the framework.
We recommend setting it to true first because it is a requirement for well-behaving bundles and second because it provides useful features such as removing all bundle files when the bundle is uninstalled.
If you set it to true, path parameters are relative to the bundle space root but:
The reason is these files must be installed separately and are not related to a bundle.
This version requires the platform supports file systems
.Default: true.
If it is set, allPermissionPolicy is the path to a policy file with syntax conforming to the Java 2 security specification. If defaultPolicy is also set it means:
The following no-brainer allPermissionPolicy will work in all cases:
grant {
permission java.security.AllPermission;
};
Note that you should never grant permissions in cachePath/archive policy as these files are downloaded from the archive location.
Default: the parameter has no default value.
If it is set, defaultPolicy is the path to a policy file with syntax conforming to the Java 2 security specification. If allPermissionPolicy is also set it means:
If no policy applies to the archive, then defaultPolicy is used.
Default: the parameter has no default value.
keystore is the name of the key store in cachePath directory, for instance "keystore" but not "/mydir/keystore" or "mydir/keystore".
If keystore is set, when JSPservletPkg downloads an archive, it tries
The archive user has no longer to administrate security. It is appropriate for trusted providers.
Default: the parameter has no default value.
Password JSPservletPkg uses to access the keystore.
Default: the parameter has no default value.
When JSPservletPkg implements sandboxes, it processes signed archives and retrieve classes certificate chain. If CAURL is set, it connects to this URL and expects to retrieve a Certificate Authority certificate used in the classes certificate chain.
If it fails to connect to the CA or if what it retrieves is not a certificate, it logs an ERROR entry with "directory access failure". If the certificate is valid but not present in a class certificate chain, it invalidates the class just as if one of its certificates was revoked.
Note that JSPservletPkg doesn’t load the class and therefore doesn’t raise a security but a class not found exception.
If you set this parameter, you MUST add JNDI to your Java Server CLASSPATH in JDK 1.2. In JDK 1.3, you don’t have to, as JNDI is included in JDK.
Default: the parameter has no default value.
When JSPservletPkg implements sandboxes, it processes signed archives and retrieve classes certificates.
If CRLURL is set, it connects to this URL and expects to retrieve a Certificate Revocation List (CRL) used to check if a class certificate is revoked.
If it fails to connect to the CA or if what it retrieves is not a CRL, it logs an ERROR entry with "directory access failure". If the CRL is valid and it finds one of the class certificates in it, it invalidates the class.
Note JSPservletPkg doesn’t load the class and therefore doesn’t raise a security but a class not found exception.
If you set this parameter, you MUST add JNDI to your Java Server CLASSPATH in JDK 1.2. In JDK 1.3, you don’t have to, as JNDI is included in JDK.
Default: the parameter has no default value.
Principal used to connect to the Directory server to retrieve CAURL.
Default: the parameter has no default value. If it is not set, the tool connects to the Directory server without credential and password (LDAPpasswd).
Password used to connect to the Directory server to retrieve CAURL.
Default: the parameter has no default value.
Principal used to connect to the Directory server to retrieve CAURL.
Default: the parameter has no default value. If it is not set, the tool connects to the Directory server without credential and password (LDAPpasswd).
Password used to connect to the Directory server to retrieve CAURL.
Default: the parameter has no default value.
Defines how often the tool will connect to check for CRL updates in seconds.
Default: 7 * 24 * 3600 (1 week).
Figure 1: Statistics using ServletStat
Figure 2: log using ServletLog
You can use the log path that we list at the top of the screen to find out the bundle location.
However it is not a hidden secret: It starts with the value of com.sun.jes.framework.bundles.baseurl, which is
D:\Documents and Settings\Administrator\jescache in this case, followed by bundlebundle_id\data, where bundle_id is a number set by the framework.
Dynamic update of jar file is supported though ServletUpdate.
ServletUpdate display is split in two sections:
ServletUpdate uses GET mode. It is a servlet defined in the JSPservlet package.
Definition sectionYou must fill the JAR Name field without extension. If you don’t fill the remote location the current location is reused. It is the JAR file URL minus the file name.
Assuming you specified a jar name myjar and a remote location http://www.mydownloadsite.com, JSPserletPkg will download http://www.mydownloadsite.com/myjar.jar and persist your action in RemoteLocations with a property myjar=http://www.mydownloadsite.com.
Note the URL of ServletUpdate http://localhost:6080/jdj/JSPupdate. jdj is the contextPath. If you deploy different JSPservlet bundles, you must select the appropriate JSPservlet to require an update. When you updates, the local cache is removed and the jar is always loaded from the remote location. You can also use ServletUpdate to add a jar.
It supports a trace checkbox and two buttons:
You can safely require an update when pages are accessed.
GC allows to invoke System.gc() in the Java server context.
Typical case of that is image handling.
Suppose a JSP whose URL is http://www.mysite.com/jdj/myjar/myJSP references an image with a relative path images/myimage.gif. The Application Server looks for http://www.mysite.com/jdj/myjar/images/myimage.gif and therefore invokes JSPresourceServlet.
JSPresourceServlet looks first for images/myimage.gif in the archive. If it doesn’t find it, it retrieves the download location in the myjar’s RemoteLocations property. If it finds its remote location is
www.mydownloadsite.com, it downloads the image from www.mydownloadsite.com/images/myimage.gif.The only case where you must modify your code is when you need using a RequestDispatcher either to include or forward a request. You can use JSPservlet.getJAR() helper function.
RequestDispatcher rd = getServletContext().getRequestDispatcher(
JSPservlet.getJAR(getClass().getClassLoader()) + OtherServlet);
The reason is as a servlet developer you should not hardcode neither the Web Application name as the standard enforces it, neither the jar name where your servlet will be deployed.
JSPservlet allows using SSL to download archives using the ssl.jar bundle.
The explanation below is not JSPservlet related but it still can help you to configure SSL. As it can fail at your first attempt, we recommend you reading the JSSE API user guide. It explains you how to trace the SSL connection with javax.net.debug=all and gives you a lot of information.
You need first to SSL enable the Web Server where you download the archive from. It implies generating a key pair. The server keeps the private key internally and asks you to submit a certificate request to the Certificate Authority of your choice.
During the SSL handshaking, jsse will check it knows the certificate chain the Web Server presents it using the keystore specified by com.sun.jes.impl.keystore.store. A default keystore is defined in JES installation path/lib/tlscerts.
tlscerts format is jks, which means you can use keytool to display or update its content.If the server Certificate Authority certificate is not in the list, you have to add it.
Retrieving it depends on the browser and on the Certificate Authority. You can ask for a DER encoded or for a base 64 format.
Then you can add your server certificate with:
keytool -import -file C:\TEMP \serverCA.cer -alias myCA -keystore <JES2-home>/lib/tlscerts -storepass passphrase
With up to 3000 servlets in a single jar file.
The performance impact of tracing is below 10%.
The sandbox performance impact is not measurable.
ServletUpdate
Multiple archives, multiple web applications
Invalid archive name/location
Non-signed archive
Signed archive with and without sandbox. With sandbox:
1 policy file per web application or 1 per archive.
No permission granted to a signed archive.
Policy/certificate download
We checked the tool supports:
Limitations can be:
We chose to use Sun packages as much as possible.
public class TagextActivator implements BundleActivator {
public void start(BundleContext bundlecontext) {}
public void stop(BundleContext bundlecontext) {}
public TagextActivator() {}
}
We packaged the bundle with this manifest:
Manifest-Version: 1.0
Bundle-Vendor: apache.org
Bundle-Version: 1.0
Bundle-Activator: tagext.TagextActivator
Bundle-DocURL: http://jakarta.apache.org
Created-By: 1.2.2 (Sun Microsystems Inc.)
Bundle-Name: tagext
Bundle-ContactAddress: alexis.grandemange@pagebox.net
Export-Package: javax.servlet.jsp.tagext
Bundle-Description: tag extension
Import-Package: javax.servlet,javax.servlet.jsp,javax.servlet.http,org.apache.jasper,org.apache.jasper.runtime
You can consider an alternate solution where you add the JSP related stuff to JSPservlet.
Application Server version supports Servlet 2.2.
JES 2 version supports JES 2 Servlet 2.1.
Both versions should follow closely framework versions in the future.
Regarding development, it is the main difference.
The major design difference is
This has two important implications:
We chose to design the JES 2 version in that way to minimize its footprint.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Package name: JSPLoaderPkg.
Source files:
CRLchecker.java | JNDI/LDAP code |
JSPloader.java | class loader |
JSPloaderException.java | package exception |
JSPhandler.java | Web application handler |
JSPresourceServlet.java | Resource handling servlet |
PageBoxAPI.java | API to get the PageBox ID and log user messages |
ResourcePrivilegedAction.java | resource loader |
ServletLog.java | servlet to clear and display log |
ServletStat.java | servlet to display stats |
ServletUpdate.java | update servlet |
Documentation:
Installation
Constellations
Versions
Demo
Publisher
Mapper
Cocoon/SOAP
Security
Configurator
J2EE version
Embedded version
Diskless version
Contact:support@pagebox.net
©2001-2004 Alexis Grandemange
Last modified