Esempio n. 1
0
static void
perform_prompting (GkdSecretCreate *self)
{
    GkdSecretPrompt *prompt = GKD_SECRET_PROMPT (self);

    /* Does the alias exist? */
    if (locate_alias_collection_if_exists (self)) {
        unlock_or_complete_this_prompt (self);

        /* Have we gotten a password yet? */
    } else if (self->master == NULL) {
        setup_password_prompt (self);
        gcr_prompt_password_async (GCR_PROMPT (self),
                                   gkd_secret_prompt_get_cancellable (prompt),
                                   on_prompt_password_complete, NULL);

        /* Check that the password is not empty */
    } else if (!self->confirmed) {
        setup_confirmation_prompt (self);
        gcr_prompt_confirm_async (GCR_PROMPT (self),
                                  gkd_secret_prompt_get_cancellable (prompt),
                                  on_prompt_confirmation_complete, NULL);

        /* Actually create the keyring */
    } else  if (create_collection_with_secret (self, self->master)) {
        gkd_secret_prompt_complete (prompt);

        /* Failed */
    } else {
        gkd_secret_prompt_dismiss (prompt);
    }
}
Esempio n. 2
0
static void
on_prompt_password_complete (GObject *source,
                             GAsyncResult *result,
                             gpointer user_data)
{
    GkdSecretCreate *self = GKD_SECRET_CREATE (source);
    GkdSecretPrompt *prompt = GKD_SECRET_PROMPT (source);
    GError *error = NULL;

    gcr_prompt_password_finish (GCR_PROMPT (source), result, &error);

    if (error != NULL) {
        gkd_secret_prompt_dismiss_with_error (prompt, error);
        g_error_free (error);
        return;
    }

    self->master = gkd_secret_prompt_take_secret (prompt);
    if (self->master == NULL) {
        gkd_secret_prompt_dismiss (prompt);
        return;
    }

    /* If the password strength is greater than zero, then don't confirm */
    if (gcr_prompt_get_password_strength (GCR_PROMPT (source)) > 0)
        self->confirmed = TRUE;

    perform_prompting (self);
}
Esempio n. 3
0
static void
setup_confirmation_prompt (GkdSecretCreate *self)
{
    gcr_prompt_set_message (GCR_PROMPT (self), _("Store passwords unencrypted?"));
    gcr_prompt_set_description (GCR_PROMPT (self),
                                _("By choosing to use a blank password, your stored passwords will not be safely encrypted. "
                                  "They will be accessible by anyone with access to your files."));
}
Esempio n. 4
0
static void
setup_unlock_token (GkmWrapPrompt *self,
                    CK_TOKEN_INFO_PTR tinfo)
{
	GcrPrompt *prompt;
	const gchar *choice;
	gchar *label;
	gchar *text;

	g_assert (GKM_IS_WRAP_PROMPT (self));
	prompt = GCR_PROMPT (self);

	label = g_strndup ((gchar*)tinfo->label, sizeof (tinfo->label));
	g_strchomp (label);

	/* Build up the prompt */
	gcr_prompt_set_title (prompt, _("Unlock certificate/key storage"));
	gcr_prompt_set_message (prompt, _("Enter password to unlock the certificate/key storage"));

	/* TRANSLATORS: The storage is locked, and needs unlocking before the application can use it. */
	text = g_strdup_printf (_("An application wants access to the certificate/key storage “%s”, but it is locked"), label);
	gcr_prompt_set_description (prompt, text);
	g_free (text);

	choice = NULL;
	if (gkm_wrap_login_is_usable ())
		choice = _("Automatically unlock whenever I’m logged in");
	gcr_prompt_set_choice_label (prompt, choice);

	gcr_prompt_set_continue_label (prompt, _("Unlock"));

	g_free (label);
}
Esempio n. 5
0
static void
setup_unlock_object (GkmWrapPrompt *self,
                     const gchar *label,
                     CK_OBJECT_CLASS klass)
{
	GcrPrompt *prompt;
	const gchar *choice;
	gchar *text;

	g_assert (GKM_IS_WRAP_PROMPT (self));
	prompt = GCR_PROMPT (self);

	gcr_prompt_set_title (prompt, calc_unlock_object_title (klass));
	gcr_prompt_set_message (prompt, calc_unlock_object_primary (klass));

	text = calc_unlock_object_secondary (klass, label);
	gcr_prompt_set_description (prompt, text);
	g_free (text);

	choice = NULL;
	if (gkm_wrap_login_is_usable ())
		choice = calc_unlock_object_choice (klass);
	gcr_prompt_set_choice_label (prompt, choice);
	gcr_prompt_set_continue_label (prompt, _("Unlock"));
}
Esempio n. 6
0
static void
setup_unlock_keyring_other (GkmWrapPrompt *self,
                            const gchar *label)
{
	GcrPrompt *prompt;
	const gchar *choice;
	gchar *text;

	g_assert (GKM_IS_WRAP_PROMPT (self));
	prompt = GCR_PROMPT (self);

	gcr_prompt_set_title (prompt, _("Unlock Keyring"));

	text = _("Enter password to unlock");
	gcr_prompt_set_message (prompt, text);

	text = g_markup_printf_escaped (_("An application wants access to the keyring “%s”, but it is locked"), label);
	gcr_prompt_set_description (prompt, text);
	g_free (text);

	choice = NULL;
	if (gkm_wrap_login_is_usable ())
		choice = _("Automatically unlock this keyring whenever I’m logged in");
	gcr_prompt_set_choice_label (prompt, choice);
	gcr_prompt_set_continue_label (prompt, _("Unlock"));
}
Esempio n. 7
0
static GcrPrompt *
create_prompt (pinentry_t pe, int confirm)
{
  GcrPrompt *prompt;
  GError *error = NULL;
  char *msg;

  /* Create the prompt.  */
  prompt = GCR_PROMPT (gcr_system_prompt_open (-1, NULL, &error));
  if (! prompt)
    {
      g_warning ("couldn't create prompt for gnupg passphrase: %s",
		 error->message);
      g_error_free (error);
      return NULL;
    }

  /* Set the messages for the various buttons, etc.  */
  if (pe->title)
    {
      msg = pinentry_utf8_validate (pe->title);
      gcr_prompt_set_title (prompt, msg);
      g_free (msg);
    }

  if (pe->description)
    {
      msg = pinentry_utf8_validate (pe->description);
      gcr_prompt_set_description (prompt, msg);
      g_free (msg);
    }

  /* An error occured during the last prompt.  */
  if (pe->error)
    {
      msg = pinentry_utf8_validate (pe->error);
      gcr_prompt_set_warning (prompt, msg);
      g_free (msg);
    }

  if (! pe->prompt && confirm)
    gcr_prompt_set_message (prompt, "Message");
  else if (! pe->prompt && ! confirm)
    gcr_prompt_set_message (prompt, "Enter Passphrase");
  else
    {
      msg = pinentry_utf8_validate (pe->prompt);
      gcr_prompt_set_message (prompt, msg);
      g_free (msg);
    }

  if (! confirm)
    gcr_prompt_set_password_new (prompt, !!pe->repeat_passphrase);

  if (pe->ok || pe->default_ok)
    {
      msg = pinentry_utf8_validate (pe->ok ?: pe->default_ok);
      gcr_prompt_set_continue_label (prompt, msg);
      g_free (msg);
    }
Esempio n. 8
0
static void
setup_password_prompt (GkdSecretCreate *self)
{
    gchar *label;
    gchar *text;

    if (!gck_attributes_find_string (self->attributes, CKA_LABEL, &label))
        label = g_strdup (_("Unnamed"));

    text = g_strdup_printf (_("An application wants to create a new keyring called '%s'. "
                              "Choose the password you want to use for it."), label);
    g_free (label);

    gcr_prompt_set_message (GCR_PROMPT (self), _("Choose password for new keyring"));
    gcr_prompt_set_description (GCR_PROMPT (self), text);
    gcr_prompt_set_password_new (GCR_PROMPT (self), TRUE);

    g_free (text);
}
Esempio n. 9
0
static void
on_prompt_clicked (GtkToolButton *button,
                   gpointer user_data)
{
    GcrPrompt *prompt;
    GError *error = NULL;
    const gchar *password;
    GtkWidget *parent = user_data;
    gchar *caller_id;

    prompt = gcr_system_prompt_open (-1, NULL, &error);
    if (error != NULL) {
        g_warning ("couldn't open prompt: %s", error->message);
        g_error_free (error);
        return;
    }
    g_object_add_weak_pointer (G_OBJECT (prompt), (gpointer *)&prompt);

    gcr_prompt_set_title (GCR_PROMPT (prompt), "This is the title");
    gcr_prompt_set_message (GCR_PROMPT (prompt), "This is the message");
    gcr_prompt_set_description (GCR_PROMPT (prompt), "This is the description");

    caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_XID (gtk_widget_get_window (parent)));
    gcr_prompt_set_caller_window (GCR_PROMPT (prompt), caller_id);
    g_free (caller_id);

    password = gcr_prompt_password_run (GCR_PROMPT (prompt), NULL, &error);
    if (error != NULL) {
        g_warning ("couldn't prompt for password: %s", error->message);
        g_error_free (error);
        g_object_unref (prompt);
        return;
    }

    g_print ("password: %s\n", password);
    g_object_unref (prompt);
    g_assert (prompt == NULL);
}
Esempio n. 10
0
static void
set_unlock_options_on_prompt (GkmWrapPrompt *self, CK_ATTRIBUTE_PTR options, CK_ULONG n_options)
{
	gboolean chosen = FALSE;
	gboolean bval;

	g_assert (GKM_IS_WRAP_PROMPT (self));
	g_assert (options || !n_options);

	if (gkm_attributes_find_boolean (options, n_options, CKA_GNOME_TRANSIENT, &bval))
		chosen = bval;

	gcr_prompt_set_choice_chosen (GCR_PROMPT (self), chosen);
}
Esempio n. 11
0
static GcrPrompt *
open_password_prompt (GckSession *session,
                      const gchar *keyid,
                      const gchar *errmsg,
                      const gchar *prompt_text,
                      const gchar *description,
                      gboolean confirm)
{
	GcrPrompt *prompt;
	GError *error = NULL;
	gboolean auto_unlock;
	const gchar *choice;

	g_assert (GCK_IS_SESSION (session));

	prompt = GCR_PROMPT (gcr_system_prompt_open (-1, NULL, &error));
	if (prompt == NULL) {
		g_warning ("couldn't create prompt for gnupg passphrase: %s", egg_error_message (error));
		g_error_free (error);
		return NULL;
	}

	gcr_prompt_set_title (prompt, _("Enter Passphrase"));
	gcr_prompt_set_message (prompt, prompt_text ? prompt_text : _("Enter Passphrase"));
	gcr_prompt_set_description (prompt, description);

	gcr_prompt_set_password_new (prompt, confirm);
	gcr_prompt_set_continue_label (prompt, _("Unlock"));

	if (errmsg)
		gcr_prompt_set_warning (prompt, errmsg);

	if (keyid == NULL) {
		gcr_prompt_set_choice_label (prompt, NULL);

	} else {
		auto_unlock = gkd_login_available (session);

		choice = NULL;
		if (auto_unlock)
			choice = _("Automatically unlock this key, whenever I'm logged in");
		gcr_prompt_set_choice_label (prompt, choice);

		load_unlock_options (prompt);
	}

	return prompt;
}
Esempio n. 12
0
static void
setup_unlock_prompt (GkmWrapPrompt *self,
                     CK_ATTRIBUTE_PTR attrs,
                     CK_ULONG n_attrs,
                     gboolean first)
{
	CK_ATTRIBUTE_PTR attr;
	GcrPrompt *prompt;
	const gchar *label = NULL;
	CK_OBJECT_CLASS klass;

	g_assert (GKM_IS_WRAP_PROMPT (self));
	prompt = GCR_PROMPT (self);

	/* Load up the object class */
	if (!gkm_attributes_find_ulong (attrs, n_attrs, CKA_CLASS, &klass))
		klass = (CK_ULONG)-1;

	/* Load up its label */
	attr = gkm_attributes_find (attrs, n_attrs, CKA_LABEL);
	if (attr != NULL)
		label = attr->pValue;

	/* Load up the identifier */
	attr = gkm_attributes_find (attrs, n_attrs, CKA_ID);
	if (attr != NULL && !label)
		label = attr->pValue;

	if (!label)
		label = _("Unnamed");

	if (klass == CKO_G_COLLECTION) {
		if (is_login_keyring (attrs, n_attrs))
			setup_unlock_keyring_login (self);
		else
			setup_unlock_keyring_other (self, label);
	} else {
		setup_unlock_object (self, label, klass);
	}

	if (!first)
		gcr_prompt_set_warning (prompt, _("The unlock password was incorrect"));

	gcr_prompt_set_continue_label (prompt, _("Unlock"));
}
Esempio n. 13
0
static const gchar *
gkm_wrap_prompt_request_password (GkmWrapPrompt *self)
{
	GError *error = NULL;
	const gchar *password;

	g_assert (GKM_IS_WRAP_PROMPT (self));

	if (!gkm_wrap_prompt_prepare (self))
		return NULL;

	password = gcr_prompt_password (GCR_PROMPT (self), NULL, &error);
	if (error != NULL) {
		g_warning ("couldn't prompt for password: %s", egg_error_message (error));
		g_error_free (error);
	}

	return password;
}
Esempio n. 14
0
static void
setup_unlock_keyring_login (GkmWrapPrompt *self)
{
	GcrPrompt *prompt;
	const gchar *text;

	g_assert (GKM_IS_WRAP_PROMPT (self));

	prompt = GCR_PROMPT (self);

	gcr_prompt_set_title (prompt, _("Unlock Login Keyring"));

	text = _("Enter password to unlock your login keyring");
	gcr_prompt_set_message (prompt, text);

	if (gkm_wrap_login_did_unlock_fail ())
		text = _("The password you use to log in to your computer no longer matches that of your login keyring.");
	else
		text = _("The login keyring did not get unlocked when you logged into your computer.");
	gcr_prompt_set_description (prompt, text);

	gcr_prompt_set_choice_label (prompt, NULL);
	gcr_prompt_set_continue_label (prompt, _("Unlock"));
}
Esempio n. 15
0
static void
on_prompt_confirmation_complete (GObject *source,
                                 GAsyncResult *result,
                                 gpointer user_data)
{
    GkdSecretCreate *self = GKD_SECRET_CREATE (source);
    GkdSecretPrompt *prompt = GKD_SECRET_PROMPT (source);
    GError *error = NULL;

    self->confirmed = gcr_prompt_confirm_finish (GCR_PROMPT (source), result, &error);
    if (error != NULL) {
        gkd_secret_prompt_dismiss_with_error (prompt, error);
        g_error_free (error);
        return;
    }

    /* If not confirmed, then prompt again */
    if (!self->confirmed) {
        gkd_secret_secret_free (self->master);
        self->master = NULL;
    }

    perform_prompting (self);
}
Esempio n. 16
0
static gboolean
auto_unlock_should_attach (GkmWrapPrompt *self)
{
	return gcr_prompt_get_choice_chosen (GCR_PROMPT (self));
}
Esempio n. 17
0
static void
gkd_secret_create_init (GkdSecretCreate *self)
{
    gcr_prompt_set_title (GCR_PROMPT (self), _("New Keyring Password"));
}