Exemple #1
0
def execute_delete(pub_key_address):
    client = PubKeyClient()
    try:
        pub_key_data = client.get_status(pub_key_address)
        if pub_key_data.revoked:
            return {'error': 'The pub_key was already revoked'}, 409
        return client.revoke_pub_key(pub_key_address)
    except KeyNotFound:
        return NoContent, 404
Exemple #2
0
def execute_post(pub_key_address):
    client = PubKeyClient()
    try:
        pub_key_data = client.get_status(pub_key_address)
        now = time.time()
        valid_from = pub_key_data.payload.valid_from
        valid_to = pub_key_data.payload.valid_to
        return {'revoked': pub_key_data.revoked,
                'owner_pub_key': pub_key_data.owner,
                'entity_hash': pub_key_data.payload.entity_hash,
                'valid': not pub_key_data.revoked and valid_from < now and now < valid_to,
                'valid_from': valid_from,
                'valid_to': valid_to}
    except KeyNotFound:
        return NoContent, 404
Exemple #3
0
async def get_public_key_info(request):
    request.params = request.params or {}
    try:
        public_key_address = request.params['public_key_address']
    except KeyError:
        raise RpcInvalidParamsError(message='Missed public_key_address')

    client = PubKeyClient()
    try:
        pub_key_data = client.get_status(public_key_address)
        now = time.time()
        valid_from = pub_key_data.payload.valid_from
        valid_to = pub_key_data.payload.valid_to
        return {'is_revoked': pub_key_data.revoked,
                'owner_public_key': pub_key_data.owner,
                'is_valid': (not pub_key_data.revoked and valid_from < now and
                             now < valid_to),
                'valid_from': valid_from,
                'valid_to': valid_to,
                'entity_hash': pub_key_data.payload.entity_hash,
                'entity_hash_signature': pub_key_data.payload.entity_hash_signature}
    except KeyNotFound:
        raise KeyNotFound('Public key info not found')