From 8da7b6bf5ba56a9a86b299304ad62c3498d942a1 Mon Sep 17 00:00:00 2001 From: Joe Huss Date: Thu, 28 Jul 2022 17:04:55 -0400 Subject: [PATCH] formatting update --- bin/list_certs.php | 1 + bin/make_cert.php | 26 +- bin/parse_ssl_extra.php | 8 +- src/GlobalSign.php | 2902 +++++++++++++++++++------------------- src/Plugin.php | 288 ++-- tests/GlobalSignTest.php | 662 ++++----- tests/bootstrap.php | 145 +- 7 files changed, 2017 insertions(+), 2015 deletions(-) diff --git a/bin/list_certs.php b/bin/list_certs.php index c7b5e2a..330c916 100755 --- a/bin/list_certs.php +++ b/bin/list_certs.php @@ -1,4 +1,5 @@ session->sessionid; */ if (file_exists(__DIR__.'/.make_cert.last')) { - include __DIR__.'/.make_cert.last'; + include __DIR__.'/.make_cert.last'; } $vars = ['fqdn' => 'Fully Qualified Domain Name', 'email' => 'Email Address', 'city' => 'City', 'state' => 'State (Full State Not Abbreviation)', 'country' => 'Country (2 Letters)', 'company' => 'Company', department => 'Department']; $fout = " $description) { - if (isset($settings[$var])) { - fwrite(STDOUT, "$description [" . $settings[$var] . ']? '); - $t = trim(fgets(STDIN)); - if ($t == '') { - $t = $settings[$var]; - } - } else { - fwrite(STDOUT, "$description? "); - $t = trim(fgets(STDIN)); - } - $fout .= "\$settings['{$var}'] = '{$t}';\n"; - eval('$'.$var.' = "$t";'); + if (isset($settings[$var])) { + fwrite(STDOUT, "$description [" . $settings[$var] . ']? '); + $t = trim(fgets(STDIN)); + if ($t == '') { + $t = $settings[$var]; + } + } else { + fwrite(STDOUT, "$description? "); + $t = trim(fgets(STDIN)); + } + $fout .= "\$settings['{$var}'] = '{$t}';\n"; + eval('$'.$var.' = "$t";'); } $fout .= "?>\n"; $fd = fopen(__DIR__.'/.make_cert.last', 'wb'); diff --git a/bin/parse_ssl_extra.php b/bin/parse_ssl_extra.php index f8aeb2b..02b8e26 100755 --- a/bin/parse_ssl_extra.php +++ b/bin/parse_ssl_extra.php @@ -8,10 +8,10 @@ $db2 = clone $db; $result = $db->query('select * from ssl_certs where ssl_id=' .intval($_SERVER['argv'][1])); while ($db->next_record(MYSQL_ASSOC)) { - echo 'Got Unparsed '.$db->Record['ssl_extra'].PHP_EOL; - $extra = myadmin_unstringify($db->Record['ssl_extra']); - print_r($extra); -// $updates[] = "ssl_extra='" .$db->real_escape($extra)."'"; + echo 'Got Unparsed '.$db->Record['ssl_extra'].PHP_EOL; + $extra = myadmin_unstringify($db->Record['ssl_extra']); + print_r($extra); + // $updates[] = "ssl_extra='" .$db->real_escape($extra)."'"; // echo "updates:".print_r($updates,true).PHP_EOL; // $db2->query("update ssl_certs set " . implode(', ', $updates) . " where ssl_id=" . $db->Record['ssl_id'], __LINE__, __FILE__); } diff --git a/src/GlobalSign.php b/src/GlobalSign.php index f0b89b1..e7a2f10 100644 --- a/src/GlobalSign.php +++ b/src/GlobalSign.php @@ -35,1494 +35,1494 @@ */ class GlobalSign { - public $functionsWsdl = 'https://system.globalsign.com/kb/ws/v1/ServerSSLService?wsdl'; - public $queryWsdl = 'https://system.globalsign.com/kb/ws/v1/GASService?wsdl'; - public $accountWsdl = 'https://system.globalsign.com/kb/ws/v1/AccountService?wsdl'; + public $functionsWsdl = 'https://system.globalsign.com/kb/ws/v1/ServerSSLService?wsdl'; + public $queryWsdl = 'https://system.globalsign.com/kb/ws/v1/GASService?wsdl'; + public $accountWsdl = 'https://system.globalsign.com/kb/ws/v1/AccountService?wsdl'; - public $testFunctionsWsdl = 'https://test-gcc.globalsign.com/kb/ws/v1/ServerSSLService?wsdl'; - public $testQueryWsdl = 'https://test-gcc.globalsign.com/kb/ws/v1/GASService?wsdl'; - public $testAccountWsdl = 'https://test-gcc.globalsign.com/kb/ws/v1/AccountService?wsdl'; + public $testFunctionsWsdl = 'https://test-gcc.globalsign.com/kb/ws/v1/ServerSSLService?wsdl'; + public $testQueryWsdl = 'https://test-gcc.globalsign.com/kb/ws/v1/GASService?wsdl'; + public $testAccountWsdl = 'https://test-gcc.globalsign.com/kb/ws/v1/AccountService?wsdl'; - private $username = ''; - private $password = ''; + private $username = ''; + private $password = ''; - public $testing = false; - public $connectionTimeout = 1000; + public $testing = false; + public $connectionTimeout = 1000; - public $functionsClient; - public $accountClient; - public $queryClient; + public $functionsClient; + public $accountClient; + public $queryClient; - public $userAgent = 'MyAdmin GlobalSign Plugin'; - public $traceConnections = 1; + public $userAgent = 'MyAdmin GlobalSign Plugin'; + public $traceConnections = 1; - public $extra; + public $extra; - /** - * GlobalSign::GlobalSign() - * - * @param string $username the API username - * @param string $password the API password - * @param bool $testing optional (defaults to false) testing - */ - public function __construct($username, $password, $testing = false) - { - //myadmin_log('ssl', 'info', "__construct({$username}, {$password})", __LINE__, __FILE__); - $this->username = $username; - $this->password = $password; - $this->testing = $testing; - $soapOptions = [ - 'user_agent' => $this->userAgent, - 'connection_timeout' => $this->connectionTimeout, - 'trace' => $this->traceConnections, - 'cache_wsdl' => WSDL_CACHE_BOTH - ]; - $this->functionsClient = new \SoapClient($this->testing != true ? $this->functionsWsdl : $this->testFunctionsWsdl, $soapOptions); - $this->accountClient = new \SoapClient($this->testing != true ? $this->accountWsdl : $this->testAccountWsdl, $soapOptions); - $this->queryClient = new \SoapClient($this->testing != true ? $this->queryWsdl : $this->testQueryWsdl, $soapOptions); - } - - public function queryCall($function, $params) - { - return $this->soapCall($this->queryClient, $function, $params); - } - - public function functionsCall($function, $params) - { - return $this->soapCall($this->functionsClient, $function, $params); - } - - public function accountCall($function, $params) - { - return $this->soapCall($this->accountClient, $function, $params); - } - - public function soapCall(&$client, $function, $params) - { - \StatisticClient::tick('GlobalSign', $function); - try { - myadmin_log('ssl', 'info', $function, __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($params), __LINE__, __FILE__); - $response = $client->__soapCall($function, $params); - \StatisticClient::report('GlobalSign', $function, true, 0, '', STATISTICS_SERVER); - } catch (SoapFault $exception) { - \StatisticClient::report('GlobalSign', $function, false, $e->getCode(), $e->getMessage(), STATISTICS_SERVER); - } - return $response; - } + /** + * GlobalSign::GlobalSign() + * + * @param string $username the API username + * @param string $password the API password + * @param bool $testing optional (defaults to false) testing + */ + public function __construct($username, $password, $testing = false) + { + //myadmin_log('ssl', 'info', "__construct({$username}, {$password})", __LINE__, __FILE__); + $this->username = $username; + $this->password = $password; + $this->testing = $testing; + $soapOptions = [ + 'user_agent' => $this->userAgent, + 'connection_timeout' => $this->connectionTimeout, + 'trace' => $this->traceConnections, + 'cache_wsdl' => WSDL_CACHE_BOTH + ]; + $this->functionsClient = new \SoapClient($this->testing != true ? $this->functionsWsdl : $this->testFunctionsWsdl, $soapOptions); + $this->accountClient = new \SoapClient($this->testing != true ? $this->accountWsdl : $this->testAccountWsdl, $soapOptions); + $this->queryClient = new \SoapClient($this->testing != true ? $this->queryWsdl : $this->testQueryWsdl, $soapOptions); + } - /** - * Searching order information by Order ID - * - * @param string $orderId - * @return array - */ - public function GetOrderByOrderID($orderId) - { - $params = [ - 'GetOrderByOrderID' => [ - 'Request' => [ - 'QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], - 'OrderID' => $orderId, - 'OrderQueryOption' => [ - 'ReturnOrderOption' => 'true', - 'ReturnCertificateInfo' => 'true', - 'ReturnFulfillment' => 'true', - 'ReturnCACerts' => 'true' - ]]]]; - $this->extra['GetOrderByOrderID_params'] = $params; - return obj2array($this->queryCall('GetOrderByOrderID', $params)); - } + public function queryCall($function, $params) + { + return $this->soapCall($this->queryClient, $function, $params); + } - /** - * GlobalSign::GetOrderByDateRange() - * - * @param string $fromdate optional from date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format - * @param string $todate optional to date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format - * @return mixed - */ - public function GetOrderByDateRange($fromdate, $todate) - { - $params = [ - 'GetOrderByDateRange' => [ - 'Request' => [ - 'QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], - 'FromDate' => $fromdate, - 'ToDate' => $todate - ]]]; - $this->extra['GetOrderByDateRange_params'] = $params; - return $this->queryCall('GetOrderByDateRange', $params); - } + public function functionsCall($function, $params) + { + return $this->soapCall($this->functionsClient, $function, $params); + } - /** - * return a list of orders based on criteria provided. - * sample date might be 2017-10-08T04:54:12.000-05:00 - * to access response its something like: - * $response->Response->SearchOrderDetails->SearchOrderDetail[0]->OrderID - * - * @param string $fromdate optional from date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format - * @param string $todate optional to date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format - * @param string $fqdn optional domain name to check/lookup - * @param string $status optional status to check, status can be 1: INITIAL, 2: Waiting for phishing check, 3: Cancelled - Not Issued, 4: Issue completed, 5: Cancelled - Issued, 6: Waiting for revocation, 7: Revoked - * @return mixed - */ - public function GetCertificateOrders($fromdate = '', $todate = '', $fqdn = '', $status = '') - { - $params = [ - 'GetCertificateOrders' => [ - 'Request' => [ - 'QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], - ]]]; - if ($fromdate != '') { - $params['GetCertificateOrders']['Request']['FromDate'] = $fromdate; - } - if ($todate != '') { - $params['GetCertificateOrders']['Request']['ToDate'] = $todate; - } - if ($fqdn != '') { - $params['GetCertificateOrders']['Request']['FQDN'] = $fqdn; - } - if ($status != '') { - $params['GetCertificateOrders']['Request']['OrderStatus'] = $status; - } - $this->extra['GetCertificateOrders'] = $params; - return $this->queryCall('GetCertificateOrders', $params); - } + public function accountCall($function, $params) + { + return $this->soapCall($this->accountClient, $function, $params); + } - /** - * Checking order parameter validity - * - * @param string $product - * @param string $fqdn - * @param string $csr - * @param bool $wildcard - * @return mixed - */ - public function ValidateOrderParameters($product, $fqdn, $csr = '', $wildcard = false) - { - // 1.1 Extracting Common Name from the CSR and carrying out a Phishing DB Check - $OrderType = 'new'; - $params = [ - 'ValidateOrderParameters' => [ - 'Request' => [ - 'OrderRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], - 'OrderRequestParameter' => [ - 'ProductCode' => $product, - 'OrderKind' => $OrderType, - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'] - ], - 'FQDN' => $fqdn - ]]]; - if ($wildcard === true) { - $params['ValidateOrderParameters']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; - } - if ($csr != '') { - $params['ValidateOrderParameters']['Request']['OrderRequestParameter']['CSR'] = $csr; - unset($params['ValidateOrderParameters']['Request']['FQDN']); - } - $this->extra['ValidateOrderParameters_params'] = $params; - $res = $this->queryCall('ValidateOrderParameters', $params); - return $res; - } + public function soapCall(&$client, $function, $params) + { + \StatisticClient::tick('GlobalSign', $function); + try { + myadmin_log('ssl', 'info', $function, __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($params), __LINE__, __FILE__); + $response = $client->__soapCall($function, $params); + \StatisticClient::report('GlobalSign', $function, true, 0, '', STATISTICS_SERVER); + } catch (SoapFault $exception) { + \StatisticClient::report('GlobalSign', $function, false, $e->getCode(), $e->getMessage(), STATISTICS_SERVER); + } + return $response; + } - /** - * Getting list of approver email addresses and OrderID for DVOrder (DomainSSL and AlphaSSL only) - * - * @param string $fqdn - * @return mixed - */ - public function GetDVApproverList($fqdn) - { - // 1.1 Receive List of Approver email addresses - $params = ['GetDVApproverList' => ['Request' => ['QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], 'FQDN' => $fqdn]]]; - $this->extra['GetDVApproverList_params'] = $params; - myadmin_log('ssl', 'info', 'Calling GetDVApproverList', __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($params), __LINE__, __FILE__); - return $this->functionsCall('GetDVApproverList', $params); - } + /** + * Searching order information by Order ID + * + * @param string $orderId + * @return array + */ + public function GetOrderByOrderID($orderId) + { + $params = [ + 'GetOrderByOrderID' => [ + 'Request' => [ + 'QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], + 'OrderID' => $orderId, + 'OrderQueryOption' => [ + 'ReturnOrderOption' => 'true', + 'ReturnCertificateInfo' => 'true', + 'ReturnFulfillment' => 'true', + 'ReturnCACerts' => 'true' + ]]]]; + $this->extra['GetOrderByOrderID_params'] = $params; + return obj2array($this->queryCall('GetOrderByOrderID', $params)); + } - /** - * GlobalSign::renewValidateOrderParameters() - * - * @param string $product - * @param string $fqdn - * @param string $csr - * @param bool $wildcard - * @param bool $orderId - * @return mixed - */ - public function renewValidateOrderParameters($product, $fqdn, $csr = '', $wildcard = false, $orderId = false) - { - // 1.1 Extracting Common Name from the CSR and carrying out a Phishing DB Check - if ($wildcard === true) { - $wild_card_str = 'wildcard'; - } else { - $wild_card_str = ''; - } - $params = [ - 'ValidateOrderParameters' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ]], - 'OrderRequestParameter' => [ - 'ProductCode' => $product, - 'OrderKind' => 'renewal', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - //'BaseOption' => $wild_card_str, - 'CSR' => $csr, - 'RenewalTargetOrderID' => $orderId, - 'RenewaltargetOrderID' => $orderId, - ], - 'FQDN' => $fqdn - ]]]; - //if ($csr != '') - //unset($params['ValidateOrderParameters']['Request']['FQDN']); - $this->extra['ValidateOrderParameters_params'] = $params; - myadmin_log('ssl', 'info', 'Params: '.json_encode($params), __LINE__, __FILE__); - $res = $this->queryCall('ValidateOrderParameters', $params); - return $res; - } + /** + * GlobalSign::GetOrderByDateRange() + * + * @param string $fromdate optional from date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format + * @param string $todate optional to date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format + * @return mixed + */ + public function GetOrderByDateRange($fromdate, $todate) + { + $params = [ + 'GetOrderByDateRange' => [ + 'Request' => [ + 'QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], + 'FromDate' => $fromdate, + 'ToDate' => $todate + ]]]; + $this->extra['GetOrderByDateRange_params'] = $params; + return $this->queryCall('GetOrderByDateRange', $params); + } - /** - * Resend Approver Emails for AlphaSSL & DomainSSL orders - * - * @param string $orderID - * @return mixed - */ - public function ResendEmail($orderID) - { - myadmin_log('ssl', 'info', "In function : ResendEmail($orderID)", __LINE__, __FILE__); - $params = ['ResendEmail' => ['Request' => ['OrderRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], 'OrderID' => $orderID, 'ResendEmailType' =>'APPROVEREMAIL']]]; - myadmin_log('ssl', 'info', 'Params: '.json_encode($params), __LINE__, __FILE__); - return $this->functionsCall('ResendEmail', $params); - } + /** + * return a list of orders based on criteria provided. + * sample date might be 2017-10-08T04:54:12.000-05:00 + * to access response its something like: + * $response->Response->SearchOrderDetails->SearchOrderDetail[0]->OrderID + * + * @param string $fromdate optional from date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format + * @param string $todate optional to date for lookup in YYYY-MM-DDTHH:MM:SS.000Z format + * @param string $fqdn optional domain name to check/lookup + * @param string $status optional status to check, status can be 1: INITIAL, 2: Waiting for phishing check, 3: Cancelled - Not Issued, 4: Issue completed, 5: Cancelled - Issued, 6: Waiting for revocation, 7: Revoked + * @return mixed + */ + public function GetCertificateOrders($fromdate = '', $todate = '', $fqdn = '', $status = '') + { + $params = [ + 'GetCertificateOrders' => [ + 'Request' => [ + 'QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], + ]]]; + if ($fromdate != '') { + $params['GetCertificateOrders']['Request']['FromDate'] = $fromdate; + } + if ($todate != '') { + $params['GetCertificateOrders']['Request']['ToDate'] = $todate; + } + if ($fqdn != '') { + $params['GetCertificateOrders']['Request']['FQDN'] = $fqdn; + } + if ($status != '') { + $params['GetCertificateOrders']['Request']['OrderStatus'] = $status; + } + $this->extra['GetCertificateOrders'] = $params; + return $this->queryCall('GetCertificateOrders', $params); + } - /** - * Change the email address that the approval request is sent to for domain validated products - * - * @param string $orderID - * @param string $approverEmail - * @param string $fqdn - * @return string - * @internal param mixed $fdqn - */ - public function ChangeApproverEmail($orderID, $approverEmail, $fqdn) - { - $params = [ - 'ChangeApproverEmail' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderID' => $orderID, - 'ApproverEmail'=>$approverEmail, - 'FQDN'=>$fqdn - ]]]; - return $this->functionsCall('ChangeApproverEmail', $params); - } + /** + * Checking order parameter validity + * + * @param string $product + * @param string $fqdn + * @param string $csr + * @param bool $wildcard + * @return mixed + */ + public function ValidateOrderParameters($product, $fqdn, $csr = '', $wildcard = false) + { + // 1.1 Extracting Common Name from the CSR and carrying out a Phishing DB Check + $OrderType = 'new'; + $params = [ + 'ValidateOrderParameters' => [ + 'Request' => [ + 'OrderRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], + 'OrderRequestParameter' => [ + 'ProductCode' => $product, + 'OrderKind' => $OrderType, + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'] + ], + 'FQDN' => $fqdn + ]]]; + if ($wildcard === true) { + $params['ValidateOrderParameters']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; + } + if ($csr != '') { + $params['ValidateOrderParameters']['Request']['OrderRequestParameter']['CSR'] = $csr; + unset($params['ValidateOrderParameters']['Request']['FQDN']); + } + $this->extra['ValidateOrderParameters_params'] = $params; + $res = $this->queryCall('ValidateOrderParameters', $params); + return $res; + } - /** - * Certificate ReIssue - * - * @param string $orderID - * @param string $csr - * @return mixed - */ - public function ReIssue($orderID, $csr) - { - $params = ['ReIssue' => ['Request' => ['OrderRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], 'OrderParameter' => ['CSR' => $csr], 'TargetOrderID' => $orderID, 'HashAlgorithm' =>'SHA256']]]; - return $this->queryCall('ReIssue', $params); - } + /** + * Getting list of approver email addresses and OrderID for DVOrder (DomainSSL and AlphaSSL only) + * + * @param string $fqdn + * @return mixed + */ + public function GetDVApproverList($fqdn) + { + // 1.1 Receive List of Approver email addresses + $params = ['GetDVApproverList' => ['Request' => ['QueryRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], 'FQDN' => $fqdn]]]; + $this->extra['GetDVApproverList_params'] = $params; + myadmin_log('ssl', 'info', 'Calling GetDVApproverList', __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($params), __LINE__, __FILE__); + return $this->functionsCall('GetDVApproverList', $params); + } - /** - * Order AlphaSSL or DomainSSL Certificate with Approver Email validation - * - * @param string $product - * @param string $orderId - * @param string $approverEmail - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param bool $wildcard - * @return mixed - */ - public function DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard = false) - { + /** + * GlobalSign::renewValidateOrderParameters() + * + * @param string $product + * @param string $fqdn + * @param string $csr + * @param bool $wildcard + * @param bool $orderId + * @return mixed + */ + public function renewValidateOrderParameters($product, $fqdn, $csr = '', $wildcard = false, $orderId = false) + { + // 1.1 Extracting Common Name from the CSR and carrying out a Phishing DB Check + if ($wildcard === true) { + $wild_card_str = 'wildcard'; + } else { + $wild_card_str = ''; + } + $params = [ + 'ValidateOrderParameters' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ]], + 'OrderRequestParameter' => [ + 'ProductCode' => $product, + 'OrderKind' => 'renewal', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + //'BaseOption' => $wild_card_str, + 'CSR' => $csr, + 'RenewalTargetOrderID' => $orderId, + 'RenewaltargetOrderID' => $orderId, + ], + 'FQDN' => $fqdn + ]]]; + //if ($csr != '') + //unset($params['ValidateOrderParameters']['Request']['FQDN']); + $this->extra['ValidateOrderParameters_params'] = $params; + myadmin_log('ssl', 'info', 'Params: '.json_encode($params), __LINE__, __FILE__); + $res = $this->queryCall('ValidateOrderParameters', $params); + return $res; + } - /* - * $Options = array( - * 'Option' => array( - * 'OptionName' => 'SAN', - * 'OptionValue' => 'true', - * ), - * ); - * $params['DVOrder']['Request']['OrderRequestParameter']['Options'] = $Options; + /** + * Resend Approver Emails for AlphaSSL & DomainSSL orders + * + * @param string $orderID + * @return mixed + */ + public function ResendEmail($orderID) + { + myadmin_log('ssl', 'info', "In function : ResendEmail($orderID)", __LINE__, __FILE__); + $params = ['ResendEmail' => ['Request' => ['OrderRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], 'OrderID' => $orderID, 'ResendEmailType' =>'APPROVEREMAIL']]]; + myadmin_log('ssl', 'info', 'Params: '.json_encode($params), __LINE__, __FILE__); + return $this->functionsCall('ResendEmail', $params); + } - * $SANEntries => array( - * 'SANEntry' => array( - * array( - * 'SANOptionType' => '1', - * 'SubjectAltName' => 'mail.test12345.com', - * ), - * array( - * 'SANOptionType' => '3', - * 'SubjectAltName' => 'tester.test12345.com', - * ), - * ), - * ); - * $params['DVOrder']['Request']['SANEntries'] = $SANEntries; - */ - $params = [ - 'DVOrder' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameter' => [ - 'ProductCode' => $product, - 'OrderKind' => 'new', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'CSR' => $csr - ], - 'OrderID' => $orderId, - 'ApproverEmail' => $approverEmail, - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ]]]]; - if ($wildcard === true) { - $params['DVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; - } - $this->extra['DVOrder_params'] = $params; - // ini_set("max_input_time", -1); - // ini_set("max_execution_time", -1); - ini_set('max_execution_time', 1000); // just put a lot of time - ini_set('default_socket_timeout', 1000); // same - $res = $this->functionsCall('DVOrder', $params); - return $res; - } + /** + * Change the email address that the approval request is sent to for domain validated products + * + * @param string $orderID + * @param string $approverEmail + * @param string $fqdn + * @return string + * @internal param mixed $fdqn + */ + public function ChangeApproverEmail($orderID, $approverEmail, $fqdn) + { + $params = [ + 'ChangeApproverEmail' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderID' => $orderID, + 'ApproverEmail'=>$approverEmail, + 'FQDN'=>$fqdn + ]]]; + return $this->functionsCall('ChangeApproverEmail', $params); + } - /** - * GlobalSign::DVOrderWithoutCSR() - * - * @param string $fqdn - * @param string $orderId - * @param string $approverEmail - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param bool $wildcard - * @return mixed - */ - public function DVOrderWithoutCSR($fqdn, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $wildcard = false) - { - $params = [ - 'DVOrderWithoutCSR' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameterWithoutCSR' => [ - 'ProductCode' => 'DV_SKIP_SHA2', - 'OrderKind' => 'new', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'PIN' => '', - 'KeyLength' => '', - 'Options' => [ - 'Option' => [ - 'OptionName' => 'SAN', - 'OptionValue' => 'true' - ] - ] - ], - 'OrderID' => $orderId, - 'FQDN' => $fqdn, - 'DVCSRInfo' => ['Country' => 'US'], - 'ApproverEmail' => $approverEmail, - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ], - 'SANEntries' => [ - 'SANEntry' => [ - [ - 'SANOptionType' => '1', - 'SubjectAltName' => 'mail.test12345.com' - ], - [ - 'SANOptionType' => '3', - 'SubjectAltName' => 'tester.test12345.com' - ]]]]]]; - if ($wildcard === true) { - $params['DVOrderWithoutCSR']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; - } - $this->extra['DVOrderWithoutCSR_params'] = $params; - return $this->functionsCall('DVOrderWithoutCSR', $params); - } + /** + * Certificate ReIssue + * + * @param string $orderID + * @param string $csr + * @return mixed + */ + public function ReIssue($orderID, $csr) + { + $params = ['ReIssue' => ['Request' => ['OrderRequestHeader' => ['AuthToken' => ['UserName' => $this->username, 'Password' => $this->password]], 'OrderParameter' => ['CSR' => $csr], 'TargetOrderID' => $orderID, 'HashAlgorithm' =>'SHA256']]]; + return $this->queryCall('ReIssue', $params); + } - /** - * Order OrganizationSSL Certificate - * - * @param string $fqdn - * @param string $csr - * @param string $orderId - * @param string $approverEmail - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param bool $wildcard - * @return mixed - */ - public function OVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard = false) - { - $params = [ - 'OVOrder' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameter' => [ - 'ProductCode' => 'OV_SHA2', - 'OrderKind' => 'new', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'CSR' => $csr, - /* - * 'Options' => array( - * 'Option' => array( - * 'OptionName' => 'SAN', - * 'OptionValue' => 'true', - * ), - * ), - */ - ], - 'OrderID' => $orderId, - 'ApproverEmail' => $approverEmail, - 'SubID' => null, - 'OrganizationInfo' => [ - 'OrganizationName' => $company, 'OrganizationAddress' => [ - 'AddressLine1' => $address, - 'City' => $city, - 'Region' => $state, - 'PostalCode' => $zip, - 'Country' => 'US', - 'Phone' => $phone - ] - ], - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ], - /* - * 'SANEntries' => array( - * 'SANEntry' => array( - * array( - * 'SANOptionType' => '1', - * 'SubjectAltName' => 'mail.test12345.com', - * ), - * array( - * 'SANOptionType' => '3', - * 'SubjectAltName' => 'tester.test12345.com', - * ), - * ), - * ), - */ - ]]]; - if ($wildcard === true) { - $params['OVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; - } - $this->extra['OVOrder_params'] = $params; - $res = $this->functionsCall('OVOrder', $params); - return $res; - } + /** + * Order AlphaSSL or DomainSSL Certificate with Approver Email validation + * + * @param string $product + * @param string $orderId + * @param string $approverEmail + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param bool $wildcard + * @return mixed + */ + public function DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard = false) + { - /** - * GlobalSign::OVOrderWithoutCSR() - * - * @param string $fqdn - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param bool $wildcard - * @return mixed - */ - public function OVOrderWithoutCSR($fqdn, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard = false) - { - $params = [ - 'OVOrderWithoutCSR' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameterWithoutCSR' => [ - 'ProductCode' => 'OV_SKIP_SHA2', - 'OrderKind' => 'new', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'PIN' => '', - 'KeyLength' => '', - 'Options' => [ - 'Option' => [ - 'OptionName' => 'SAN', - 'OptionValue' => 'true' - ] - ] - ], - 'OrganizationInfo' => [ - 'OrganizationName' => $company, 'OrganizationAddress' => [ - 'AddressLine1' => $address, - 'City' => $city, - 'Region' => $state, - 'PostalCode' => $zip, - 'Country' => 'US', - 'Phone' => $phone - ] - ], - 'FQDN' => $fqdn, - 'OVCSRInfo' => [ - 'OrganizationName' => $company, - 'Locality' => $city, - 'StateOrProvince' => $state, - 'Country' => 'US' - ], - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ], - 'SANEntries' => [ - 'SANEntry' => [ - [ - 'SANOptionType' => '1', - 'SubjectAltName' => 'mail.test12345.com' - ], - [ - 'SANOptionType' => '3', - 'SubjectAltName' => 'tester.test12345.com' - ]]]]]]; - if ($wildcard === true) { - $params['OVOrderWithoutCSR']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; - } - $this->extra['OVOrderWithoutCSR_params'] = $params; - $res = $this->functionsCall('OVOrderWithoutCSR', $params); - return $res; - } + /* + * $Options = array( + * 'Option' => array( + * 'OptionName' => 'SAN', + * 'OptionValue' => 'true', + * ), + * ); + * $params['DVOrder']['Request']['OrderRequestParameter']['Options'] = $Options; - /** - * Order ExtendedSSL Certificate - * - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param string $businessCategory PO, GE, or BE for Private Organization, Government Entity, or Business Entity - * @param string $agency - * @return mixed - */ - public function EVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency) - { - $params = [ - 'EVOrder' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameter' => [ - 'ProductCode' => 'EV_SHA2', - 'OrderKind' => 'new', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'CSR' => $csr, - /* - * 'Options' => array( - * 'Option' => array( - * 'OptionName' => 'SAN', - * 'OptionValue' => 'true', - * ), - * ), - */ - ], - 'OrganizationInfoEV' => [ - 'BusinessCategoryCode' => $businessCategory, - 'OrganizationAddress' => [ - 'AddressLine1' => $address, - 'City' => $city, - 'Region' => $state, - 'PostalCode' => $zip, - 'Country' => 'US', - 'Phone' => $phone - ] - ], - 'RequestorInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email, - 'OrganizationName' => $company - ], - 'ApproverInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email, - 'OrganizationName' => $company - ], - 'AuthorizedSignerInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ], - 'JurisdictionInfo' => [ - 'Country' => 'US', - 'StateOrProvince' => $state, - 'Locality' => $city, - 'IncorporatingAgencyRegistrationNumber' => $agency - ], - 'OrganizationInfo' => [ - 'OrganizationName' => $company, - 'OrganizationAddress' => [ - 'AddressLine1' => $address, - 'City' => $city, - 'Region' => $state, - 'PostalCode' => $zip, - 'Country' => 'US', - 'Phone' => $phone - ] - ], - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ], - /* - * 'SANEntries' => array( - * 'SANEntry' => array( - * array( - * 'SANOptionType' => '1', - * 'SubjectAltName' => 'mail.test12345.com', - * ), - * array( - * 'SANOptionType' => '3', - * 'SubjectAltName' => 'tester.test12345.com', - * ), - * ), - * ), - */ - ]]]; - $this->extra['EVOrder_params'] = $params; - $res = $this->functionsCall('EVOrder', $params); - return $res; - } + * $SANEntries => array( + * 'SANEntry' => array( + * array( + * 'SANOptionType' => '1', + * 'SubjectAltName' => 'mail.test12345.com', + * ), + * array( + * 'SANOptionType' => '3', + * 'SubjectAltName' => 'tester.test12345.com', + * ), + * ), + * ); + * $params['DVOrder']['Request']['SANEntries'] = $SANEntries; + */ + $params = [ + 'DVOrder' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameter' => [ + 'ProductCode' => $product, + 'OrderKind' => 'new', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'CSR' => $csr + ], + 'OrderID' => $orderId, + 'ApproverEmail' => $approverEmail, + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ]]]]; + if ($wildcard === true) { + $params['DVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; + } + $this->extra['DVOrder_params'] = $params; + // ini_set("max_input_time", -1); + // ini_set("max_execution_time", -1); + ini_set('max_execution_time', 1000); // just put a lot of time + ini_set('default_socket_timeout', 1000); // same + $res = $this->functionsCall('DVOrder', $params); + return $res; + } - /** - * GlobalSign::create_alphassl() - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $approverEmail - * @param bool $wildcard - * @return array - */ - public function create_alphassl($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false) - { - $product = 'DV_LOW_SHA2'; - $res = $this->ValidateOrderParameters($product, $fqdn, $csr, $wildcard); - $this->extra = []; - $this->extra['laststep'] = 'ValidateOrderParameters'; - $this->extra['ValidateOrderParameters'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - $this->extra['error'] = 'Error In order'; - } - $this->__construct($this->username, $this->password); - $res = $this->GetDVApproverList($fqdn); - $this->extra['laststep'] = 'GetDVApproverList'; - $this->extra['GetDVApproverList'] = obj2array($res); - if ($res->Response->QueryResponseHeader->SuccessCode != 0) { - $this->extra['error'] = 'Error In order'; - // return $this->extra; - $subject = 'GlobalSign SSL Error While Getting ApproverList for Registering '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - return false; - } - $orderId = $res->Response->OrderID; - $this->extra['order_id'] = $orderId; - if ($approverEmail == '') { - $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; - } - myadmin_log('ssl', 'info', "DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard)", __LINE__, __FILE__); - $this->__construct($this->username, $this->password); - $res = $this->DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard); - myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); - $this->extra['laststep'] = 'DVOrder'; - $this->extra['DVOrder'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - } else { - $subject = 'GlobalSign SSL Error While Registering '.$fqdn; - } - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - return false; - } else { - $this->extra['finished'] = 1; - dialog('Order Completed', 'Your SSL Certificate order has been successfully processed.'); - } - return $this->extra; - } + /** + * GlobalSign::DVOrderWithoutCSR() + * + * @param string $fqdn + * @param string $orderId + * @param string $approverEmail + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param bool $wildcard + * @return mixed + */ + public function DVOrderWithoutCSR($fqdn, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $wildcard = false) + { + $params = [ + 'DVOrderWithoutCSR' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameterWithoutCSR' => [ + 'ProductCode' => 'DV_SKIP_SHA2', + 'OrderKind' => 'new', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'PIN' => '', + 'KeyLength' => '', + 'Options' => [ + 'Option' => [ + 'OptionName' => 'SAN', + 'OptionValue' => 'true' + ] + ] + ], + 'OrderID' => $orderId, + 'FQDN' => $fqdn, + 'DVCSRInfo' => ['Country' => 'US'], + 'ApproverEmail' => $approverEmail, + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ], + 'SANEntries' => [ + 'SANEntry' => [ + [ + 'SANOptionType' => '1', + 'SubjectAltName' => 'mail.test12345.com' + ], + [ + 'SANOptionType' => '3', + 'SubjectAltName' => 'tester.test12345.com' + ]]]]]]; + if ($wildcard === true) { + $params['DVOrderWithoutCSR']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; + } + $this->extra['DVOrderWithoutCSR_params'] = $params; + return $this->functionsCall('DVOrderWithoutCSR', $params); + } - /** - * GlobalSign::create_domainssl() - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $approverEmail - * @param bool $wildcard - * @return array|bool - */ - public function create_domainssl($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false) - { - $product = 'DV_SHA2'; - $res = $this->ValidateOrderParameters($product, $fqdn, $csr, $wildcard); - myadmin_log('ssl', 'info', "ValidateOrderParameters($product, $fqdn, [CSR], $wildcard) returned: ".json_encode($res), __LINE__, __FILE__); - $this->extra = []; - $this->extra['laststep'] = 'ValidateOrderParameters'; - $this->extra['ValidateOrderParameters'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - $subject = 'GlobalSign SSL Error while validating order '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } - $this->__construct($this->username, $this->password); - $res = $this->GetDVApproverList($fqdn); - myadmin_log('ssl', 'info', "GetDVApproverList($fqdn) returned: ".json_encode($res), __LINE__, __FILE__); - $this->extra['laststep'] = 'GetDVApproverList'; - $this->extra['GetDVApproverList'] = obj2array($res); - if ($res->Response->QueryResponseHeader->SuccessCode != 0) { - $subject = 'GlobalSign SSL Error while processing order '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } - $orderId = $res->Response->OrderID; - $this->extra['order_id'] = $orderId; - if ($approverEmail == '') { - $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; - } - $this->__construct($this->username, $this->password); - $res = $this->DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard); - myadmin_log('ssl', 'info', "DVOrder($product, $orderId, $approverEmail, $fqdn, [CSR], $firstname, $lastname, $phone, $email, $wildcard) returned: ".json_encode($res), __LINE__, __FILE__); - $this->extra['laststep'] = 'DVOrder'; - $this->extra['DVOrder'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - } else { - $subject = 'GlobalSign SSL Error While Registering '.$fqdn; - } - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } else { - $this->extra['finished'] = 1; - dialog('Order Completed', 'Your SSL Certificate order has been successfully processed.'); - } - return $this->extra; - } + /** + * Order OrganizationSSL Certificate + * + * @param string $fqdn + * @param string $csr + * @param string $orderId + * @param string $approverEmail + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param bool $wildcard + * @return mixed + */ + public function OVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard = false) + { + $params = [ + 'OVOrder' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameter' => [ + 'ProductCode' => 'OV_SHA2', + 'OrderKind' => 'new', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'CSR' => $csr, + /* + * 'Options' => array( + * 'Option' => array( + * 'OptionName' => 'SAN', + * 'OptionValue' => 'true', + * ), + * ), + */ + ], + 'OrderID' => $orderId, + 'ApproverEmail' => $approverEmail, + 'SubID' => null, + 'OrganizationInfo' => [ + 'OrganizationName' => $company, 'OrganizationAddress' => [ + 'AddressLine1' => $address, + 'City' => $city, + 'Region' => $state, + 'PostalCode' => $zip, + 'Country' => 'US', + 'Phone' => $phone + ] + ], + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ], + /* + * 'SANEntries' => array( + * 'SANEntry' => array( + * array( + * 'SANOptionType' => '1', + * 'SubjectAltName' => 'mail.test12345.com', + * ), + * array( + * 'SANOptionType' => '3', + * 'SubjectAltName' => 'tester.test12345.com', + * ), + * ), + * ), + */ + ]]]; + if ($wildcard === true) { + $params['OVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; + } + $this->extra['OVOrder_params'] = $params; + $res = $this->functionsCall('OVOrder', $params); + return $res; + } - /** - * GlobalSign::create_domainssl_autocsr() - * @param string $fqdn - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $approverEmail - * @param bool $wildcard - * @return bool - */ - public function create_domainssl_autocsr($fqdn, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false) - { - $res = $this->GetDVApproverList($fqdn); - if ($res->Response->QueryResponseHeader->SuccessCode != 0) { - $subject = 'GlobalSign SSL Error processing Registering '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - return false; - } - $orderId = $res->Response->OrderID; - if ($approverEmail == '') { - $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; - } + /** + * GlobalSign::OVOrderWithoutCSR() + * + * @param string $fqdn + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param bool $wildcard + * @return mixed + */ + public function OVOrderWithoutCSR($fqdn, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard = false) + { + $params = [ + 'OVOrderWithoutCSR' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameterWithoutCSR' => [ + 'ProductCode' => 'OV_SKIP_SHA2', + 'OrderKind' => 'new', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'PIN' => '', + 'KeyLength' => '', + 'Options' => [ + 'Option' => [ + 'OptionName' => 'SAN', + 'OptionValue' => 'true' + ] + ] + ], + 'OrganizationInfo' => [ + 'OrganizationName' => $company, 'OrganizationAddress' => [ + 'AddressLine1' => $address, + 'City' => $city, + 'Region' => $state, + 'PostalCode' => $zip, + 'Country' => 'US', + 'Phone' => $phone + ] + ], + 'FQDN' => $fqdn, + 'OVCSRInfo' => [ + 'OrganizationName' => $company, + 'Locality' => $city, + 'StateOrProvince' => $state, + 'Country' => 'US' + ], + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ], + 'SANEntries' => [ + 'SANEntry' => [ + [ + 'SANOptionType' => '1', + 'SubjectAltName' => 'mail.test12345.com' + ], + [ + 'SANOptionType' => '3', + 'SubjectAltName' => 'tester.test12345.com' + ]]]]]]; + if ($wildcard === true) { + $params['OVOrderWithoutCSR']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; + } + $this->extra['OVOrderWithoutCSR_params'] = $params; + $res = $this->functionsCall('OVOrderWithoutCSR', $params); + return $res; + } - $this->__construct($this->username, $this->password); - $res = $this->DVOrderWithoutCSR($fqdn, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $wildcard); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - } else { - $subject = 'GlobalSign SSL Error While Registering '.$fqdn; - } - myadmin_log('ssl', 'info', 'create_domainssl_autocsrf returned: '.json_encode($res), __LINE__, __FILE__); - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - return false; - } else { - echo 'Your Order Has Been Completed'; - } - return $orderId; - } + /** + * Order ExtendedSSL Certificate + * + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param string $businessCategory PO, GE, or BE for Private Organization, Government Entity, or Business Entity + * @param string $agency + * @return mixed + */ + public function EVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency) + { + $params = [ + 'EVOrder' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameter' => [ + 'ProductCode' => 'EV_SHA2', + 'OrderKind' => 'new', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'CSR' => $csr, + /* + * 'Options' => array( + * 'Option' => array( + * 'OptionName' => 'SAN', + * 'OptionValue' => 'true', + * ), + * ), + */ + ], + 'OrganizationInfoEV' => [ + 'BusinessCategoryCode' => $businessCategory, + 'OrganizationAddress' => [ + 'AddressLine1' => $address, + 'City' => $city, + 'Region' => $state, + 'PostalCode' => $zip, + 'Country' => 'US', + 'Phone' => $phone + ] + ], + 'RequestorInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email, + 'OrganizationName' => $company + ], + 'ApproverInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email, + 'OrganizationName' => $company + ], + 'AuthorizedSignerInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ], + 'JurisdictionInfo' => [ + 'Country' => 'US', + 'StateOrProvince' => $state, + 'Locality' => $city, + 'IncorporatingAgencyRegistrationNumber' => $agency + ], + 'OrganizationInfo' => [ + 'OrganizationName' => $company, + 'OrganizationAddress' => [ + 'AddressLine1' => $address, + 'City' => $city, + 'Region' => $state, + 'PostalCode' => $zip, + 'Country' => 'US', + 'Phone' => $phone + ] + ], + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ], + /* + * 'SANEntries' => array( + * 'SANEntry' => array( + * array( + * 'SANOptionType' => '1', + * 'SubjectAltName' => 'mail.test12345.com', + * ), + * array( + * 'SANOptionType' => '3', + * 'SubjectAltName' => 'tester.test12345.com', + * ), + * ), + * ), + */ + ]]]; + $this->extra['EVOrder_params'] = $params; + $res = $this->functionsCall('EVOrder', $params); + return $res; + } - /** - * GlobalSign::create_organizationssl() - * - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param string $approverEmail - * @param bool $wildcard - * @return array|bool - */ - public function create_organizationssl($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $approverEmail, $wildcard = false) - { - $res = $this->ValidateOrderParameters('OV_SHA2', $fqdn, $csr, $wildcard); - myadmin_log('ssl', 'info', 'ValidateOrderParameters returned '.json_encode($res), __LINE__, __FILE__); - $this->extra = []; - $this->extra['laststep'] = 'ValidateOrderParameters'; - $this->extra['ValidateOrderParameters'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - myadmin_log('ssl', 'info', 'create_organizationssl returned: '.json_encode($res), __LINE__, __FILE__); - $subject = 'GlobalSign SSL Error While processing order '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - return false; - } - $orderId = $res->Response->OrderID; - $this->__construct($this->username, $this->password); - $res = $this->OVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard); - $this->extra['laststep'] = 'OVOrder'; - $this->extra['OVOrder'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - } else { - $subject = 'GlobalSign SSL Error While Registering '.$fqdn; - } - myadmin_log('ssl', 'info', 'create_organizationssl returned: '.json_encode($res), __LINE__, __FILE__); - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - return false; - } else { - $this->extra['finished'] = 1; - echo 'Your Order Has Been Completed'; - myadmin_log('ssl', 'info', 'SSL Renew Order Success - create_organizationssl', __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); - } - $this->extra['order_id'] = $orderId; - return $this->extra; - } + /** + * GlobalSign::create_alphassl() + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $approverEmail + * @param bool $wildcard + * @return array + */ + public function create_alphassl($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false) + { + $product = 'DV_LOW_SHA2'; + $res = $this->ValidateOrderParameters($product, $fqdn, $csr, $wildcard); + $this->extra = []; + $this->extra['laststep'] = 'ValidateOrderParameters'; + $this->extra['ValidateOrderParameters'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + $this->extra['error'] = 'Error In order'; + } + $this->__construct($this->username, $this->password); + $res = $this->GetDVApproverList($fqdn); + $this->extra['laststep'] = 'GetDVApproverList'; + $this->extra['GetDVApproverList'] = obj2array($res); + if ($res->Response->QueryResponseHeader->SuccessCode != 0) { + $this->extra['error'] = 'Error In order'; + // return $this->extra; + $subject = 'GlobalSign SSL Error While Getting ApproverList for Registering '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + return false; + } + $orderId = $res->Response->OrderID; + $this->extra['order_id'] = $orderId; + if ($approverEmail == '') { + $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; + } + myadmin_log('ssl', 'info', "DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard)", __LINE__, __FILE__); + $this->__construct($this->username, $this->password); + $res = $this->DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard); + myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); + $this->extra['laststep'] = 'DVOrder'; + $this->extra['DVOrder'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + } else { + $subject = 'GlobalSign SSL Error While Registering '.$fqdn; + } + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + return false; + } else { + $this->extra['finished'] = 1; + dialog('Order Completed', 'Your SSL Certificate order has been successfully processed.'); + } + return $this->extra; + } - /** - * GlobalSign::create_organizationssl_autocsr() - * - * @param string $fqdn - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param $wildcard - * @return bool - */ - public function create_organizationssl_autocsr($fqdn, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard) - { - $res = $this->OVOrderWithoutCSR($fqdn, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - } else { - $subject = 'GlobalSign SSL Error While Registering '.$fqdn; - } - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - myadmin_log('ssl', 'info', 'create_organizationalssl_autocsr returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } else { - echo 'Your Order Has Been Completed'; - } - $orderId = $res->Response->OrderID; - return $orderId; - } + /** + * GlobalSign::create_domainssl() + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $approverEmail + * @param bool $wildcard + * @return array|bool + */ + public function create_domainssl($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false) + { + $product = 'DV_SHA2'; + $res = $this->ValidateOrderParameters($product, $fqdn, $csr, $wildcard); + myadmin_log('ssl', 'info', "ValidateOrderParameters($product, $fqdn, [CSR], $wildcard) returned: ".json_encode($res), __LINE__, __FILE__); + $this->extra = []; + $this->extra['laststep'] = 'ValidateOrderParameters'; + $this->extra['ValidateOrderParameters'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + $subject = 'GlobalSign SSL Error while validating order '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } + $this->__construct($this->username, $this->password); + $res = $this->GetDVApproverList($fqdn); + myadmin_log('ssl', 'info', "GetDVApproverList($fqdn) returned: ".json_encode($res), __LINE__, __FILE__); + $this->extra['laststep'] = 'GetDVApproverList'; + $this->extra['GetDVApproverList'] = obj2array($res); + if ($res->Response->QueryResponseHeader->SuccessCode != 0) { + $subject = 'GlobalSign SSL Error while processing order '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } + $orderId = $res->Response->OrderID; + $this->extra['order_id'] = $orderId; + if ($approverEmail == '') { + $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; + } + $this->__construct($this->username, $this->password); + $res = $this->DVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard); + myadmin_log('ssl', 'info', "DVOrder($product, $orderId, $approverEmail, $fqdn, [CSR], $firstname, $lastname, $phone, $email, $wildcard) returned: ".json_encode($res), __LINE__, __FILE__); + $this->extra['laststep'] = 'DVOrder'; + $this->extra['DVOrder'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + } else { + $subject = 'GlobalSign SSL Error While Registering '.$fqdn; + } + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + myadmin_log('ssl', 'info', 'create_domainssl returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } else { + $this->extra['finished'] = 1; + dialog('Order Completed', 'Your SSL Certificate order has been successfully processed.'); + } + return $this->extra; + } - /** - * GlobalSign::create_extendedssl() - * - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param string $businessCategory - * @param string $agency - * @return array|bool - */ - public function create_extendedssl($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency) - { - $res = $this->ValidateOrderParameters('EV_SHA2', $fqdn, $csr); + /** + * GlobalSign::create_domainssl_autocsr() + * @param string $fqdn + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $approverEmail + * @param bool $wildcard + * @return bool + */ + public function create_domainssl_autocsr($fqdn, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false) + { + $res = $this->GetDVApproverList($fqdn); + if ($res->Response->QueryResponseHeader->SuccessCode != 0) { + $subject = 'GlobalSign SSL Error processing Registering '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + return false; + } + $orderId = $res->Response->OrderID; + if ($approverEmail == '') { + $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; + } - $this->extra = []; - $this->extra['laststep'] = 'ValidateOrderParameters'; - $this->extra['ValidateOrderParameters'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fdqn; - } else { - $subject = 'GlobalSign SSL Error While Registering '.$fqdn; - } - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - myadmin_log('ssl', 'info', 'create_extendedssl returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } - $this->__construct($this->username, $this->password); + $this->__construct($this->username, $this->password); + $res = $this->DVOrderWithoutCSR($fqdn, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $wildcard); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + } else { + $subject = 'GlobalSign SSL Error While Registering '.$fqdn; + } + myadmin_log('ssl', 'info', 'create_domainssl_autocsrf returned: '.json_encode($res), __LINE__, __FILE__); + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + return false; + } else { + echo 'Your Order Has Been Completed'; + } + return $orderId; + } - $res = $this->EVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency); - $orderId = $res->Response->OrderID; - $this->extra['laststep'] = 'EVOrder'; - $this->extra['EVOrder'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fdqn; - } else { - $subject = 'GlobalSign SSL Error While Registering '.$fqdn; - } - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); - myadmin_log('ssl', 'info', 'create_extendedssl returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } else { - $this->extra['finished'] = 1; - echo 'Your Order Has Been Completed'; - } - $this->extra['order_id'] = $orderId; - return $this->extra; - } + /** + * GlobalSign::create_organizationssl() + * + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param string $approverEmail + * @param bool $wildcard + * @return array|bool + */ + public function create_organizationssl($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $approverEmail, $wildcard = false) + { + $res = $this->ValidateOrderParameters('OV_SHA2', $fqdn, $csr, $wildcard); + myadmin_log('ssl', 'info', 'ValidateOrderParameters returned '.json_encode($res), __LINE__, __FILE__); + $this->extra = []; + $this->extra['laststep'] = 'ValidateOrderParameters'; + $this->extra['ValidateOrderParameters'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + myadmin_log('ssl', 'info', 'create_organizationssl returned: '.json_encode($res), __LINE__, __FILE__); + $subject = 'GlobalSign SSL Error While processing order '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + return false; + } + $orderId = $res->Response->OrderID; + $this->__construct($this->username, $this->password); + $res = $this->OVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard); + $this->extra['laststep'] = 'OVOrder'; + $this->extra['OVOrder'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + } else { + $subject = 'GlobalSign SSL Error While Registering '.$fqdn; + } + myadmin_log('ssl', 'info', 'create_organizationssl returned: '.json_encode($res), __LINE__, __FILE__); + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + return false; + } else { + $this->extra['finished'] = 1; + echo 'Your Order Has Been Completed'; + myadmin_log('ssl', 'info', 'SSL Renew Order Success - create_organizationssl', __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); + } + $this->extra['order_id'] = $orderId; + return $this->extra; + } - /** - * GlobalSIgn::renewAlphaDomain() - * - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $approverEmail - * @param bool $wildcard - * @param string $sslType - * @param string $oldOrderId - * @return array - */ - public function renewAlphaDomain($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false, $sslType, $oldOrderId) - { - myadmin_log('ssl', 'info', "renew AlphaDomain called - renewAlphaDomain($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard, $sslType, $oldOrderId)", __LINE__, __FILE__); - if ($sslType == 1) { - $product = 'DV_LOW_SHA2'; - } else { - $product = 'DV_SHA2'; - } - $res = $this->renewValidateOrderParameters($product, $fqdn, $csr, $wildcard, $oldOrderId); - myadmin_log('ssl', 'info', "renewValidateOrderParameters($product, $fqdn, $csr, $wildcard, $oldOrderId)", __LINE__, __FILE__); - $this->extra = []; - $this->extra['laststep'] = 'ValidateOrderParameters'; - $this->extra['ValidateOrderParameters'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); - } else { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); - } - myadmin_log('ssl', 'info', 'renewValidateOrderParameters returned: '.json_encode($res), __LINE__, __FILE__); - $this->extra['error'] = 'Error In order'; - return $this->extra; - } - $orderId = $res->Response->OrderID; - $this->extra['order_id'] = $orderId; - $this->__construct($this->username, $this->password); - $res = $this->GetDVApproverList($fqdn); - $this->extra['laststep'] = 'GetDVApproverList'; - $this->extra['GetDVApproverList'] = obj2array($res); - if ($res->Response->QueryResponseHeader->SuccessCode != 0) { - $this->extra['error'] = 'Error In order'; - myadmin_log('ssl', 'info', 'SSL Renew Order Error in GetDVApproverList - renewAlphaDomain', __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); - } - if ($approverEmail == '') { - $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; - } - myadmin_log('ssl', 'info', "renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard, $oldOrderId)", __LINE__, __FILE__); - $this->__construct($this->username, $this->password); - $res = $this->renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard, $oldOrderId); - $this->extra['laststep'] = 'DVOrder'; - $this->extra['DVOrder'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - $this->extra['error'] = 'Error In order'; - if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); - } else { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); - } - myadmin_log('ssl', 'info', 'renewValidateOrderParameters returned: '.json_encode($res), __LINE__, __FILE__); - } else { - $this->extra['finished'] = 1; - myadmin_log('ssl', 'info', 'SSL Renew Order success - renewAlphaDomain', __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); - } - return $this->extra; - } + /** + * GlobalSign::create_organizationssl_autocsr() + * + * @param string $fqdn + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param $wildcard + * @return bool + */ + public function create_organizationssl_autocsr($fqdn, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard) + { + $res = $this->OVOrderWithoutCSR($fqdn, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + } else { + $subject = 'GlobalSign SSL Error While Registering '.$fqdn; + } + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + myadmin_log('ssl', 'info', 'create_organizationalssl_autocsr returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } else { + echo 'Your Order Has Been Completed'; + } + $orderId = $res->Response->OrderID; + return $orderId; + } - /** - * GlobalSign::renewDVOrder() - * - * @param string $product - * @param string $orderId - * @param string $approverEmail - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param bool $wildcard - * @param string $oldOrderID - * @return mixed - */ - public function renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard = false, $oldOrderID) - { - myadmin_log('ssl', 'info', "Called renewDVOrder - renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard, $oldOrderID)", __LINE__, __FILE__); - $params = [ - 'DVOrder' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameter' => [ - 'ProductCode' => $product, - 'OrderKind' => 'renewal', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'RenewalTargetOrderID' => $oldOrderID, - 'CSR' => $csr - ], - 'OrderID' => $orderId, - 'ApproverEmail' => $approverEmail, - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ]]]]; - if ($wildcard === true) { - $params['DVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; - } - $this->extra['DVOrder_params'] = $params; - // ini_set("max_input_time", -1); - // ini_set("max_execution_time", -1); - ini_set('max_execution_time', 1000); // just put a lot of time - ini_set('default_socket_timeout', 1000); // same - myadmin_log('ssl', 'info', 'Params - '.json_encode($params), __LINE__, __FILE__); - $res = $this->functionsCall('DVOrder', $params); - return $res; - } + /** + * GlobalSign::create_extendedssl() + * + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param string $businessCategory + * @param string $agency + * @return array|bool + */ + public function create_extendedssl($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency) + { + $res = $this->ValidateOrderParameters('EV_SHA2', $fqdn, $csr); - /** - * GlobalSign::renewOVOrder() - * - * @param string $fqdn - * @param string $csr - * @param string $orderId - * @param string $approverEmail - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param bool $wildcard - * @param string $oldOrderId - * @return mixed - */ - public function renewOVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard = false, $oldOrderId) - { - $params = [ - 'OVOrder' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameter' => [ - 'ProductCode' => 'OV_SHA2', - 'OrderKind' => 'renewal', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'RenewaltargetOrderID' => $oldOrderId, - 'RenewalTargetOrderID' => $oldOrderId, - 'CSR' => $csr - /* - * 'Options' => array( - * 'Option' => array( - * 'OptionName' => 'SAN', - * 'OptionValue' => 'true', - * ), - * ), - */ - ], - 'OrderID' => $orderId, - 'ApproverEmail' => $approverEmail, - 'OrganizationInfo' => [ - 'OrganizationName' => $company, 'OrganizationAddress' => [ - 'AddressLine1' => $address, - 'City' => $city, - 'Region' => $state, - 'PostalCode' => $zip, - 'Country' => 'US', - 'Phone' => $phone - ] - ], - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ], - /* - * 'SANEntries' => array( - * 'SANEntry' => array( - * array( - * 'SANOptionType' => '1', - * 'SubjectAltName' => 'mail.test12345.com', - * ), - * array( - * 'SANOptionType' => '3', - * 'SubjectAltName' => 'tester.test12345.com', - * ), - * ), - * ), - */ - ]]]; - if ($wildcard === true) { - $params['OVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; - } - $this->extra['OVOrder_params'] = $params; - $res = $this->functionsCall('OVOrder', $params); - return $res; - } + $this->extra = []; + $this->extra['laststep'] = 'ValidateOrderParameters'; + $this->extra['ValidateOrderParameters'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fdqn; + } else { + $subject = 'GlobalSign SSL Error While Registering '.$fqdn; + } + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + myadmin_log('ssl', 'info', 'create_extendedssl returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } + $this->__construct($this->username, $this->password); - /** - * GlobalSign::renewOrganizationSSL() - * - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param string $approverEmail - * @param bool $wildcard - * @param string $oldOrderId - * @return array|bool - */ - public function renewOrganizationSSL($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $approverEmail, $wildcard = false, $oldOrderId) - { - $res = $this->renewValidateOrderParameters('OV_SHA2', $fqdn, $csr, $wildcard); - $this->extra = []; - $this->extra['laststep'] = 'ValidateOrderParameters'; - $this->extra['ValidateOrderParameters'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); - } else { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); - } - myadmin_log('ssl', 'info', 'renewOrganizationSSL returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } - $orderId = $res->Response->OrderID; - $this->__construct($this->username, $this->password); - $res = $this->renewOVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard, $oldOrderId); - $this->extra['laststep'] = 'OVOrder'; - $this->extra['OVOrder'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); - } else { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); - } - myadmin_log('ssl', 'info', 'renewOrganizationSSL returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } else { - $this->extra['finished'] = 1; - echo 'Your Order Has Been Completed'; - myadmin_log('ssl', 'info', 'SSL Renew Order Success - renewOrganizationSSL', __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); - } - $this->extra['order_id'] = $orderId; - return $this->extra; - } + $res = $this->EVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency); + $orderId = $res->Response->OrderID; + $this->extra['laststep'] = 'EVOrder'; + $this->extra['EVOrder'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if (isset($res->Response->OrderResponseHeader->Errors) && (strpos($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage, 'Your account does not have enough remaining balance to process this request') !== false || $res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error')) { + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fdqn; + } else { + $subject = 'GlobalSign SSL Error While Registering '.$fqdn; + } + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin_email_ssl_error.tpl'); + myadmin_log('ssl', 'info', 'create_extendedssl returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } else { + $this->extra['finished'] = 1; + echo 'Your Order Has Been Completed'; + } + $this->extra['order_id'] = $orderId; + return $this->extra; + } - /** - * GlobalSign::EVOrder() - * - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param string $businessCategory - * @param string $agency - * @param string $oldOrderId - * @return mixed - */ - public function renewEVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency, $oldOrderId) - { - $params = [ - 'EVOrder' => [ - 'Request' => [ - 'OrderRequestHeader' => [ - 'AuthToken' => [ - 'UserName' => $this->username, - 'Password' => $this->password - ] - ], - 'OrderRequestParameter' => [ - 'ProductCode' => 'EV_SHA2', - 'OrderKind' => 'renewal', - 'Licenses' => '1', - 'ValidityPeriod' => ['Months' => '12'], - 'RenewaltargetOrderID'=>$oldOrderId, - 'RenewalTargetOrderID'=>$oldOrderId, - 'CSR' => $csr - ], - 'OrganizationInfoEV' => [ - 'BusinessCategoryCode' => $businessCategory, 'OrganizationAddress' => [ - 'AddressLine1' => $address, - 'City' => $city, - 'Region' => $state, - 'PostalCode' => $zip, - 'Country' => 'US', - 'Phone' => $phone - ] - ], - 'RequestorInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email, - 'OrganizationName' => $company - ], - 'ApproverInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email, - 'OrganizationName' => $company - ], - 'AuthorizedSignerInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ], - 'JurisdictionInfo' => [ - 'Country' => 'US', - 'StateOrProvince' => $state, - 'Locality' => $city, - 'IncorporatingAgencyRegistrationNumber' => $agency - ], - 'OrganizationInfo' => [ - 'OrganizationName' => $company, 'OrganizationAddress' => [ - 'AddressLine1' => $address, - 'City' => $city, - 'Region' => $state, - 'PostalCode' => $zip, - 'Country' => 'US', - 'Phone' => $phone - ] - ], - 'ContactInfo' => [ - 'FirstName' => $firstname, - 'LastName' => $lastname, - 'Phone' => $phone, - 'Email' => $email - ]]]]; - $this->extra = []; - $this->extra['EVOrder_params'] = $params; - $res = $this->functionsCall('EVOrder', $params); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - return false; - } else { - $this->extra['finished'] = 1; - $this->extra['EVOrder'] = obj2array($res); - } - return $this->extra; - } + /** + * GlobalSIgn::renewAlphaDomain() + * + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $approverEmail + * @param bool $wildcard + * @param string $sslType + * @param string $oldOrderId + * @return array + */ + public function renewAlphaDomain($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard = false, $sslType, $oldOrderId) + { + myadmin_log('ssl', 'info', "renew AlphaDomain called - renewAlphaDomain($fqdn, $csr, $firstname, $lastname, $phone, $email, $approverEmail, $wildcard, $sslType, $oldOrderId)", __LINE__, __FILE__); + if ($sslType == 1) { + $product = 'DV_LOW_SHA2'; + } else { + $product = 'DV_SHA2'; + } + $res = $this->renewValidateOrderParameters($product, $fqdn, $csr, $wildcard, $oldOrderId); + myadmin_log('ssl', 'info', "renewValidateOrderParameters($product, $fqdn, $csr, $wildcard, $oldOrderId)", __LINE__, __FILE__); + $this->extra = []; + $this->extra['laststep'] = 'ValidateOrderParameters'; + $this->extra['ValidateOrderParameters'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); + } else { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); + } + myadmin_log('ssl', 'info', 'renewValidateOrderParameters returned: '.json_encode($res), __LINE__, __FILE__); + $this->extra['error'] = 'Error In order'; + return $this->extra; + } + $orderId = $res->Response->OrderID; + $this->extra['order_id'] = $orderId; + $this->__construct($this->username, $this->password); + $res = $this->GetDVApproverList($fqdn); + $this->extra['laststep'] = 'GetDVApproverList'; + $this->extra['GetDVApproverList'] = obj2array($res); + if ($res->Response->QueryResponseHeader->SuccessCode != 0) { + $this->extra['error'] = 'Error In order'; + myadmin_log('ssl', 'info', 'SSL Renew Order Error in GetDVApproverList - renewAlphaDomain', __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); + } + if ($approverEmail == '') { + $approverEmail = $res->Response->Approvers->SearchOrderDetail[0]->ApproverEmail; + } + myadmin_log('ssl', 'info', "renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard, $oldOrderId)", __LINE__, __FILE__); + $this->__construct($this->username, $this->password); + $res = $this->renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard, $oldOrderId); + $this->extra['laststep'] = 'DVOrder'; + $this->extra['DVOrder'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + $this->extra['error'] = 'Error In order'; + if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); + } else { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); + } + myadmin_log('ssl', 'info', 'renewValidateOrderParameters returned: '.json_encode($res), __LINE__, __FILE__); + } else { + $this->extra['finished'] = 1; + myadmin_log('ssl', 'info', 'SSL Renew Order success - renewAlphaDomain', __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); + } + return $this->extra; + } - /** - * GlobalSign::renewExtendedSSL() - * - * @param string $fqdn - * @param string $csr - * @param string $firstname - * @param string $lastname - * @param string $phone - * @param string $email - * @param string $company - * @param string $address - * @param string $city - * @param string $state - * @param string $zip - * @param string $businessCategory - * @param string $agency - * @param string $oldOrderId - * @return array|bool - */ - public function renewExtendedSSL($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency, $oldOrderId) - { - $res = $this->renewValidateOrderParameters('EV_SHA2', $fqdn, $csr, false); - $this->extra = []; - $this->extra['laststep'] = 'ValidateOrderParameters'; - $this->extra['ValidateOrderParameters'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - echo "Error In order\n"; - myadmin_log('ssl', 'info', 'SSL Renew Order Error in validation - renewExtendedSSL', __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); - return false; - } - $this->__construct($this->username, $this->password); + /** + * GlobalSign::renewDVOrder() + * + * @param string $product + * @param string $orderId + * @param string $approverEmail + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param bool $wildcard + * @param string $oldOrderID + * @return mixed + */ + public function renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard = false, $oldOrderID) + { + myadmin_log('ssl', 'info', "Called renewDVOrder - renewDVOrder($product, $orderId, $approverEmail, $fqdn, $csr, $firstname, $lastname, $phone, $email, $wildcard, $oldOrderID)", __LINE__, __FILE__); + $params = [ + 'DVOrder' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameter' => [ + 'ProductCode' => $product, + 'OrderKind' => 'renewal', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'RenewalTargetOrderID' => $oldOrderID, + 'CSR' => $csr + ], + 'OrderID' => $orderId, + 'ApproverEmail' => $approverEmail, + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ]]]]; + if ($wildcard === true) { + $params['DVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; + } + $this->extra['DVOrder_params'] = $params; + // ini_set("max_input_time", -1); + // ini_set("max_execution_time", -1); + ini_set('max_execution_time', 1000); // just put a lot of time + ini_set('default_socket_timeout', 1000); // same + myadmin_log('ssl', 'info', 'Params - '.json_encode($params), __LINE__, __FILE__); + $res = $this->functionsCall('DVOrder', $params); + return $res; + } - $orderId = $res->Response->OrderID; - $res = $this->renewEVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency, $oldOrderId); - $this->extra['laststep'] = 'EVOrder'; - $this->extra['EVOrder'] = obj2array($res); - if ($res->Response->OrderResponseHeader->SuccessCode != 0) { - if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); - $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); - } else { - dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); - } - myadmin_log('ssl', 'info', 'renewExtendedSSL returned: '.json_encode($res), __LINE__, __FILE__); - return false; - } else { - $this->extra['finished'] = 1; - echo 'Your Order Has Been Completed'; - myadmin_log('ssl', 'info', 'SSL Renew Order Success - renewExtendedSSL', __LINE__, __FILE__); - myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); - } - $this->extra['order_id'] = $orderId; - return $this->extra; - } + /** + * GlobalSign::renewOVOrder() + * + * @param string $fqdn + * @param string $csr + * @param string $orderId + * @param string $approverEmail + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param bool $wildcard + * @param string $oldOrderId + * @return mixed + */ + public function renewOVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard = false, $oldOrderId) + { + $params = [ + 'OVOrder' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameter' => [ + 'ProductCode' => 'OV_SHA2', + 'OrderKind' => 'renewal', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'RenewaltargetOrderID' => $oldOrderId, + 'RenewalTargetOrderID' => $oldOrderId, + 'CSR' => $csr + /* + * 'Options' => array( + * 'Option' => array( + * 'OptionName' => 'SAN', + * 'OptionValue' => 'true', + * ), + * ), + */ + ], + 'OrderID' => $orderId, + 'ApproverEmail' => $approverEmail, + 'OrganizationInfo' => [ + 'OrganizationName' => $company, 'OrganizationAddress' => [ + 'AddressLine1' => $address, + 'City' => $city, + 'Region' => $state, + 'PostalCode' => $zip, + 'Country' => 'US', + 'Phone' => $phone + ] + ], + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ], + /* + * 'SANEntries' => array( + * 'SANEntry' => array( + * array( + * 'SANOptionType' => '1', + * 'SubjectAltName' => 'mail.test12345.com', + * ), + * array( + * 'SANOptionType' => '3', + * 'SubjectAltName' => 'tester.test12345.com', + * ), + * ), + * ), + */ + ]]]; + if ($wildcard === true) { + $params['OVOrder']['Request']['OrderRequestParameter']['BaseOption'] = 'wildcard'; + } + $this->extra['OVOrder_params'] = $params; + $res = $this->functionsCall('OVOrder', $params); + return $res; + } + + /** + * GlobalSign::renewOrganizationSSL() + * + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param string $approverEmail + * @param bool $wildcard + * @param string $oldOrderId + * @return array|bool + */ + public function renewOrganizationSSL($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $approverEmail, $wildcard = false, $oldOrderId) + { + $res = $this->renewValidateOrderParameters('OV_SHA2', $fqdn, $csr, $wildcard); + $this->extra = []; + $this->extra['laststep'] = 'ValidateOrderParameters'; + $this->extra['ValidateOrderParameters'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); + } else { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); + } + myadmin_log('ssl', 'info', 'renewOrganizationSSL returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } + $orderId = $res->Response->OrderID; + $this->__construct($this->username, $this->password); + $res = $this->renewOVOrder($fqdn, $csr, $orderId, $approverEmail, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $wildcard, $oldOrderId); + $this->extra['laststep'] = 'OVOrder'; + $this->extra['OVOrder'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); + } else { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team'); + } + myadmin_log('ssl', 'info', 'renewOrganizationSSL returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } else { + $this->extra['finished'] = 1; + echo 'Your Order Has Been Completed'; + myadmin_log('ssl', 'info', 'SSL Renew Order Success - renewOrganizationSSL', __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); + } + $this->extra['order_id'] = $orderId; + return $this->extra; + } + + /** + * GlobalSign::EVOrder() + * + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param string $businessCategory + * @param string $agency + * @param string $oldOrderId + * @return mixed + */ + public function renewEVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency, $oldOrderId) + { + $params = [ + 'EVOrder' => [ + 'Request' => [ + 'OrderRequestHeader' => [ + 'AuthToken' => [ + 'UserName' => $this->username, + 'Password' => $this->password + ] + ], + 'OrderRequestParameter' => [ + 'ProductCode' => 'EV_SHA2', + 'OrderKind' => 'renewal', + 'Licenses' => '1', + 'ValidityPeriod' => ['Months' => '12'], + 'RenewaltargetOrderID'=>$oldOrderId, + 'RenewalTargetOrderID'=>$oldOrderId, + 'CSR' => $csr + ], + 'OrganizationInfoEV' => [ + 'BusinessCategoryCode' => $businessCategory, 'OrganizationAddress' => [ + 'AddressLine1' => $address, + 'City' => $city, + 'Region' => $state, + 'PostalCode' => $zip, + 'Country' => 'US', + 'Phone' => $phone + ] + ], + 'RequestorInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email, + 'OrganizationName' => $company + ], + 'ApproverInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email, + 'OrganizationName' => $company + ], + 'AuthorizedSignerInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ], + 'JurisdictionInfo' => [ + 'Country' => 'US', + 'StateOrProvince' => $state, + 'Locality' => $city, + 'IncorporatingAgencyRegistrationNumber' => $agency + ], + 'OrganizationInfo' => [ + 'OrganizationName' => $company, 'OrganizationAddress' => [ + 'AddressLine1' => $address, + 'City' => $city, + 'Region' => $state, + 'PostalCode' => $zip, + 'Country' => 'US', + 'Phone' => $phone + ] + ], + 'ContactInfo' => [ + 'FirstName' => $firstname, + 'LastName' => $lastname, + 'Phone' => $phone, + 'Email' => $email + ]]]]; + $this->extra = []; + $this->extra['EVOrder_params'] = $params; + $res = $this->functionsCall('EVOrder', $params); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + return false; + } else { + $this->extra['finished'] = 1; + $this->extra['EVOrder'] = obj2array($res); + } + return $this->extra; + } + + /** + * GlobalSign::renewExtendedSSL() + * + * @param string $fqdn + * @param string $csr + * @param string $firstname + * @param string $lastname + * @param string $phone + * @param string $email + * @param string $company + * @param string $address + * @param string $city + * @param string $state + * @param string $zip + * @param string $businessCategory + * @param string $agency + * @param string $oldOrderId + * @return array|bool + */ + public function renewExtendedSSL($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency, $oldOrderId) + { + $res = $this->renewValidateOrderParameters('EV_SHA2', $fqdn, $csr, false); + $this->extra = []; + $this->extra['laststep'] = 'ValidateOrderParameters'; + $this->extra['ValidateOrderParameters'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + echo "Error In order\n"; + myadmin_log('ssl', 'info', 'SSL Renew Order Error in validation - renewExtendedSSL', __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); + return false; + } + $this->__construct($this->username, $this->password); + + $orderId = $res->Response->OrderID; + $res = $this->renewEVOrder($fqdn, $csr, $firstname, $lastname, $phone, $email, $company, $address, $city, $state, $zip, $businessCategory, $agency, $oldOrderId); + $this->extra['laststep'] = 'EVOrder'; + $this->extra['EVOrder'] = obj2array($res); + if ($res->Response->OrderResponseHeader->SuccessCode != 0) { + if ($res->Response->OrderResponseHeader->Errors->Error->ErrorMessage == 'Balance Error') { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); + $subject = 'GlobalSign Balance/Funds Error While Registering '.$fqdn; + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); + } else { + dialog('Error In Order', 'There was an error procesisng your order. Please contact our support team.'); + } + myadmin_log('ssl', 'info', 'renewExtendedSSL returned: '.json_encode($res), __LINE__, __FILE__); + return false; + } else { + $this->extra['finished'] = 1; + echo 'Your Order Has Been Completed'; + myadmin_log('ssl', 'info', 'SSL Renew Order Success - renewExtendedSSL', __LINE__, __FILE__); + myadmin_log('ssl', 'info', json_encode($res), __LINE__, __FILE__); + } + $this->extra['order_id'] = $orderId; + return $this->extra; + } } diff --git a/src/Plugin.php b/src/Plugin.php index 65631a6..6fe55a2 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -12,154 +12,154 @@ */ class Plugin { - public static $name = 'GlobalSign SSL'; - public static $description = 'Allows selling of GlobalSign Server and VPS License Types. More info at https://www.netenberg.com/globalsign.php'; - public static $help = 'It provides more than one million end users the ability to quickly install dozens of the leading open source content management systems into their web space. Must have a pre-existing cPanel license with cPanelDirect to purchase a globalsign license. Allow 10 minutes for activation.'; - public static $module = 'ssl'; - public static $type = 'service'; + public static $name = 'GlobalSign SSL'; + public static $description = 'Allows selling of GlobalSign Server and VPS License Types. More info at https://www.netenberg.com/globalsign.php'; + public static $help = 'It provides more than one million end users the ability to quickly install dozens of the leading open source content management systems into their web space. Must have a pre-existing cPanel license with cPanelDirect to purchase a globalsign license. Allow 10 minutes for activation.'; + public static $module = 'ssl'; + public static $type = 'service'; - /** - * Plugin constructor. - */ - public function __construct() - { - } + /** + * Plugin constructor. + */ + public function __construct() + { + } - /** - * @return array - */ - public static function getHooks() - { - return [ - self::$module.'.activate' => [__CLASS__, 'getActivate'], - self::$module.'.reactivate' => [__CLASS__, 'getActivate'], - self::$module.'.settings' => [__CLASS__, 'getSettings'], - 'function.requirements' => [__CLASS__, 'getRequirements'] - ]; - } + /** + * @return array + */ + public static function getHooks() + { + return [ + self::$module.'.activate' => [__CLASS__, 'getActivate'], + self::$module.'.reactivate' => [__CLASS__, 'getActivate'], + self::$module.'.settings' => [__CLASS__, 'getSettings'], + 'function.requirements' => [__CLASS__, 'getRequirements'] + ]; + } - /** - * @param \Symfony\Component\EventDispatcher\GenericEvent $event - */ - public static function getActivate(GenericEvent $event) - { - if ($event['category'] == get_service_define('GLOBALSIGN')) { - $serviceClass = $event->getSubject(); - myadmin_log(self::$module, 'info', 'GlobalSign Activation', __LINE__, __FILE__, self::$module, $serviceClass->getId()); - $serviceTypes = run_event('get_service_types', false, self::$module); - $settings = get_module_settings(self::$module); - $extra = run_event('parse_service_extra', $serviceClass->getExtra(), self::$module); - $GS = new GlobalSign(GLOBALSIGN_USERNAME, GLOBALSIGN_PASSWORD); - $orderData = $GS->GetOrderByOrderID($serviceClass->getOrderId()); - $renew = $orderData['Response']['OrderDetail']['OrderInfo']['OrderStatus'] == 4 && (new \DateTime($orderData['Response']['OrderDetail']['CertificateInfo']['EndDate']))->diff(new \DateTime('now'))->invert == 1; - if (!isset($extra['csr']) || '' == $extra['csr']) { - $extra = ensure_csr($serviceClass->getId()); - } - if (!isset($extra['approver_email'])) { - $extra['approver_email'] = ''; - } - myadmin_log(self::$module, 'info', "starting SSL Hostname {$serviceClass->getHostname()} Type ".$event['field1'].' Got CSR Size: '.mb_strlen($extra['csr']), __LINE__, __FILE__, self::$module, $serviceClass->getId()); - myadmin_log(self::$module, 'info', $renew === true ? 'found order_id already set and GetOrderByOrderID is returning a vald order so decided to renew the cert' : 'order_id is either not seto or invalid so placing a new order', __LINE__, __FILE__, self::$module, $serviceClass->getId()); - $ssl_typeArray = ['AlphaSSL' =>1, 'DomainSSL' =>2, 'OrganizationSSL' =>3, 'ExtendedSSL' =>4, 'Alpha SSL w/ WildCard' => 5, 'DomainSSL w/ WildCard' => 6, 'OrganizationSSL w/ WildCard' => 7]; - if ($renew === false) { - // placing new ssl order - switch ($event['field1']) { - case 'DV_LOW': - $res = $GS->create_alphassl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $extra['approver_email'], $event['field2'] == 'wildcard'); - break; - case 'DV_SKIP': - $res = $GS->create_domainssl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $extra['approver_email'], $event['field2'] == 'wildcard'); - break; - case 'EV': - $res = $GS->create_extendedssl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['business_category'], $extra['agency'], $extra['approver_email']); - break; - case 'OV_SKIP': - $res = $GS->create_organizationssl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['approver_email'], $event['field2'] == 'wildcard'); - break; - } - if ($res !== false) { - foreach ($res as $key => $value) { - $extra[$key] = $value; - } - $orderId = $extra['order_id']; - $serviceClass->setOrderId($orderId)->setExtra(myadmin_stringify($extra))->save(); - } - if ($res === false) { - myadmin_log(self::$module, 'debug', 'Error so setting up status to pending', __LINE__, __FILE__, self::$module, $serviceClass->getId()); - $serviceClass->setStatus('pending')->save(); - } - } else { - // renewing ssl order - switch ($event['field1']) { - case 'DV_LOW': - case 'DV_SKIP': - myadmin_log('ssl', 'info', "renewAlphaDomain({$serviceClass->getHostname()}, {$extra['csr']}, {$serviceClass->getFirstname()}, {$serviceClass->getLastname()}, {$serviceClass->getPhone()}, {$serviceClass->getEmail()}, {$extra['approver_email']}, FALSE, {$ssl_typeArray[$serviceTypes[$serviceClass->getType()]['services_name']]}, {$serviceClass->getOrderId()})", __LINE__, __FILE__, self::$module, $serviceClass->getId()); - $res = $GS->renewAlphaDomain($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $extra['approver_email'], $event['field2'] == 'wildcard', $ssl_typeArray[$serviceTypes[$serviceClass->getType()]['services_name']], $serviceClass->getOrderId()); - break; - case 'EV': - myadmin_log('ssl', 'info', "renewExtendedSSL({$serviceClass->getHostname()}, {$extra['csr']}, {$serviceClass->getFirstname()}, {$serviceClass->getLastname()}, {$serviceClass->getPhone()}, {$serviceClass->getEmail()}, {$serviceClass->getCompany()}, {$serviceClass->getAddress()}, {$serviceClass->getCity()}, {$serviceClass->getState()}, {$serviceClass->getZip()}, {$extra['business_category']}, {$extra['agency']}, {$serviceClass->getOrderId()})", __LINE__, __FILE__, self::$module, $serviceClass->getId()); - $res = $GS->renewExtendedSSL($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['business_category'], $extra['agency'], $serviceClass->getOrderId()); - break; - case 'OV_SKIP': - myadmin_log('ssl', 'info', "renewOrganizationSSL({$serviceClass->getHostname()}, {$extra['csr']}, {$serviceClass->getFirstname()}, {$serviceClass->getLastname()}, {$serviceClass->getPhone()}, {$serviceClass->getEmail()}, {$serviceClass->getCompany()}, {$serviceClass->getAddress()}, {$serviceClass->getCity()}, {$serviceClass->getState()}, {$serviceClass->getZip()}, {$extra['approver_email']}, TRUE, {$serviceClass->getOrderId()})", __LINE__, __FILE__, self::$module, $serviceClass->getId()); - $res = $GS->renewOrganizationSSL($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['approver_email'], $event['field2'] == 'wildcard', $serviceClass->getOrderId()); - break; - } - if ($res != false && isset($res['finished']) && $res['finished'] == 1) { - $orderId = $res['order_id']; - $serviceClass->setOrderId($orderId)->save(); - } - } - if (!isset($orderId)) { - dialog('Error Registering Cert', 'The order process did not complete successfully. Please contact support so they can get it registered.'); - $subject = 'Error Registering SSL Certificate '.$serviceClass->getHostname(); - (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); - myadmin_log('ssl', 'info', $subject, __LINE__, __FILE__, self::$module, $serviceClass->getId()); - $event['success'] = false; - } - $event->stopPropagation(); - } - } + /** + * @param \Symfony\Component\EventDispatcher\GenericEvent $event + */ + public static function getActivate(GenericEvent $event) + { + if ($event['category'] == get_service_define('GLOBALSIGN')) { + $serviceClass = $event->getSubject(); + myadmin_log(self::$module, 'info', 'GlobalSign Activation', __LINE__, __FILE__, self::$module, $serviceClass->getId()); + $serviceTypes = run_event('get_service_types', false, self::$module); + $settings = get_module_settings(self::$module); + $extra = run_event('parse_service_extra', $serviceClass->getExtra(), self::$module); + $GS = new GlobalSign(GLOBALSIGN_USERNAME, GLOBALSIGN_PASSWORD); + $orderData = $GS->GetOrderByOrderID($serviceClass->getOrderId()); + $renew = $orderData['Response']['OrderDetail']['OrderInfo']['OrderStatus'] == 4 && (new \DateTime($orderData['Response']['OrderDetail']['CertificateInfo']['EndDate']))->diff(new \DateTime('now'))->invert == 1; + if (!isset($extra['csr']) || '' == $extra['csr']) { + $extra = ensure_csr($serviceClass->getId()); + } + if (!isset($extra['approver_email'])) { + $extra['approver_email'] = ''; + } + myadmin_log(self::$module, 'info', "starting SSL Hostname {$serviceClass->getHostname()} Type ".$event['field1'].' Got CSR Size: '.mb_strlen($extra['csr']), __LINE__, __FILE__, self::$module, $serviceClass->getId()); + myadmin_log(self::$module, 'info', $renew === true ? 'found order_id already set and GetOrderByOrderID is returning a vald order so decided to renew the cert' : 'order_id is either not seto or invalid so placing a new order', __LINE__, __FILE__, self::$module, $serviceClass->getId()); + $ssl_typeArray = ['AlphaSSL' =>1, 'DomainSSL' =>2, 'OrganizationSSL' =>3, 'ExtendedSSL' =>4, 'Alpha SSL w/ WildCard' => 5, 'DomainSSL w/ WildCard' => 6, 'OrganizationSSL w/ WildCard' => 7]; + if ($renew === false) { + // placing new ssl order + switch ($event['field1']) { + case 'DV_LOW': + $res = $GS->create_alphassl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $extra['approver_email'], $event['field2'] == 'wildcard'); + break; + case 'DV_SKIP': + $res = $GS->create_domainssl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $extra['approver_email'], $event['field2'] == 'wildcard'); + break; + case 'EV': + $res = $GS->create_extendedssl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['business_category'], $extra['agency'], $extra['approver_email']); + break; + case 'OV_SKIP': + $res = $GS->create_organizationssl($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['approver_email'], $event['field2'] == 'wildcard'); + break; + } + if ($res !== false) { + foreach ($res as $key => $value) { + $extra[$key] = $value; + } + $orderId = $extra['order_id']; + $serviceClass->setOrderId($orderId)->setExtra(myadmin_stringify($extra))->save(); + } + if ($res === false) { + myadmin_log(self::$module, 'debug', 'Error so setting up status to pending', __LINE__, __FILE__, self::$module, $serviceClass->getId()); + $serviceClass->setStatus('pending')->save(); + } + } else { + // renewing ssl order + switch ($event['field1']) { + case 'DV_LOW': + case 'DV_SKIP': + myadmin_log('ssl', 'info', "renewAlphaDomain({$serviceClass->getHostname()}, {$extra['csr']}, {$serviceClass->getFirstname()}, {$serviceClass->getLastname()}, {$serviceClass->getPhone()}, {$serviceClass->getEmail()}, {$extra['approver_email']}, FALSE, {$ssl_typeArray[$serviceTypes[$serviceClass->getType()]['services_name']]}, {$serviceClass->getOrderId()})", __LINE__, __FILE__, self::$module, $serviceClass->getId()); + $res = $GS->renewAlphaDomain($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $extra['approver_email'], $event['field2'] == 'wildcard', $ssl_typeArray[$serviceTypes[$serviceClass->getType()]['services_name']], $serviceClass->getOrderId()); + break; + case 'EV': + myadmin_log('ssl', 'info', "renewExtendedSSL({$serviceClass->getHostname()}, {$extra['csr']}, {$serviceClass->getFirstname()}, {$serviceClass->getLastname()}, {$serviceClass->getPhone()}, {$serviceClass->getEmail()}, {$serviceClass->getCompany()}, {$serviceClass->getAddress()}, {$serviceClass->getCity()}, {$serviceClass->getState()}, {$serviceClass->getZip()}, {$extra['business_category']}, {$extra['agency']}, {$serviceClass->getOrderId()})", __LINE__, __FILE__, self::$module, $serviceClass->getId()); + $res = $GS->renewExtendedSSL($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['business_category'], $extra['agency'], $serviceClass->getOrderId()); + break; + case 'OV_SKIP': + myadmin_log('ssl', 'info', "renewOrganizationSSL({$serviceClass->getHostname()}, {$extra['csr']}, {$serviceClass->getFirstname()}, {$serviceClass->getLastname()}, {$serviceClass->getPhone()}, {$serviceClass->getEmail()}, {$serviceClass->getCompany()}, {$serviceClass->getAddress()}, {$serviceClass->getCity()}, {$serviceClass->getState()}, {$serviceClass->getZip()}, {$extra['approver_email']}, TRUE, {$serviceClass->getOrderId()})", __LINE__, __FILE__, self::$module, $serviceClass->getId()); + $res = $GS->renewOrganizationSSL($serviceClass->getHostname(), $extra['csr'], $serviceClass->getFirstname(), $serviceClass->getLastname(), $serviceClass->getPhone(), $serviceClass->getEmail(), $serviceClass->getCompany(), $serviceClass->getAddress(), $serviceClass->getCity(), $serviceClass->getState(), $serviceClass->getZip(), $extra['approver_email'], $event['field2'] == 'wildcard', $serviceClass->getOrderId()); + break; + } + if ($res != false && isset($res['finished']) && $res['finished'] == 1) { + $orderId = $res['order_id']; + $serviceClass->setOrderId($orderId)->save(); + } + } + if (!isset($orderId)) { + dialog('Error Registering Cert', 'The order process did not complete successfully. Please contact support so they can get it registered.'); + $subject = 'Error Registering SSL Certificate '.$serviceClass->getHostname(); + (new \MyAdmin\Mail())->adminMail($subject, $subject.PHP_EOL.print_r($res, false), false, 'admin/ssl_error.tpl'); + myadmin_log('ssl', 'info', $subject, __LINE__, __FILE__, self::$module, $serviceClass->getId()); + $event['success'] = false; + } + $event->stopPropagation(); + } + } - /** - * @param \Symfony\Component\EventDispatcher\GenericEvent $event - */ - public static function getMenu(GenericEvent $event) - { - $menu = $event->getSubject(); - if ($GLOBALS['tf']->ima == 'admin') { - $menu->add_link(self::$module, 'choice=none.reusable_globalsign', '/images/myadmin/to-do.png', _('ReUsable GlobalSign Licenses')); - $menu->add_link(self::$module, 'choice=none.globalsign_list', '/images/myadmin/to-do.png', _('GlobalSign Licenses Breakdown')); - $menu->add_link(self::$module.'api', 'choice=none.globalsign_licenses_list', '/images/whm/createacct.gif', _('List all GlobalSign Licenses')); - } - } + /** + * @param \Symfony\Component\EventDispatcher\GenericEvent $event + */ + public static function getMenu(GenericEvent $event) + { + $menu = $event->getSubject(); + if ($GLOBALS['tf']->ima == 'admin') { + $menu->add_link(self::$module, 'choice=none.reusable_globalsign', '/images/myadmin/to-do.png', _('ReUsable GlobalSign Licenses')); + $menu->add_link(self::$module, 'choice=none.globalsign_list', '/images/myadmin/to-do.png', _('GlobalSign Licenses Breakdown')); + $menu->add_link(self::$module.'api', 'choice=none.globalsign_licenses_list', '/images/whm/createacct.gif', _('List all GlobalSign Licenses')); + } + } - /** - * @param \Symfony\Component\EventDispatcher\GenericEvent $event - */ - public static function getRequirements(GenericEvent $event) - { - /** - * @var \MyAdmin\Plugins\Loader $this->loader - */ - $loader = $event->getSubject(); - $loader->add_requirement('class.GlobalSign', '/../vendor/detain/myadmin-globalsign-ssl/src/GlobalSign.php', '\\Detain\\MyAdminGlobalSign\\'); - } + /** + * @param \Symfony\Component\EventDispatcher\GenericEvent $event + */ + public static function getRequirements(GenericEvent $event) + { + /** + * @var \MyAdmin\Plugins\Loader $this->loader + */ + $loader = $event->getSubject(); + $loader->add_requirement('class.GlobalSign', '/../vendor/detain/myadmin-globalsign-ssl/src/GlobalSign.php', '\\Detain\\MyAdminGlobalSign\\'); + } - /** - * @param \Symfony\Component\EventDispatcher\GenericEvent $event - */ - public static function getSettings(GenericEvent $event) - { - /** - * @var \MyAdmin\Settings $settings - **/ - $settings = $event->getSubject(); - $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_username', _('GlobalSign Username'), _('Username to use for GlobalSign API Authentication'), $settings->get_setting('GLOBALSIGN_USERNAME')); - $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_password', _('GlobalSign Password'), _('Password to use for GlobalSign API Authentication'), $settings->get_setting('GLOBALSIGN_PASSWORD')); - $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_test_username', _('GlobalSign Username'), _('Username to use for GlobalSign API Testing Authentication'), $settings->get_setting('GLOBALSIGN_TEST_USERNAME')); - $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_test_password', _('GlobalSign Password'), _('Password to use for GlobalSign API Testing Authentication'), $settings->get_setting('GLOBALSIGN_TEST_PASSWORD')); - $settings->add_dropdown_setting(self::$module, _('Out of Stock'), 'globalsign_testing', _('GlobalSign Test Mode'), _('Enable API Test mode (doesnt create real certs or cost)'), GLOBALSIGN_TESTING, ['false', 'true'], ['No', 'Yes']); - $settings->add_dropdown_setting(self::$module, _('Out of Stock'), 'outofstock_globalsign_ssl', _('Out Of Stock GlobalSign SSL'), _('Enable/Disable Sales Of This Type'), OUTOFSTOCK_GLOBALSIGN_SSL, ['0', '1'], ['No', 'Yes']); - } + /** + * @param \Symfony\Component\EventDispatcher\GenericEvent $event + */ + public static function getSettings(GenericEvent $event) + { + /** + * @var \MyAdmin\Settings $settings + **/ + $settings = $event->getSubject(); + $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_username', _('GlobalSign Username'), _('Username to use for GlobalSign API Authentication'), $settings->get_setting('GLOBALSIGN_USERNAME')); + $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_password', _('GlobalSign Password'), _('Password to use for GlobalSign API Authentication'), $settings->get_setting('GLOBALSIGN_PASSWORD')); + $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_test_username', _('GlobalSign Username'), _('Username to use for GlobalSign API Testing Authentication'), $settings->get_setting('GLOBALSIGN_TEST_USERNAME')); + $settings->add_text_setting(self::$module, _('API Settings'), 'globalsign_test_password', _('GlobalSign Password'), _('Password to use for GlobalSign API Testing Authentication'), $settings->get_setting('GLOBALSIGN_TEST_PASSWORD')); + $settings->add_dropdown_setting(self::$module, _('Out of Stock'), 'globalsign_testing', _('GlobalSign Test Mode'), _('Enable API Test mode (doesnt create real certs or cost)'), GLOBALSIGN_TESTING, ['false', 'true'], ['No', 'Yes']); + $settings->add_dropdown_setting(self::$module, _('Out of Stock'), 'outofstock_globalsign_ssl', _('Out Of Stock GlobalSign SSL'), _('Enable/Disable Sales Of This Type'), OUTOFSTOCK_GLOBALSIGN_SSL, ['0', '1'], ['No', 'Yes']); + } } diff --git a/tests/GlobalSignTest.php b/tests/GlobalSignTest.php index ab0c6f0..47b68c6 100644 --- a/tests/GlobalSignTest.php +++ b/tests/GlobalSignTest.php @@ -8,363 +8,363 @@ */ class GlobalSignTest extends TestCase { - /** - * @var GlobalSign - */ - protected $object; + /** + * @var GlobalSign + */ + protected $object; - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - if (file_exists(__DIR__.'/.env')) { - $dotenv = new Dotenv\Dotenv(__DIR__); - $dotenv->load(); - } - $testing = false; - if ($testing == true) { - $this->object = new GlobalSign(getenv('GLOBALSIGN_TEST_USERNAME'), getenv('GLOBALSIGN_TEST_PASSWORD'), true); - } else { - $this->object = new GlobalSign(getenv('GLOBALSIGN_USERNAME'), getenv('GLOBALSIGN_PASSWORD')); - } - } + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + if (file_exists(__DIR__.'/.env')) { + $dotenv = new Dotenv\Dotenv(__DIR__); + $dotenv->load(); + } + $testing = false; + if ($testing == true) { + $this->object = new GlobalSign(getenv('GLOBALSIGN_TEST_USERNAME'), getenv('GLOBALSIGN_TEST_PASSWORD'), true); + } else { + $this->object = new GlobalSign(getenv('GLOBALSIGN_USERNAME'), getenv('GLOBALSIGN_PASSWORD')); + } + } - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::GetOrderByOrderID - */ - public function testGetOrderByOrderID() - { - $response = $this->object->GetOrderByOrderID('CE201011028514'); - $this->assertArrayHasKey('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertArrayHasKey('OrderResponseHeader', $response['Response'], 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); - $this->assertArrayHasKey('SuccessCode', $response['Response']['OrderResponseHeader'], 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response['Response']['OrderResponseHeader']['SuccessCode'], 0, 'Ensuring we got the proper SuccessCode (0)'); - $this->assertArrayHasKey('OrderDetail', $response['Response'], 'Ensuring Valid Respone Field "OrderDetail" Exists'); - $this->assertArrayHasKey('OrderId', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "OrderID" Exists'); - $this->assertArrayHasKey('ProductCode', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "OrderKind" Exists'); - $this->assertArrayHasKey('OrderStatus', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "OrderStatus" Exists'); - $this->assertArrayHasKey('DomainName', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "FQDN" Exists'); - $this->assertEquals($response['Response']['OrderDetail']['OrderInfo']['DomainName'], 'inssl.net', 'Ensuring Valid Respone Field "DomainName" has expected inssl.net value'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::GetOrderByOrderID + */ + public function testGetOrderByOrderID() + { + $response = $this->object->GetOrderByOrderID('CE201011028514'); + $this->assertArrayHasKey('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertArrayHasKey('OrderResponseHeader', $response['Response'], 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); + $this->assertArrayHasKey('SuccessCode', $response['Response']['OrderResponseHeader'], 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response['Response']['OrderResponseHeader']['SuccessCode'], 0, 'Ensuring we got the proper SuccessCode (0)'); + $this->assertArrayHasKey('OrderDetail', $response['Response'], 'Ensuring Valid Respone Field "OrderDetail" Exists'); + $this->assertArrayHasKey('OrderId', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "OrderID" Exists'); + $this->assertArrayHasKey('ProductCode', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "OrderKind" Exists'); + $this->assertArrayHasKey('OrderStatus', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "OrderStatus" Exists'); + $this->assertArrayHasKey('DomainName', $response['Response']['OrderDetail']['OrderInfo'], 'Ensuring Valid Respone Field "FQDN" Exists'); + $this->assertEquals($response['Response']['OrderDetail']['OrderInfo']['DomainName'], 'inssl.net', 'Ensuring Valid Respone Field "DomainName" has expected inssl.net value'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::GetOrderByDateRange - */ - public function testGetOrderByDateRange() - { - $response = $this->object->GetOrderByDateRange('2017-11-24T00:00:01.000-05:00', '2017-11-24T23:23:59.000-05:00'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - //var_export($response); - $this->assertEquals(0, $response->Response->QueryResponseHeader->SuccessCode, 'Ensuring we got the proper SuccessCode (0)'); - $this->assertObjectHasAttribute('OrderDetails', $response->Response, 'Ensuring Valid Respone Field "OrderDetails" Exists'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::GetOrderByDateRange + */ + public function testGetOrderByDateRange() + { + $response = $this->object->GetOrderByDateRange('2017-11-24T00:00:01.000-05:00', '2017-11-24T23:23:59.000-05:00'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + //var_export($response); + $this->assertEquals(0, $response->Response->QueryResponseHeader->SuccessCode, 'Ensuring we got the proper SuccessCode (0)'); + $this->assertObjectHasAttribute('OrderDetails', $response->Response, 'Ensuring Valid Respone Field "OrderDetails" Exists'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::GetCertificateOrders - */ - public function testGetCertificateOrders() - { - $response = $this->object->GetCertificateOrders('2017-11-24T00:00:01.000-05:00', '2017-11-24T23:23:59.000-05:00'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - //var_export($response); - $this->assertEquals(0, $response->Response->QueryResponseHeader->SuccessCode, 'Ensuring we got the proper SuccessCode (0)'); - $this->assertObjectHasAttribute('SearchOrderDetails', $response->Response, 'Ensuring Valid Respone Field "SearchOrderDetails" Exists'); - $response = $this->object->GetCertificateOrders('', '', 'interserver.net'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->QueryResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); - $this->assertObjectHasAttribute('SearchOrderDetails', $response->Response, 'Ensuring Valid Respone Field "SearchOrderDetails" Exists'); - $this->assertTrue(is_array($response->Response->SearchOrderDetails->SearchOrderDetail)); - $this->assertArrayHasKey(0, $response->Response->SearchOrderDetails->SearchOrderDetail, 'Ensuring Response Field is an Array with at least 1 item'); - $this->assertObjectHasAttribute('OrderID', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderID" Exists'); - $this->assertObjectHasAttribute('OrderKind', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderKind" Exists'); - $this->assertObjectHasAttribute('OrderStatus', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderStatus" Exists'); - $this->assertObjectHasAttribute('FQDN', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "FQDN" Exists'); - $this->assertTrue(strpos($response->Response->SearchOrderDetails->SearchOrderDetail[0]->FQDN, 'interserver.net') !== false); - $response = $this->object->GetCertificateOrders('', '', '', '3'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->QueryResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); - $this->assertObjectHasAttribute('SearchOrderDetails', $response->Response, 'Ensuring Valid Respone Field "SearchOrderDetails" Exists'); - $this->assertTrue(is_array($response->Response->SearchOrderDetails->SearchOrderDetail)); - $this->assertArrayHasKey(0, $response->Response->SearchOrderDetails->SearchOrderDetail, 'Ensuring Response Field is an Array with at least 1 item'); - $this->assertObjectHasAttribute('OrderID', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderID" Exists'); - $this->assertObjectHasAttribute('OrderKind', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderKind" Exists'); - $this->assertObjectHasAttribute('OrderStatus', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderStatus" Exists'); - $this->assertObjectHasAttribute('FQDN', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "FQDN" Exists'); - $this->assertTrue($response->Response->SearchOrderDetails->SearchOrderDetail[0]->OrderStatus == '3'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::GetCertificateOrders + */ + public function testGetCertificateOrders() + { + $response = $this->object->GetCertificateOrders('2017-11-24T00:00:01.000-05:00', '2017-11-24T23:23:59.000-05:00'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + //var_export($response); + $this->assertEquals(0, $response->Response->QueryResponseHeader->SuccessCode, 'Ensuring we got the proper SuccessCode (0)'); + $this->assertObjectHasAttribute('SearchOrderDetails', $response->Response, 'Ensuring Valid Respone Field "SearchOrderDetails" Exists'); + $response = $this->object->GetCertificateOrders('', '', 'interserver.net'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->QueryResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); + $this->assertObjectHasAttribute('SearchOrderDetails', $response->Response, 'Ensuring Valid Respone Field "SearchOrderDetails" Exists'); + $this->assertTrue(is_array($response->Response->SearchOrderDetails->SearchOrderDetail)); + $this->assertArrayHasKey(0, $response->Response->SearchOrderDetails->SearchOrderDetail, 'Ensuring Response Field is an Array with at least 1 item'); + $this->assertObjectHasAttribute('OrderID', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderID" Exists'); + $this->assertObjectHasAttribute('OrderKind', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderKind" Exists'); + $this->assertObjectHasAttribute('OrderStatus', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderStatus" Exists'); + $this->assertObjectHasAttribute('FQDN', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "FQDN" Exists'); + $this->assertTrue(strpos($response->Response->SearchOrderDetails->SearchOrderDetail[0]->FQDN, 'interserver.net') !== false); + $response = $this->object->GetCertificateOrders('', '', '', '3'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->QueryResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); + $this->assertObjectHasAttribute('SearchOrderDetails', $response->Response, 'Ensuring Valid Respone Field "SearchOrderDetails" Exists'); + $this->assertTrue(is_array($response->Response->SearchOrderDetails->SearchOrderDetail)); + $this->assertArrayHasKey(0, $response->Response->SearchOrderDetails->SearchOrderDetail, 'Ensuring Response Field is an Array with at least 1 item'); + $this->assertObjectHasAttribute('OrderID', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderID" Exists'); + $this->assertObjectHasAttribute('OrderKind', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderKind" Exists'); + $this->assertObjectHasAttribute('OrderStatus', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "OrderStatus" Exists'); + $this->assertObjectHasAttribute('FQDN', $response->Response->SearchOrderDetails->SearchOrderDetail[0], 'Ensuring Valid Respone Field "FQDN" Exists'); + $this->assertTrue($response->Response->SearchOrderDetails->SearchOrderDetail[0]->OrderStatus == '3'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::ValidateOrderParameters - */ - public function testValidateOrderParameters() - { - $fqdn = 'somerandomnewdomain.net'; - list($csr, $cert, $pke) = make_csr($fqdn, 'my@interserver.net', 'Secaucus', 'NJ', 'US', 'none', 'Administration') ; - $response = $this->object->ValidateOrderParameters('DV_SHA2', $fqdn, $csr, false); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); - $this->assertObjectHasAttribute('Price', $response->Response, 'Ensuring Valid Respone Field "Price" Exists'); - $this->assertObjectHasAttribute('ValidityPeriod', $response->Response, 'Ensuring Valid Respone Field "ValidityPeriod" Exists'); - $this->assertObjectHasAttribute('Months', $response->Response->ValidityPeriod, 'Ensuring Valid Respone Field "Months" Exists'); - $this->assertObjectHasAttribute('ParsedCSR', $response->Response, 'Ensuring Valid Respone Field "ParsedCSR" Exists'); - $this->assertObjectHasAttribute('DomainName', $response->Response->ParsedCSR, 'Ensuring Valid Respone Field "DomainName" Exists'); - $this->assertObjectHasAttribute('Email', $response->Response->ParsedCSR, 'Ensuring Valid Respone Field "Email" Exists'); - $this->assertObjectHasAttribute('IsValidDomainName', $response->Response->ParsedCSR, 'Ensuring Valid Respone Field "IsValidDomainName" Exists'); - unset($response); - $response = $this->object->ValidateOrderParameters('DV_SHA2', $fqdn, 'invalid csr', false); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Invalid CSR Returns Error'); - $this->assertObjectHasAttribute('Errors', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "Errors" Exists'); - $this->assertObjectHasAttribute('Error', $response->Response->OrderResponseHeader->Errors, 'Ensuring Valid Respone Field "Error" Exists'); - $this->assertObjectHasAttribute('ErrorCode', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorCode" Exists'); - $this->assertObjectHasAttribute('ErrorMessage', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorMessage" Exists'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::ValidateOrderParameters + */ + public function testValidateOrderParameters() + { + $fqdn = 'somerandomnewdomain.net'; + list($csr, $cert, $pke) = make_csr($fqdn, 'my@interserver.net', 'Secaucus', 'NJ', 'US', 'none', 'Administration') ; + $response = $this->object->ValidateOrderParameters('DV_SHA2', $fqdn, $csr, false); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); + $this->assertObjectHasAttribute('Price', $response->Response, 'Ensuring Valid Respone Field "Price" Exists'); + $this->assertObjectHasAttribute('ValidityPeriod', $response->Response, 'Ensuring Valid Respone Field "ValidityPeriod" Exists'); + $this->assertObjectHasAttribute('Months', $response->Response->ValidityPeriod, 'Ensuring Valid Respone Field "Months" Exists'); + $this->assertObjectHasAttribute('ParsedCSR', $response->Response, 'Ensuring Valid Respone Field "ParsedCSR" Exists'); + $this->assertObjectHasAttribute('DomainName', $response->Response->ParsedCSR, 'Ensuring Valid Respone Field "DomainName" Exists'); + $this->assertObjectHasAttribute('Email', $response->Response->ParsedCSR, 'Ensuring Valid Respone Field "Email" Exists'); + $this->assertObjectHasAttribute('IsValidDomainName', $response->Response->ParsedCSR, 'Ensuring Valid Respone Field "IsValidDomainName" Exists'); + unset($response); + $response = $this->object->ValidateOrderParameters('DV_SHA2', $fqdn, 'invalid csr', false); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Invalid CSR Returns Error'); + $this->assertObjectHasAttribute('Errors', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "Errors" Exists'); + $this->assertObjectHasAttribute('Error', $response->Response->OrderResponseHeader->Errors, 'Ensuring Valid Respone Field "Error" Exists'); + $this->assertObjectHasAttribute('ErrorCode', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorCode" Exists'); + $this->assertObjectHasAttribute('ErrorMessage', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorMessage" Exists'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::GetDVApproverList - */ - public function testGetDVApproverList() - { - $response = $this->object->GetDVApproverList('interserver.net'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->QueryResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); - $this->assertObjectHasAttribute('Approvers', $response->Response, 'Ensuring Valid Respone Field "Approvers" Exists'); - $this->assertObjectHasAttribute('OrderID', $response->Response, 'Ensuring Valid Respone Field "OrderID" Exists'); - $this->assertTrue(is_array($response->Response->Approvers->SearchOrderDetail)); - $this->assertArrayHasKey(0, $response->Response->Approvers->SearchOrderDetail, 'Ensuring Response Field is an Array with at least 1 item'); - $this->assertObjectHasAttribute('ApproverType', $response->Response->Approvers->SearchOrderDetail[0], 'Ensuring Valid Respone Field "ApproverType" Exists'); - $this->assertObjectHasAttribute('ApproverEmail', $response->Response->Approvers->SearchOrderDetail[0], 'Ensuring Valid Respone Field "ApproverEmail" Exists'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::GetDVApproverList + */ + public function testGetDVApproverList() + { + $response = $this->object->GetDVApproverList('interserver.net'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('QueryResponseHeader', $response->Response, 'Ensuring Valid Respone Field "QueryResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->QueryResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->QueryResponseHeader->SuccessCode, 0, 'Ensuring we got the proper SuccessCode (0)'); + $this->assertObjectHasAttribute('Approvers', $response->Response, 'Ensuring Valid Respone Field "Approvers" Exists'); + $this->assertObjectHasAttribute('OrderID', $response->Response, 'Ensuring Valid Respone Field "OrderID" Exists'); + $this->assertTrue(is_array($response->Response->Approvers->SearchOrderDetail)); + $this->assertArrayHasKey(0, $response->Response->Approvers->SearchOrderDetail, 'Ensuring Response Field is an Array with at least 1 item'); + $this->assertObjectHasAttribute('ApproverType', $response->Response->Approvers->SearchOrderDetail[0], 'Ensuring Valid Respone Field "ApproverType" Exists'); + $this->assertObjectHasAttribute('ApproverEmail', $response->Response->Approvers->SearchOrderDetail[0], 'Ensuring Valid Respone Field "ApproverEmail" Exists'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::renewValidateOrderParameters - */ - public function testRenewValidateOrderParameters() - { - $response = $this->object->renewValidateOrderParameters('DV_LOW_SHA2', 'synergypublishers.com', "", false, 'CE20171125014256'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Invalid CSR Returns Error'); - $this->assertObjectHasAttribute('Errors', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "Errors" Exists'); - $this->assertObjectHasAttribute('Error', $response->Response->OrderResponseHeader->Errors, 'Ensuring Valid Respone Field "Error" Exists'); - $this->assertObjectHasAttribute('ErrorCode', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorCode" Exists'); - $this->assertObjectHasAttribute('ErrorMessage', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorMessage" Exists'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::renewValidateOrderParameters + */ + public function testRenewValidateOrderParameters() + { + $response = $this->object->renewValidateOrderParameters('DV_LOW_SHA2', 'synergypublishers.com', "", false, 'CE20171125014256'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Invalid CSR Returns Error'); + $this->assertObjectHasAttribute('Errors', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "Errors" Exists'); + $this->assertObjectHasAttribute('Error', $response->Response->OrderResponseHeader->Errors, 'Ensuring Valid Respone Field "Error" Exists'); + $this->assertObjectHasAttribute('ErrorCode', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorCode" Exists'); + $this->assertObjectHasAttribute('ErrorMessage', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorMessage" Exists'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::ResendEmail - */ - public function testResendEmail() - { - $response = $this->object->ResendEmail('CE198105220000'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Invalid Order ID Returns Error'); - $this->assertObjectHasAttribute('Errors', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "Errors" Exists'); - $this->assertObjectHasAttribute('Error', $response->Response->OrderResponseHeader->Errors, 'Ensuring Valid Respone Field "Error" Exists'); - $this->assertObjectHasAttribute('ErrorCode', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorCode" Exists'); - $this->assertObjectHasAttribute('ErrorMessage', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorMessage" Exists'); - $response = $this->object->ResendEmail('CE201011028514'); - $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); - $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); - $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); - $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Ensuring we got the proper SuccessCode (0)'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::ResendEmail + */ + public function testResendEmail() + { + $response = $this->object->ResendEmail('CE198105220000'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Invalid Order ID Returns Error'); + $this->assertObjectHasAttribute('Errors', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "Errors" Exists'); + $this->assertObjectHasAttribute('Error', $response->Response->OrderResponseHeader->Errors, 'Ensuring Valid Respone Field "Error" Exists'); + $this->assertObjectHasAttribute('ErrorCode', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorCode" Exists'); + $this->assertObjectHasAttribute('ErrorMessage', $response->Response->OrderResponseHeader->Errors->Error, 'Ensuring Valid Respone Field "ErrorMessage" Exists'); + $response = $this->object->ResendEmail('CE201011028514'); + $this->assertObjectHasAttribute('Response', $response, 'Ensuring Valid Respone Field "Response" Exists'); + $this->assertObjectHasAttribute('OrderResponseHeader', $response->Response, 'Ensuring Valid Respone Field "OrderResponseHeader" Exists'); + $this->assertObjectHasAttribute('SuccessCode', $response->Response->OrderResponseHeader, 'Ensuring Valid Respone Field "SuccessCode" Exists'); + $this->assertEquals($response->Response->OrderResponseHeader->SuccessCode, -1, 'Ensuring we got the proper SuccessCode (0)'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::ChangeApproverEmail - * @todo Implement testChangeApproverEmail(). - */ - public function testChangeApproverEmail() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::ChangeApproverEmail + * @todo Implement testChangeApproverEmail(). + */ + public function testChangeApproverEmail() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::ReIssue - * @todo Implement testReIssue(). - */ - public function testReIssue() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::ReIssue + * @todo Implement testReIssue(). + */ + public function testReIssue() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::DVOrder - * @todo Implement testDVOrder(). - */ - public function testDVOrder() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::DVOrder + * @todo Implement testDVOrder(). + */ + public function testDVOrder() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::DVOrderWithoutCSR - * @todo Implement testDVOrderWithoutCSR(). - */ - public function testDVOrderWithoutCSR() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::DVOrderWithoutCSR + * @todo Implement testDVOrderWithoutCSR(). + */ + public function testDVOrderWithoutCSR() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::OVOrder - * @todo Implement testOVOrder(). - */ - public function testOVOrder() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::OVOrder + * @todo Implement testOVOrder(). + */ + public function testOVOrder() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::OVOrderWithoutCSR - * @todo Implement testOVOrderWithoutCSR(). - */ - public function testOVOrderWithoutCSR() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::OVOrderWithoutCSR + * @todo Implement testOVOrderWithoutCSR(). + */ + public function testOVOrderWithoutCSR() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::EVOrder - * @todo Implement testEVOrder(). - */ - public function testEVOrder() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::EVOrder + * @todo Implement testEVOrder(). + */ + public function testEVOrder() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::create_alphassl - * @todo Implement testCreate_alphassl(). - */ - public function testCreate_alphassl() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::create_alphassl + * @todo Implement testCreate_alphassl(). + */ + public function testCreate_alphassl() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::create_domainssl - * @todo Implement testCreate_domainssl(). - */ - public function testCreate_domainssl() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::create_domainssl + * @todo Implement testCreate_domainssl(). + */ + public function testCreate_domainssl() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::create_domainssl_autocsr - * @todo Implement testCreate_domainssl_autocsr(). - */ - public function testCreate_domainssl_autocsr() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::create_domainssl_autocsr + * @todo Implement testCreate_domainssl_autocsr(). + */ + public function testCreate_domainssl_autocsr() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::create_organizationssl - * @todo Implement testCreate_organizationssl(). - */ - public function testCreate_organizationssl() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::create_organizationssl + * @todo Implement testCreate_organizationssl(). + */ + public function testCreate_organizationssl() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::create_organizationssl_autocsr - * @todo Implement testCreate_organizationssl_autocsr(). - */ - public function testCreate_organizationssl_autocsr() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::create_organizationssl_autocsr + * @todo Implement testCreate_organizationssl_autocsr(). + */ + public function testCreate_organizationssl_autocsr() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::create_extendedssl - * @todo Implement testCreate_extendedssl(). - */ - public function testCreate_extendedssl() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::renewAlphaDomain - * @todo Implement testRenewAlphaDomain(). - */ - public function testRenewAlphaDomain() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::create_extendedssl + * @todo Implement testCreate_extendedssl(). + */ + public function testCreate_extendedssl() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::renewAlphaDomain + * @todo Implement testRenewAlphaDomain(). + */ + public function testRenewAlphaDomain() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::renewDVOrder - * @todo Implement testRenewDVOrder(). - */ - public function testRenewDVOrder() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::renewDVOrder + * @todo Implement testRenewDVOrder(). + */ + public function testRenewDVOrder() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::renewOVOrder - * @todo Implement testRenewOVOrder(). - */ - public function testRenewOVOrder() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::renewOVOrder + * @todo Implement testRenewOVOrder(). + */ + public function testRenewOVOrder() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::renewOrganizationSSL - * @todo Implement testRenewOrganizationSSL(). - */ - public function testRenewOrganizationSSL() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::renewOrganizationSSL + * @todo Implement testRenewOrganizationSSL(). + */ + public function testRenewOrganizationSSL() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::renewEVOrder - * @todo Implement testRenewEVOrder(). - */ - public function testRenewEVOrder() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::renewEVOrder + * @todo Implement testRenewEVOrder(). + */ + public function testRenewEVOrder() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } - /** - * @covers Detain\MyAdminGlobalSign\GlobalSign::renewExtendedSSL - * @todo Implement testRenewExtendedSSL(). - */ - public function testRenewExtendedSSL() - { - $this->markTestIncomplete('This test has not been implemented yet.'); - } + /** + * @covers Detain\MyAdminGlobalSign\GlobalSign::renewExtendedSSL + * @todo Implement testRenewExtendedSSL(). + */ + public function testRenewExtendedSSL() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 63f61df..713343e 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,82 +1,83 @@ '/etc/pki/tls/openssl.cnf', - //'config' => '/etc/ssl/openssl.cnf', - //'config' => '/etc/tinyca/openssl.cnf', - //'config' => '/etc/openvpn/easy-rsa/openssl.cnf', - 'encrypt_key' => true, - 'private_key_type' => OPENSSL_KEYTYPE_RSA, - 'digest_alg' => 'sha2', - 'x509_extensions' => 'v3_ca', - 'private_key_bits' => 2048 - ]; - // $fqdn = domain name for normal certs, individuals full name for s/MIME certs - $dn = [ - 'countryName' => $country, - 'stateOrProvinceName' => $state, - 'localityName' => $city, - 'organizationName' => $company, - 'organizationalUnitName' => $department, - 'commonName' => $fqdn, - 'emailAddress' => $email - ]; - // Generate a new private (and public) key pair - $privkey = openssl_pkey_new($SSLcnf); - // Generate a certificate signing request - $csr = openssl_csr_new($dn, $privkey, $SSLcnf); - openssl_csr_export($csr, $csrout); - // You will usually want to create a self-signed certificate at this point until your CA fulfills your request. This creates a self-signed cert that is valid for 365 days - $sscert = openssl_csr_sign($csr, null, $privkey, 365); - // Now you will want to preserve your private key, CSR and self-signed cert so that they can be installed into your web server, mail server or mail client (depending on the intended use of the certificate). This example shows how to get those things into variables, but you can also store them directly into files. Typically, you will send the CSR on to your CA who will then issue you with the "real" certificate. - openssl_x509_export($sscert, $certout); - openssl_pkey_export($privkey, $pkeout); - // Show any errors that occurred here - //while (($e = openssl_error_string()) !== false) - // echo $e.PHP_EOL; - return [$csrout, $certout, $pkeout]; - } + /** + * make_csr() + * @param string $fqdn + * @param string $email + * @param string $city + * @param string $state + * @param string $country + * @param string $company + * @param string $department + * @return array + */ + function make_csr($fqdn, $email, $city, $state, $country, $company, $department) + { + $SSLcnf = [ + //'config' => '/etc/pki/tls/openssl.cnf', + //'config' => '/etc/ssl/openssl.cnf', + //'config' => '/etc/tinyca/openssl.cnf', + //'config' => '/etc/openvpn/easy-rsa/openssl.cnf', + 'encrypt_key' => true, + 'private_key_type' => OPENSSL_KEYTYPE_RSA, + 'digest_alg' => 'sha2', + 'x509_extensions' => 'v3_ca', + 'private_key_bits' => 2048 + ]; + // $fqdn = domain name for normal certs, individuals full name for s/MIME certs + $dn = [ + 'countryName' => $country, + 'stateOrProvinceName' => $state, + 'localityName' => $city, + 'organizationName' => $company, + 'organizationalUnitName' => $department, + 'commonName' => $fqdn, + 'emailAddress' => $email + ]; + // Generate a new private (and public) key pair + $privkey = openssl_pkey_new($SSLcnf); + // Generate a certificate signing request + $csr = openssl_csr_new($dn, $privkey, $SSLcnf); + openssl_csr_export($csr, $csrout); + // You will usually want to create a self-signed certificate at this point until your CA fulfills your request. This creates a self-signed cert that is valid for 365 days + $sscert = openssl_csr_sign($csr, null, $privkey, 365); + // Now you will want to preserve your private key, CSR and self-signed cert so that they can be installed into your web server, mail server or mail client (depending on the intended use of the certificate). This example shows how to get those things into variables, but you can also store them directly into files. Typically, you will send the CSR on to your CA who will then issue you with the "real" certificate. + openssl_x509_export($sscert, $certout); + openssl_pkey_export($privkey, $pkeout); + // Show any errors that occurred here + //while (($e = openssl_error_string()) !== false) + // echo $e.PHP_EOL; + return [$csrout, $certout, $pkeout]; + } } if (!function_exists('obj2array')) { - function obj2array($obj) - { - $out = []; - //myadmin_log('myadmin', 'debug', json_encode($obj), __LINE__, __FILE__); - foreach ($obj as $key => $val) { - switch (true) { - case is_object($val): - $out[$key] = obj2array($val); - break; - case is_array($val): - $out[$key] = obj2array($val); - break; - default: - $out[$key] = $val; - break; - } - } - return $out; - } + function obj2array($obj) + { + $out = []; + //myadmin_log('myadmin', 'debug', json_encode($obj), __LINE__, __FILE__); + foreach ($obj as $key => $val) { + switch (true) { + case is_object($val): + $out[$key] = obj2array($val); + break; + case is_array($val): + $out[$key] = obj2array($val); + break; + default: + $out[$key] = $val; + break; + } + } + return $out; + } }