Enable BlazeDS 4 on Glassfish V3.1.1

I had been using BlazeDS 3 on Sun Glassfish Enterprise Application Server V2.1.1 for a long time. At that time, I followed someone's guide and hacked TomcatValve.java. And then BlazeDS 3 will be fully supported on Glassfish V2.1.1, including authentication of course.

But for Glassfish V3, I cannot find any guide, and authentication failed for Glassfish V3.1.1. And then I downloaded the source code of Glassfish V3.1.1 and BlazeDS 4, after 1 day's debugging. I got the solution hacking TomcatValve again. If you don't want to know the detail, just download the jar file or java file. For java file you have to compile that by yourself in BlazeDS 4 open source project. And for jar file, put them into the following directory:

$glassfish_home/glassfish/lib/

If you want to know all the detail about this issue, you can read the article below.

[b]What caused BlazeDS's TomcatValve failed to authenticate?[/b]

No method found for Realm.authenticate(String username, String password).

[b]Why BlazeDS's TomcatValve doesn't work for Glassfish V3.1.1 Server? [/b]

Glassfish changed it's method signature to Realm.authenticate(String username, char[] password).

[b]How to hack?[/b]

Simple replace the method invocation with the following code segment:

char[] passwordCharArray = password.toCharArray();

try {
Method m = realm.getClass().getMethod("authenticate",
String.class, char[].class);
principal = (Principal) m.invoke(realm, username,
passwordCharArray);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}



More details.

Glassfish(Tomcat) Server will configure Web Module via following class and method:

[align=center]WebModule.configureCatalinaProperties[/align]

/**
* Configure the <code>WebModule</code< properties.
* @param propName the property name
* @param propValue the property value
*/
protected void configureCatalinaProperties(String propName,
String propValue){
if (propName == null || propValue == null) {
logger.log(Level.WARNING,
"webcontainer.nullWebModuleProperty",
getName());
return;
}

if (propName.startsWith("valve_")) {
addValve(propValue);
} else if (propName.startsWith("listener_")) {
addCatalinaListener(propValue);
}
}



We can see, why we have to configure "<property name="valve_1" value="flex.messaging.security.TomcatValve"/>" into glassfish-web.xml,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值