Focal Point
[SOLVED] Custom wfext to enforce cookie-based security - how to load?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6337073016

September 28, 2011, 12:53 PM
TomC
[SOLVED] Custom wfext to enforce cookie-based security - how to load?
First of all thanks for reading this, and sorry if it turns into a long post.

I have written a very basic custom wfext in Java which extends ibi.webfoc.WFEXTDefault. Eventually the class will decrypt an encrypted cookie and set variables in the variable table for my reports based on the value of the cookie. Right now I'm just checking for the cookie's existence, and setting a WebFOCUS variable in either case.

The class is compiled and sitting in what I think is the classpath (ibi\WebFOCUS77\webapps\webfocus\WEB-INF\classes). I updated Site.wfs through the administration console to call the class's main function. Although the documentation I'm reading (WebFocus 7 Security and Administration) doesn't seem to mention it, I saw in another post here that I needed to edit ibi\WebFOCUS77\webapps\webfocus\WEB-INF\web.xml to tell it to load my class.

The documentation says that if my deployment is open-directory based this should be enough, but I don't know how to check if it is, or if it's .war based. I'm assuming .war based (and therefore I have to rebuild the .war as so far nothing has changed and my reports do not have access to the parameter I set in the wfext).

I am hoping that someone will be kind enough to help me answer the following questions:
1) Which .war file needs rebuilding for my class to be recognised by WebFOCUS (so far I haven't experimented as others are using the reporting server. I assume it's this one ibi\WebFOCUS77\webapps\webfocus.war)?
2) My class includes a number of system.out.println statements for debugging but I have no idea how I turn on tracing or where I would see the output. I do not have much experience with Tomcat or with Java servlets.

Please see relevant code extracts below:

wfext class
 
public class cookieInterpreter extends ibi.webfoc.WFEXTDefault
{
	public cookieInterpreter() { 
		super();
		System.out.println("[WFEXT] cookieInterpreter"); 
	}

	public long setAuthCookie(String[] NewVars, HttpServletRequest req) {

		...

		if(hasAuthCookie) {
			NewVars[0] = "ROLE=Administrator";
			return 0;
		} else {
			NewVars[0] = "ROLE=None";
			return 1;
		}
		
		...
	}
}


Site.wfs
<call> setAuthCookie()


web.xml
  <servlet>
    <description>WebFOCUS Servlet</description>
    <display-name>WFServlet</display-name>
    <servlet-name>WFServlet</servlet-name>
    <servlet-class>ibi.webfoc.WFServlet</servlet-class>
	<init-param>
		<param-name>WFEXT</param-name>
		<param-value>cookieInterpreter</param-value>
		<description>WebFocus servlet callable exit</description>
	</init-param>
    <load-on-startup>2</load-on-startup>  
  </servlet>

This message has been edited. Last edited by: Kerry,


WebFocus 7.7
Windows Server 2008 R2
HTML Reporting
September 28, 2011, 01:38 PM
Sayed
You should be able to deploy/undeploy using the Admin/Manager link on Tomcat.

Look at this post.
Deploy WAR file on Tomcat

Thanks,
Sayed


WF 8.x and 7.7.x Win/UNIX/AS400, MRE/Portal/Self-Service, IIS/Tomcat, WebSphere, IWA, Realmdriver, Active Directory, Oracle, SQLServer, DB2, MySQL, JD Edwards, E-BIZ, SAP BW, R/3, ECC, ESSBASE
September 28, 2011, 02:40 PM
TomC
Sayed thanks for your response. However I'm still unsure on two things:
1) Is it the webfocus.war archive that I need?
2) Once the .war is re-deployed I understand it will be unpacked into a directory structure - is there any danger of this overwriting currently configuration files? I didn't deploy the current system and don't know what could break from the re-deploy.


WebFocus 7.7
Windows Server 2008 R2
HTML Reporting
September 28, 2011, 03:30 PM
Sayed
1)Yes, webfocus.war.
2)I'd backup the whole ibi directory or atleast ibi\webfocusXXX as a precaution.

Thanks,
Sayed


WF 8.x and 7.7.x Win/UNIX/AS400, MRE/Portal/Self-Service, IIS/Tomcat, WebSphere, IWA, Realmdriver, Active Directory, Oracle, SQLServer, DB2, MySQL, JD Edwards, E-BIZ, SAP BW, R/3, ECC, ESSBASE
September 28, 2011, 07:56 PM
TomC
After re-deploying the .war and figuring out how to enable tracing I see the following in my trace:

ibi.webfoc.wfutil.WFAction_CALL.Invoke(WFScriptAction.java:1523):Could not load user class: my.namespace.wfservlet.cookieInterpreter

Since re-deploying the updated .war I can see my class in ibi\WebFOCUS77\webapps\webfocus\WEB-INF\classes. Can anyone confirm that this is the correct location?

Is it possible that I'm having a namespacing problem? The namespace of my class's package matches the fully-qualified path I used in the Administration Console's Configuration -> Plugin -> WFEXT value.

I have no idea where to go next and unfortunately the documentation is not helping. Any assistance would be greatly appreciated.


WebFocus 7.7
Windows Server 2008 R2
HTML Reporting
October 03, 2011, 03:33 PM
dhagen
quote:
Originally posted by TomC:

ibi.webfoc.wfutil.WFAction_CALL.Invoke(WFScriptAction.java:1523):Could not load user class: my.namespace.wfservlet.cookieInterpreter

Since re-deploying the updated .war I can see my class in ibi\WebFOCUS77\webapps\webfocus\WEB-INF\classes. Can anyone confirm that this is the correct location?

If you are deploying this as a class, then it should be in ibi\WebFOCUS77\webapps\webfocus\WEB-INF\classes\my\namespace\wfservlet. classes must be deployed in a directory structure that matches the package name.

p.s. You should change your return types to a long ... 0L instead of 0, and 1L instead of 1.

This message has been edited. Last edited by: dhagen,


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
October 04, 2011, 05:39 PM
TomC
Thanks dhagen that did the trick, now my class is being loaded as expected


WebFocus 7.7
Windows Server 2008 R2
HTML Reporting