@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | use Exception; |
| 25 | 25 | |
| 26 | -require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/config/_config.php"; |
|
| 26 | +require_once dirname(dirname(dirname(dirname(__FILE__))))."/config/_config.php"; |
|
| 27 | 27 | |
| 28 | 28 | class API { |
| 29 | 29 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | const ACTIONS = [ |
| 85 | 85 | # inst-level actions |
| 86 | 86 | API::ACTION_NEWINST_BY_REF => [ |
| 87 | - "REQ" => [API::AUXATTRIB_EXTERNALID,], |
|
| 87 | + "REQ" => [API::AUXATTRIB_EXTERNALID, ], |
|
| 88 | 88 | "OPT" => [ |
| 89 | 89 | 'general:geo_coordinates', |
| 90 | 90 | 'general:logo_file', |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | ], |
| 102 | 102 | ], |
| 103 | 103 | API::ACTION_NEWINST => [ |
| 104 | - "REQ" => [API::AUXATTRIB_INSTTYPE,], // "IdP", "SP" or "IdPSP" |
|
| 104 | + "REQ" => [API::AUXATTRIB_INSTTYPE, ], // "IdP", "SP" or "IdPSP" |
|
| 105 | 105 | "OPT" => [ |
| 106 | 106 | 'general:instname', |
| 107 | 107 | 'general:geo_coordinates', |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | "OPT" => [API::AUXATTRIB_TARGETMAIL], |
| 145 | 145 | "RETVAL" => [ |
| 146 | 146 | ["TOKEN URL", |
| 147 | - "EMAIL SENT", // dependent on TARGETMAIL input |
|
| 147 | + "EMAIL SENT", // dependent on TARGETMAIL input |
|
| 148 | 148 | "EMAIL TRANSPORT SECURE"], // dependent on TARGETMAIL input |
| 149 | 149 | ] |
| 150 | 150 | ], |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | API::ACTION_ENDUSER_NEW => [ |
| 207 | 207 | "REQ" => [API::AUXATTRIB_CAT_PROFILE_ID, API::AUXATTRIB_SB_USERNAME, API::AUXATTRIB_SB_EXPIRY], |
| 208 | 208 | "OPT" => [], |
| 209 | - "RETVAL" => [ API::AUXATTRIB_SB_USERNAME, API::AUXATTRIB_SB_USERID ], |
|
| 209 | + "RETVAL" => [API::AUXATTRIB_SB_USERNAME, API::AUXATTRIB_SB_USERID], |
|
| 210 | 210 | ], |
| 211 | 211 | API::ACTION_ENDUSER_DEACTIVATE => [ |
| 212 | 212 | "REQ" => [API::AUXATTRIB_CAT_PROFILE_ID, API::AUXATTRIB_SB_USERID], |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | "REQ" => [API::AUXATTRIB_CAT_PROFILE_ID], |
| 218 | 218 | "OPT" => [], |
| 219 | 219 | "RETVAL" => [ |
| 220 | - [ API::AUXATTRIB_SB_USERID => API::AUXATTRIB_SB_USERNAME], |
|
| 220 | + [API::AUXATTRIB_SB_USERID => API::AUXATTRIB_SB_USERNAME], |
|
| 221 | 221 | ], |
| 222 | 222 | ], |
| 223 | 223 | API::ACTION_TOKEN_NEW => [ |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | "RETVAL" => [ |
| 227 | 227 | API::AUXATTRIB_TOKENURL, |
| 228 | 228 | API::AUXATTRIB_TOKEN, |
| 229 | - "EMAIL SENT", // dependent on TARGETMAIL input |
|
| 229 | + "EMAIL SENT", // dependent on TARGETMAIL input |
|
| 230 | 230 | "EMAIL TRANSPORT SECURE", // dependent on TARGETMAIL input |
| 231 | - "SMS SENT", // dependent on TARGETSMS input |
|
| 231 | + "SMS SENT", // dependent on TARGETSMS input |
|
| 232 | 232 | ] |
| 233 | 233 | ], |
| 234 | 234 | API::ACTION_TOKEN_REVOKE => [ |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | "REQ" => [API::AUXATTRIB_CAT_PROFILE_ID, API::AUXATTRIB_SB_USERID], |
| 248 | 248 | "OPT" => [], |
| 249 | 249 | "RETVAL" => [ |
| 250 | - [ API::AUXATTRIB_SB_CERTSERIAL => ["ISSUED", "EXPIRY", "STATUS", "DEVICE", "CN" ]] |
|
| 250 | + [API::AUXATTRIB_SB_CERTSERIAL => ["ISSUED", "EXPIRY", "STATUS", "DEVICE", "CN"]] |
|
| 251 | 251 | ] |
| 252 | 252 | ], |
| 253 | 253 | API::ACTION_CERT_REVOKE => [ |
@@ -377,8 +377,8 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | case \core\Options::TYPECODE_COORDINATES: |
| 379 | 379 | $extension = \core\Options::TYPECODE_TEXT; |
| 380 | - $coercedInline["option"][$basename] = $oneAttrib['NAME'] . "#"; |
|
| 381 | - $coercedInline["value"][$basename . "-" . $extension] = $oneAttrib['VALUE']; |
|
| 380 | + $coercedInline["option"][$basename] = $oneAttrib['NAME']."#"; |
|
| 381 | + $coercedInline["value"][$basename."-".$extension] = $oneAttrib['VALUE']; |
|
| 382 | 382 | break; |
| 383 | 383 | case \core\Options::TYPECODE_TEXT: |
| 384 | 384 | // fall-through: they all get the same treatment |
@@ -388,19 +388,19 @@ discard block |
||
| 388 | 388 | // fall-through: they all get the same treatment |
| 389 | 389 | case \core\Options::TYPECODE_INTEGER: |
| 390 | 390 | $extension = $optionInfo['type']; |
| 391 | - $coercedInline["option"][$basename] = $oneAttrib['NAME'] . "#"; |
|
| 392 | - $coercedInline["value"][$basename . "-" . $extension] = $oneAttrib['VALUE']; |
|
| 391 | + $coercedInline["option"][$basename] = $oneAttrib['NAME']."#"; |
|
| 392 | + $coercedInline["value"][$basename."-".$extension] = $oneAttrib['VALUE']; |
|
| 393 | 393 | if ($optionInfo['flag'] == "ML") { |
| 394 | - $coercedInline["value"][$basename . "-lang"] = $oneAttrib['LANG']; |
|
| 394 | + $coercedInline["value"][$basename."-lang"] = $oneAttrib['LANG']; |
|
| 395 | 395 | } |
| 396 | 396 | break; |
| 397 | 397 | case \core\Options::TYPECODE_FILE: |
| 398 | 398 | // binary data is expected in base64 encoding. This is true |
| 399 | 399 | // also for PEM files! |
| 400 | 400 | $extension = $optionInfo['type']; |
| 401 | - $coercedInline["option"][$basename] = $oneAttrib['NAME'] . "#"; |
|
| 402 | - file_put_contents($dir['dir'] . "/" . $basename . "-" . $extension, base64_decode($oneAttrib['VALUE'])); |
|
| 403 | - $coercedFile["value"]['tmp_name'][$basename . "-" . $extension] = $dir['dir'] . "/" . $basename . "-" . $extension; |
|
| 401 | + $coercedInline["option"][$basename] = $oneAttrib['NAME']."#"; |
|
| 402 | + file_put_contents($dir['dir']."/".$basename."-".$extension, base64_decode($oneAttrib['VALUE'])); |
|
| 403 | + $coercedFile["value"]['tmp_name'][$basename."-".$extension] = $dir['dir']."/".$basename."-".$extension; |
|
| 404 | 404 | break; |
| 405 | 405 | default: |
| 406 | 406 | throw new Exception("We don't seem to know this type code!"); |
@@ -100,88 +100,88 @@ |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | switch ($operationMode) { |
| 103 | - case OPERATION_MODE_EDIT: |
|
| 104 | - $idp = $validator->IdP($_GET['inst_id']); |
|
| 105 | - // editing IdPs is done from within the popup. When we're done, send the |
|
| 106 | - // user back to the popup (append the result of the operation later) |
|
| 107 | - $redirect_destination = "manageAdmins.inc.php?inst_id=" . $idp->identifier . "&"; |
|
| 108 | - $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination); |
|
| 109 | - // is the user primary admin of this IdP? |
|
| 110 | - $is_owner = $idp->isPrimaryOwner($_SESSION['user']); |
|
| 111 | - // check if he is (also) federation admin for the federation this IdP is in. His invitations have more blessing then. |
|
| 112 | - $fedadmin = $userObject->isFederationAdmin($idp->federation); |
|
| 113 | - // check if he is either one, if not, complain |
|
| 114 | - if (!$is_owner && !$fedadmin) { |
|
| 115 | - echo "<p>" . sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst) . "</p>"; |
|
| 116 | - exit(1); |
|
| 117 | - } |
|
| 103 | + case OPERATION_MODE_EDIT: |
|
| 104 | + $idp = $validator->IdP($_GET['inst_id']); |
|
| 105 | + // editing IdPs is done from within the popup. When we're done, send the |
|
| 106 | + // user back to the popup (append the result of the operation later) |
|
| 107 | + $redirect_destination = "manageAdmins.inc.php?inst_id=" . $idp->identifier . "&"; |
|
| 108 | + $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination); |
|
| 109 | + // is the user primary admin of this IdP? |
|
| 110 | + $is_owner = $idp->isPrimaryOwner($_SESSION['user']); |
|
| 111 | + // check if he is (also) federation admin for the federation this IdP is in. His invitations have more blessing then. |
|
| 112 | + $fedadmin = $userObject->isFederationAdmin($idp->federation); |
|
| 113 | + // check if he is either one, if not, complain |
|
| 114 | + if (!$is_owner && !$fedadmin) { |
|
| 115 | + echo "<p>" . sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst) . "</p>"; |
|
| 116 | + exit(1); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - $prettyprintname = $idp->name; |
|
| 120 | - $newtokens = $mgmt->createTokens($fedadmin, $mailaddress, $idp); |
|
| 121 | - $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP " . $idp->identifier . " - Token created for " . implode(",", $mailaddress)); |
|
| 122 | - $introtext = "CO-ADMIN"; |
|
| 123 | - $participant_type = $idp->type; |
|
| 124 | - break; |
|
| 125 | - case OPERATION_MODE_NEWUNLINKED: |
|
| 126 | - $redirect_destination = "../overview_federation.php?"; |
|
| 127 | - $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination); |
|
| 128 | - // run an input check and conversion of the raw inputs... just in case |
|
| 129 | - $newinstname = $validator->string($_POST['name']); |
|
| 130 | - $newcountry = $validator->string($_POST['country']); |
|
| 131 | - $participant_type = $validator->partType($_POST['participant_type']); |
|
| 132 | - $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($newcountry); |
|
| 133 | - if ($new_idp_authorized_fedadmin !== TRUE) { |
|
| 134 | - throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!"); |
|
| 135 | - } |
|
| 136 | - $federation = $validator->Federation($newcountry); |
|
| 137 | - $prettyprintname = $newinstname; |
|
| 138 | - $introtext = "NEW-FED"; |
|
| 139 | - // send the user back to his federation overview page, append the result of the operation later |
|
| 140 | - // do the token creation magic |
|
| 141 | - $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $newinstname, 0, $newcountry, $participant_type); |
|
| 142 | - $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE - Token created for $participant_type " . implode(",", $mailaddress)); |
|
| 143 | - break; |
|
| 144 | - case OPERATION_MODE_NEWFROMDB: |
|
| 145 | - $redirect_destination = "../overview_federation.php?"; |
|
| 146 | - $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination); |
|
| 147 | - // a real external DB entry was submitted and all the required parameters are there |
|
| 148 | - $newexternalid = $validator->string($_POST['externals']); |
|
| 149 | - $extinfo = $catInstance->getExternalDBEntityDetails($newexternalid); |
|
| 150 | - $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($extinfo['country']); |
|
| 151 | - if ($new_idp_authorized_fedadmin !== TRUE) { |
|
| 152 | - throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!"); |
|
| 153 | - } |
|
| 154 | - $federation = $validator->Federation($extinfo['country']); |
|
| 155 | - $newcountry = $extinfo['country']; |
|
| 156 | - // see if the inst name is defined in the currently set language; if not, pick its English name; if N/A, pick the last in the list |
|
| 157 | - $prettyprintname = ""; |
|
| 158 | - foreach ($extinfo['names'] as $lang => $name) { |
|
| 159 | - if ($lang == $languageInstance->getLang()) { |
|
| 160 | - $prettyprintname = $name; |
|
| 119 | + $prettyprintname = $idp->name; |
|
| 120 | + $newtokens = $mgmt->createTokens($fedadmin, $mailaddress, $idp); |
|
| 121 | + $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP " . $idp->identifier . " - Token created for " . implode(",", $mailaddress)); |
|
| 122 | + $introtext = "CO-ADMIN"; |
|
| 123 | + $participant_type = $idp->type; |
|
| 124 | + break; |
|
| 125 | + case OPERATION_MODE_NEWUNLINKED: |
|
| 126 | + $redirect_destination = "../overview_federation.php?"; |
|
| 127 | + $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination); |
|
| 128 | + // run an input check and conversion of the raw inputs... just in case |
|
| 129 | + $newinstname = $validator->string($_POST['name']); |
|
| 130 | + $newcountry = $validator->string($_POST['country']); |
|
| 131 | + $participant_type = $validator->partType($_POST['participant_type']); |
|
| 132 | + $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($newcountry); |
|
| 133 | + if ($new_idp_authorized_fedadmin !== TRUE) { |
|
| 134 | + throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!"); |
|
| 161 | 135 | } |
| 162 | - } |
|
| 163 | - if ($prettyprintname == "" && isset($extinfo['names']['en'])) { |
|
| 164 | - $prettyprintname = $extinfo['names']['en']; |
|
| 165 | - } |
|
| 166 | - if ($prettyprintname == "") { |
|
| 167 | - foreach ($extinfo['names'] as $name) { |
|
| 168 | - $prettyprintname = $name; |
|
| 136 | + $federation = $validator->Federation($newcountry); |
|
| 137 | + $prettyprintname = $newinstname; |
|
| 138 | + $introtext = "NEW-FED"; |
|
| 139 | + // send the user back to his federation overview page, append the result of the operation later |
|
| 140 | + // do the token creation magic |
|
| 141 | + $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $newinstname, 0, $newcountry, $participant_type); |
|
| 142 | + $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE - Token created for $participant_type " . implode(",", $mailaddress)); |
|
| 143 | + break; |
|
| 144 | + case OPERATION_MODE_NEWFROMDB: |
|
| 145 | + $redirect_destination = "../overview_federation.php?"; |
|
| 146 | + $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination); |
|
| 147 | + // a real external DB entry was submitted and all the required parameters are there |
|
| 148 | + $newexternalid = $validator->string($_POST['externals']); |
|
| 149 | + $extinfo = $catInstance->getExternalDBEntityDetails($newexternalid); |
|
| 150 | + $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($extinfo['country']); |
|
| 151 | + if ($new_idp_authorized_fedadmin !== TRUE) { |
|
| 152 | + throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!"); |
|
| 169 | 153 | } |
| 170 | - } |
|
| 171 | - // TODO when we have access to the data |
|
| 172 | - $participant_type = "IdPSP"; |
|
| 173 | - // fill the rest of the text |
|
| 174 | - $introtext = "EXISTING-FED"; |
|
| 175 | - // do the token creation magic |
|
| 176 | - $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid); |
|
| 177 | - $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE - Token created for " . implode(",", $mailaddress)); |
|
| 178 | - break; |
|
| 179 | - default: // includes OPERATION_MODE_INVALID |
|
| 180 | - $wrongcontent = print_r($_POST, TRUE); |
|
| 181 | - echo "<pre>Wrong parameters in POST: |
|
| 154 | + $federation = $validator->Federation($extinfo['country']); |
|
| 155 | + $newcountry = $extinfo['country']; |
|
| 156 | + // see if the inst name is defined in the currently set language; if not, pick its English name; if N/A, pick the last in the list |
|
| 157 | + $prettyprintname = ""; |
|
| 158 | + foreach ($extinfo['names'] as $lang => $name) { |
|
| 159 | + if ($lang == $languageInstance->getLang()) { |
|
| 160 | + $prettyprintname = $name; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + if ($prettyprintname == "" && isset($extinfo['names']['en'])) { |
|
| 164 | + $prettyprintname = $extinfo['names']['en']; |
|
| 165 | + } |
|
| 166 | + if ($prettyprintname == "") { |
|
| 167 | + foreach ($extinfo['names'] as $name) { |
|
| 168 | + $prettyprintname = $name; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + // TODO when we have access to the data |
|
| 172 | + $participant_type = "IdPSP"; |
|
| 173 | + // fill the rest of the text |
|
| 174 | + $introtext = "EXISTING-FED"; |
|
| 175 | + // do the token creation magic |
|
| 176 | + $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid); |
|
| 177 | + $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE - Token created for " . implode(",", $mailaddress)); |
|
| 178 | + break; |
|
| 179 | + default: // includes OPERATION_MODE_INVALID |
|
| 180 | + $wrongcontent = print_r($_POST, TRUE); |
|
| 181 | + echo "<pre>Wrong parameters in POST: |
|
| 182 | 182 | " . htmlspecialchars($wrongcontent) . " |
| 183 | 183 | </pre>"; |
| 184 | - exit(1); |
|
| 184 | + exit(1); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // send, and invalidate the token immediately if the mail could not be sent! |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * <base_url>/copyright.php after deploying the software |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -require_once dirname(dirname(dirname(__DIR__))) . "/config/_config.php"; |
|
| 23 | +require_once dirname(dirname(dirname(__DIR__)))."/config/_config.php"; |
|
| 24 | 24 | |
| 25 | 25 | $auth = new \web\lib\admin\Authentication(); |
| 26 | 26 | $auth->authenticate(); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $addressSegments = explode(",", $newmailaddress); |
| 48 | 48 | $confirmedMails = []; |
| 49 | 49 | if ($addressSegments === FALSE) { |
| 50 | - header("Location: $redirect_destination" . "invitation=INVALIDSYNTAX"); |
|
| 50 | + header("Location: $redirect_destination"."invitation=INVALIDSYNTAX"); |
|
| 51 | 51 | exit; |
| 52 | 52 | } |
| 53 | 53 | foreach ($addressSegments as $oneAddressCandidate) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | if (count($confirmedMails) == 0) { |
| 60 | - header("Location: $redirect_destination" . "invitation=INVALIDSYNTAX"); |
|
| 60 | + header("Location: $redirect_destination"."invitation=INVALIDSYNTAX"); |
|
| 61 | 61 | exit; |
| 62 | 62 | } else { |
| 63 | 63 | return $confirmedMails; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $idp = $validator->IdP($_GET['inst_id']); |
| 105 | 105 | // editing IdPs is done from within the popup. When we're done, send the |
| 106 | 106 | // user back to the popup (append the result of the operation later) |
| 107 | - $redirect_destination = "manageAdmins.inc.php?inst_id=" . $idp->identifier . "&"; |
|
| 107 | + $redirect_destination = "manageAdmins.inc.php?inst_id=".$idp->identifier."&"; |
|
| 108 | 108 | $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination); |
| 109 | 109 | // is the user primary admin of this IdP? |
| 110 | 110 | $is_owner = $idp->isPrimaryOwner($_SESSION['user']); |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | $fedadmin = $userObject->isFederationAdmin($idp->federation); |
| 113 | 113 | // check if he is either one, if not, complain |
| 114 | 114 | if (!$is_owner && !$fedadmin) { |
| 115 | - echo "<p>" . sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst) . "</p>"; |
|
| 115 | + echo "<p>".sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst)."</p>"; |
|
| 116 | 116 | exit(1); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $prettyprintname = $idp->name; |
| 120 | 120 | $newtokens = $mgmt->createTokens($fedadmin, $mailaddress, $idp); |
| 121 | - $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP " . $idp->identifier . " - Token created for " . implode(",", $mailaddress)); |
|
| 121 | + $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP ".$idp->identifier." - Token created for ".implode(",", $mailaddress)); |
|
| 122 | 122 | $introtext = "CO-ADMIN"; |
| 123 | 123 | $participant_type = $idp->type; |
| 124 | 124 | break; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $participant_type = $validator->partType($_POST['participant_type']); |
| 132 | 132 | $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($newcountry); |
| 133 | 133 | if ($new_idp_authorized_fedadmin !== TRUE) { |
| 134 | - throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!"); |
|
| 134 | + throw new Exception("Something's wrong... you want to create a new ".$uiElements->nomenclatureInst.", but are not a ".$uiElements->nomenclatureFed." admin for the ".$uiElements->nomenclatureFed." it should be in!"); |
|
| 135 | 135 | } |
| 136 | 136 | $federation = $validator->Federation($newcountry); |
| 137 | 137 | $prettyprintname = $newinstname; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | // send the user back to his federation overview page, append the result of the operation later |
| 140 | 140 | // do the token creation magic |
| 141 | 141 | $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $newinstname, 0, $newcountry, $participant_type); |
| 142 | - $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE - Token created for $participant_type " . implode(",", $mailaddress)); |
|
| 142 | + $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE - Token created for $participant_type ".implode(",", $mailaddress)); |
|
| 143 | 143 | break; |
| 144 | 144 | case OPERATION_MODE_NEWFROMDB: |
| 145 | 145 | $redirect_destination = "../overview_federation.php?"; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $extinfo = $catInstance->getExternalDBEntityDetails($newexternalid); |
| 150 | 150 | $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($extinfo['country']); |
| 151 | 151 | if ($new_idp_authorized_fedadmin !== TRUE) { |
| 152 | - throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!"); |
|
| 152 | + throw new Exception("Something's wrong... you want to create a new ".$uiElements->nomenclatureInst.", but are not a ".$uiElements->nomenclatureFed." admin for the ".$uiElements->nomenclatureFed." it should be in!"); |
|
| 153 | 153 | } |
| 154 | 154 | $federation = $validator->Federation($extinfo['country']); |
| 155 | 155 | $newcountry = $extinfo['country']; |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | $introtext = "EXISTING-FED"; |
| 175 | 175 | // do the token creation magic |
| 176 | 176 | $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid); |
| 177 | - $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE - Token created for " . implode(",", $mailaddress)); |
|
| 177 | + $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE - Token created for ".implode(",", $mailaddress)); |
|
| 178 | 178 | break; |
| 179 | 179 | default: // includes OPERATION_MODE_INVALID |
| 180 | 180 | $wrongcontent = print_r($_POST, TRUE); |
| 181 | 181 | echo "<pre>Wrong parameters in POST: |
| 182 | -" . htmlspecialchars($wrongcontent) . " |
|
| 182 | +" . htmlspecialchars($wrongcontent)." |
|
| 183 | 183 | </pre>"; |
| 184 | 184 | exit(1); |
| 185 | 185 | } |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | if (count($status) == 0) { |
| 207 | - header("Location: $redirect_destination" . "invitation=FAILURE"); |
|
| 207 | + header("Location: $redirect_destination"."invitation=FAILURE"); |
|
| 208 | 208 | exit; |
| 209 | 209 | } |
| 210 | 210 | $finalDestParams = "invitation=SUCCESS"; |
| 211 | 211 | if (count($status) < count($totalSegments)) { // only a subset of mails was sent, update status |
| 212 | 212 | $finalDestParams = "invitation=PARTIAL"; |
| 213 | 213 | } |
| 214 | -$finalDestParams .= "&successcount=" . count($status); |
|
| 214 | +$finalDestParams .= "&successcount=".count($status); |
|
| 215 | 215 | if ($allEncrypted === TRUE) { |
| 216 | 216 | $finalDestParams .= "&transportsecurity=ENCRYPTED"; |
| 217 | 217 | } elseif ($allClear === TRUE) { |
@@ -220,4 +220,4 @@ discard block |
||
| 220 | 220 | $finalDestParams .= "&transportsecurity=PARTIAL"; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | -header("Location: $redirect_destination" . $finalDestParams); |
|
| 223 | +header("Location: $redirect_destination".$finalDestParams); |
|
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | ?> |
| 22 | 22 | <?php |
| 23 | -require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/config/_config.php"; |
|
| 23 | +require_once dirname(dirname(dirname(dirname(__FILE__))))."/config/_config.php"; |
|
| 24 | 24 | |
| 25 | 25 | $auth = new \web\lib\admin\Authentication(); |
| 26 | 26 | $uiElements = new \web\lib\admin\UIElements(); |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | <?php |
| 58 | 58 | echo sprintf(_("On this page, you can add a new %s to your %s. Please fill out the form below to send out an email invitation to the new %s administrator."), $uiElements->nomenclatureInst, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst); |
| 59 | 59 | if (CONFIG['DB']['enforce-external-sync']) { |
| 60 | - echo "<p>" . sprintf(_("You can either register a known %s (as defined in the %s database) or create a totally new %s."), $uiElements->nomenclatureInst, CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], $uiElements->nomenclatureInst) . "</p>"; |
|
| 61 | - echo "<p>" . sprintf(_("The latter one is typically for an %s which is yet in a testing phase and therefore doesn't appear in the %s database yet."), $uiElements->nomenclatureInst, CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "</p>"; |
|
| 60 | + echo "<p>".sprintf(_("You can either register a known %s (as defined in the %s database) or create a totally new %s."), $uiElements->nomenclatureInst, CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], $uiElements->nomenclatureInst)."</p>"; |
|
| 61 | + echo "<p>".sprintf(_("The latter one is typically for an %s which is yet in a testing phase and therefore doesn't appear in the %s database yet."), $uiElements->nomenclatureInst, CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'])."</p>"; |
|
| 62 | 62 | } |
| 63 | 63 | ?> |
| 64 | 64 | <hr/> |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | <?php |
| 69 | 69 | if (CONFIG['DB']['enforce-external-sync']) { |
| 70 | 70 | echo "<tr><td> |
| 71 | - <input type='radio' name='creation' value='existing'>" . sprintf(_("Existing %s:"), $uiElements->nomenclatureParticipant) . "</input> |
|
| 71 | + <input type='radio' name='creation' value='existing'>" . sprintf(_("Existing %s:"), $uiElements->nomenclatureParticipant)."</input> |
|
| 72 | 72 | </td>"; |
| 73 | 73 | |
| 74 | 74 | echo "<td colspan='4'> |
| 75 | 75 | <select id='externals' name='externals' onchange='document.sendinvite.creation[0].checked=true; document.sendinvite.mailaddr.value=this.options[this.selectedIndex].id;'> |
| 76 | - <option value='FREETEXT'>" . _("--- select IdP here ---") . "</option>"; |
|
| 76 | + <option value='FREETEXT'>" . _("--- select IdP here ---")."</option>"; |
|
| 77 | 77 | |
| 78 | 78 | foreach ($feds as $fed_value) { |
| 79 | 79 | $thefed = new \core\Federation(strtoupper($fed_value['value'])); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $entities = $thefed->listExternalEntities(TRUE); |
| 83 | 83 | |
| 84 | 84 | foreach ($entities as $v) { |
| 85 | - echo "<option id='" . $v['contactlist'] . "' value='" . $v['ID'] . "'>[" . $fed_value['value'] . "] " . $v['name'] . "</option>"; |
|
| 85 | + echo "<option id='".$v['contactlist']."' value='".$v['ID']."'>[".$fed_value['value']."] ".$v['name']."</option>"; |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | ?> |
| 92 | 92 | <tr> |
| 93 | 93 | <td> |
| 94 | - <input type='radio' name='creation' value='new'><?php echo sprintf(_("New %s"),$uiElements->nomenclatureParticipant); ?></input> |
|
| 94 | + <input type='radio' name='creation' value='new'><?php echo sprintf(_("New %s"), $uiElements->nomenclatureParticipant); ?></input> |
|
| 95 | 95 | </td> |
| 96 | 96 | <td> |
| 97 | 97 | <?php echo _("Name"); ?><input type='text' size='30' id='name' name='name' onchange='document.sendinvite.creation[1].checked = true'/> |
| 98 | 98 | </td> |
| 99 | 99 | <td> |
| 100 | 100 | <select name="participant_type"> |
| 101 | - <option value="IdPSP" selected><?php printf(_("%s and %s"),$uiElements->nomenclatureInst, $uiElements->nomenclatureHotspot)?></option> |
|
| 102 | - <option value="IdP"><?php printf(_("%s"),$uiElements->nomenclatureInst)?></option> |
|
| 103 | - <option value="SP"><?php printf(_("%s"),$uiElements->nomenclatureHotspot)?></option> |
|
| 101 | + <option value="IdPSP" selected><?php printf(_("%s and %s"), $uiElements->nomenclatureInst, $uiElements->nomenclatureHotspot)?></option> |
|
| 102 | + <option value="IdP"><?php printf(_("%s"), $uiElements->nomenclatureInst)?></option> |
|
| 103 | + <option value="SP"><?php printf(_("%s"), $uiElements->nomenclatureHotspot)?></option> |
|
| 104 | 104 | </select> |
| 105 | 105 | </td> |
| 106 | 106 | <td><?php echo $uiElements->nomenclatureFed; ?> |
@@ -115,213 +115,213 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | switch ($inputDecoded['ACTION']) { |
| 118 | - case web\lib\admin\API::ACTION_NEWINST: |
|
| 119 | - // create the inst, no admin, no attributes |
|
| 120 | - $type = $validator->partType($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_INSTTYPE)); |
|
| 121 | - $idp = new \core\IdP($fed->newIdP($type, "PENDING", "API")); |
|
| 122 | - // now add all submitted attributes |
|
| 123 | - $inputs = $adminApi->uglify($scrubbedParameters); |
|
| 124 | - $optionParser->processSubmittedFields($idp, $inputs["POST"], $inputs["FILES"]); |
|
| 125 | - $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_CAT_INST_ID => $idp->identifier]); |
|
| 126 | - break; |
|
| 127 | - case web\lib\admin\API::ACTION_DELINST: |
|
| 128 | - try { |
|
| 129 | - $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 130 | - } catch (Exception $e) { |
|
| 131 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 132 | - exit(1); |
|
| 133 | - } |
|
| 134 | - $idp->destroy(); |
|
| 135 | - $adminApi->returnSuccess([]); |
|
| 136 | - break; |
|
| 137 | - case web\lib\admin\API::ACTION_ADMIN_LIST: |
|
| 138 | - try { |
|
| 139 | - $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 140 | - } catch (Exception $e) { |
|
| 141 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 142 | - exit(1); |
|
| 143 | - } |
|
| 144 | - $adminApi->returnSuccess($idp->listOwners()); |
|
| 145 | - break; |
|
| 146 | - case web\lib\admin\API::ACTION_ADMIN_ADD: |
|
| 147 | - // IdP in question |
|
| 148 | - try { |
|
| 149 | - $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 150 | - } catch (Exception $e) { |
|
| 151 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 152 | - exit(1); |
|
| 153 | - } |
|
| 154 | - // here is the token |
|
| 155 | - $mgmt = new core\UserManagement(); |
|
| 156 | - // we know we have an admin ID but scrutinizer wants this checked more explicitly |
|
| 157 | - $admin = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID); |
|
| 158 | - if ($admin === FALSE) { |
|
| 159 | - throw new Exception("A required parameter is missing, and this wasn't caught earlier?!"); |
|
| 160 | - } |
|
| 161 | - $newtokens = $mgmt->createTokens(true, [$admin], $idp); |
|
| 162 | - $URL = "https://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . "/action_enrollment.php?token=" . array_keys($newtokens)[0]; |
|
| 163 | - $success = ["TOKEN URL" => $URL, "TOKEN" => array_keys($newtokens)[0]]; |
|
| 164 | - // done with the essentials - display in response. But if we also have an email address, send it there |
|
| 165 | - $email = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TARGETMAIL); |
|
| 166 | - if ($email !== FALSE) { |
|
| 167 | - $sent = \core\common\OutsideComm::adminInvitationMail($email, "EXISTING-FED", array_keys($newtokens)[0], $idp->name, $fed, $idp->type); |
|
| 168 | - $success["EMAIL SENT"] = $sent["SENT"]; |
|
| 169 | - if ($sent["SENT"] === TRUE) { |
|
| 170 | - $success["EMAIL TRANSPORT SECURE"] = $sent["TRANSPORT"]; |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - $adminApi->returnSuccess($success); |
|
| 174 | - break; |
|
| 175 | - case web\lib\admin\API::ACTION_ADMIN_DEL: |
|
| 176 | - // IdP in question |
|
| 177 | - try { |
|
| 178 | - $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 179 | - } catch (Exception $e) { |
|
| 180 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 181 | - exit(1); |
|
| 182 | - } |
|
| 183 | - $currentAdmins = $idp->listOwners(); |
|
| 184 | - $toBeDeleted = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID); |
|
| 185 | - if ($toBeDeleted === FALSE) { |
|
| 186 | - throw new Exception("A required parameter is missing, and this wasn't caught earlier?!"); |
|
| 187 | - } |
|
| 188 | - $found = FALSE; |
|
| 189 | - foreach ($currentAdmins as $oneAdmin) { |
|
| 190 | - if ($oneAdmin['MAIL'] == $toBeDeleted) { |
|
| 191 | - $found = TRUE; |
|
| 192 | - $mgmt = new core\UserManagement(); |
|
| 193 | - $mgmt->removeAdminFromIdP($idp, $oneAdmin['ID']); |
|
| 118 | + case web\lib\admin\API::ACTION_NEWINST: |
|
| 119 | + // create the inst, no admin, no attributes |
|
| 120 | + $type = $validator->partType($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_INSTTYPE)); |
|
| 121 | + $idp = new \core\IdP($fed->newIdP($type, "PENDING", "API")); |
|
| 122 | + // now add all submitted attributes |
|
| 123 | + $inputs = $adminApi->uglify($scrubbedParameters); |
|
| 124 | + $optionParser->processSubmittedFields($idp, $inputs["POST"], $inputs["FILES"]); |
|
| 125 | + $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_CAT_INST_ID => $idp->identifier]); |
|
| 126 | + break; |
|
| 127 | + case web\lib\admin\API::ACTION_DELINST: |
|
| 128 | + try { |
|
| 129 | + $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 130 | + } catch (Exception $e) { |
|
| 131 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 132 | + exit(1); |
|
| 194 | 133 | } |
| 195 | - } |
|
| 196 | - if ($found) { |
|
| 134 | + $idp->destroy(); |
|
| 197 | 135 | $adminApi->returnSuccess([]); |
| 198 | - } |
|
| 199 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP " . $idp->identifier); |
|
| 200 | - break; |
|
| 201 | - case web\lib\admin\API::ACTION_STATISTICS_FED: |
|
| 202 | - $adminApi->returnSuccess($fed->downloadStats("array")); |
|
| 203 | - break; |
|
| 204 | - case \web\lib\admin\API::ACTION_NEWPROF_RADIUS: |
|
| 205 | - // fall-through intended: both get mostly identical treatment |
|
| 206 | - case web\lib\admin\API::ACTION_NEWPROF_SB: |
|
| 207 | - try { |
|
| 208 | - $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 209 | - } catch (Exception $e) { |
|
| 210 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 211 | - exit(1); |
|
| 212 | - } |
|
| 213 | - if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) { |
|
| 214 | - $type = "RADIUS"; |
|
| 215 | - } else { |
|
| 216 | - $type = "SILVERBULLET"; |
|
| 217 | - } |
|
| 218 | - $profile = $idp->newProfile($type); |
|
| 219 | - if ($profile === NULL) { |
|
| 220 | - $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support."); |
|
| 221 | - exit(1); |
|
| 222 | - } |
|
| 223 | - $inputs = $adminApi->uglify($scrubbedParameters); |
|
| 224 | - $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]); |
|
| 225 | - if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) { |
|
| 226 | - // auto-accept ToU? |
|
| 227 | - if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) { |
|
| 228 | - $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1); |
|
| 229 | - } |
|
| 230 | - // we're done at this point |
|
| 231 | - $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]); |
|
| 232 | - continue; |
|
| 233 | - } |
|
| 234 | - if (!$profile instanceof core\ProfileRADIUS) { |
|
| 235 | - throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS."); |
|
| 236 | - } |
|
| 237 | - /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM'; |
|
| 238 | - const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */ |
|
| 239 | - $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM); |
|
| 240 | - $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE); |
|
| 241 | - if ($realm !== FALSE) { |
|
| 242 | - if ($outer === FALSE) { |
|
| 243 | - $outer = ""; |
|
| 244 | - $profile->setAnonymousIDSupport(FALSE); |
|
| 136 | + break; |
|
| 137 | + case web\lib\admin\API::ACTION_ADMIN_LIST: |
|
| 138 | + try { |
|
| 139 | + $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 140 | + } catch (Exception $e) { |
|
| 141 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 142 | + exit(1); |
|
| 143 | + } |
|
| 144 | + $adminApi->returnSuccess($idp->listOwners()); |
|
| 145 | + break; |
|
| 146 | + case web\lib\admin\API::ACTION_ADMIN_ADD: |
|
| 147 | + // IdP in question |
|
| 148 | + try { |
|
| 149 | + $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 150 | + } catch (Exception $e) { |
|
| 151 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 152 | + exit(1); |
|
| 153 | + } |
|
| 154 | + // here is the token |
|
| 155 | + $mgmt = new core\UserManagement(); |
|
| 156 | + // we know we have an admin ID but scrutinizer wants this checked more explicitly |
|
| 157 | + $admin = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID); |
|
| 158 | + if ($admin === FALSE) { |
|
| 159 | + throw new Exception("A required parameter is missing, and this wasn't caught earlier?!"); |
|
| 160 | + } |
|
| 161 | + $newtokens = $mgmt->createTokens(true, [$admin], $idp); |
|
| 162 | + $URL = "https://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . "/action_enrollment.php?token=" . array_keys($newtokens)[0]; |
|
| 163 | + $success = ["TOKEN URL" => $URL, "TOKEN" => array_keys($newtokens)[0]]; |
|
| 164 | + // done with the essentials - display in response. But if we also have an email address, send it there |
|
| 165 | + $email = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TARGETMAIL); |
|
| 166 | + if ($email !== FALSE) { |
|
| 167 | + $sent = \core\common\OutsideComm::adminInvitationMail($email, "EXISTING-FED", array_keys($newtokens)[0], $idp->name, $fed, $idp->type); |
|
| 168 | + $success["EMAIL SENT"] = $sent["SENT"]; |
|
| 169 | + if ($sent["SENT"] === TRUE) { |
|
| 170 | + $success["EMAIL TRANSPORT SECURE"] = $sent["TRANSPORT"]; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + $adminApi->returnSuccess($success); |
|
| 174 | + break; |
|
| 175 | + case web\lib\admin\API::ACTION_ADMIN_DEL: |
|
| 176 | + // IdP in question |
|
| 177 | + try { |
|
| 178 | + $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 179 | + } catch (Exception $e) { |
|
| 180 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 181 | + exit(1); |
|
| 182 | + } |
|
| 183 | + $currentAdmins = $idp->listOwners(); |
|
| 184 | + $toBeDeleted = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID); |
|
| 185 | + if ($toBeDeleted === FALSE) { |
|
| 186 | + throw new Exception("A required parameter is missing, and this wasn't caught earlier?!"); |
|
| 187 | + } |
|
| 188 | + $found = FALSE; |
|
| 189 | + foreach ($currentAdmins as $oneAdmin) { |
|
| 190 | + if ($oneAdmin['MAIL'] == $toBeDeleted) { |
|
| 191 | + $found = TRUE; |
|
| 192 | + $mgmt = new core\UserManagement(); |
|
| 193 | + $mgmt->removeAdminFromIdP($idp, $oneAdmin['ID']); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + if ($found) { |
|
| 197 | + $adminApi->returnSuccess([]); |
|
| 198 | + } |
|
| 199 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP " . $idp->identifier); |
|
| 200 | + break; |
|
| 201 | + case web\lib\admin\API::ACTION_STATISTICS_FED: |
|
| 202 | + $adminApi->returnSuccess($fed->downloadStats("array")); |
|
| 203 | + break; |
|
| 204 | + case \web\lib\admin\API::ACTION_NEWPROF_RADIUS: |
|
| 205 | + // fall-through intended: both get mostly identical treatment |
|
| 206 | + case web\lib\admin\API::ACTION_NEWPROF_SB: |
|
| 207 | + try { |
|
| 208 | + $idp = $validator->IdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID)); |
|
| 209 | + } catch (Exception $e) { |
|
| 210 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!"); |
|
| 211 | + exit(1); |
|
| 212 | + } |
|
| 213 | + if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) { |
|
| 214 | + $type = "RADIUS"; |
|
| 245 | 215 | } else { |
| 246 | - $outer = $outer . "@"; |
|
| 247 | - $profile->setAnonymousIDSupport(TRUE); |
|
| 216 | + $type = "SILVERBULLET"; |
|
| 248 | 217 | } |
| 249 | - $profile->setRealm($outer . $realm); |
|
| 250 | - } |
|
| 251 | - /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */ |
|
| 252 | - $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER); |
|
| 253 | - if ($testuser !== FALSE) { |
|
| 254 | - $profile->setRealmCheckUser(TRUE, $testuser); |
|
| 255 | - } |
|
| 256 | - /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM'; |
|
| 218 | + $profile = $idp->newProfile($type); |
|
| 219 | + if ($profile === NULL) { |
|
| 220 | + $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support."); |
|
| 221 | + exit(1); |
|
| 222 | + } |
|
| 223 | + $inputs = $adminApi->uglify($scrubbedParameters); |
|
| 224 | + $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]); |
|
| 225 | + if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) { |
|
| 226 | + // auto-accept ToU? |
|
| 227 | + if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) { |
|
| 228 | + $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1); |
|
| 229 | + } |
|
| 230 | + // we're done at this point |
|
| 231 | + $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]); |
|
| 232 | + continue; |
|
| 233 | + } |
|
| 234 | + if (!$profile instanceof core\ProfileRADIUS) { |
|
| 235 | + throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS."); |
|
| 236 | + } |
|
| 237 | + /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM'; |
|
| 238 | + const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */ |
|
| 239 | + $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM); |
|
| 240 | + $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE); |
|
| 241 | + if ($realm !== FALSE) { |
|
| 242 | + if ($outer === FALSE) { |
|
| 243 | + $outer = ""; |
|
| 244 | + $profile->setAnonymousIDSupport(FALSE); |
|
| 245 | + } else { |
|
| 246 | + $outer = $outer . "@"; |
|
| 247 | + $profile->setAnonymousIDSupport(TRUE); |
|
| 248 | + } |
|
| 249 | + $profile->setRealm($outer . $realm); |
|
| 250 | + } |
|
| 251 | + /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */ |
|
| 252 | + $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER); |
|
| 253 | + if ($testuser !== FALSE) { |
|
| 254 | + $profile->setRealmCheckUser(TRUE, $testuser); |
|
| 255 | + } |
|
| 256 | + /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM'; |
|
| 257 | 257 | const AUXATTRIB_PROFILE_INPUT_VERIFY = 'ATTRIB-PROFILE-VERIFYREALM'; */ |
| 258 | - $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT); |
|
| 259 | - $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY); |
|
| 260 | - if ($enforce !== FALSE) { |
|
| 261 | - $profile->setInputVerificationPreference($enforce, $hint); |
|
| 262 | - } |
|
| 263 | - /* const AUXATTRIB_PROFILE_EAPTYPE */ |
|
| 264 | - $iterator = 1; |
|
| 265 | - foreach ($scrubbedParameters as $oneParam) { |
|
| 266 | - if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) { |
|
| 267 | - $type = new \core\common\EAP($oneParam["VALUE"]); |
|
| 268 | - $profile->addSupportedEapMethod($type, $iterator); |
|
| 269 | - $iterator = $iterator + 1; |
|
| 258 | + $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT); |
|
| 259 | + $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY); |
|
| 260 | + if ($enforce !== FALSE) { |
|
| 261 | + $profile->setInputVerificationPreference($enforce, $hint); |
|
| 270 | 262 | } |
| 271 | - } |
|
| 272 | - // reinstantiate $profile freshly from DB - it was updated in the process |
|
| 273 | - $profileFresh = new core\ProfileRADIUS($profile->identifier); |
|
| 274 | - $profileFresh->prepShowtime(); |
|
| 275 | - $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]); |
|
| 276 | - break; |
|
| 277 | - case web\lib\admin\API::ACTION_ENDUSER_NEW: |
|
| 278 | - $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 279 | - if ($prof_id === FALSE) { |
|
| 280 | - exit(1); |
|
| 281 | - } |
|
| 282 | - $evaluation = commonSbProfileChecks($fed, $prof_id); |
|
| 283 | - if ($evaluation === FALSE) { |
|
| 284 | - exit(1); |
|
| 285 | - } |
|
| 286 | - list($idp, $profile) = $evaluation; |
|
| 287 | - $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME)); |
|
| 288 | - $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY); |
|
| 289 | - if ($expiryRaw === FALSE) { |
|
| 290 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request."); |
|
| 291 | - exit(1); |
|
| 292 | - } |
|
| 293 | - $expiry = new DateTime($expiryRaw); |
|
| 294 | - try { |
|
| 295 | - $retval = $profile->addUser($user, $expiry); |
|
| 296 | - } catch (Exception $e) { |
|
| 297 | - $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed. Maybe a duplicate username, or malformed expiry date?"); |
|
| 298 | - exit(1); |
|
| 299 | - } |
|
| 300 | - if ($retval == 0) {// that didn't work, it seems |
|
| 301 | - $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed subtly. Contact the administrators."); |
|
| 302 | - exit(1); |
|
| 303 | - } |
|
| 304 | - $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $user, \web\lib\admin\API::AUXATTRIB_SB_USERID => $retval]); |
|
| 305 | - break; |
|
| 306 | - case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE: |
|
| 307 | - // fall-through intended: both actions are very similar |
|
| 308 | - case \web\lib\admin\API::ACTION_TOKEN_NEW: |
|
| 309 | - $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 310 | - if ($profile_id === FALSE) { |
|
| 311 | - exit(1); |
|
| 312 | - } |
|
| 313 | - $evaluation = commonSbProfileChecks($fed, $profile_id); |
|
| 314 | - if ($evaluation === FALSE) { |
|
| 315 | - exit(1); |
|
| 316 | - } |
|
| 317 | - list($idp, $profile) = $evaluation; |
|
| 318 | - $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID)); |
|
| 319 | - if ($userId === FALSE) { |
|
| 320 | - $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer."); |
|
| 321 | - exit(1); |
|
| 322 | - } |
|
| 323 | - $additionalInfo = []; |
|
| 324 | - switch ($inputDecoded['ACTION']) { // this is where the two differ |
|
| 263 | + /* const AUXATTRIB_PROFILE_EAPTYPE */ |
|
| 264 | + $iterator = 1; |
|
| 265 | + foreach ($scrubbedParameters as $oneParam) { |
|
| 266 | + if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) { |
|
| 267 | + $type = new \core\common\EAP($oneParam["VALUE"]); |
|
| 268 | + $profile->addSupportedEapMethod($type, $iterator); |
|
| 269 | + $iterator = $iterator + 1; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + // reinstantiate $profile freshly from DB - it was updated in the process |
|
| 273 | + $profileFresh = new core\ProfileRADIUS($profile->identifier); |
|
| 274 | + $profileFresh->prepShowtime(); |
|
| 275 | + $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]); |
|
| 276 | + break; |
|
| 277 | + case web\lib\admin\API::ACTION_ENDUSER_NEW: |
|
| 278 | + $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 279 | + if ($prof_id === FALSE) { |
|
| 280 | + exit(1); |
|
| 281 | + } |
|
| 282 | + $evaluation = commonSbProfileChecks($fed, $prof_id); |
|
| 283 | + if ($evaluation === FALSE) { |
|
| 284 | + exit(1); |
|
| 285 | + } |
|
| 286 | + list($idp, $profile) = $evaluation; |
|
| 287 | + $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME)); |
|
| 288 | + $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY); |
|
| 289 | + if ($expiryRaw === FALSE) { |
|
| 290 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request."); |
|
| 291 | + exit(1); |
|
| 292 | + } |
|
| 293 | + $expiry = new DateTime($expiryRaw); |
|
| 294 | + try { |
|
| 295 | + $retval = $profile->addUser($user, $expiry); |
|
| 296 | + } catch (Exception $e) { |
|
| 297 | + $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed. Maybe a duplicate username, or malformed expiry date?"); |
|
| 298 | + exit(1); |
|
| 299 | + } |
|
| 300 | + if ($retval == 0) {// that didn't work, it seems |
|
| 301 | + $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed subtly. Contact the administrators."); |
|
| 302 | + exit(1); |
|
| 303 | + } |
|
| 304 | + $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $user, \web\lib\admin\API::AUXATTRIB_SB_USERID => $retval]); |
|
| 305 | + break; |
|
| 306 | + case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE: |
|
| 307 | + // fall-through intended: both actions are very similar |
|
| 308 | + case \web\lib\admin\API::ACTION_TOKEN_NEW: |
|
| 309 | + $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 310 | + if ($profile_id === FALSE) { |
|
| 311 | + exit(1); |
|
| 312 | + } |
|
| 313 | + $evaluation = commonSbProfileChecks($fed, $profile_id); |
|
| 314 | + if ($evaluation === FALSE) { |
|
| 315 | + exit(1); |
|
| 316 | + } |
|
| 317 | + list($idp, $profile) = $evaluation; |
|
| 318 | + $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID)); |
|
| 319 | + if ($userId === FALSE) { |
|
| 320 | + $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer."); |
|
| 321 | + exit(1); |
|
| 322 | + } |
|
| 323 | + $additionalInfo = []; |
|
| 324 | + switch ($inputDecoded['ACTION']) { // this is where the two differ |
|
| 325 | 325 | case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE: |
| 326 | 326 | $result = $profile->deactivateUser($userId); |
| 327 | 327 | break; |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | break; |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | 359 | if ($result !== TRUE) { |
| 360 | 360 | $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "These parameters did not lead to an existing, active user."); |
@@ -362,21 +362,21 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | $adminApi->returnSuccess($additionalInfo); |
| 364 | 364 | break; |
| 365 | - case \web\lib\admin\API::ACTION_ENDUSER_LIST: |
|
| 366 | - // fall-through: those two are similar |
|
| 367 | - case \web\lib\admin\API::ACTION_TOKEN_LIST: |
|
| 368 | - $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 369 | - if ($profile_id === FALSE) { |
|
| 370 | - exit(1); |
|
| 371 | - } |
|
| 372 | - $evaluation = commonSbProfileChecks($fed, $profile_id); |
|
| 373 | - if ($evaluation === FALSE) { |
|
| 374 | - exit(1); |
|
| 375 | - } |
|
| 376 | - list($idp, $profile) = $evaluation; |
|
| 377 | - $allUsers = $profile->listAllUsers(); |
|
| 378 | - // this is where they differ |
|
| 379 | - switch ($inputDecoded['ACTION']) { |
|
| 365 | + case \web\lib\admin\API::ACTION_ENDUSER_LIST: |
|
| 366 | + // fall-through: those two are similar |
|
| 367 | + case \web\lib\admin\API::ACTION_TOKEN_LIST: |
|
| 368 | + $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 369 | + if ($profile_id === FALSE) { |
|
| 370 | + exit(1); |
|
| 371 | + } |
|
| 372 | + $evaluation = commonSbProfileChecks($fed, $profile_id); |
|
| 373 | + if ($evaluation === FALSE) { |
|
| 374 | + exit(1); |
|
| 375 | + } |
|
| 376 | + list($idp, $profile) = $evaluation; |
|
| 377 | + $allUsers = $profile->listAllUsers(); |
|
| 378 | + // this is where they differ |
|
| 379 | + switch ($inputDecoded['ACTION']) { |
|
| 380 | 380 | case \web\lib\admin\API::ACTION_ENDUSER_LIST: |
| 381 | 381 | $adminApi->returnSuccess($allUsers); |
| 382 | 382 | break; |
@@ -395,71 +395,71 @@ discard block |
||
| 395 | 395 | $infoSet[$oneTokenObject->userId] = [\web\lib\admin\API::AUXATTRIB_TOKEN => $oneTokenObject->invitationTokenString, "STATUS" => $oneTokenObject->invitationTokenStatus]; |
| 396 | 396 | } |
| 397 | 397 | $adminApi->returnSuccess($infoSet); |
| 398 | - } |
|
| 399 | - break; |
|
| 400 | - case \web\lib\admin\API::ACTION_TOKEN_REVOKE: |
|
| 401 | - $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN); |
|
| 402 | - if ($tokenRaw === FALSE) { |
|
| 403 | - exit(1); |
|
| 404 | - } |
|
| 405 | - $token = new core\SilverbulletInvitation($tokenRaw); |
|
| 406 | - if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) { |
|
| 407 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token."); |
|
| 408 | - exit(1); |
|
| 409 | - } |
|
| 410 | - $token->revokeInvitation(); |
|
| 411 | - $adminApi->returnSuccess([]); |
|
| 412 | - break; |
|
| 413 | - case \web\lib\admin\API::ACTION_CERT_LIST: |
|
| 414 | - $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 415 | - $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID); |
|
| 416 | - if ($prof_id === FALSE || !is_int($user_id)) { |
|
| 417 | - exit(1); |
|
| 418 | - } |
|
| 419 | - $evaluation = commonSbProfileChecks($fed, $prof_id); |
|
| 420 | - if ($evaluation === FALSE) { |
|
| 421 | - exit(1); |
|
| 422 | - } |
|
| 423 | - list($idp, $profile) = $evaluation; |
|
| 424 | - $invitations = $profile->userStatus($user_id); |
|
| 425 | - // now pull out cert information from the object |
|
| 426 | - $certs = []; |
|
| 427 | - foreach ($invitations as $oneInvitation) { |
|
| 428 | - $certs = array_merge($certs, $oneInvitation->associatedCertificates); |
|
| 429 | - } |
|
| 430 | - // extract relevant subset of information from cert objects |
|
| 431 | - $certDetails = []; |
|
| 432 | - foreach ($certs as $cert) { |
|
| 433 | - $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username]; |
|
| 434 | - } |
|
| 435 | - $adminApi->returnSuccess($certDetails); |
|
| 436 | - break; |
|
| 437 | - case \web\lib\admin\API::ACTION_CERT_REVOKE: |
|
| 438 | - $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 439 | - if ($prof_id === FALSE) { |
|
| 440 | - exit(1); |
|
| 441 | - } |
|
| 442 | - $evaluation = commonSbProfileChecks($fed, $prof_id); |
|
| 443 | - if ($evaluation === FALSE) { |
|
| 444 | - exit(1); |
|
| 445 | - } |
|
| 446 | - list($idp, $profile) = $evaluation; |
|
| 447 | - // tear apart the serial |
|
| 448 | - $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL); |
|
| 449 | - if ($serialRaw === FALSE) { |
|
| 450 | - exit(1); |
|
| 451 | - } |
|
| 452 | - $serial = explode(":", $serialRaw); |
|
| 453 | - $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]); |
|
| 454 | - if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) { |
|
| 455 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found."); |
|
| 456 | - } |
|
| 457 | - if ($cert->profileId != $profile->identifier) { |
|
| 458 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile."); |
|
| 459 | - } |
|
| 460 | - $cert->revokeCertificate(); |
|
| 461 | - $adminApi->returnSuccess([]); |
|
| 398 | + } |
|
| 462 | 399 | break; |
| 463 | - default: |
|
| 464 | - $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet."); |
|
| 400 | + case \web\lib\admin\API::ACTION_TOKEN_REVOKE: |
|
| 401 | + $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN); |
|
| 402 | + if ($tokenRaw === FALSE) { |
|
| 403 | + exit(1); |
|
| 404 | + } |
|
| 405 | + $token = new core\SilverbulletInvitation($tokenRaw); |
|
| 406 | + if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) { |
|
| 407 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token."); |
|
| 408 | + exit(1); |
|
| 409 | + } |
|
| 410 | + $token->revokeInvitation(); |
|
| 411 | + $adminApi->returnSuccess([]); |
|
| 412 | + break; |
|
| 413 | + case \web\lib\admin\API::ACTION_CERT_LIST: |
|
| 414 | + $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 415 | + $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID); |
|
| 416 | + if ($prof_id === FALSE || !is_int($user_id)) { |
|
| 417 | + exit(1); |
|
| 418 | + } |
|
| 419 | + $evaluation = commonSbProfileChecks($fed, $prof_id); |
|
| 420 | + if ($evaluation === FALSE) { |
|
| 421 | + exit(1); |
|
| 422 | + } |
|
| 423 | + list($idp, $profile) = $evaluation; |
|
| 424 | + $invitations = $profile->userStatus($user_id); |
|
| 425 | + // now pull out cert information from the object |
|
| 426 | + $certs = []; |
|
| 427 | + foreach ($invitations as $oneInvitation) { |
|
| 428 | + $certs = array_merge($certs, $oneInvitation->associatedCertificates); |
|
| 429 | + } |
|
| 430 | + // extract relevant subset of information from cert objects |
|
| 431 | + $certDetails = []; |
|
| 432 | + foreach ($certs as $cert) { |
|
| 433 | + $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username]; |
|
| 434 | + } |
|
| 435 | + $adminApi->returnSuccess($certDetails); |
|
| 436 | + break; |
|
| 437 | + case \web\lib\admin\API::ACTION_CERT_REVOKE: |
|
| 438 | + $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID); |
|
| 439 | + if ($prof_id === FALSE) { |
|
| 440 | + exit(1); |
|
| 441 | + } |
|
| 442 | + $evaluation = commonSbProfileChecks($fed, $prof_id); |
|
| 443 | + if ($evaluation === FALSE) { |
|
| 444 | + exit(1); |
|
| 445 | + } |
|
| 446 | + list($idp, $profile) = $evaluation; |
|
| 447 | + // tear apart the serial |
|
| 448 | + $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL); |
|
| 449 | + if ($serialRaw === FALSE) { |
|
| 450 | + exit(1); |
|
| 451 | + } |
|
| 452 | + $serial = explode(":", $serialRaw); |
|
| 453 | + $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]); |
|
| 454 | + if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) { |
|
| 455 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found."); |
|
| 456 | + } |
|
| 457 | + if ($cert->profileId != $profile->identifier) { |
|
| 458 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile."); |
|
| 459 | + } |
|
| 460 | + $cert->revokeCertificate(); |
|
| 461 | + $adminApi->returnSuccess([]); |
|
| 462 | + break; |
|
| 463 | + default: |
|
| 464 | + $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet."); |
|
| 465 | 465 | } |
| 466 | 466 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | ?> |
| 31 | 31 | <?php |
| 32 | 32 | |
| 33 | -require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php"; |
|
| 33 | +require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php"; |
|
| 34 | 34 | |
| 35 | 35 | $auth = new \web\lib\admin\Authentication(); |
| 36 | 36 | $deco = new \web\lib\admin\PageDecoration(); |
@@ -70,22 +70,22 @@ discard block |
||
| 70 | 70 | $federation = CONFIG_CONFASSISTANT['CONSORTIUM']['selfservice_registration']; |
| 71 | 71 | break; |
| 72 | 72 | default: |
| 73 | - $token = $validator->token(filter_input(INPUT_GET,'token',FILTER_SANITIZE_STRING)); |
|
| 73 | + $token = $validator->token(filter_input(INPUT_GET, 'token', FILTER_SANITIZE_STRING)); |
|
| 74 | 74 | $checkval = $usermgmt->checkTokenValidity($token); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | if ($checkval < 0) { |
| 78 | 78 | echo $deco->pageheader(_("Error creating new IdP binding!"), "ADMIN-IDP"); |
| 79 | - echo "<h1>" . _("Error creating new IdP binding!") . "</h1>"; |
|
| 79 | + echo "<h1>"._("Error creating new IdP binding!")."</h1>"; |
|
| 80 | 80 | switch ($checkval) { |
| 81 | 81 | case \core\UserManagement::TOKENSTATUS_FAIL_ALREADYCONSUMED: |
| 82 | - echo "<p>" . sprintf(_("Sorry... this token has already been used. The %s is already created. If you got the invitation from a mailing list, probably someone else used it before you."), $elements->nomenclatureInst) . "</p>"; |
|
| 82 | + echo "<p>".sprintf(_("Sorry... this token has already been used. The %s is already created. If you got the invitation from a mailing list, probably someone else used it before you."), $elements->nomenclatureInst)."</p>"; |
|
| 83 | 83 | break; |
| 84 | 84 | case \core\UserManagement::TOKENSTATUS_FAIL_EXPIRED: |
| 85 | - echo "<p>" . sprintf(_("Sorry... this token has expired. Invitation tokens are valid for 24 hours. The %s administrator can create a new one for you."), $elements->nomenclatureFed) . "</p>"; |
|
| 85 | + echo "<p>".sprintf(_("Sorry... this token has expired. Invitation tokens are valid for 24 hours. The %s administrator can create a new one for you."), $elements->nomenclatureFed)."</p>"; |
|
| 86 | 86 | break; |
| 87 | 87 | default: |
| 88 | - echo "<p>" . _("Sorry... you have come to the enrollment page without a valid token. Are you a nasty person? If not, you should go to <a href='overview_user.php'>your profile page</a> instead.") . "</p>"; |
|
| 88 | + echo "<p>"._("Sorry... you have come to the enrollment page without a valid token. Are you a nasty person? If not, you should go to <a href='overview_user.php'>your profile page</a> instead.")."</p>"; |
|
| 89 | 89 | } |
| 90 | 90 | echo $deco->footer(); |
| 91 | 91 | throw new Exception("Terminating because something is wrong with the token we received."); |
@@ -100,12 +100,12 @@ discard block |
||
| 100 | 100 | case "SELF-REGISTER": |
| 101 | 101 | $fed = new \core\Federation($federation); |
| 102 | 102 | $newidp = new \core\IdP($fed->newIdP(core\IdP::TYPE_IDPSP, $user, "FED", "SELFSERVICE")); |
| 103 | - $loggerInstance->writeAudit($user, "MOD", "IdP " . $newidp->identifier . " - selfservice registration"); |
|
| 103 | + $loggerInstance->writeAudit($user, "MOD", "IdP ".$newidp->identifier." - selfservice registration"); |
|
| 104 | 104 | break; |
| 105 | 105 | default: |
| 106 | 106 | $newidp = $usermgmt->createIdPFromToken($token, $user); |
| 107 | 107 | $usermgmt->invalidateToken($token); |
| 108 | - $loggerInstance->writeAudit($user, "MOD", "IdP " . $newidp->identifier . " - Token used and invalidated"); |
|
| 108 | + $loggerInstance->writeAudit($user, "MOD", "IdP ".$newidp->identifier." - Token used and invalidated"); |
|
| 109 | 109 | break; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $loggerInstance->debug(4, "OutsideComm::mailAddressValidSecure: no MX."); |
| 118 | 118 | return OutsideComm::MAILDOMAIN_NO_MX; |
| 119 | 119 | } |
| 120 | - $loggerInstance->debug(5, "Domain: $domain MX: " . print_r($mx, TRUE)); |
|
| 120 | + $loggerInstance->debug(5, "Domain: $domain MX: ".print_r($mx, TRUE)); |
|
| 121 | 121 | // create a pool of A and AAAA records for all the MXes |
| 122 | 122 | $ipAddrs = []; |
| 123 | 123 | foreach ($mx as $onemx) { |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | $ipAddrs[] = $oneipv4['ip']; |
| 128 | 128 | } |
| 129 | 129 | foreach ($v6list as $oneipv6) { |
| 130 | - $ipAddrs[] = "[" . $oneipv6['ipv6'] . "]"; |
|
| 130 | + $ipAddrs[] = "[".$oneipv6['ipv6']."]"; |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | if (count($ipAddrs) == 0) { |
| 134 | 134 | $loggerInstance->debug(4, "OutsideComm::mailAddressValidSecure: no mailserver hosts."); |
| 135 | 135 | return OutsideComm::MAILDOMAIN_NO_HOST; |
| 136 | 136 | } |
| 137 | - $loggerInstance->debug(5, "Domain: $domain Addrs: " . print_r($ipAddrs, TRUE)); |
|
| 137 | + $loggerInstance->debug(5, "Domain: $domain Addrs: ".print_r($ipAddrs, TRUE)); |
|
| 138 | 138 | // connect to all hosts. If all can't connect, return MAILDOMAIN_NO_CONNECT. |
| 139 | 139 | // If at least one does not support STARTTLS or one of the hosts doesn't connect |
| 140 | 140 | // , return MAILDOMAIN_NO_STARTTLS (one which we can't connect to we also |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | switch (CONFIG_CONFASSISTANT['SMSSETTINGS']['provider']) { |
| 187 | 187 | case 'Nexmo': |
| 188 | 188 | // taken from https://docs.nexmo.com/messaging/sms-api |
| 189 | - $url = 'https://rest.nexmo.com/sms/json?' . http_build_query( |
|
| 189 | + $url = 'https://rest.nexmo.com/sms/json?'.http_build_query( |
|
| 190 | 190 | [ |
| 191 | 191 | 'api_key' => CONFIG_CONFASSISTANT['SMSSETTINGS']['username'], |
| 192 | 192 | 'api_secret' => CONFIG_CONFASSISTANT['SMSSETTINGS']['password'], |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | $loggerInstance->debug(2, 'Problem with SMS invitation: no message was sent!'); |
| 209 | 209 | return OutsideComm::SMS_NOTSENT; |
| 210 | 210 | } |
| 211 | - $loggerInstance->debug(2, 'Total of ' . $messageCount . ' messages were attempted to send.'); |
|
| 211 | + $loggerInstance->debug(2, 'Total of '.$messageCount.' messages were attempted to send.'); |
|
| 212 | 212 | |
| 213 | 213 | $totalFailures = 0; |
| 214 | 214 | foreach ($decoded_response['messages'] as $message) { |
| 215 | 215 | if ($message['status'] == 0) { |
| 216 | - $loggerInstance->debug(2, $message['message-id'] . ": Success"); |
|
| 216 | + $loggerInstance->debug(2, $message['message-id'].": Success"); |
|
| 217 | 217 | } else { |
| 218 | - $loggerInstance->debug(2, $message['message-id'] . ": Failed (failure code = " . $message['status'] . ")"); |
|
| 218 | + $loggerInstance->debug(2, $message['message-id'].": Failed (failure code = ".$message['status'].")"); |
|
| 219 | 219 | $totalFailures++; |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $proto = "https://"; |
| 283 | 283 | } |
| 284 | 284 | // then, send out the mail |
| 285 | - $message = _("Hello,") . "\n\n" . wordwrap($introTexts[$introtext] . " " . $validity, 72) . "\n\n"; |
|
| 285 | + $message = _("Hello,")."\n\n".wordwrap($introTexts[$introtext]." ".$validity, 72)."\n\n"; |
|
| 286 | 286 | // default means we don't have a Reply-To. |
| 287 | 287 | $replyToMessage = wordwrap(_("manually. Please do not reply to this mail; this is a send-only address.")); |
| 288 | 288 | |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | // see if we are supposed to add a custom message |
| 291 | 291 | $customtext = $federation->getAttributes('fed:custominvite'); |
| 292 | 292 | if (count($customtext) > 0) { |
| 293 | - $message .= wordwrap(sprintf(_("Additional message from your %s administrator:"), Entity::$nomenclature_fed), 72) . "\n---------------------------------" . |
|
| 294 | - wordwrap($customtext[0]['value'], 72) . "\n---------------------------------\n\n"; |
|
| 293 | + $message .= wordwrap(sprintf(_("Additional message from your %s administrator:"), Entity::$nomenclature_fed), 72)."\n---------------------------------". |
|
| 294 | + wordwrap($customtext[0]['value'], 72)."\n---------------------------------\n\n"; |
|
| 295 | 295 | } |
| 296 | 296 | // and add Reply-To already now |
| 297 | 297 | foreach ($federation->listFederationAdmins() as $fedadmin_id) { |
@@ -306,19 +306,19 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $message .= wordwrap(sprintf(_("To enlist as an administrator for that %s, please click on the following link:"), Entity::$nomenclature_participant), 72) . "\n\n" . |
|
| 310 | - $proto . $_SERVER['SERVER_NAME'] . CONFIG['PATHS']['cat_base_url'] . "admin/action_enrollment.php?token=$newtoken\n\n" . |
|
| 311 | - wordwrap(sprintf(_("If clicking the link doesn't work, you can also go to the %s Administrator Interface at"), CONFIG['APPEARANCE']['productname']), 72) . "\n\n" . |
|
| 312 | - $proto . $_SERVER['SERVER_NAME'] . CONFIG['PATHS']['cat_base_url'] . "admin/\n\n" . |
|
| 313 | - _("and enter the invitation token") . "\n\n" . |
|
| 314 | - $newtoken . "\n\n$replyToMessage\n\n" . |
|
| 315 | - wordwrap(_("Do NOT forward the mail before the token has expired - or the recipients may be able to consume the token on your behalf!"), 72) . "\n\n" . |
|
| 316 | - wordwrap(sprintf(_("We wish you a lot of fun with the %s."), CONFIG['APPEARANCE']['productname']), 72) . "\n\n" . |
|
| 309 | + $message .= wordwrap(sprintf(_("To enlist as an administrator for that %s, please click on the following link:"), Entity::$nomenclature_participant), 72)."\n\n". |
|
| 310 | + $proto.$_SERVER['SERVER_NAME'].CONFIG['PATHS']['cat_base_url']."admin/action_enrollment.php?token=$newtoken\n\n". |
|
| 311 | + wordwrap(sprintf(_("If clicking the link doesn't work, you can also go to the %s Administrator Interface at"), CONFIG['APPEARANCE']['productname']), 72)."\n\n". |
|
| 312 | + $proto.$_SERVER['SERVER_NAME'].CONFIG['PATHS']['cat_base_url']."admin/\n\n". |
|
| 313 | + _("and enter the invitation token")."\n\n". |
|
| 314 | + $newtoken."\n\n$replyToMessage\n\n". |
|
| 315 | + wordwrap(_("Do NOT forward the mail before the token has expired - or the recipients may be able to consume the token on your behalf!"), 72)."\n\n". |
|
| 316 | + wordwrap(sprintf(_("We wish you a lot of fun with the %s."), CONFIG['APPEARANCE']['productname']), 72)."\n\n". |
|
| 317 | 317 | sprintf(_("Sincerely,\n\nYour friendly folks from %s Operations"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']); |
| 318 | 318 | |
| 319 | 319 | |
| 320 | 320 | // who to whom? |
| 321 | - $mail->FromName = CONFIG['APPEARANCE']['productname'] . " Invitation System"; |
|
| 321 | + $mail->FromName = CONFIG['APPEARANCE']['productname']." Invitation System"; |
|
| 322 | 322 | |
| 323 | 323 | if (isset(CONFIG['APPEARANCE']['invitation-bcc-mail']) && CONFIG['APPEARANCE']['invitation-bcc-mail'] !== NULL) { |
| 324 | 324 | $mail->addBCC(CONFIG['APPEARANCE']['invitation-bcc-mail']); |