summaryrefslogtreecommitdiff
path: root/plugins/OStatus
diff options
context:
space:
mode:
authorJames Walker <walkah@walkah.net>2010-02-22 22:55:26 -0500
committerJames Walker <walkah@walkah.net>2010-02-22 23:30:31 -0500
commit74f5c1e16968110caefeeb8431869897f2f8ddfb (patch)
treee42a0c1f43a05d7ce59e3dc7f5a198caafad1a33 /plugins/OStatus
parentcb32b676fa4d7e95ec32c3e8968d0ccddbfa42fa (diff)
db_objectified magic sig - for persistence of local keypairs
Diffstat (limited to 'plugins/OStatus')
-rw-r--r--plugins/OStatus/classes/Magicsig.php46
1 files changed, 39 insertions, 7 deletions
diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php
index 9d9d32744..6d09c54ec 100644
--- a/plugins/OStatus/classes/Magicsig.php
+++ b/plugins/OStatus/classes/Magicsig.php
@@ -29,21 +29,53 @@
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);