ILIAS  trunk Revision v12.0_alpha-1613-gae4c99ebb18
ILIAS\AuthSOAP\ConnectionTester Class Reference
+ Collaboration diagram for ILIAS\AuthSOAP\ConnectionTester:

Public Member Functions

 __construct (private \ilSetting $settings, private Factory $ui_factory, private ilLogger $logger,)
 
 testConnection (string $ext_uid, string $soap_pw, bool $new_user)
 

Private Member Functions

 renderXmlBlock (string $xml)
 
 formatXmlForDisplay (string $xml)
 
 prettyPrintXml (string $xml)
 

Detailed Description

Definition at line 27 of file ConnectionTester.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AuthSOAP\ConnectionTester::__construct ( private \ilSetting  $settings,
private Factory  $ui_factory,
private ilLogger  $logger 
)

Definition at line 29 of file ConnectionTester.php.

33 {
34 }

Member Function Documentation

◆ formatXmlForDisplay()

ILIAS\AuthSOAP\ConnectionTester::formatXmlForDisplay ( string  $xml)
private

Definition at line 82 of file ConnectionTester.php.

82 : string
83 {
84 if (trim($xml) === '') {
85 return '(no XML captured)';
86 }
87
88 $formatted = $this->prettyPrintXml($xml);
89 $escaped = htmlspecialchars($formatted, ENT_QUOTES);
90 $escaped = str_replace(' ', ' ', $escaped);
91
92 return nl2br($escaped, false);
93 }

References ILIAS\AuthSOAP\ConnectionTester\prettyPrintXml().

Referenced by ILIAS\AuthSOAP\ConnectionTester\renderXmlBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prettyPrintXml()

ILIAS\AuthSOAP\ConnectionTester::prettyPrintXml ( string  $xml)
private

Definition at line 95 of file ConnectionTester.php.

95 : string
96 {
97 if (trim($xml) === '') {
98 return '';
99 }
100
101 $dom = new \DOMDocument('1.0', 'UTF-8');
102 $dom->preserveWhiteSpace = false;
103 $dom->formatOutput = true;
104
105 if (@$dom->loadXML($xml) === false) {
106 return str_replace(['>', '" '], [">\n", "\"\n "], $xml);
107 }
108
109 return (string) $dom->saveXML();
110 }

Referenced by ILIAS\AuthSOAP\ConnectionTester\formatXmlForDisplay().

+ Here is the caller graph for this function:

◆ renderXmlBlock()

ILIAS\AuthSOAP\ConnectionTester::renderXmlBlock ( string  $xml)
private

Definition at line 75 of file ConnectionTester.php.

75 : Component
76 {
77 return $this->ui_factory->legacy()->content(
78 $this->formatXmlForDisplay($xml)
79 );
80 }

References ILIAS\AuthSOAP\ConnectionTester\formatXmlForDisplay().

Referenced by ILIAS\AuthSOAP\ConnectionTester\testConnection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testConnection()

ILIAS\AuthSOAP\ConnectionTester::testConnection ( string  $ext_uid,
string  $soap_pw,
bool  $new_user 
)
Returns
list<Component>

Definition at line 39 of file ConnectionTester.php.

39 : array
40 {
41 $client = (new SoapAuthEndpoint($this->settings))->createValidationClient();
42
43 try {
44 $result = $client->validateSession($ext_uid, $soap_pw, $new_user);
45 } catch (\SoapFault $e) {
46 $this->logger->error('SOAP auth connection test failed: ' . $e->getMessage());
47 $this->logger->error($e->getTraceAsString());
48
49 return [
50 $this->ui_factory->messageBox()->failure(
51 'SOAP Authentication Call Error: ' . $e->getMessage()
52 )
53 ];
54 }
55
56 $validation = $result->validation;
57 $is_valid = (bool) ($validation['valid'] ?? false);
58 $status = $is_valid
59 ? $this->ui_factory->messageBox()->success('SOAP authentication succeeded.')
60 : $this->ui_factory->messageBox()->info('SOAP authentication returned invalid credentials.');
61
62 return [
63 $status,
64 $this->ui_factory->listing()->descriptive([
65 'Valid' => $is_valid ? 'true' : 'false',
66 'First Name' => (string) ($validation['firstname'] ?? ''),
67 'Last Name' => (string) ($validation['lastname'] ?? ''),
68 'Email' => (string) ($validation['email'] ?? ''),
69 'Request XML' => $this->renderXmlBlock($result->request),
70 'Response XML' => $this->renderXmlBlock($result->response),
71 ]),
72 ];
73 }
$soap_pw
$ext_uid
$new_user
$client

References $client, Vendor\Package\$e, $ext_uid, $new_user, $soap_pw, ILIAS\Repository\logger(), ILIAS\AuthSOAP\ConnectionTester\renderXmlBlock(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: