# Path: webmachine/util/const.py
# KEY_SIZE = 32
# 
# SECRET_SIZE = 32 
# 
# VERIFIER_SIZE = 16
# 
# TOKEN_TYPES = (
#     (TOKEN_ACCESS, _("Access")),
#     (TOKEN_REQUEST, _("Request"))
# )
# 
# PENDING = 1
# 
# CONSUMER_STATES = (
#     (PENDING,  _('Pending')),
#     (ACCEPTED, _('Accepted')),
#     (CANCELED, _('Canceled')),
#     (REJECTED, _('Rejected')),
# )
# 
# Path: webmachine/managers.py
# class ConsumerManager(KeyManager):
# 
#     def create_consumer(self, name=None, description=None, user=None):
#         key, secret = self.generate_key_secret()
#         consumer = self.create(
#                 key=key, 
#                 secret=secret,
#                 name=name or '',
#                 description=description or '', 
#                 user=user
#         )
#         return consumer
# 
# class TokenManager(KeyManager):
# 
#     def create_token(self, consumer, token_type, timestamp, user=None):
#         key, secret = self.generate_key_secret()
#         kwargs = dict(
#             key=key, 
#             secret=secret, 
#             token_type=token_type,
#             consumer=consumer,
#             timestamp=timestamp,
#             user=user
#         )
#         if not user:
#             del kwargs["user"]
#         token = self.create(**kwargs)
#         return token


import time
import urllib
import urlparse
from django.contrib.auth.models import User
from django.db import models
from webmachine.util.const import KEY_SIZE, SECRET_SIZE, VERIFIER_SIZE, \
TOKEN_TYPES, PENDING, CONSUMER_STATES
from webmachine.managers import ConsumerManager, TokenManager
# -*- coding: utf-8 -
#
# This file is part of dj-webmachine released under the MIT license. 
# See the NOTICE for more information.





def generate_random(length=SECRET_SIZE):
    return User.objects.make_random_password(length=length)

class Nonce(models.Model):
    token_key = models.CharField(max_length=KEY_SIZE)
    consumer_key = models.CharField(max_length=KEY_SIZE)
    key = models.CharField(max_length=255)

class Consumer(models.Model):
    name = models.CharField(max_length=255)
    key = models.CharField(max_length=KEY_SIZE)

# Path: webmachine/util/const.py
# KEY_SIZE = 32
# 
# SECRET_SIZE = 32 
# 
# VERIFIER_SIZE = 16
# 
# TOKEN_TYPES = (
#     (TOKEN_ACCESS, _("Access")),
#     (TOKEN_REQUEST, _("Request"))
# )
# 
# PENDING = 1
# 
# CONSUMER_STATES = (
#     (PENDING,  _('Pending')),
#     (ACCEPTED, _('Accepted')),
#     (CANCELED, _('Canceled')),
#     (REJECTED, _('Rejected')),
# )
# 
# Path: webmachine/managers.py
# class ConsumerManager(KeyManager):
# 
#     def create_consumer(self, name=None, description=None, user=None):
#         key, secret = self.generate_key_secret()
#         consumer = self.create(
#                 key=key, 
#                 secret=secret,
#                 name=name or '',
#                 description=description or '', 
#                 user=user
#         )
#         return consumer
# 
# class TokenManager(KeyManager):
# 
#     def create_token(self, consumer, token_type, timestamp, user=None):
#         key, secret = self.generate_key_secret()
#         kwargs = dict(
#             key=key, 
#             secret=secret, 
#             token_type=token_type,
#             consumer=consumer,
#             timestamp=timestamp,
#             user=user
#         )
#         if not user:
#             del kwargs["user"]
#         token = self.create(**kwargs)
#         return token


# Path: webmachine/models.py
import time
import urllib
import urlparse
from django.contrib.auth.models import User
from django.db import models
from webmachine.util.const import KEY_SIZE, SECRET_SIZE, VERIFIER_SIZE, \
TOKEN_TYPES, PENDING, CONSUMER_STATES
from webmachine.managers import ConsumerManager, TokenManager

# -*- coding: utf-8 -
#
# This file is part of dj-webmachine released under the MIT license. 
# See the NOTICE for more information.





def generate_random(length=SECRET_SIZE):
    return User.objects.make_random_password(length=length)

class Nonce(models.Model):
    token_key = models.CharField(max_length=KEY_SIZE)
    consumer_key = models.CharField(max_length=KEY_SIZE)
    key = models.CharField(max_length=255)

class Consumer(models.Model):
    name = models.CharField(max_length=255)
    key = models.CharField(max_length=KEY_SIZE)

    secret = models.CharField(max_length=SECRET_SIZE)