summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Model/User
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-05-10 15:23:58 +0200
committerChristian Weiske <cweiske@cweiske.de>2011-05-10 15:23:58 +0200
commitc13689813e71413f3c98664568c47c167c00580a (patch)
tree1dc202379157c1c5926d251b13a148238db249fc /src/SemanticScuttle/Model/User
parent967ba79ece58dd0164accbf46078964c58fec230 (diff)
downloadsemanticscuttle-c13689813e71413f3c98664568c47c167c00580a.tar.gz
semanticscuttle-c13689813e71413f3c98664568c47c167c00580a.tar.bz2
prepare user interface to register and delete client certificates on the profile page
Diffstat (limited to 'src/SemanticScuttle/Model/User')
-rw-r--r--src/SemanticScuttle/Model/User/SslClientCert.php78
1 files changed, 77 insertions, 1 deletions
diff --git a/src/SemanticScuttle/Model/User/SslClientCert.php b/src/SemanticScuttle/Model/User/SslClientCert.php
index ab7b288..383b601 100644
--- a/src/SemanticScuttle/Model/User/SslClientCert.php
+++ b/src/SemanticScuttle/Model/User/SslClientCert.php
@@ -29,9 +29,11 @@ class SemanticScuttle_Model_User_SslClientCert
public $sslName;
public $sslEmail;
+
+
/**
* Creates and returns a new object and fills it with
- * tha passed values from the database.
+ * the passed values from the database.
*
* @param array $arCertRow Database row array
*
@@ -51,6 +53,29 @@ class SemanticScuttle_Model_User_SslClientCert
/**
+ * Loads the user's/browser's client certificate information into
+ * an object and returns it.
+ * Expects that all information is available.
+ * Better check with
+ * SemanticScuttle_Service_User_SslClientCert::hasValidCert() before.
+ *
+ * @return SemanticScuttle_Model_User_SslClientCert
+ *
+ * @see SemanticScuttle_Service_User_SslClientCert::hasValidCert()
+ */
+ public static function fromCurrentCert()
+ {
+ $cert = new self();
+ $cert->sslSerial = $_SERVER['SSL_CLIENT_M_SERIAL'];
+ $cert->sslClientIssuerDn = $_SERVER['SSL_CLIENT_I_DN'];
+ $cert->sslName = $_SERVER['SSL_CLIENT_S_DN_CN'];
+ $cert->sslEmail = $_SERVER['SSL_CLIENT_S_DN_Email'];
+ return $cert;
+ }
+
+
+
+ /**
* Tells you if this certificate is the one the user is currently browsing
* with.
*
@@ -68,5 +93,56 @@ class SemanticScuttle_Model_User_SslClientCert
&& $this->sslClientIssuerDn == $_SERVER['SSL_CLIENT_I_DN'];
}
+
+
+ /**
+ * Checks if this certificate is registered (exists) in the certificate
+ * array
+ *
+ * @param array $arCertificates Array of certificate objects
+ *
+ * @return boolean True or false
+ */
+ public function isRegistered($arCertificates)
+ {
+ foreach ($arCertificates as $cert) {
+ if ($cert->equals($this)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+
+ /**
+ * Deletes this certificate from database
+ *
+ * @return boolean True if all went well, false if not
+ */
+ public function delete()
+ {
+ $ok = SemanticScuttle_Service_Factory::get('User_SslClientCert')
+ ->delete($this);
+ if ($ok) {
+ $this->id = null;
+ }
+ return $ok;
+ }
+
+
+
+ /**
+ * Compares this certificate with the given one.
+ *
+ * @param SemanticScuttle_Service_Factory $cert Another user certificate
+ *
+ * @return boolean True if both match.
+ */
+ public function equals(SemanticScuttle_Model_User_SslClientCert $cert)
+ {
+ return $this->sslSerial == $cert->sslSerial
+ && $this->sslClientIssuerDn == $cert->sslClientIssuerDn;
+ }
}
?> \ No newline at end of file