Skip to content

Commit

Permalink
Fix bugs as suggested by scrutinizer-ci.com .
Browse files Browse the repository at this point in the history
  • Loading branch information
terrencegf committed Nov 25, 2019
1 parent 4762a98 commit 71e9720
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 81 deletions.
46 changes: 31 additions & 15 deletions src/Service/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public static function printWAYF($showremember = true, $samlidps = false)
if (!empty($idphintlist)) {
$useselectedidp = true;
$providerId = $idphintlist[0];
$newidps = array();
// Update the IdP selection list to show just the idphintlist.
foreach ($idphintlist as $value) {
$newidps[$value] = $idps[$value];
Expand Down Expand Up @@ -885,26 +886,41 @@ public static function printIdPMetadata()
href="http://refeds.org/category/research-and-scholarship">REFEDS
R &amp; S</a>:</th>
<td>' , ($idplist->isREFEDSRandS($idp) ? 'Yes' : 'No') , '</td>
<td>' ,
(($eduGainWithoutRandSandSIRTFI &&
!$idplist->isREFEDSRandS($idp)) ?
Content::printIcon('warn', 'This IdP does not support both ' .
'REFEDS R&amp;S and SIRTFI. CILogon functionality may be limited.') :
'') ,
'</td>
<td>';
if (
($eduGainWithoutRandSandSIRTFI &&
!$idplist->isREFEDSRandS($idp))
) {
Content::printIcon(
'warn',
'This IdP does not support both ' .
'REFEDS R&amp;S and SIRTFI. ' .
'CILogon functionality may be limited.'
);
}

echo ' </td>
</tr>
<tr class="odd">
<th><a style="text-decoration:underline" target="_blank"
href="https://refeds.org/sirtfi">SIRTFI</a>:</th>
<td>' , ($idplist->isSIRTFI($idp) ? 'Yes' : 'No') , '</td>
<td>',
(($eduGainWithoutRandSandSIRTFI &&
!$idplist->isSIRTFI($idp)) ?
Content::printIcon('warn', 'This IdP does not support both ' .
'REFEDS R&amp;S and SIRTFI. CILogon functionality may be limited.') :
'') ,
'</td>
<td>';

if (
($eduGainWithoutRandSandSIRTFI &&
!$idplist->isSIRTFI($idp))
) {
Content::printIcon(
'warn',
'This IdP does not support both ' .
'REFEDS R&amp;S and SIRTFI. ' .
'CILogon functionality may be limited.'
);
}

echo ' </td>
</tr>
<tr>
Expand Down Expand Up @@ -1323,7 +1339,7 @@ public static function verifyCurrentUserSession($providerId = '')
* 'submit' variable to be set upon return from the 'getuser'
* script. This is utilized to control the flow of this script
* after 'getuser'. Defaults to 'gotuser'.
* @param string responseurl (Optional) A response url for redirection
* @param string $responseurl (Optional) A response url for redirection
* after successful processing at /secure/getuser/. Defaults to
* the current script directory.
* @param bool $allowsilver Is it okay to request silver assurance in
Expand Down
2 changes: 0 additions & 2 deletions src/Service/DBProps.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public function getHostspec()
*/
public function getDBConnect()
{
$retval = null;

$db = new DB(); // So defined constants get read in
$dsn = array(
'phptype' => $this->dbtype,
Expand Down
73 changes: 33 additions & 40 deletions src/Service/DBService.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,137 +128,137 @@ class DBService
);

/**
* @var int $status The returned status code from dbService calls
* @var int|null $status The returned status code from dbService calls
*/
public $status;

/**
* @var string $user_uid The CILogon UID
* @var string|null $user_uid The CILogon UID
*/
public $user_uid;

/**
* @var string $remote_user The HTTP session REMOTE_USER
* @var string|null $remote_user The HTTP session REMOTE_USER
*/
public $remote_user;

/**
* @var string $idp The Identity Provider's entityId
* @var string|null $idp The Identity Provider's entityId
*/
public $idp;

/**
* @var string $idp_display_name The Identity Provider's name
* @var string|null $idp_display_name The Identity Provider's name
*/
public $idp_display_name;

/**
* @var string $first_name User's given name
* @var string|null $first_name User's given name
*/
public $first_name;

/**
* @var string $last_name User's family name
* @var string|null $last_name User's family name
*/
public $last_name;

/**
* @var string $display_name User's full name
* @var string|null $display_name User's full name
*/
public $display_name;

/**
* @var string $email User's email address
* @var string|null $email User's email address
*/
public $email;

/**
* @var string $distinguished_name X.509 DN + email address
* @var string|null $distinguished_name X.509 DN + email address
*/
public $distinguished_name;

/**
* @var string $eppn eduPersonPrincipalName
* @var string|null $eppn eduPersonPrincipalName
*/
public $eppn;

/**
* @var string $eptid eduPersonTargetedID
* @var string|null $eptid eduPersonTargetedID
*/
public $eptid;

/**
* @var string $open_id Old Google OpenID 2.0 identifier
* @var string|null $open_id Old Google OpenID 2.0 identifier
*/
public $open_id;

/**
* @var string $oidc OpenID Connect identifier
* @var string|null $oidc OpenID Connect identifier
*/
public $oidc;

/**
* @var string $affiliation eduPersonScopedAffiliation
* @var string|null $affiliation eduPersonScopedAffiliation
*/
public $affiliation;

/**
* @var string $ou Organizational Unit
* @var string|null $ou Organizational Unit
*/
public $ou;

/**
* @var string $member_of isMemberOf group information
* @var string|null $member_of isMemberOf group information
*/
public $member_of;

/**
* @var string $acr Authentication Context Class Ref
* @var string|null $acr Authentication Context Class Ref
*/
public $acr;

/**
* @var string $entitlement eduPersonEntitlement
* @var string|null $entitlement eduPersonEntitlement
*/
public $entitlement;

/**
* @var string $itrustuin Person's univeristy ID number
* @var string|null $itrustuin Person's univeristy ID number
*/
public $itrustuin;

/**
* @var string $serial_string CILogon serial string (e.g., A34201)
* @var string|null $serial_string CILogon serial string (e.g., A34201)
*/
public $serial_string;

/**
* @var string $create_time Time user entry was created
* @var string|null $create_time Time user entry was created
*/
public $create_time;

/**
* @var string $oauth_token OAuth 2.0 token
* @var string|null $oauth_token OAuth 2.0 token
*/
public $oauth_token;

/**
* @var string $cilogon_callback OAuth 1.0a callback URL
* @var string|null $cilogon_callback OAuth 1.0a callback URL
*/
public $cilogon_callback;

/**
* @var string $cilogon_success OAuth 1.0a success URL
* @var string|null $cilogon_success OAuth 1.0a success URL
*/
public $cilogon_success;

/**
* @var string $cilogon_failure OAuth 1.0a failure URL
* @var string|null $cilogon_failure OAuth 1.0a failure URL
*/
public $cilogon_failure;

/**
* @var string $cilogon_portal_name OAuth client name
* @var string|null $cilogon_portal_name OAuth client name
*/
public $cilogon_portal_name;

Expand All @@ -268,17 +268,17 @@ class DBService
public $idp_uids;

/**
* @var string $client_name OAuth 2.0 client name
* @var string|null $client_name OAuth 2.0 client name
*/
public $client_name;

/**
* @var string $client_id OAuth 2.0 client identifier
* @var string|null $client_id OAuth 2.0 client identifier
*/
public $client_id;

/**
* @var string $client_home_uri OAuth 2.0 client home URL
* @var string|null $client_home_uri OAuth 2.0 client home URL
*/
public $client_home_uri;

Expand All @@ -288,7 +288,7 @@ class DBService
public $client_callback_uris;

/**
* @var string $dbservice URL The URL to use for the dbService
* @var string|null $dbservice URL The URL to use for the dbService
*/
private $dbserviceurl;

Expand Down Expand Up @@ -370,7 +370,6 @@ public function clearUser()
$this->oidc = null;
$this->serial_string = null;
$this->create_time = null;
$this->two_factor = null;
$this->affiliation = null;
$this->ou = null;
$this->member_of = null;
Expand Down Expand Up @@ -690,7 +689,7 @@ public function getClient($cid)
*
* @param string $code The 'code' as returned by the OAuth 2.0 server.
* @param string $uid The database user UID.
* @param int The Unix timestamp of the user authentication.
* @param int $authntime The Unix timestamp of the user authentication.
* @param string $loa (Optional) The Level of Assurance: '' = basic,
* 'openid' = OpenID Connect (e.g., Google),
* 'http://incommonfederation.org/assurance/silver' = silver
Expand Down Expand Up @@ -829,9 +828,6 @@ public function call($params)
if (preg_match('/cilogon_portal_name=([^\r\n]+)/', $output, $match)) {
$this->cilogon_portal_name = urldecode($match[1]);
}
if (preg_match('/two_factor=([^\r\n]+)/', $output, $match)) {
$this->two_factor = urldecode($match[1]);
}
if (preg_match_all('/idp_uid=([^\r\n]+)/', $output, $match)) {
foreach ($match[1] as $value) {
$this->idp_uids[] = urldecode($value);
Expand Down Expand Up @@ -886,7 +882,7 @@ public function dump()
{
if (!is_null($this->status)) {
echo "status=$this->status (" .
array_search($this->status, static::$STATUS) . ")\n";
(string)(array_search($this->status, static::$STATUS)) . ")\n";
}
if (!is_null($this->user_uid)) {
echo "user_uid=$this->user_uid\n";
Expand Down Expand Up @@ -966,9 +962,6 @@ public function dump()
if (!is_null($this->cilogon_portal_name)) {
echo "cilogon_portal_name=$this->cilogon_portal_name\n";
}
if (!is_null($this->two_factor)) {
echo "two_factor=$this->two_factor\n";
}
if (count($this->idp_uids) > 0) {
uasort($this->idp_uids, 'strcasecmp');
echo "idp_uids={\n";
Expand Down
18 changes: 11 additions & 7 deletions src/Service/IdpList.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ public function readXML()
$retval = false; // Assume read failed

$filename = $this->getFilename();
$doc = new DOMDocument();
if (
(is_readable($filename)) &&
(($dom = DOMDocument::load($filename, LIBXML_NOBLANKS)) !== false)
(($dom = $doc->load($filename, LIBXML_NOBLANKS)) !== false)
) {
$this->idpdom = $dom;
$this->idpdom->preserveWhiteSpace = false;
Expand Down Expand Up @@ -377,7 +378,8 @@ public function create()
);

// Create a DOMDocument to build up the list of IdPs.
$dom = DOMImplementation::createDocument(null, 'idps');
$domi = new DOMImplementation();
$dom = $domi->createDocument(null, 'idps');
$idps = $dom->documentElement; // Top level <idps> element

// Loop through the IdPs searching for desired attributes
Expand Down Expand Up @@ -696,11 +698,12 @@ public function create()
}

// Read in any test IdPs and add them to the list
$doc = new DOMDocument();
if (
(defined('TEST_IDP_XML')) &&
(!empty(TEST_IDP_XML)) &&
(is_readable(TEST_IDP_XML)) &&
(($dom2 = DOMDocument::load(TEST_IDP_XML)) !== false)
(($dom2 = $doc->load(TEST_IDP_XML)) !== false)
) {
$idpnodes = $dom2->getElementsByTagName('idp');
foreach ($idpnodes as $idpnode) {
Expand Down Expand Up @@ -1309,8 +1312,8 @@ public function getShibInfo($entityID = '')
* idplist.xml and returns a 2D array where the keys are entityIDs
* and the values are arrays of attributes for each IdP.
*
* @param DOMDocument The DOM containing the list of IdPs to convert to
* an array. Returns null on error.
* @param DOMDocument $dom The DOM containing the list of IdPs to convert
* to an array. Returns null on error.
* @return array An array corresponding to the DOM of the IdPs.
*/
public function DOM2Array($dom)
Expand Down Expand Up @@ -1342,15 +1345,16 @@ public function DOM2Array($dom)
* This function takes an array of IdPs (such as idparray) and
* returns a corresponding DOM which can be written to XML.
*
* @param array $arr An array corresponding to the idplist.
* @param array|null $arr An array corresponding to the idplist.
* @return DOMDocument A DOM for the idplist which can be written to XML.
*/
public function array2DOM($arr)
{
$retdom = null;

if (!is_null($arr)) {
$dom = DOMImplementation::createDocument(null, 'idps');
$domi = new DOMImplementation();
$dom = $domi->createDocument(null, 'idps');
$idps = $dom->documentElement; // Top level <idps> element

foreach ($arr as $entityID => $attrs) {
Expand Down
2 changes: 1 addition & 1 deletion src/Service/MyProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static function getMyProxyCredential(
}

// Run the myproxy-logon command and capture the output and any error
unset($output);
$output = array();
$cmd = '/bin/env ' .
$USER_CERT_ENV . ' ' .
$env . ' ' .
Expand Down

0 comments on commit 71e9720

Please sign in to comment.