コード例 #1
0
ファイル: views.py プロジェクト: srri/OpenRelay
def key_publish(request):
    if request.method == 'POST':
        form = KeySelectionForm(request.POST)
        if form.is_valid():
            try:
                network = NetworkCall()
                key = Key.get(gpg, form.cleaned_data['key'])
                network.publish_key(key)
                messages.success(request, _(u'Key publish request for key: %s, has been sent') % key)
                return HttpResponseRedirect(reverse('home_view'))
            except AnnounceClientError:
                messages.error(request, _(u'Unable to send key publish call'))
                return HttpResponseRedirect(reverse('key_publish'))
    else:
        form = KeySelectionForm()

    return render_to_response('generic_form.html', {
        'form': form,
        'title': _(u'Publish a key to the OpenRelay network'),
    }, context_instance=RequestContext(request))       
コード例 #2
0
ファイル: __init__.py プロジェクト: srri/OpenRelay
def create_identify(sender, **kwargs):
    node, created = LocalNode.objects.get_or_create(lock_id='1')
    if created or not node.uuid:
        print 'Creating local node identity ...'
        name_real = raw_input('Enter a name to describe this node: ')
        name_email = raw_input('Enter an e-mail associated with this node: ')
        name_comment = raw_input('Enter comment for this node: ')
        while True:
            passphrase = raw_input('Enter a passphrase to lock this key: ')
            passphrase_verify = raw_input('Enter again the same passphrase to verify: ')
            if passphrase == passphrase_verify:
                break
            else:
                print '\nPassphrases do not match, try again.\n'
        key_args = {
            'name_real': name_real,
            'name_email': name_email,
            'name_comment': name_comment,
            'passphrase': passphrase,
            'key_type': 'RSA',
            'key_length': 2048,
            'subkey_type': 'RSA',
            'subkey_length': 2048,
            'expire_date': 0,
        }
        print 'Creating node key, type on the keyboard, move the mouse, utilize the disks to generate entropy.'
        try:
            key = gpg.create_key(**key_args)
            node.uuid = key.fingerprint
            node.name = name_real
            node.email = name_email
            node.comment = name_comment
            node.save()
            network = NetworkCall()
            network.publish_key(key)
        except Exception, msg:
            print 'Unhandled exception: %s' % msg