1<? 2# zxid/zxidwspdemo.php - Hello World Id-WSF WSP using zxid PHP extension 3# 4# Copyright (c) 2010 Sampo Kellomaki (sampo@iki.fi), All Rights Reserved. 5# Copyright (c) 2009 Symlabs (symlabs@symlabs.com), All Rights Reserved. 6# Author: Sampo Kellomaki (sampo@iki.fi) 7# This is confidential unpublished proprietary source code of the author. 8# NO WARRANTY, not even implied warranties. Contains trade secrets. 9# Distribution prohibited unless authorized in writing. 10# Licensed under Apache License 2.0, see file COPYING. 11# $Id$ 12# 27.11.2009, Created, --Sampo 13# 14# QUERY_STRING=o=B REQUEST_METHOD=GET php ./zxidwspdemo.php 15# Discovery registration: ./zxcot -e http://sp.tas3.pt:8082/zxidwspdemo.php 'TAS3 WSP PHP Demo' http://sp.tas3.pt:8082/zxidwspdemo.php?o=B urn:x-foobar | ./zxcot -d -b /var/zxid/idpdimd 16 17dl("php_zxid.so"); # These three lines can go to initialization: they only need to run once 18# CONFIG: You must have created /var/zxid directory hierarchy. See `make dir' 19# CONFIG: You must edit the URL to match your domain name and port 20#$conf = "URL=https://sp1.zxidsp.org:5443/zxidwspdemo.php&PATH=/var/zxid/"; 21$conf = "PATH=/var/zxid/&URL=http://sp.tas3.pt:8082/zxidwspdemo.php"; 22$cf = zxid_new_conf_to_cf($conf); 23zxid_set_opt_cstr($cf, 2, "\tzxphp"); 24?> 25<? 26zxid_set_opt_cstr($cf, 3, "wsp: "); 27$fullURL = "http://" + $_SERVER['HTTP_HOST'] + $_SERVER['SCRIPT_NAME']; 28#zxid_url_set($cf, $fullURL); # Virtual host support 29error_log("fullURL($fullURL)"); 30 31# For every page that is accessed. Debug: QUERY_STRING=o=E REQUEST_METHOD=GET ./zxidhlo.php 32#print_r(phpinfo()); 33#print_r($_SERVER); 34$qs = $_SERVER['REQUEST_METHOD'] == 'GET' 35 ? $_SERVER['QUERY_STRING'] 36 : file_get_contents('php://input'); 37error_log("zxidphp: qs($qs)"); 38 39if ($qs == "o=B") { # As a pure WSP, we only support metadata request. No SSO here. 40 $res = zxid_simple_cf($cf, -1, $qs, null, 0x1814); 41 error_log("zxidphp: res($res) conf($conf)"); 42 switch (substr($res, 0, 1)) { 43 case 'L': header($res); zxid_set_opt_cstr($cf, 4, "wsp: "); exit; # Redirect (Location header) 44 case '<': header('Content-type: text/xml'); echo $res; zxid_set_opt_cstr($cf, 4, "wsp: "); exit; # Metadata or SOAP 45 default: zxid_set_opt_cstr($cf, 4, "wsp: "); die("Unhandled zxid_simple() res($res)"); 46 } 47} 48 49error_log("zxidphp: processing SOAP request "); 50 51$ses = zxid_fetch_ses($cf, $attr['sesid']); 52 53$nid = zxid_wsp_validate($cf, $ses, null, $qs); 54 55error_log("working for nid($nid)"); 56 57if (zxid_az_cf_ses($cf, "Action=Call", $ses)) { 58 echo zxid_wsp_decorate($cf, $ses, null, 59 "<barfoo>" + 60 "<lu:Status code=\"OK\" comment=\"Permit\"></lu:Status>" + 61 "<data>nid="+nid+"</data>" + 62 "</barfoo>"); 63} else { 64 echo zxid_wsp_decorate($cf, $ses, null, 65 "<barfoo>" + 66 "<lu:Status code=\"Fail\" comment=\"Deny\"></lu:Status>" + 67 "<data>Deny: nid="+nid+"</data>" + 68 "</barfoo>"); 69} 70 71zxid_set_opt_cstr($cf, 4, "wsp: "); 72 73?> 74