Code Duplication    Length = 12-15 lines in 9 locations

main/auth/cas/lib/CAS.php 9 locations

@@ 1179-1192 (lines=14) @@
1176
     * @param $url the login URL
1177
     * @since 0.4.21 by Wyman Chan
1178
     */
1179
    function setServerLoginURL($url = '')
1180
    {
1181
        global $PHPCAS_CLIENT;
1182
        phpCAS:: traceBegin();
1183
        if (!is_object($PHPCAS_CLIENT)) {
1184
            phpCAS:: error('this method should only be called after
1185
							' . __CLASS__ . '::client()');
1186
        }
1187
        if (gettype($url) != 'string') {
1188
            phpCAS:: error('type mismatched for parameter $url (should be
1189
						`string\')');
1190
        }
1191
        $PHPCAS_CLIENT->setServerLoginURL($url);
1192
        phpCAS:: traceEnd();
1193
    }
1194
1195
    /**
@@ 1201-1214 (lines=14) @@
1198
     * @param $url the serviceValidate URL
1199
     * @since 1.1.0 by Joachim Fritschi
1200
     */
1201
    function setServerServiceValidateURL($url = '')
1202
    {
1203
        global $PHPCAS_CLIENT;
1204
        phpCAS:: traceBegin();
1205
        if (!is_object($PHPCAS_CLIENT)) {
1206
            phpCAS:: error('this method should only be called after
1207
							' . __CLASS__ . '::client()');
1208
        }
1209
        if (gettype($url) != 'string') {
1210
            phpCAS:: error('type mismatched for parameter $url (should be
1211
						`string\')');
1212
        }
1213
        $PHPCAS_CLIENT->setServerServiceValidateURL($url);
1214
        phpCAS:: traceEnd();
1215
    }
1216
1217
    /**
@@ 1223-1236 (lines=14) @@
1220
     * @param $url the proxyValidate URL
1221
     * @since 1.1.0 by Joachim Fritschi
1222
     */
1223
    function setServerProxyValidateURL($url = '')
1224
    {
1225
        global $PHPCAS_CLIENT;
1226
        phpCAS:: traceBegin();
1227
        if (!is_object($PHPCAS_CLIENT)) {
1228
            phpCAS:: error('this method should only be called after
1229
							' . __CLASS__ . '::client()');
1230
        }
1231
        if (gettype($url) != 'string') {
1232
            phpCAS:: error('type mismatched for parameter $url (should be
1233
						`string\')');
1234
        }
1235
        $PHPCAS_CLIENT->setServerProxyValidateURL($url);
1236
        phpCAS:: traceEnd();
1237
    }
1238
1239
    /**
@@ 1244-1257 (lines=14) @@
1241
     * @param $url the samlValidate URL
1242
     * @since 1.1.0 by Joachim Fritschi
1243
     */
1244
    function setServerSamlValidateURL($url = '')
1245
    {
1246
        global $PHPCAS_CLIENT;
1247
        phpCAS:: traceBegin();
1248
        if (!is_object($PHPCAS_CLIENT)) {
1249
            phpCAS:: error('this method should only be called after
1250
							' . __CLASS__ . '::client()');
1251
        }
1252
        if (gettype($url) != 'string') {
1253
            phpCAS:: error('type mismatched for parameter $url (should be
1254
						`string\')');
1255
        }
1256
        $PHPCAS_CLIENT->setServerSamlValidateURL($url);
1257
        phpCAS:: traceEnd();
1258
    }
1259
1260
    /**
@@ 1280-1293 (lines=14) @@
1277
     * @param $url the logout URL
1278
     * @since 0.4.21 by Wyman Chan
1279
     */
1280
    function setServerLogoutURL($url = '')
1281
    {
1282
        global $PHPCAS_CLIENT;
1283
        phpCAS:: traceBegin();
1284
        if (!is_object($PHPCAS_CLIENT)) {
1285
            phpCAS:: error('this method should only be called after
1286
							' . __CLASS__ . '::client()');
1287
        }
1288
        if (gettype($url) != 'string') {
1289
            phpCAS:: error('type mismatched for parameter $url (should be
1290
						`string\')');
1291
        }
1292
        $PHPCAS_CLIENT->setServerLogoutURL($url);
1293
        phpCAS:: traceEnd();
1294
    }
1295
1296
    /**
@@ 1332-1346 (lines=15) @@
1329
     * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1330
     * @param $service a URL that will be transmitted to the CAS server
1331
     */
1332
    function logoutWithRedirectService($service)
1333
    {
1334
        global $PHPCAS_CLIENT;
1335
        phpCAS:: traceBegin();
1336
        if (!is_object($PHPCAS_CLIENT)) {
1337
            phpCAS:: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1338
        }
1339
        if (!is_string($service)) {
1340
            phpCAS:: error('type mismatched for parameter $service (should be `string\')');
1341
        }
1342
        $PHPCAS_CLIENT->logout(array(
1343
            "service" => $service
1344
        ));
1345
        // never reached
1346
        phpCAS:: traceEnd();
1347
    }
1348
1349
    /**
@@ 1353-1367 (lines=15) @@
1350
     * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1351
     * @param $url a URL that will be transmitted to the CAS server
1352
     */
1353
    function logoutWithUrl($url)
1354
    {
1355
        global $PHPCAS_CLIENT;
1356
        phpCAS:: traceBegin();
1357
        if (!is_object($PHPCAS_CLIENT)) {
1358
            phpCAS:: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1359
        }
1360
        if (!is_string($url)) {
1361
            phpCAS:: error('type mismatched for parameter $url (should be `string\')');
1362
        }
1363
        $PHPCAS_CLIENT->logout(array(
1364
            "url" => $url
1365
        ));
1366
        // never reached
1367
        phpCAS:: traceEnd();
1368
    }
1369
1370
    /**
@@ 1471-1482 (lines=12) @@
1468
     *
1469
     * @param $cert the PEM certificate
1470
     */
1471
    function setCasServerCert($cert)
1472
    {
1473
        global $PHPCAS_CLIENT;
1474
        phpCAS:: traceBegin();
1475
        if (!is_object($PHPCAS_CLIENT)) {
1476
            phpCAS:: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1477
        }
1478
        if (gettype($cert) != 'string') {
1479
            phpCAS:: error('type mismatched for parameter $cert (should be `string\')');
1480
        }
1481
        $PHPCAS_CLIENT->setCasServerCert($cert);
1482
        phpCAS:: traceEnd();
1483
    }
1484
1485
    /**
@@ 1490-1501 (lines=12) @@
1487
     *
1488
     * @param $cert the CA certificate
1489
     */
1490
    function setCasServerCACert($cert)
1491
    {
1492
        global $PHPCAS_CLIENT;
1493
        phpCAS:: traceBegin();
1494
        if (!is_object($PHPCAS_CLIENT)) {
1495
            phpCAS:: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1496
        }
1497
        if (gettype($cert) != 'string') {
1498
            phpCAS:: error('type mismatched for parameter $cert (should be `string\')');
1499
        }
1500
        $PHPCAS_CLIENT->setCasServerCACert($cert);
1501
        phpCAS:: traceEnd();
1502
    }
1503
1504
    /**