Skip to content
Browse files

Add Foobar format

  • Loading branch information...
1 parent da25b31 commit 88c96767a0738ab35941cd0241a1e690b5373300 @icy icy committed Sep 25, 2012
Showing with 13 additions and 3 deletions.
  1. +5 −3 lib/trocla.rb
  2. +7 −0 lib/trocla/formats/foobar.rb
  3. +1 −0 trocla.gemspec
View
8 lib/trocla.rb
@@ -30,7 +30,9 @@ def password(key,format,options={})
return password
end
- if options['random'] and not %w{ssh_rsa_public ssh_dsa_public ssl_cert}.include?(format)
+ # previous value not found, we will have to generate them (randomly
+ # or from the other value)
+ if options['random'] and not %w{foobar ssh_rsa_public ssh_dsa_public ssl_cert}.include?(format)
if %w{ssh_rsa ssh_dsa}.include?(format)
if get_password(key, "#{format}_public")
raise "Trocla: You can't generate new private key for '#{key}' once its public key does exist"
@@ -46,8 +48,8 @@ def password(key,format,options={})
else
# previous value not found. we will generate it from the plain
# password or from the private key
- if %w{ssh_rsa ssh_dsa}.include?(format)
- raise "Trocla: SSH key can't be generated from a password. Please use `set` instead."
+ if %w{foobar ssh_rsa ssh_dsa}.include?(format)
+ raise "Trocla: #{format} can't be generated from a password. Please use `set` instead."
elsif %w{ssh_rsa_public ssh_dsa_public}.include?(format)
private_key = get_password(key, format.slice(0,7))
raise "Trocla: You request to generate public key for '#{key}' but the private key doesn't exist." if not private_key
View
7 lib/trocla/formats/foobar.rb
@@ -0,0 +1,7 @@
+class Trocla::Formats::Foobar
+
+ def format(plain_password,options={})
+ plain_password
+ end
+
+end
View
1 trocla.gemspec
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
"lib/trocla.rb",
"lib/trocla/default_config.yaml",
"lib/trocla/formats.rb",
+ "lib/trocla/formats/foobar.rb",
"lib/trocla/formats/bcrypt.rb",
"lib/trocla/formats/md5crypt.rb",
"lib/trocla/formats/mysql.rb",

0 comments on commit 88c9676

Please sign in to comment.
Something went wrong with that request. Please try again.