Skip to content
This repository has been archived by the owner on Dec 20, 2020. It is now read-only.

Commit

Permalink
Refactored to have a parallel API to other cert drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
pcbaldwin committed Sep 27, 2018
1 parent 00b3b00 commit 04919fa
Show file tree
Hide file tree
Showing 7 changed files with 473 additions and 351 deletions.
55 changes: 28 additions & 27 deletions controllers/certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* @package lets-encrypt
* @subpackage controllers
* @author eGloo <developer@egloo.ca>
* @copyright 2017 Marc Laporte
* @copyright 2017-2018 Marc Laporte
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later
* @link https://github.com/eglooca/app-lets-encrypt
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -40,9 +40,9 @@
* @package lets-encrypt
* @subpackage controllers
* @author eGloo <developer@egloo.ca>
* @copyright 2017 Marc Laporte
* @copyright 2017-2018 Marc Laporte
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later
* @link https://github.com/eglooca/app-lets-encrypt
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

class Certificate extends ClearOS_Controller
Expand All @@ -59,13 +59,13 @@ function index()
//------------------

$this->lang->load('lets_encrypt');
$this->load->library('lets_encrypt/Lets_Encrypt');
$this->load->library('lets_encrypt/Certificates_Class');

// Load view data
//---------------

try {
$data['certificates'] = $this->lets_encrypt->get_certificates();
$data['certificates'] = $this->certificates_class->listing();
} catch (Engine_Engine_Exception $e) {
$this->page->view_exception($e);
return;
Expand All @@ -89,14 +89,15 @@ function add()
//------------------

$this->lang->load('lets_encrypt');
$this->load->library('lets_encrypt/Lets_Encrypt');
$this->load->library('lets_encrypt/Certificates_Class');
$this->load->library('lets_encrypt/Lets_Encrypt_Class');

// Set validation rules
//---------------------

$this->form_validation->set_policy('email', 'lets_encrypt/Lets_Encrypt', 'validate_email', TRUE);
$this->form_validation->set_policy('domain', 'lets_encrypt/Lets_Encrypt', 'validate_domain', TRUE);
$this->form_validation->set_policy('domains', 'lets_encrypt/Lets_Encrypt', 'validate_domains');
$this->form_validation->set_policy('email', 'lets_encrypt/Certificates_Class', 'validate_email', TRUE);
$this->form_validation->set_policy('domain', 'lets_encrypt/Certificates_Class', 'validate_domain', TRUE);
$this->form_validation->set_policy('domains', 'lets_encrypt/Certificates_Class', 'validate_domains');
$form_ok = $this->form_validation->run();

// Handle form submit
Expand All @@ -121,7 +122,7 @@ function add()
//---------------

try {
$data['email'] = $this->lets_encrypt->get_email();
$data['email'] = $this->lets_encrypt_class->get_email();
} catch (Engine_Engine_Exception $e) {
$this->page->view_exception($e);
return;
Expand All @@ -145,12 +146,12 @@ function add_ajax()
//------------------

$this->lang->load('lets_encrypt');
$this->load->library('lets_encrypt/Lets_Encrypt');
$this->load->library('lets_encrypt/Certificates_Class');

// Add certificate
//----------------

$error = $this->lets_encrypt->add(
$error = $this->certificates_class->create(
$this->input->post('email'),
$this->input->post('domain'),
$this->input->post('domains')
Expand Down Expand Up @@ -191,13 +192,13 @@ function destroy($certificate)
// Load libraries
//---------------

$this->load->library('Lets_Encrypt');
$this->load->library('Certificates_Class');

// Handle form submit
//-------------------

try {
$this->lets_encrypt->delete($certificate);
$this->lets_encrypt_class->delete($certificate);
$this->page->set_status_deleted();

redirect('/lets_encrypt');
Expand All @@ -222,8 +223,8 @@ function view($certificate, $is_new = FALSE)
//------------------

$this->lang->load('lets_encrypt');
$this->load->library('lets_encrypt/Lets_Encrypt');
$this->load->library('certificate_manager/Certificate_Manager');
$this->load->library('lets_encrypt/Certificates_Class');
$this->load->library('certificate_manager/Certificate_Store');

// Load view data
//---------------
Expand All @@ -234,15 +235,15 @@ function view($certificate, $is_new = FALSE)

if ($form_type === 'add') {
} else {
$attributes = $this->lets_encrypt->get_certificate_attributes($certificate);
$attributes = $this->certificates_class->get($certificate);

$data['issued'] = $attributes['issued'];
$data['expires'] = $attributes['expires'];
$data['key_size'] = $attributes['key_size'];
$data['domains'] = $attributes['domains'];
$data['details'] = $attributes['details'];
$data['issued'] = $attributes['certificate']['issued'];
$data['expires'] = $attributes['certificate']['expires'];
$data['key_size'] = $attributes['certificate']['key_size'];
$data['domains'] = $attributes['certificate']['domains'];
$data['details'] = $attributes['certificate']['details'];

$data['state'] = $this->certificate_manager->get_state($certificate);
$data['state'] = $this->certificate_store->get_state($certificate);
$data['is_new'] = $is_new;
}
} catch (Exception $e) {
Expand All @@ -269,13 +270,13 @@ function download($certificate)
// Load dependencies
//------------------

$this->load->library('lets_encrypt/Lets_Encrypt');
$this->load->library('lets_encrypt/Certificates_Class');

// Load view data
//---------------

try {
$attributes = $this->lets_encrypt->get_certificate_attributes($certificate);
$attributes = $this->lets_encrypt_class->get_certificate_attributes($certificate);
} catch (Engine_Exception $e) {
$this->page->view_exception($e);
return;
Expand Down Expand Up @@ -307,7 +308,7 @@ function get_log($certificate)
// Load dependencies
//------------------

$this->load->library('lets_encrypt/Lets_Encrypt');
$this->load->library('lets_encrypt/Certificates_Class');

// Grab data
//----------
Expand Down
16 changes: 8 additions & 8 deletions controllers/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* @package lets-encrypt
* @subpackage controllers
* @author eGloo <developer@egloo.ca>
* @copyright 2017 Marc Laporte
* @copyright 2017-2018 Marc Laporte
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later
* @link https://github.com/eglooca/app-lets-encrypt
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -40,9 +40,9 @@
* @package lets-encrypt
* @subpackage controllers
* @author eGloo <developer@egloo.ca>
* @copyright 2017 Marc Laporte
* @copyright 2017-2018 Marc Laporte
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later
* @link https://github.com/eglooca/app-lets-encrypt
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

class Settings extends ClearOS_Controller
Expand Down Expand Up @@ -94,20 +94,20 @@ function _common($form_type)
//------------------

$this->lang->load('lets_encrypt');
$this->load->library('lets_encrypt/Lets_Encrypt');
$this->load->library('lets_encrypt/Lets_Encrypt_Class');

// Set validation rules
//---------------------

$this->form_validation->set_policy('email', 'lets_encrypt/Lets_Encrypt', 'validate_email', TRUE);
$this->form_validation->set_policy('email', 'lets_encrypt/Lets_Encrypt_Class', 'validate_email', TRUE);
$form_ok = $this->form_validation->run();

// Handle form submit
//-------------------

if ($this->input->post('submit') && $form_ok) {
try {
$this->lets_encrypt->set_email($this->input->post('email'));
$this->lets_encrypt_class->set_email($this->input->post('email'));

$this->page->set_status_updated();
redirect('/lets_encrypt/settings');
Expand All @@ -122,7 +122,7 @@ function _common($form_type)

try {
$data['form_type'] = $form_type;
$data['email'] = $this->lets_encrypt->get_email();
$data['email'] = $this->lets_encrypt_class->get_email();
} catch (Exception $e) {
$this->page->view_exception($e);
return;
Expand Down
2 changes: 1 addition & 1 deletion deploy/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

$app['core_requires'] = array(
'app-network-core',
'app-certificate-manager-core >= 1:2.4.10',
'app-certificate-manager-core >= 1:2.5.10',
'app-events-core',
'app-tasks-core',
'certbot >= 0.21.0'
Expand Down
5 changes: 2 additions & 3 deletions htdocs/lets_encrypt.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* @package lets-encrypt
* @subpackage javascript
* @author eGloo <developer@egloo.ca>
* @copyright 2017 Marc Laporte
* @copyright 2017-2018 Marc Laporte
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later
* @link https://github.com/eglooca/app-lets-encrypt
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -83,4 +83,3 @@ function showLog(payload) {
});

// vim: ts=4 syntax=javascript

Loading

0 comments on commit 04919fa

Please sign in to comment.