Example #1
0
def add_secret(wkf):
    'add a secret to a domain'
    echo('Adding secret value.')
    domain_name = prompt('Domain name: ')
    secret_name = prompt('Secret name: ')
    secret_value = prompt('Secret value: ')
    return wkf.add_secret(domain_name, secret_name, secret_value)
Example #2
0
def update_secret(wkf):
    'update a secret value in a domain'
    echo('Updating secret value.')
    domain_name = prompt('Domain name: ')
    secret_name = prompt('Secret name: ')
    secret_value = prompt('Secret value: ')
    return wkf.update_secret(domain_name, secret_name, secret_value)
Example #3
0
def list_domains(kf):
    'print a list of domain names, if any'
    domain_names = kf.get_domain_names()
    if domain_names:
        echo('\n'.join(domain_names))
    else:
        echo.err('(No domains in protected at %s)' % kf.path)
    return
Example #4
0
def list_domain_secrets(kf, domain_name):
    'print a list of secret names for a given domain'
    secret_names = kf.get_domain_secret_names(domain_name)
    if secret_names:
        echo('\n'.join(secret_names))
    else:
        echo.err('(No secrets in domain %r of protected at %s)'
                 % (domain_name, kf.path))
    return
Example #5
0
def list_all_secrets(kf):
    'print a list of all secret names, along with the domains that define each'
    secrets_map = kf.get_all_secret_names()
    if not secrets_map:
        echo.err('(No secrets in protected at %s)' % kf.path)
    else:
        for secret_name in sorted(secrets_map):
            domain_names = sorted(set(secrets_map[secret_name]))
            echo('%s: %s' % (secret_name, ', '.join(domain_names)))
    return
Example #6
0
def decrypt_domain(kf, creds, domain_name):
    'output the decrypted contents of a domain in JSON format'
    decrypted_dict = kf.decrypt_domain(domain_name, creds)
    echo(json.dumps(decrypted_dict, indent=2, sort_keys=True))
    return 0
Example #7
0
def print_version():
    'print the PocketProtector version and exit'
    echo('pocket_protector version %s' % __version__)
    sys.exit(0)
Example #8
0
def rm_secret(wkf):
    'remove a secret from a domain'
    echo('Updating secret value.')
    domain_name = prompt('Domain name: ')
    secret_name = prompt('Secret name: ')
    return wkf.rm_secret(domain_name, secret_name)
Example #9
0
def rm_owner(wkf):
    'remove a key custodian from the owner list of a domain'
    echo('Removing domain owner.')
    domain_name = prompt('Domain name: ')
    owner_name = prompt('Owner email: ')
    return wkf.rm_owner(domain_name, owner_name)
Example #10
0
def add_owner(wkf, creds):
    'add a key custodian to the owner list of a specific domain'
    echo('Adding domain owner.')
    domain_name = prompt('Domain name: ')
    new_owner_name = prompt('New owner email: ')
    return wkf.add_owner(domain_name, new_owner_name, creds)
Example #11
0
def rm_domain(wkf):
    'remove a domain and all of its keys from the protected'
    echo('Removing domain.')
    domain_name = prompt('Domain name: ')
    return wkf.rm_domain(domain_name)
Example #12
0
def add_domain(wkf, creds):
    'add a new domain to the protected'
    echo('Adding new domain.')
    domain_name = prompt('Domain name: ')

    return wkf.add_domain(domain_name, creds.name)
Example #13
0
def add_key_custodian(wkf):
    'add a new key custodian to the protected'
    echo('Adding new key custodian.')
    creds = _get_new_creds()
    return wkf.add_key_custodian(creds)