我能想到的解决方法是CustomFormAuthenticator
扩展org.apache.catalina.authenticator.FormAuthenticator
并在/server/default/deployers/jbossweb.deployer/META-INF/war-deployers-jboss-beans.xml
. 现在在 Jboss AS 7 中,他们引入了阀门概念,您可以CustomAuthenticator
在其中注册jboss-web.xml
。
就像是..
public class CustomFormAuthenticator extends FormAuthenticator {
@override
public boolean authenticate(Request request, Response response, LoginConfig config) throws IOException {
boolean authenticate = super.authenticate(request, response, config);
//here you might need to keep track whether your custom/static code executed once or not,
//just to avoid executing the same code again and again.
if(authenticate) {
int i = CustomSingleton.getInstnce().getExecuteCount();
if(i <= 0) {
//invoke custom code.
//increment the count
CustomSingleton.getInstnce().incrementExecuteCount();
}
}
}
}
现在,需要server
在/server/default/deployers/jbossweb.deployer/META-INF/war-deployers-jboss-beans.xml
将以下内容添加entry
到authenticators
部分中进行注册。
<entry>
<key>CUSTOM-FORM</key>
<value>full.qaulified.CustomFormAuthenticator</value>
</entry>
然后,在 web.xml 中有CUSTOM-FORM
asauth-method
<login-config>
<auth-method>CUSTOM-FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/login-error.html</form-error-page>
</form-login-config>
<login-config>
希望这可以帮助..