]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
db_objectified magic sig - for persistence of local keypairs
authorJames Walker <walkah@walkah.net>
Tue, 23 Feb 2010 03:55:26 +0000 (22:55 -0500)
committerJames Walker <walkah@walkah.net>
Tue, 23 Feb 2010 04:30:31 +0000 (23:30 -0500)
plugins/OStatus/classes/Magicsig.php

index 9d9d3274472d03134aa86c2f266eb2e9c4a7d72e..6d09c54ecb2735a75df876974f20a0f694db87c8 100644 (file)
 
 require_once 'Crypt/RSA.php';
 
-class Magicsig
+class Magicsig extends Memcached_DataObject
 {
 
+    public $__table = 'magicsig';
+
+    public $user_id;
     public $keypair;
+    public $alg;
     
-    public function __construct($init = null)
+    private $_rsa;
+
+    public /*static*/ function staticGet($k, $v=null)
     {
-        if (is_null($init)) {
-            $this->generate();
-        } else {
-            $this->fromString($init);
-        }
+        return parent::staticGet(__CLASS__, $k, $v);
+    }
+
+
+    function table()
+    {
+        return array(
+            'user_id' => DB_DATAOBJECT_INT,
+            'keypair' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+            'alg'     => DB_DATAOBJECT_STR
+        );
+    }
+
+    static function schemaDef()
+    {
+        return array(new ColumnDef('user_id', 'integer',
+                                   null, true, 'PRI'),
+                     new ColumnDef('keypair', 'varchar',
+                                   255, false),
+                     new ColumnDef('alg', 'varchar',
+                                   64, false));
     }
 
 
+    function keys()
+    {
+        return array_keys($this->keyTypes());
+    }
+
+    function keyTypes()
+    {
+        return array('user_id' => 'K');
+    }
+    
     public function generate($key_length = 512)
     {
         $keypair = new Crypt_RSA_KeyPair($key_length);