[ Avaa Bypassed ]




Upload:

Command:

www-data@3.143.211.215: ~ $
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
import abc
import os


class MemoryOpsStore:
    ''' A multi-op store that stores the operations in memory.
    '''
    def __init__(self):
        self._store = {}

    def put_ops(self, key, time, ops):
        ''' Put an ops only if not already there, otherwise it's a no op.
        '''
        if self._store.get(key) is None:
            self._store[key] = ops

    def get_ops(self, key):
        ''' Returns ops from the key if found otherwise raises a KeyError.
        '''
        ops = self._store.get(key)
        if ops is None:
            raise KeyError(
                'cannot get operations for {}'.format(key))
        return ops


class RootKeyStore(object):
    ''' Defines a store for macaroon root keys.
    '''
    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def get(self, id):
        ''' Returns the root key for the given id.
        If the item is not there, it returns None.
        @param id: bytes
        @return: bytes
        '''
        raise NotImplementedError('get method must be defined in '
                                  'subclass')

    @abc.abstractmethod
    def root_key(self):
        ''' Returns the root key to be used for making a new macaroon, and an
        id that can be used to look it up later with the get method.
        Note that the root keys should remain available for as long as the
        macaroons using them are valid.
        Note that there is no need for it to return a new root key for every
        call - keys may be reused, although some key cycling is over time is
        advisable.
        @return: bytes
        '''


class MemoryKeyStore(RootKeyStore):
    ''' MemoryKeyStore returns an implementation of
    Store that generates a single key and always
    returns that from root_key. The same id ("0") is always
    used.
    '''
    def __init__(self, key=None):
        ''' If the key is not specified a random key will be generated.
        @param key: bytes
        '''
        if key is None:
            key = os.urandom(24)
        self._key = key

    def get(self, id):
        if id != b'0':
            return None
        return self._key

    def root_key(self):
        return self._key, b'0'

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
_internal Folder 0755
__init__.py File 2.62 KB 0644
_authorizer.py File 4.01 KB 0644
_bakery.py File 3.13 KB 0644
_checker.py File 16.33 KB 0644
_codec.py File 10.2 KB 0644
_discharge.py File 9.16 KB 0644
_error.py File 2.26 KB 0644
_identity.py File 4.05 KB 0644
_keys.py File 2.87 KB 0644
_macaroon.py File 15.18 KB 0644
_oven.py File 10.39 KB 0644
_store.py File 2.24 KB 0644
_third_party.py File 2.01 KB 0644
_versions.py File 176 B 0644