adding a token service Driver to define the interface

This commit is contained in:
Joe Heck 2012-02-05 16:24:42 -08:00
parent 446b26850d
commit fca3e9c045
2 changed files with 49 additions and 1 deletions

View File

@ -1,9 +1,10 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
from keystone import token
from keystone.common import kvs
class Token(kvs.Base):
class Token(kvs.Base, token.Driver):
# Public interface
def get_token(self, token_id):
return self.db.get('token-%s' % token_id)

View File

@ -19,3 +19,50 @@ class Manager(manager.Manager):
def __init__(self):
super(Manager, self).__init__(CONF.token.driver)
class Driver(object):
"""Interface description for a Token driver."""
def get_token(self, token_id):
"""Get a token by id.
:param token_id: identity of the token
:type token_id: string
:returns: token_ref or None.
"""
raise NotImplementedError()
def create_token(self, token_id, data):
"""Create a token by id and data.
:param token_id: identity of the token
:type token_id: string
:param data: dictionary with additional reference information
::
{
expires=''
id=token_id,
user=user_ref,
tenant=tenant_ref,
metadata=metadata_ref
}
:type data: dict
:returns: token_ref or None.
"""
raise NotImplementedError()
def delete_token(self, token_id):
"""Deletes a token by id.
:param token_id: identity of the token
:type token_id: string
:returns: None.
"""
raise NotImplementedError()