2006-05-08

Setting SSL on Apache 2.0

I have been working on Ajax and JSOD recently to prototype different ways to access a secure web service in a cross domain manner. As a result, I need to setup different SSL secure domains on my local box. I have used name based virtual host with Apache 2.0 before to setup mutiple hosts on my box. But setting SSL sites could be a challenge.

Fortunately I found a execllent guide on the web and was able to follow it through. By the end of the last week, I had three virtual SSL hosts setup on my local desktop. Here are some important configurations for it to work.

Listen 443
LoadModule ssl_module modules/mod_ssl.so

Include conf/ssl.conf

SSLMutex none
SSLRandomSeed startup builtin
SSLSessionCache none

#
# Use name-based virtual hosting.
#
NameVirtualHost *:443

SSLEngine On
SSLCertificateFile conf/ssl/tokentest.crt
SSLCertificateKeyFile conf/ssl/tokentest.key
DocumentRoot C:/tmp/sites/token.test.com
ServerName token.test.com
ErrorLog C:/tmp/sites/token.test.com/error.log
CustomLog C:/tmp/sites/token.test.com/access.log common

SSLEngine On
SSLCertificateFile conf/ssl/tokentest.crt
SSLCertificateKeyFile conf/ssl/tokentest.key
DocumentRoot C:/tmp/sites/www.test.com
ServerName www.test.com
ErrorLog C:/tmp/sites/www.test.com/error.log
CustomLog C:/tmp/sites/www.test.com/access.log common

SSLEngine On
SSLCertificateFile conf/ssl/tokentest.crt
SSLCertificateKeyFile conf/ssl/tokentest.key
DocumentRoot C:/tmp/sites/www.tokentest.com
ServerName www.tokentest.com
ErrorLog C:/tmp/sites/www.tokentest.com/error.log
CustomLog C:/tmp/sites/www.tokentest.com/access.log common

Implementing web service on JBoss 4.0.3

My recent project involves implementing web services on JBoss platform. The current implementation (4.0.3) is based on a modified Axis code base and does not provides a good support on top-down (starts from WSDL) development approach. I ended up have to integrate Axis 1.2 with JBoss 4.0.3. It works well so far.

At the same time, I have been looking into the next generation of JBoss WS which looks like very promising. During the course, I was also able to make some contribution to the new code base, fixing two defects (JBWS 754-755). I hope I will have more time in the future to make more contributions.

A maven 1.x plug-in for Agitar

I have been spending some time to create a Maven 1.x plug-in for Agitar . It was finally done last week and I have posted it on Agitar's forum .

2006-04-05

A Python script to sync. with Perforce

I have been using Fitnesse for a while. But I am not happy with the file system based backup. There is no easy way to setup a SCM back end for the Fitnesse. So I end up have to write a Python script to periodically sync. my local page with a Perforce depot. It works quite convenient.

Bitten by Maven

I have been struggling with my Maven script for a few hours. Finally it turned out is because of a property name I used. After I changed the name from "someA-someB" to "someA.someB", the problem is gone. Maven just does not like '-'.

2006-03-06

Turn off caching for Firefox

I have a need to turn off the caching for a particular page. I suppose the correct way is to set the cache directive in my Http request:

Cache-Control: no-cache

The server correctly returns the new version. The Firefox, however, insists to return me the cached old version.
So I have to turn the entire Firefox caching capability off through its about:config page
network.http.use-cache = false.

Too bad.

My first grease monkey script

I wrote my first grease monkey script today. It is to apply a XSLT style sheet on certain types of XML files. This is because usually the xml contains too much information and I just want ot view certain part of it and in more clean format such as a table. Here is the code:

/*
Title:
xml transformer

Description:
This is a Greasemonkey user script for Firefox.

This script applies XSLT on plain XML files
*/

// ==UserScript==
// @name xml transformer
// @namespace http://sample.com
// @description apply XSLT on plain XML
// @include http://localhost/*.xml
// ==/UserScript==

var contentType = 'text/html';
detectFormats();

function detectFormats() {
// define classNames and URLs of corresponding XSLT files - edit this to add new formats
var b = new Array();
b[0] = new Array('Root1', 'http://localhost/gmonkey/xslt/root1.xslt', 'text/html');
b[1] = new Array('Root2', 'http://localhost/gmonkey/xslt/root2.xslt', 'text/html');

// look for certain signature in document
for (i=0; i<b.len; i++) {
var schemaType = b[i][0];
if (document.getElementsByTagName(schemaType).length > 0){
xsltURL = b[i][1];
contentType = b[i][2];
GM_log(xsltURL);
fetchXSLT(xsltURL);
}
}
}

function fetchXSLT(url){
GM_xmlhttpRequest({
method: "GET",
url: url,
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept': 'application/atom+xml,application/xml,text/xml',
'Cache-Control': 'no-cache',
},
onload: function(response) {
var xslt = new DOMParser().parseFromString(response.responseText, "text/xml");
transformXML(xslt);
}
});
}

// transform the document to RDF using the XSLT file
function transformXML(xslt){
var processor = new XSLTProcessor();
processor.importStylesheet(xslt);
var dataXML = document;
var processed = processor.transformToDocument(dataXML);
var dataString = (new XMLSerializer()).serializeToString(processed);
location.href = 'data:' + contentType + ',' + dataString;
}

2006-02-17

Mapping xml to Python objects

I need to process XML in my python code and prefer to deal with the data in the pythonic way. From a wide options available, I choose to play with 3 of them.

* generateDS
*
gnosis.xml.objectify
*
amara

Because I am a fan of XmlBeans, it seems that generateDS should be my favorite choice. However, when I tried to run the code-generating script on my schema file, it encountered some recursive problem and complained:

.... parent.collectElementNames(elementNames) File "C:\Python\Lib\site-packages\generateDS.py", line 478, in collectElementNames parent.collectElementNames(elementNames) File "C:\Python\Lib\site-packages\generateDS.py", line 475, in collectElementNames base = self.getBase() RuntimeError: maximum recursion depth exceeded

The same schema file works fine with XMLBeans however.

gnosis.xml.objectify and amara are similar in that they don't require a schema file and will just turn any well-formed xml file into python objects. I had no problem parse the xml files with both modules. However, the gnosis.xml.objectify module seems not aware of the namespace prefix. Given following xml element:

<ns:book xmlns:ns="http://mycompany/bookproject">..

It generates an object called ns_book. It does not recognize : as a namespace prefix and just blindly translates it to _. I tried to search for a solution, but could not find anything.

The amara module, however, correct translates the object name to book and also keeps the namespace information. It seems that I will use this module at this time.

2006-02-16

2 tips about JBoss

* to retrieve the server name, such as "minimal", "default", "max", in your code

String serverName = System.getProperty( org.jboss.system.server.ServerConfig.SERVER_NAME); 


* to set an unique Xid for each JBoss instance

if you are running multiple JBoss instances on the same machine, you probably want to give each instance a unique Xid base name. To do it, you need to add
the following line in the jboss-service.xml:

<mbean code="org.jboss.tm.XidFactory" name="jboss:service=XidFactory">
<attribute name="BaseGlobalId">UniqueInstanceName</attribute>
<!--attribute name="Pad">true</attribute-->
</mbean>

2006-02-15

Successfully installed Twisted

I need to install the latest Twisted with Python 2.4. Unfortunately I don't have Visual Studio on my machine. Is there a way to do it. I find this excellent instruction on how to install Python extensions without VS. It works as advertised. I am happily running Twisted now!