# Path: src/custodia/compat.py

# 
# Path: src/custodia/log.py
# LOGGING_FORMAT = "%(asctime)s - %(origin)-32s - %(message)s"
# LOGGING_DATEFORMAT = "%Y-%m-%d %H:%M:%S"
# AUDIT_NONE = 0
# AUDIT_GET_ALLOWED = 1
# AUDIT_GET_DENIED = 2
# AUDIT_SET_ALLOWED = 3
# AUDIT_SET_DENIED = 4
# AUDIT_DEL_ALLOWED = 5
# AUDIT_DEL_DENIED = 6
# AUDIT_LAST = 7
# AUDIT_SVC_NONE = 8
# AUDIT_SVC_AUTH_PASS = 9
# AUDIT_SVC_AUTH_FAIL = 10
# AUDIT_SVC_AUTHZ_PASS = 11
# AUDIT_SVC_AUTHZ_FAIL = 12
# AUDIT_SVC_LAST = 13
# AUDIT_MESSAGES = [
#     "AUDIT FAILURE",
#     "ALLOWED: '%(client)s' requested key '%(key)s'",  # AUDIT_GET_ALLOWED
#     "DENIED: '%(client)s' requested key '%(key)s'",   # AUDIT_GET_DENIED
#     "ALLOWED: '%(client)s' stored key '%(key)s'",     # AUDIT_SET_ALLOWED
#     "DENIED: '%(client)s' stored key '%(key)s'",      # AUDIT_SET_DENIED
#     "ALLOWED: '%(client)s' deleted key '%(key)s'",    # AUDIT_DEL_ALLOWED
#     "DENIED: '%(client)s' deleted key '%(key)s'",     # AUDIT_DEL_DENIED
#     "AUDIT FAILURE 7",
#     "AUDIT FAILURE 8",
#     "PASS: '%(cli)s' authenticated as '%(name)s'",  # SVC_AUTH_PASS
#     "FAIL: '%(cli)s' authenticated as '%(name)s'",  # SVC_AUTH_FAIL
#     "PASS: '%(cli)s' authorized for '%(name)s'",    # SVC_AUTHZ_PASS
#     "FAIL: '%(cli)s' authorized for '%(name)s'",    # SVC_AUTHZ_FAIL
#     "AUDIT FAILURE 13",
# ]
# class OriginContextFilter(logging.Filter):
# class CustodiaFormatter(logging.Formatter):
# class CustodiaLoggingAdapter(logging.LoggerAdapter):
# class AuditLog(object):
# class ProvisionalWarning(FutureWarning):
#     def filter(self, record):
#     def format(self, record):
#     def __init__(self, plugin, debug):
#     def exception(self, msg, *args, **kwargs):
# def getLogger(name):
#     def exception(self, msg, *args, **kwargs):
# def setup_logging(debug=False, auditfile=None, handler=None):
#     def __init__(self, logger):
#     def key_access(self, origin, action, client, keyname):
#     def svc_access(self, origin, action, client, name):
# def warn_provisional(modulename, stacklevel=3):


import abc
import grp
import inspect
import json
import pwd
import re
import sys
import six
from jwcrypto.common import json_encode
from .compat import configparser
from .log import CustodiaLoggingAdapter, auditlog, getLogger
    def _get_regex(self, section, name, default):
        value = self.parser.get(section, name, fallback=default)
        if not value:
            return None
        else:
            return re.compile(value)

    def _get_str(self, section, name, default):
        return self.parser.get(section, name, fallback=default)

    def _split_string(self, value):
        if ',' in value:
            values = value.split(',')
        else:
            values = value.split(' ')
        return list(v.strip() for v in values if v.strip())

    def _get_str_set(self, section, name, default):
        try:
            value = self.parser.get(section, name)
        except configparser.NoOptionError:
            return default
        if not value or not value.strip():
            return None
        else:
            return set(self._split_string(value))

    def _get_str_list(self, section, name, default):
        try:
            value = self.parser.get(section, name)

# Path: src/custodia/compat.py

# 
# Path: src/custodia/log.py
# LOGGING_FORMAT = "%(asctime)s - %(origin)-32s - %(message)s"
# LOGGING_DATEFORMAT = "%Y-%m-%d %H:%M:%S"
# AUDIT_NONE = 0
# AUDIT_GET_ALLOWED = 1
# AUDIT_GET_DENIED = 2
# AUDIT_SET_ALLOWED = 3
# AUDIT_SET_DENIED = 4
# AUDIT_DEL_ALLOWED = 5
# AUDIT_DEL_DENIED = 6
# AUDIT_LAST = 7
# AUDIT_SVC_NONE = 8
# AUDIT_SVC_AUTH_PASS = 9
# AUDIT_SVC_AUTH_FAIL = 10
# AUDIT_SVC_AUTHZ_PASS = 11
# AUDIT_SVC_AUTHZ_FAIL = 12
# AUDIT_SVC_LAST = 13
# AUDIT_MESSAGES = [
#     "AUDIT FAILURE",
#     "ALLOWED: '%(client)s' requested key '%(key)s'",  # AUDIT_GET_ALLOWED
#     "DENIED: '%(client)s' requested key '%(key)s'",   # AUDIT_GET_DENIED
#     "ALLOWED: '%(client)s' stored key '%(key)s'",     # AUDIT_SET_ALLOWED
#     "DENIED: '%(client)s' stored key '%(key)s'",      # AUDIT_SET_DENIED
#     "ALLOWED: '%(client)s' deleted key '%(key)s'",    # AUDIT_DEL_ALLOWED
#     "DENIED: '%(client)s' deleted key '%(key)s'",     # AUDIT_DEL_DENIED
#     "AUDIT FAILURE 7",
#     "AUDIT FAILURE 8",
#     "PASS: '%(cli)s' authenticated as '%(name)s'",  # SVC_AUTH_PASS
#     "FAIL: '%(cli)s' authenticated as '%(name)s'",  # SVC_AUTH_FAIL
#     "PASS: '%(cli)s' authorized for '%(name)s'",    # SVC_AUTHZ_PASS
#     "FAIL: '%(cli)s' authorized for '%(name)s'",    # SVC_AUTHZ_FAIL
#     "AUDIT FAILURE 13",
# ]
# class OriginContextFilter(logging.Filter):
# class CustodiaFormatter(logging.Formatter):
# class CustodiaLoggingAdapter(logging.LoggerAdapter):
# class AuditLog(object):
# class ProvisionalWarning(FutureWarning):
#     def filter(self, record):
#     def format(self, record):
#     def __init__(self, plugin, debug):
#     def exception(self, msg, *args, **kwargs):
# def getLogger(name):
#     def exception(self, msg, *args, **kwargs):
# def setup_logging(debug=False, auditfile=None, handler=None):
#     def __init__(self, logger):
#     def key_access(self, origin, action, client, keyname):
#     def svc_access(self, origin, action, client, name):
# def warn_provisional(modulename, stacklevel=3):


# Path: src/custodia/plugin.py
import abc
import grp
import inspect
import json
import pwd
import re
import sys
import six
from jwcrypto.common import json_encode
from .compat import configparser
from .log import CustodiaLoggingAdapter, auditlog, getLogger

    def _get_regex(self, section, name, default):
        value = self.parser.get(section, name, fallback=default)
        if not value:
            return None
        else:
            return re.compile(value)

    def _get_str(self, section, name, default):
        return self.parser.get(section, name, fallback=default)

    def _split_string(self, value):
        if ',' in value:
            values = value.split(',')
        else:
            values = value.split(' ')
        return list(v.strip() for v in values if v.strip())

    def _get_str_set(self, section, name, default):
        try:
            value = self.parser.get(section, name)
        except configparser.NoOptionError:
            return default
        if not value or not value.strip():
            return None
        else:
            return set(self._split_string(value))

    def _get_str_list(self, section, name, default):
        try:
            value = self.parser.get(section, name)

        except configparser.NoOptionError: