1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-06-06 11:07:47 +02:00
ldapcherry/ldapcherry/exceptions.py

217 lines
5.9 KiB
Python
Raw Normal View History

2015-04-15 21:13:14 +02:00
# -*- coding: utf-8 -*-
# vim:set expandtab tabstop=4 shiftwidth=4:
#
# The MIT License (MIT)
# LdapCherry
# Copyright (c) 2014 Carpentier Pierre-Francois
2015-05-26 22:51:57 +02:00
import string
2015-07-10 21:06:28 +02:00
2015-04-15 23:10:01 +02:00
class MissingParameter(Exception):
def __init__(self, section, key):
self.section = section
self.key = key
self.log = \
"missing parameter '%(key)s' in section '%(section)s'" % \
{'key': key, 'section': section}
2015-07-10 21:06:28 +02:00
2015-05-12 01:24:16 +02:00
class MissingKey(Exception):
2015-05-14 22:10:26 +02:00
def __init__(self, key, section, ymlfile):
2015-05-12 01:24:16 +02:00
self.key = key
2015-05-14 22:10:26 +02:00
self.section = section
self.ymlfile = ymlfile
self.log = \
"missing key '%(key)s' in section '%(section)s'" \
" inside file '%(ymlfile)s'" % \
{'key': key, 'section': section, 'ymlfile': ymlfile}
2015-07-10 21:06:28 +02:00
2015-05-12 01:24:16 +02:00
class DumplicateRoleKey(Exception):
def __init__(self, role):
self.role = role
self.log = \
"duplicate role key '%(role)s' in role file" % \
{'role': role}
2015-07-10 21:06:28 +02:00
2015-05-12 01:24:16 +02:00
class MissingRole(Exception):
def __init__(self, role):
self.role = role
self.log = \
"role '%(role)s' does not exist in role file" % \
{'role': role}
2015-07-10 21:06:28 +02:00
class MissingBackend(Exception):
def __init__(self, backend):
self.backend = backend
self.log = \
"backend '%(backend)s' does not exist in main config file" % \
{'backend': backend}
2015-07-10 21:06:28 +02:00
class WrongBackend(Exception):
def __init__(self, backend):
self.backend = backend
self.log = \
"backend '%(backend)s' does not exist" % \
{'backend': backend}
2015-07-10 21:06:28 +02:00
2015-05-12 01:24:16 +02:00
class DumplicateRoleContent(Exception):
def __init__(self, role1, role2):
self.role1 = role1
self.role2 = role2
self.log = \
"role '%(role1)s' and '%(role2)s' are identical" % \
{'role1': role1, 'role2': role2}
2015-07-10 21:06:28 +02:00
class MissingRolesFile(Exception):
def __init__(self, rolefile):
self.rolefile = rolefile
self.log = \
"fail to open role file '%(rolefile)s'" % \
{'rolefile': rolefile}
2015-07-10 21:06:28 +02:00
2015-05-17 12:24:29 +02:00
class PasswordMissMatch(Exception):
def __init__(self):
self.log = "password missmatch"
class PPolicyError(Exception):
def __init__(self):
self.log = "password doesn't match ppolicy"
class MissingMainFile(Exception):
def __init__(self, config):
self.rolefile = rolefile
self.log = \
"fail to open main file '%(config)s'" % \
{'rolefile': rolefile}
2015-07-10 21:06:28 +02:00
2015-05-17 12:24:29 +02:00
class MissingAttributesFile(Exception):
def __init__(self, attributesfile):
self.attributesfile = attributesfile
self.log = \
"fail to open attributes file '%(attributesfile)s'" % \
{'attributesfile': attributesfile}
2015-07-10 21:06:28 +02:00
2015-05-17 19:49:13 +02:00
class BackendModuleLoadingFail(Exception):
def __init__(self, module):
self.module = module
self.log = \
"module '%(module)s' not in python path" % \
{'module': module}
2015-07-10 21:06:28 +02:00
class BackendModuleInitFail(Exception):
def __init__(self, module):
self.module = module
self.log = \
"fail to init module '%(module)s'" % \
{'module': module}
2015-07-10 21:06:28 +02:00
2015-05-26 22:51:57 +02:00
class WrongParamValue(Exception):
def __init__(self, param, section, possible_values):
self.possible_values = possible_values
self.section = section
self.param = param
possible_values_str = string.join(possible_values, ', ')
self.log = \
"wrong value for param '%(param)s' in section '%(section)s'"\
", possible values are [%(values)s]" % \
{
'param': param,
'section': section,
'values': possible_values_str
}
2015-05-26 22:51:57 +02:00
2015-07-10 21:06:28 +02:00
2015-05-31 18:07:46 +02:00
class DumplicateUserKey(Exception):
def __init__(self, attrid1, attrid2):
self.attrid1 = attrid1
self.attrid2 = attrid2
self.log = \
"duplicate key in '%(attrid1)s' and '%(attrid2)s'" % \
{'attrid1': attrid1, 'attrid2': attrid2}
2015-05-31 18:07:46 +02:00
2015-07-10 21:06:28 +02:00
2015-05-31 18:07:46 +02:00
class MissingUserKey(Exception):
def __init__(self):
self.log = "missing key"
2015-07-10 21:06:28 +02:00
2015-05-17 19:49:13 +02:00
class WrongAttributeType(Exception):
def __init__(self, key, section, ymlfile):
self.key = key
self.section = section
self.ymlfile = ymlfile
self.log = \
"wrong attribute type '%(key)s'" \
" in section '%(section)s'" \
" inside file '%(ymlfile)s'" % \
{'key': key, 'section': section, 'ymlfile': ymlfile}
class PasswordAttributesCollision(Exception):
def __init__(self, key):
self.key = key
self.log = \
"key '" + key + "' type is password," \
" keys '" + key + "1' and '" + key + "2'"\
" are reserved and cannot be used"
class WrongAttrValue(Exception):
def __init__(self, attr, attrtype):
self.attr = attr
self.attrtype = attrtype
self.log = \
"input for attribute '" + attr + "'" \
" doesn't match type '" + attrtype + "'"
class AttrNotDefined(Exception):
def __init__(self, attr):
self.attr = attr
self.log = \
"attribute '" + attr + "' is not defined in configuration"
2015-07-14 23:37:20 +02:00
class UserDoesntExist(Exception):
def __init__(self, user, backend):
self.user = user
self.bakend = backend
self.log = \
"user '" + user + "'" \
" does not exist" \
" in backend '" + backend + "'"
class UserAlreadyExists(Exception):
def __init__(self, user, backend):
self.user = user
self.bakend = backend
self.log = \
"user '" + user + "'" \
" already exists" \
" in backend '" + backend + "'"
2015-07-14 23:37:20 +02:00
class GroupDoesntExist(Exception):
def __init__(self, group, backend):
self.group = group
self.bakend = backend
self.log = \
"group '" + group + "'" \
" does not exist" \
" in backend '" + backend + "'"