1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +00:00

check if we have the public share key

This commit is contained in:
nishiki 2014-03-19 20:50:12 +01:00
parent ba297c3d7d
commit d477a8a939
3 changed files with 12 additions and 2 deletions

View file

@ -66,6 +66,11 @@ module MPW
@error_msg = I18n.t('error.config.key_bad_format')
return false
end
if !check_gpg_key?(k, false)
@error_msg = I18n.t('error.config.no_key_public', :key => k)
return false
end
end
end
@ -166,10 +171,11 @@ module MPW
end
# Check if private key exist
# @args: only_private -> search only private key
# @rtrn: true if the key exist, else false
def check_gpg_key?
def check_gpg_key?(key = @key, only_private = true)
ctx = GPGME::Ctx.new
ctx.each_key(@key, true) do |key|
ctx.each_key(key, only_private) do
return true
end

View file

@ -5,6 +5,7 @@ en:
write: "Can't write the config file!"
check: "Checkconfig failed!"
key_bad_format: "The key string isn't in good format!"
no_key_public: "You haven't the public key of %{key}!"
genkey_gpg:
exception: "Can't create the GPG key!"
name: "You must define a name for your GPG key!"
@ -90,6 +91,7 @@ en:
length: "Size of the GPG key [default=2048]: "
expire: "Expire time of the GPG key [default=0 (unlimited)]: "
wait: "Please waiting during the GPG key generate, this process can take few minutes."
valid: "Your GPG key has been created ;-)"
update:
title: "Update an item"
name: "Enter the name [%{name}]: "

View file

@ -5,6 +5,7 @@ fr:
write: "Impossible d'écrire le fichier de configuration!"
check: "Le fichier de configuration est invalide!"
key_bad_format: "La clé GPG est invalide!"
no_key_public: "Vous ne possédez pas la clé publique de %{key}!"
genkey_gpg:
exception: "La création de la clé GPG n'a pas pu aboutir!"
name: "Vous devez définir un nom pour votre clé GPG!"
@ -90,6 +91,7 @@ fr:
length: "Taille de la clé GPG [défaut=2048]: "
expire: "Expiration de la clé GPG [défaut=0 (illimité)]: "
wait: "Veuillez patienter durant la génération de votre clé GPG, ce processus peut prendre quelques minutes."
valid: "Votre clé GPG a bien été créée ;-)"
update:
title: "Mis à jour d'un élément"
name: "Entrez le nom [%{name}]: "