ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSOAPAuth.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
25 include_once("Auth/Auth.php");
26 if (version_compare(PHP_VERSION, '5.3.0', '>=') or 1)
27 {
28  include_once './webservice/soap/lib2/nusoap.php';
29 }
30 else
31 {
32  include_once './webservice/soap/lib/nusoap.php';
33 }
34 
41 class ilSOAPAuth extends Auth
42 {
43  var $valid = array();
44 
53  public static function testConnection($a_ext_uid, $a_soap_pw, $a_new_user)
54  {
55  global $ilSetting;
56 
57  $settings = $ilSetting->getAll();
58 
59  $server_hostname = $settings["soap_auth_server"];
60  $server_port = (int) $settings["soap_auth_port"];
61  $server_uri = $settings["soap_auth_uri"];
62  $namespace = $settings["soap_auth_namespace"];
63  $use_dotnet = $settings["soap_auth_use_dotnet"];
64  if ($settings["soap_auth_use_https"])
65  {
66  $uri = "https://";
67  }
68  else
69  {
70  $uri = "http://";
71  }
72 
73  $uri.= $server_hostname;
74 
75  if ($server_port > 0)
76  {
77  $uri.= ":".$server_port;
78  }
79 
80  if ($server_uri != "")
81  {
82  $uri.= "/".$server_uri;
83  }
84 
85  $soap_client = new soap_client($uri);
86  if ($err = $soap_client->getError())
87  {
88  return "SOAP Authentication Initialisation Error: ".$err;
89  }
90 
91  $soapAction = "";
92  $nspref = "";
93  if ($use_dotnet)
94  {
95  $soapAction = $namespace."/isValidSession";
96  $nspref = "ns1:";
97  }
98 
99  $valid = $soap_client->call('isValidSession',
100  array($nspref.'ext_uid' => $a_ext_uid,
101  $nspref.'soap_pw' => $a_soap_pw,
102  $nspref.'new_user' => $a_new_user),
103  $namespace,
104  $soapAction);
105 
106  return
107  "<br>== Request ==".
108  '<br><pre>' . htmlspecialchars(str_replace("\" ", "\"\n ", str_replace(">", ">\n", $soap_client->request)), ENT_QUOTES) . '</pre><br>'.
109  "<br>== Response ==".
110  "<br>Valid: -".$valid["valid"]."-".
111  '<br><pre>' . htmlspecialchars(str_replace("\" ", "\"\n ", str_replace(">", ">\n", $soap_client->response)), ENT_QUOTES) . '</pre>';
112  }
113 
114 
115 } // END class.ilSOAPAuth
116 ?>