Skip to content

Commit 67270ac

Browse files
committed
Remove deprecation warnings for SSP 1.17
1 parent 5c98414 commit 67270ac

5 files changed

Lines changed: 74 additions & 75 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"simplesamlphp/composer-module-installer": "^1.1"
1515
},
1616
"require-dev": {
17-
"simplesamlphp/simplesamlphp": ">=1.15",
17+
"simplesamlphp/simplesamlphp": ">=1.17",
1818
"phpunit/phpunit": "~4.8"
1919
},
2020
"autoload-dev": {

docs/authproc_fticks.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,40 @@ Examples
5353

5454
In its simplest form, the filter is configured like this:
5555

56-
'authproc' => array(
57-
50 => array(
56+
'authproc' => [
57+
50 => [
5858
'class' => 'fticks:Fticks',
5959
'federation' => 'ACME',
60-
),
61-
),
60+
],
61+
],
6262

6363
A more complete example looks like:
6464

65-
'authproc' => array(
66-
50 => array(
65+
'authproc' => [
66+
50 => [
6767
'class' => 'fticks:Fticks',
6868
'federation' => 'ACME',
6969
'salt' => 'someVerySecretStringDifferentFromTheDefault',
7070
'userId' => 'eduPersonPrincipalName',
7171
'realm' => 'schacHomeOrganization',
7272
'algorithm' => 'sha512',
73-
'exclude' => array('PN'),
74-
),
75-
),
73+
'exclude' => ['PN'],
74+
],
75+
],
7676

7777
Remote logging can be done like this:
7878

79-
'authproc' => array(
80-
50 => array(
79+
'authproc' => [
80+
50 => a[
8181
'class' => 'fticks:Fticks',
8282
'federation' => 'ACME',
8383
'logdest' => 'remote',
84-
'logconfig' => array(
84+
'logconfig' => [
8585
'host' => '90.147.166.156',
8686
'port' => 514,
87-
),
88-
),
89-
),
87+
],
88+
],
89+
],
9090

9191
F-ticks output
9292
--------------

lib/Auth/Process/Fticks.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<?php
2+
3+
namespace SimpleSAML\Module\fticks\Auth\Process;
4+
25
/**
36
* Filter to log F-ticks stats data
47
* See also:
58
* - https://wiki.geant.org/display/gn42jra3/F-ticks+standard
69
* - https://tools.ietf.org/html/draft-johansson-fticks-00
710
*
811
* @author Guy Halse, http://orcid.org/0000-0002-9388-8592
9-
* @copyright Copyright (c) 2018, South African Identity Federation
12+
* @copyright Copyright (c) 2019, South African Identity Federation
1013
* @package SimpleSAMLphp
1114
*/
12-
class sspmod_fticks_Auth_Process_Fticks extends SimpleSAML_Auth_ProcessingFilter
15+
class Fticks extends \SimpleSAML\Auth\ProcessingFilter
1316
{
1417
/** @var string F-ticks version number */
1518
private static $_fticksVersion = '1.0';
@@ -24,7 +27,7 @@ class sspmod_fticks_Auth_Process_Fticks extends SimpleSAML_Auth_ProcessingFilter
2427
private $logdest = 'simplesamlphp';
2528

2629
/** @var array Backend specific logging config */
27-
private $logconfig = array();
30+
private $logconfig = [];
2831

2932
/** @var string|false The username attribute to use */
3033
private $userId = false;
@@ -214,15 +217,15 @@ public function __construct($config, $reserved)
214217
if (is_array($config['exclude'])) {
215218
$this->exclude = $config['exclude'];
216219
} elseif (is_string($config['exclude'])) {
217-
$this->exclude = array($config['exclude']);
220+
$this->exclude = [$config['exclude']];
218221
} else {
219222
throw new \SimpleSAML\Error\Exception('F-ticks exclude must be an array');
220223
}
221224
}
222225

223226
if (array_key_exists('logdest', $config)) {
224227
if (is_string($config['logdest']) and
225-
in_array($config['logdest'], array('local', 'syslog', 'remote', 'stdout', 'errorlog', 'simplesamlphp'))
228+
in_array($config['logdest'], ['local', 'syslog', 'remote', 'stdout', 'errorlog', 'simplesamlphp'])
226229
) {
227230
$this->logdest = $config['logdest'];
228231
} else {
@@ -231,7 +234,7 @@ public function __construct($config, $reserved)
231234
}
232235

233236
/* match SSP config or we risk mucking up the openlog call */
234-
$globalConfig = \SimpleSAML_Configuration::getInstance();
237+
$globalConfig = \SimpleSAML\Configuration::getInstance();
235238
$defaultFacility = $globalConfig->getInteger('logging.facility', defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER);
236239
$defaultProcessName = $globalConfig->getString('logging.processname', 'SimpleSAMLphp');
237240
if (array_key_exists('logconfig', $config)) {
@@ -245,7 +248,7 @@ public function __construct($config, $reserved)
245248
$this->logconfig['processname'] = $defaultProcessName;
246249
}
247250
/* warn if we risk mucking up the openlog call (doesn't matter for remote syslog) */
248-
if (in_array($this->logdest, array('local', 'syslog'))) {
251+
if (in_array($this->logdest, ['local', 'syslog'])) {
249252
if (array_key_exists('facility', $this->logconfig) and $this->logconfig['facility'] !== $defaultFacility) {
250253
\SimpleSAML\Logger::warning('F-ticks syslog facility differs from global config which may cause SimpleSAMLphp\'s logging to behave inconsistently');
251254
}
@@ -269,7 +272,7 @@ public function process(&$state)
269272
assert('array_key_exists("Source", $state)');
270273
assert('array_key_exists("entityid", $state["Source"])');
271274

272-
$fticks = array();
275+
$fticks = [];
273276

274277
/* AFAIK the AuthProc will only execute if there is prior success */
275278
$fticks['RESULT'] = 'OK';
@@ -285,7 +288,7 @@ public function process(&$state)
285288
$fticks['RP'] = $state['Destination']['entityid'];
286289

287290
/* SAML session id */
288-
$session = \SimpleSAML_Session::getSessionFromRequest();
291+
$session = \SimpleSAML\Session::getSessionFromRequest();
289292
$fticks['CSI'] = $session->getTrackID();
290293

291294
/* Authentication method identifier */

tests/_autoload_modules.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
<?php
2-
3-
/**
4-
* This file implements a trimmed down version of the SSP module aware autoloader that can be used in tests.
5-
*
6-
* @author Patrick Radtke
7-
*/
8-
92
/**
10-
* Autoload function for local SimpleSAMLphp modules.
3+
* This file implements a trimmed down version of the SSP module aware autoloader that can be used in tests..
114
*
125
* @param string $className Name of the class.
136
*/
@@ -20,14 +13,13 @@ function SimpleSAML_test_module_autoload($className)
2013
}
2114

2215
$modNameEnd = strpos($className, '_', $modulePrefixLength);
23-
$moduleClass = substr($className, $modNameEnd + 1);
16+
$module = substr($className, $modulePrefixLength, $modNameEnd - $modulePrefixLength);
17+
$path = explode('_', substr($className, $modNameEnd + 1));
18+
$file = dirname(dirname(__FILE__)).'/lib/'.join('/', $path).'.php';
2419

25-
$file = dirname(dirname(__FILE__)) . '/lib/' . str_replace('_', '/', $moduleClass) . '.php';
26-
27-
if (file_exists($file)) {
28-
require_once($file);
20+
if (!file_exists($file)) {
21+
return;
2922
}
23+
require_once($file);
3024
}
31-
3225
spl_autoload_register('SimpleSAML_test_module_autoload');
33-

tests/lib/Auth/Process/FticksTest.php

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
<?php
2+
3+
namespace SimpleSAML\Test\Module\fticks\Auth\Process;
4+
25
// Alias the PHPUnit 6.0 ancestor if available, else fall back to legacy ancestor
36
if (class_exists('\PHPUnit\Framework\TestCase', true) and !class_exists('\PHPUnit_Framework_TestCase', true)) {
47
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase', true);
58
}
9+
require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))).'/lib/Auth/Process/Fticks.php');
610

711
/**
812
* Test for the core:CardinalitySingle filter.
913
*/
10-
class sspmod_fticks_Auth_Process_FticksTest extends \PHPUnit_Framework_TestCase
14+
class FticksTest extends \PHPUnit_Framework_TestCase
1115
{
1216
/** @var array minimal request */
13-
private static $_minrequest = array(
14-
'Source' => array(
17+
private static $_minrequest = [
18+
'Source' => [
1519
'entityid' => 'https://localhost/sp',
16-
),
17-
'Destination' => array(
20+
],
21+
'Destination' => [
1822
'entityid' => 'https://localhost/idp',
19-
),
20-
);
23+
],
24+
];
2125

2226
/** @var array SP request */
23-
private static $_sprequest = array(
27+
private static $_sprequest =[
2428
'saml:sp:IdP' => 'https://localhost/saml:sp:IdP',
2529
'saml:sp:SessionIndex' => 'saml:sp:SessionIndex',
26-
'saml:sp:State' => array(
30+
'saml:sp:State' => [
2731
'saml:sp:AuthnContext' => 'urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified',
2832
'saml:AuthnInstant' => 1000,
29-
),
30-
);
33+
],
34+
];
3135

3236
/** @var array IdP request */
33-
private static $_idprequest = array(
37+
private static $_idprequest = [
3438
'SimpleSAML_Auth_State.id' => 'SimpleSAML_Auth_State.id',
3539
'SimpleSAML_Auth_State.stage' => 'sspmod_core_Auth_UserPassBase.state',
3640
'UserID' => 'user1@example.org',
37-
);
41+
];
3842

3943
/**
4044
* Helper function to run the filter with a given configuration.
@@ -45,7 +49,7 @@ class sspmod_fticks_Auth_Process_FticksTest extends \PHPUnit_Framework_TestCase
4549
*/
4650
private static function processFilter(array $config, array $request)
4751
{
48-
$filter = new \sspmod_fticks_Auth_Process_Fticks($config, null);
52+
$filter = new \SimpleSAML\Module\fticks\Auth\Process\Fticks($config, null);
4953
$filter->process($request);
5054
return $request;
5155
}
@@ -55,13 +59,13 @@ private static function processFilter(array $config, array $request)
5559
*/
5660
protected function setUp()
5761
{
58-
\SimpleSAML_Configuration::loadFromArray(array(
62+
\SimpleSAML\Configuration::loadFromArray([
5963
'secretsalt' => 'secretsalt',
60-
), '[ARRAY]', 'simplesaml');
64+
], '[ARRAY]', 'simplesaml');
6165
/*
62-
$rm = new ReflectionMethod('SimpleSAML\Logger', 'createLoggingHandler');
66+
$rm = new ReflectionMethod('\SimpleSAML\Logger', 'createLoggingHandler');
6367
$rm->setAccessible(true);
64-
$rm->invoke('SimpleSAML\Logger\StandardErrorLoggingHandler');
68+
$rm->invoke('\SimpleSAML\Logger\StandardErrorLoggingHandler');
6569
*/
6670
}
6771

@@ -70,7 +74,7 @@ protected function setUp()
7074
*/
7175
public function testMinimal()
7276
{
73-
$config = array('federation' => 'ACME', 'logdest' => 'stdout');
77+
$config = ['federation' => 'ACME', 'logdest' => 'stdout'];
7478
$request = self::$_minrequest;
7579
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL','/').'[^#]+#TS=\d+#$/');
7680
$result = self::processFilter($config, $request);
@@ -81,7 +85,7 @@ public function testMinimal()
8185
*/
8286
public function testAsServiceProvider()
8387
{
84-
$config = array('federation' => 'ACME', 'logdest' => 'stdout',);
88+
$config = ['federation' => 'ACME', 'logdest' => 'stdout',];
8589
$request = array_merge(self::$_minrequest, self::$_sprequest);
8690
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/saml:sp:IdP#RP=https://localhost/idp#CSI=CL','/').'[^#]+'.preg_quote('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified#TS=1000#','/').'$/');
8791
$result = self::processFilter($config, $request);
@@ -92,12 +96,12 @@ public function testAsServiceProvider()
9296
*/
9397
public function testSPwithUserId()
9498
{
95-
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'userId' => 'eduPersonPrincipalName');
96-
$request = array_merge(self::$_minrequest, self::$_sprequest, array(
97-
'Attributes' => array(
99+
$config = ['federation' => 'ACME', 'logdest' => 'stdout', 'userId' => 'eduPersonPrincipalName'];
100+
$request = array_merge(self::$_minrequest, self::$_sprequest, [
101+
'Attributes' => [
98102
'eduPersonPrincipalName' => 'user2@example.net',
99-
),
100-
));
103+
],
104+
]);
101105
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/saml:sp:IdP#RP=https://localhost/idp#CSI=CL','/').'[^#]+'.preg_quote('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified#PN=e5d066a96d5809a21264e153013c3c793e6574cb77afdfa248ad2cefab9b0451#TS=1000#','/').'$/');
102106
$result = self::processFilter($config, $request);
103107
}
@@ -107,7 +111,7 @@ public function testSPwithUserId()
107111
*/
108112
public function testAsIdentityProvider()
109113
{
110-
$config = array('federation' => 'ACME', 'logdest' => 'stdout',);
114+
$config = ['federation' => 'ACME', 'logdest' => 'stdout',];
111115
$request = array_merge(self::$_minrequest, self::$_idprequest);
112116
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL','/').'[^#]+'.preg_quote('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:Password#PN=d844a9a0666bb3990e88f72b8f5c20accbcfa46f7b8a7ab38593bfbbab6e9cbc#TS=','/').'\d+#$/');
113117
$result = self::processFilter($config, $request);
@@ -118,21 +122,21 @@ public function testAsIdentityProvider()
118122
*/
119123
public function testExample()
120124
{
121-
$config = array(
125+
$config = [
122126
'federation' => 'ACME',
123127
'salt' => 'someVerySecretStringDifferentFromTheDefault',
124128
'userId' => 'eduPersonPrincipalName',
125129
'realm' => 'schacHomeOrganization',
126130
'algorithm' => 'sha512',
127-
'exclude' => array('PN'),
131+
'exclude' => ['PN'],
128132
'logdest' => 'stdout',
129-
);
130-
$request = array_merge(self::$_minrequest, self::$_idprequest, array(
131-
'Attributes' => array(
133+
];
134+
$request = array_merge(self::$_minrequest, self::$_idprequest, [
135+
'Attributes' => [
132136
'eduPersonPrincipalName' => 'user3@example.com',
133137
'schacHomeOrganization' => 'example.com',
134-
),
135-
));
138+
],
139+
]);
136140
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL','/').'[^#]+'.preg_quote('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:Password#TS=','/').'\d+#REALM=example.com#$/');
137141
$result = self::processFilter($config, $request);
138142
}
@@ -142,7 +146,7 @@ public function testExample()
142146
*/
143147
public function testFilteringArray()
144148
{
145-
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => array('PN', 'AM'));
149+
$config = ['federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => ['PN', 'AM']];
146150
$request = array_merge(self::$_minrequest, self::$_idprequest);
147151
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL','/').'[^#]+#TS=\d+#$/');
148152
$result = self::processFilter($config, $request);
@@ -153,7 +157,7 @@ public function testFilteringArray()
153157
*/
154158
public function testFilteringString()
155159
{
156-
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => 'AM');
160+
$config = ['federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => 'AM'];
157161
$request = array_merge(self::$_minrequest, self::$_idprequest);
158162
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL','/').'[^#]+'.preg_quote('#PN=d844a9a0666bb3990e88f72b8f5c20accbcfa46f7b8a7ab38593bfbbab6e9cbc#TS=','/').'\d+#$/');
159163
$result = self::processFilter($config, $request);

0 commit comments

Comments
 (0)