New GPG key event handler.

        Launches GPG choice and creation dialog
771420
def OnNewGpgKey(self, event):
        

        if gnupg is None:
            return

        if genkey is None:
            # gnupg is not present
            self.interfaces.display_warning(
                _("Python gnupg not found. No key selected."),
                _("Key selection failed."))
        else:
            # gnupg is present
            genkey()
438423
protected void gitTag(final String tagName, String message, boolean gpgSignTag, Map<String, String> messageProperties)
            throws MojoFailureException, CommandLineException {
        message = replaceProperties(message, messageProperties);

        if (gpgSignTag) {
            getLog().info("Creating GPG-signed '" + tagName + "' tag.");

            executeGitCommand("tag", "-a", "-s", tagName, "-m", message);
        } else {
            getLog().info("Creating '" + tagName + "' tag.");

            executeGitCommand("tag", "-a", tagName, "-m", message);
        }
    }
976326
function _gpfAddEventListener (event, eventsHandler) {
    /*jshint validthis:true*/ // will be invoked as an object method
    var listeners = _gpfAllocateEventDispatcherListeners(this);
    if (undefined === listeners[event]) {
        listeners[event] = [];
    }
    listeners[event].push(eventsHandler);
    return this;
}
860466
def displayNewKey(key):
    """"""

    if key.keyring:
        gpg.keyring = key.keyring
    if key.secring:
        gpg.secring = key.secring

    # Using '--fingerprint' twice will display subkey fingerprints too:
    gpg.options = ['--fingerprint', '--fingerprint']
    keylist = gpg.list_keys(secret=True)

    # `result` is a `gnupg._parsers.ListKeys`, which is list-like, so iterate
    # over all the keys and display their info:
    for gpgkey in keylist:
        for k, v in gpgkey.items():
            log.info("%s: %s" % (k.capitalize(), v))

    return keylist
914951
def gpg_app_create_key( blockchain_id, appname, keyname, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ):
    

    assert is_valid_appname(appname)
    assert is_valid_keyname(keyname)

    if config_dir is None:
        config_dir = get_config_dir()

    client_config_path = os.path.join(config_dir, blockstack_client.CONFIG_FILENAME)
    if proxy is None:
        proxy = blockstack_client.get_default_proxy(config_path=client_config_path)

    keydir = make_gpg_tmphome( "create-app-", config_dir=config_dir )
    gpg = gnupg.GPG( homedir=keydir )

    log.debug("Generating GPG key (this may take a while)")

    key_input = gpg.gen_key_input( key_type="RSA", name_email=blockchain_id + "/" + appname, key_length=4096, name_real=keyname )
    key_res = gpg.gen_key( key_input )
    key_id = key_res.fingerprint
    key_data = gpg.export_keys( [key_id], secret=True )

    shutil.rmtree(keydir)

    # propagate to blockstack
    add_res = gpg_app_put_key( blockchain_id, appname, keyname, key_data, txid=txid, immutable=immutable, proxy=proxy, wallet_keys=wallet_keys, config_dir=config_dir )
    return add_res
529040
def create_confirm_application(message):
    
    registry = Registry()

    @registry.add_binding('y')
    @registry.add_binding('Y')
    def _(event):
        event.cli.buffers[DEFAULT_BUFFER].text = 'y'
        event.cli.set_return_value(True)

    @registry.add_binding('n')
    @registry.add_binding('N')
    @registry.add_binding(Keys.ControlC)
    def _(event):
        event.cli.buffers[DEFAULT_BUFFER].text = 'n'
        event.cli.set_return_value(False)

    return create_prompt_application(message, key_bindings_registry=registry)
474321
def key_press_event(self, widget, event):
        
        # get keyname or keycode and translate to ginga standard
        # keyname =
        # keycode =
        keyname = ''  # self.transkey(keyname, keycode)
        self.logger.debug("key press event, key=%s" % (keyname))
        return self.make_ui_callback('key-press', keyname)
1104619
def do_gn(self, arg):
        
        if self.cmdprefix:
            raise CmdError("prefix not allowed")
        if arg:
            raise CmdError("too many arguments")
        if self.lastEvent:
            self.lastEvent.continueStatus = win32.DBG_EXCEPTION_NOT_HANDLED
        return self.do_go(arg)
1094377
def _keygen(self, event, ts=None):
        
        return "%s:%s" % (self.namespace(ts or time.time()), event)
1274308
def createKey(batchfile):
    
    key = gpg.gen_key(batchfile)
    fingerprint = key.fingerprint

    if not fingerprint:
        log.error("Key creation seems to have failed: %s" % key.status)
        return None, None
    return key, fingerprint
439681
def execute(opts={}, &block)
      parse_options
      self.options.merge!(opts)

      @verify_options_hook.call(self.options) if @verify_options_hook

      if options.include?(:kill)
        self.stop
      else # create process
        self.stop if options.include?(:restart)

        # If a username, uid, groupname, or gid is passed,
        # drop privileges accordingly.

        if options[:group]
          gid = options[:group].is_a?(Integer) ? options[:group] : Etc.getgrnam(options[:group]).gid
          Process::GID.change_privilege(gid)
        end

        if options[:user]
          uid = options[:user].is_a?(Integer) ? options[:user] : Etc.getpwnam(options[:user]).uid
          Process::UID.change_privilege(uid)
        end

        @startup_command = block if block_given?
        options[:daemonize] ? daemonize : start
      end
    end
1090411
def _create_gpg(user=None, gnupghome=None):
    '''
    
    '''
    if not gnupghome:
        gnupghome = _get_user_gnupghome(user)

    if GPG_1_3_1:
        gpg = gnupg.GPG(homedir=gnupghome)
    else:
        gpg = gnupg.GPG(gnupghome=gnupghome)

    return gpg
1168291
def gpg_export_key( appname, key_id, config_dir=None, include_private=False ):
    

    assert is_valid_appname(appname)
    config_dir = get_config_dir( config_dir )
    keydir = get_gpg_home( appname, config_dir=config_dir )
    gpg = gnupg.GPG( homedir=keydir )
    keydat = gpg.export_keys( [key_id], secret=include_private )

    if not keydat:
        log.debug("Failed to export key %s from '%s'" % (key_id, keydir))

    assert keydat
    return keydat
1104321
function enterConfig() {
    const config = {};
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
    });

    rl.question(`Do you want to use .gs as extension for your local code files instead of .js? [${'y'.green}/${'n'.red}]\n > `, (input) => {
        if (input === 'y') {
            config.extension = '.gs';
        } else if (input !== 'n') {
            endDialog(false);
            rl.close();
        }

        rl.question(`Do you want to use a custom OAuth 2.0 client to authenticate with Google? [${'y'.green}/${'n'.red}]\n > `, (input) => {
            if (input === 'y') {
                config.client = {};
                console.log();
                rl.question(`Enter the 'Client ID' of your client \n > `, (input) => {
                    config.client.id = input;
                    rl.question(`Enter the 'Client secret' of your client\n > `, (input) => {
                        config.client.secret = input;

                        // Remove token file to force reauth
                        fs.removeSync(tokenFile);

                        endDialog(true, config);
                        rl.close();
                    });
                });
            } else if (input === 'n') {
                endDialog(true, config);
                rl.close();
            } else {
                endDialog(false);
                rl.close();
            }
        });
    });
}
336475
private void createButtons() {

        addDialogClose(new Command() {

            public void execute() {

                cancelUpload();
            }
        });

        CmsPushButton cancelButton = new CmsPushButton();
        cancelButton.setTitle(org.opencms.gwt.client.Messages.get().key(org.opencms.gwt.client.Messages.GUI_CANCEL_0));
        cancelButton.setText(org.opencms.gwt.client.Messages.get().key(org.opencms.gwt.client.Messages.GUI_CANCEL_0));
        cancelButton.setSize(I_CmsButton.Size.medium);
        cancelButton.setUseMinWidth(true);
        cancelButton.addClickHandler(new ClickHandler() {

            /**
             * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
             */
            public void onClick(ClickEvent event) {

                cancelUpload();
            }
        });
        addButton(cancelButton);

        m_okButton = new CmsPushButton();
        m_okButton.setTitle(org.opencms.gwt.client.Messages.get().key(org.opencms.gwt.client.Messages.GUI_OK_0));
        m_okButton.setText(org.opencms.gwt.client.Messages.get().key(org.opencms.gwt.client.Messages.GUI_OK_0));
        m_okButton.setSize(I_CmsButton.Size.medium);
        m_okButton.setUseMinWidth(true);
        m_okButton.addClickHandler(new ClickHandler() {

            /**
             * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
             */
            public void onClick(ClickEvent event) {

                onOkClick();
            }
        });
        addButton(m_okButton);

        CmsDialogUploadButtonHandler buttonHandler = new CmsDialogUploadButtonHandler(
            new Supplier<I_CmsUploadContext>() {

                public I_CmsUploadContext get() {

                    return m_context;
                }
            });
        buttonHandler.setUploadDialog(this);
        // add a new upload button
        CmsUploadButton uploadButton = new CmsUploadButton(buttonHandler);
        uploadButton.addStyleName(I_CmsLayoutBundle.INSTANCE.uploadCss().uploadDialogButton());
        uploadButton.setText(Messages.get().key(Messages.GUI_UPLOAD_BUTTON_ADD_FILES_0));
        addButton(uploadButton);
        m_uploadButton = uploadButton;
    }
767856
def launch_editor(ctx, file):
    """"""
    # do not use EDITOR environment variable (rather force user to make a concious choice)
    editor = os.environ.get("PW_EDITOR")
    if not editor:
        click.echo("error: no editor set in PW_EDITOR environment variables")
        ctx.exit(1)

    # verify that database file is present
    if not os.path.exists(file):
        click.echo("error: password store not found at '%s'" % file, err=True)
        ctx.exit(1)

    # load source (decrypting if necessary)
    is_encrypted = _gpg.is_encrypted(file)
    if is_encrypted:
        original = _gpg.decrypt(file)
    else:
        original = open(file, "rb").read()

    # if encrypted, determine recipient
    if is_encrypted:
        recipient = os.environ.get("PW_GPG_RECIPIENT")
        if not recipient:
            click.echo(
                "error: no recipient set in PW_GPG_RECIPIENT environment variables"
            )
            ctx.exit(1)

    # launch the editor
    ext = _gpg.unencrypted_ext(file)
    modified = click.edit(
        original.decode("utf-8"), editor=editor, require_save=True, extension=ext
    )
    if modified is None:
        click.echo("not modified")
        return
    modified = modified.encode("utf-8")

    # not encrypted? simply overwrite file
    if not is_encrypted:
        with open(file, "wb") as fp:
            fp.write(modified)
        return

    # otherwise, the process is somewhat more complicated
    _gpg.encrypt(recipient=recipient, dest_path=file, content=modified)
816553
def do_keygen(args):
    
    if args.key_name is not None:
        key_name = args.key_name
    else:
        key_name = 'validator'

    key_dir = get_key_dir()

    if not os.path.exists(key_dir):
        raise CliException("Key directory does not exist: {}".format(key_dir))

    priv_filename = os.path.join(key_dir, key_name + '.priv')
    pub_filename = os.path.join(key_dir, key_name + '.pub')

    if not args.force:
        file_exists = False
        for filename in [priv_filename, pub_filename]:
            if os.path.exists(filename):
                file_exists = True
                print('file exists: {}'.format(filename), file=sys.stderr)
        if file_exists:
            raise CliException(
                'files exist, rerun with --force to overwrite existing files')

    context = create_context('secp256k1')

    private_key = context.new_random_private_key()
    public_key = context.get_public_key(private_key)

    try:
        priv_exists = os.path.exists(priv_filename)
        with open(priv_filename, 'w') as priv_fd:
            if not args.quiet:
                if priv_exists:
                    print('overwriting file: {}'.format(priv_filename))
                else:
                    print('writing file: {}'.format(priv_filename))
            priv_fd.write(private_key.as_hex())
            priv_fd.write('\n')
            # Get the uid and gid of the key directory
            keydir_info = os.stat(key_dir)
            keydir_gid = keydir_info.st_gid
            keydir_uid = keydir_info.st_uid
            # Set user and group on keys to the user/group of the key directory
            os.chown(priv_filename, keydir_uid, keydir_gid)
            # Set the private key u+rw g+r
            os.chmod(priv_filename, 0o640)

        pub_exists = os.path.exists(pub_filename)
        with open(pub_filename, 'w') as pub_fd:
            if not args.quiet:
                if pub_exists:
                    print('overwriting file: {}'.format(pub_filename))
                else:
                    print('writing file: {}'.format(pub_filename))
            pub_fd.write(public_key.as_hex())
            pub_fd.write('\n')
            # Set user and group on keys to the user/group of the key directory
            os.chown(pub_filename, keydir_uid, keydir_gid)
            # Set the public key u+rw g+r o+r
            os.chmod(pub_filename, 0o644)

    except IOError as ioe:
        raise CliException('IOError: {}'.format(str(ioe)))