#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Exceptions generated by CAS
"""

from bouser.excs import SerializableBaseException

__author__ = 'viruzzz-kun'
__created__ = '08.02.2015'


class EExpiredToken(SerializableBaseException):
    """
    Raised when authentication token is expired or was never taken
    """
    def __init__(self, token):
        self.token = token
        self.message = 'Token %s is expired or not taken' % token.encode('hex')


class ETokenAlreadyAcquired(SerializableBaseException):
    """
    Raised when authentication token was already acquired for the user and another is tried to be acquired
    """
    def __init__(self, user_id):
        self.message = 'Token for user id = %s already taken' % user_id


class EInvalidCredentials(SerializableBaseException):
    """
    Raised when invalid credentials were supplied
    """
    def __init__(self):
        self.message = 'Incorrect login or password'


class ENoToken(SerializableBaseException):
    """
    Raised when token-dependent operation was requested, but token was not supplied
    """
    def __init__(self):
        self.message = 'Token cookie is not set'

