Improvements to SSL classes
This commit is contained in:
@@ -35,68 +35,51 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
|
||||
public function username_value() {} // Not used
|
||||
public function password_value() {} // Not used
|
||||
|
||||
public function service_view() {
|
||||
return View::factory('service/user/plugin/ssl/view')
|
||||
->set('so',$this);
|
||||
private $_so = NULL;
|
||||
|
||||
/**
|
||||
* Resolve any queries to certificate details
|
||||
*/
|
||||
public function __call($name,$args) {
|
||||
$m = 'get_'.$name;
|
||||
|
||||
if (method_exists($this->_so,$m))
|
||||
return $this->_so->{$m}($args);
|
||||
else
|
||||
throw new Kohana_Exception('Unknown method :method',array(':method'=>$name));
|
||||
}
|
||||
|
||||
// We want to inject the SSL object into this Model
|
||||
protected function _load_values(array $values) {
|
||||
parent::_load_values($values);
|
||||
|
||||
if ($this->cert)
|
||||
$this->_so = SSL::instance($this->cert);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// If we change the SSL certificate, we need to reload our SSL object
|
||||
public function values(array $values, array $expected = NULL) {
|
||||
parent::values($values,$expected);
|
||||
|
||||
if (array_key_exists('cert',$values))
|
||||
$this->_so = SSL::instance($this->cert);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function expire() {
|
||||
return $this->valid_to();
|
||||
return $this->_so->get_valid_to();
|
||||
}
|
||||
|
||||
public function name() {
|
||||
if ($this->cert) {
|
||||
return sprintf('%s:%s',$this->ssl_ca->subject(),$this->display('cert'));
|
||||
} else
|
||||
return $this->display('csr');
|
||||
return ($this->cert) ? sprintf('%s:%s',$this->ssl_ca->subject(),$this->display('cert')) : $this->display('csr');
|
||||
}
|
||||
|
||||
public function algorithm() {
|
||||
return SSL::algorithm($this->cert);
|
||||
}
|
||||
|
||||
public function dn() {
|
||||
return SSL::dn($this->cert);
|
||||
}
|
||||
|
||||
public function dnissuer() {
|
||||
return SSL::dnissuer($this->cert);
|
||||
}
|
||||
|
||||
public function issuer() {
|
||||
return SSL::issuer($this->cert);
|
||||
}
|
||||
|
||||
// @todo This needs to be validated for this model
|
||||
public function product() {
|
||||
if ($this->provided_adsl_plan_id)
|
||||
return $this->adsl_plan;
|
||||
else
|
||||
return $this->service->product->plugin();
|
||||
}
|
||||
|
||||
public function details() {
|
||||
return SSL::details($this->cert);
|
||||
}
|
||||
|
||||
public function valid_from($format=FALSE) {
|
||||
return SSL::from($this->cert,$format);
|
||||
}
|
||||
|
||||
public function valid_to($format=FALSE) {
|
||||
return SSL::expire($this->cert,$format);
|
||||
}
|
||||
|
||||
public function serial_num() {
|
||||
return SSL::serial($this->cert);
|
||||
}
|
||||
|
||||
public function hash() {
|
||||
return SSL::hash($this->cert);
|
||||
}
|
||||
|
||||
public function version() {
|
||||
return SSL::version($this->cert);
|
||||
public function service_view() {
|
||||
return View::factory('service/user/plugin/ssl/view')
|
||||
->set('so',$this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user