Okay, so my final solution for programmatically setting up CAS via JNDI in 
JBoss:

web.xml config for the application with the CAS filter looks like this:

<filter>
  |   <filter-name>CAS Filter</filter-name>
  |   
<filter-class>com.discursive.cas.extend.client.filter.CASFilter</filter-class>
  |   <init-param>
  |     <param-name>com.discursive.cas.extend.client.config.jndi</param-name>
  |     <param-value>config/CASConfig</param-value>
  |   </init-param>
  | </filter>
  | 
  | <filter-mapping>
  |   <filter-name>CAS Filter</filter-name>
  |   <url-pattern>/*</url-pattern>
  | </filter-mapping>
  | 
  | ... 
  | 
  | <resource-ref> 
  |   <res-ref-name>config/CASConfig</res-ref-name>
  |   <res-type>com.discursive.cas.extend.client.CASConfig</res-type>  
  |   <res-auth>Container</res-auth>
  | </resource-ref>

jboss-web.xml config:

<resource-ref>
  |   <res-ref-name>config/CASConfig</res-ref-name>
  |   <jndi-name>config/CASConfig</jndi-name>
  | </resource-ref>

Now, set up a casconfig.sar with jboss-service.xml:


  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE server PUBLIC "-//JBoss//DTD MBean Service 4.0//EN"
  |           "http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd";>
  | <server>
  |   
  |   <mbean code="org.jboss.naming.JNDIBindingServiceMgr"
  |          name="com.example:service=CASConfig">
  |       <attribute name="BindingsConfig" serialDataType="jbxb">
  |          <jndi:bindings
  |             xmlns:xs="http://www.w3.org/2001/XMLSchema-instance";
  |             xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
  |             xs:schemaLocation="urn:jboss:jndi-binding-service:1.0 
resource:jndi-binding-service_1_0.xsd"
  |             >
  |             
  |                     <jndi:binding name="config/CASConfig">
  |                             <jndi:value 
editor="com.example.CASConfigLoader">
  |                                     config
  |                             </jndi:value>
  |                     </jndi:binding>
  |             
  |             
  |          </jndi:bindings>
  |       </attribute>
  |    </mbean>
  | 
  | 
  | </server>
  | 

and create two classes:


  | package com.example;
  | 
  | import org.jboss.util.propertyeditor.TextPropertyEditorSupport;
  | 
  | 
  | public class CASConfigLoader extends TextPropertyEditorSupport {
  | 
  |     public Object getValue() {
  |             SerializableCASConfig config = new SerializableCASConfig();
  |             config.setCasLogin("https://localhost:8443/cas/login";);
  |             
config.setCasValidate("https://localhost:8443/cas/proxyValidate";);
  |             config.setCasServerName("localhost:8080");
  |             config.setDummyTrust(true);
  |             
  |             return config;
  |     }
  |     
  | }
  | 

and:


  | package com.example;
  | 
  | import java.io.Serializable;
  | 
  | import com.discursive.cas.extend.client.CASConfig;
  | 
  | public class SerializableCASConfig extends CASConfig implements 
Serializable { }
  | 

Deploy the sar and your protected application and everything should be working.

In the getValue() method of your CASConfigLoader class you should be able to 
write more fancy code to pull configuration values from elsewhere .

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954147#3954147

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954147

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to