1 /* zxidwspaxisin.java  -  Handler for Axis2 module for TAS3 WSP
2  * Copyright (c) 2009 Symlabs (symlabs@symlabs.com), All Rights Reserved.
3  * Author: Sampo Kellomaki (sampo@iki.fi)
4  * This is confidential unpublished proprietary source code of the author.
5  * NO WARRANTY, not even implied warranties. Contains trade secrets.
6  * Distribution prohibited unless authorized in writing.
7  * Licensed under Apache License 2.0, see file COPYING.
8  * $Id: zxidappdemo.java,v 1.4 2009-11-29 12:23:06 sampo Exp $
9  * 15.12.2009, created --Sampo
10  *
11  * See also: zxid-java.pd, zxidwspdemo.java for server side
12  * http://ws.apache.org/axis2/1_1/modules.html
13  */
14 
15 package zxidjava;
16 
17 import zxidjava.*;   // Pull in the zxidjni.az() API
18 import java.io.*;
19 import java.util.Iterator;
20 import javax.xml.namespace.QName;
21 
22 import org.apache.axiom.om.OMElement;
23 import org.apache.axiom.soap.SOAPHeader;
24 import org.apache.axiom.soap.SOAPHeaderBlock;
25 import org.apache.axis2.AxisFault;
26 import org.apache.axis2.context.MessageContext;
27 import org.apache.axis2.handlers.AbstractHandler;
28 import org.apache.axis2.util.XMLUtils;
29 import org.apache.ws.security.processor.SAMLTokenProcessor;
30 import org.w3c.dom.Element;
31 
32 public class zxidwspaxisin extends AbstractHandler {
33 
34     static final String conf = "URL=http://sp1.zxidsp.org:8080/sso&PATH=/var/zxid/";
35     static zxidjava.zxid_conf cf;
36     static {
37 	// CONFIG: You must have created /var/zxid directory hierarchy. See `make dir'
38 	// CONFIG: You must create edit the URL to match your domain name and port
39 	System.loadLibrary("zxidjni");
40 	cf = zxidjni.new_conf_to_cf(conf);
zxidjni.set_opt(cf, 1, 1)41 	zxidjni.set_opt(cf, 1, 1);
42     }
43 
zxidwspaxisin()44     public zxidwspaxisin() {
45 	// Constructor
46     }
47 
invoke(MessageContext mctx)48     public InvocationResponse invoke(MessageContext mctx) throws AxisFault {
49         if (!context.isEngaged(zxidwspaxismod.MODULE_NAME)) {
50             return InvocationResponse.CONTINUE;
51         }
52 
53 	zxid_ses ses = mctx.getProperty("zxidses");
54 
55 	String env = mctx.getEnvelope().toString();
56 	System.err.print("wsp in processing env("+env+").\n");
57 	String nid = zxidjni.wsp_validate(cf, ses, null, env);
58 	// *** validation error not handled
59 	System.err.print("Doing work for user nid("+nid+").\n");
60         return InvocationResponse.CONTINUE;
61     }
62 
63     /* ------------ ASC (1) ----------------- */
64 
invoke(MessageContext mctx)65     public InvocationResponse invoke(MessageContext mctx) throws AxisFault {
66         if (!context.isEngaged(zxidwspaxismod.MODULE_NAME)) {
67             return InvocationResponse.CONTINUE;
68         }
69 
70 	zxid_ses ses = zxidjni.as_call(cf, idp_meta, user, pw);
71 	mctx.putProperty("zxidses", ses);
72 
73 	String env = mctx.getEnvelope().toString();
74 	System.err.print("wsp in processing env("+env+").\n");
75 	String nid = zxidjni.wsp_validate(cf, ses, null, env);
76 	System.err.print("Doing work for user nid("+nid+").\n");
77         return InvocationResponse.CONTINUE;
78     }
79 
80 
81 
82 }
83 
84 /* EOF */
85