gtk2passwordapp 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gtk2passwordapp CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- # $Date: 2009/02/22 21:43:54 $
2
+ # $Date: 2009/02/25 20:35:45 $
3
3
  ##########################################################
4
4
  require 'lib/global_options_variables'
5
- GlobalOptionsVariables.set('0.0.6',
5
+ GlobalOptionsVariables.set('0.0.7',
6
6
  <<EOT
7
7
  Usage: #{$0.sub(/^.*\//,'')} [options]
8
8
 
@@ -15,8 +15,6 @@ EOT
15
15
  )
16
16
  require 'lib/setup_user_space'
17
17
  UserSpace.setup
18
- UserSpace.mkdir('/gifs')
19
- UserSpace.copy('/gifs/logo.gif')
20
18
  require USER_CONF_DIR+CONF_FILE
21
19
  ##########################################################
22
20
  require 'lib/gtk2passwordapp'
data/bin/gtk2passwordmenu CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- # $Date: 2009/02/22 21:43:54 $
2
+ # $Date: 2009/02/25 20:35:45 $
3
3
  ##########################################################
4
4
  require 'lib/global_options_variables'
5
- GlobalOptionsVariables.set('0.0.6',
5
+ GlobalOptionsVariables.set('0.0.7',
6
6
  <<EOT
7
7
  Usage: gtk2passwordmenu [options]
8
8
 
@@ -18,8 +18,6 @@ EOT
18
18
  )
19
19
  require 'lib/setup_user_space'
20
20
  UserSpace.setup
21
- UserSpace.mkdir('/gifs')
22
- UserSpace.copy('/gifs/logo.gif')
23
21
  require USER_CONF_DIR+CONF_FILE
24
22
  ##########################################################
25
23
  require 'lib/gtk2passwordmenu'
data/lib/configuration.rb CHANGED
@@ -1,14 +1,17 @@
1
- #$Date: 2009/02/20 16:10:29 $
2
- # Note: you'll see in ~/.gtk2passwordapp a file called passphrase.txt.
1
+ # $Date: 2009/02/25 20:47:51 $
2
+ # Note: you'll see in ~/.gtk2passwordapp-* a file called passphrase.txt.
3
3
  # Do not edit or delete passphrase, or you'll loose your passwords data.
4
+ require 'gtk2'
4
5
  module Configuration
6
+ # Note that the passwords data file name is auto generated, but...
7
+ # You cam place your passwords data file in a directory other than ~/gtk2passwordapp-*
8
+ PASSWORDS_DATA_DIR = USER_CONF_DIR
9
+
5
10
  ENTRY_WIDTH = 275
6
11
  LABEL_WIDTH = 75
7
12
  SPIN_BUTTON_LENGTH = 50
8
13
  PAD = 2 # cell padding
9
14
 
10
- FONT_NAME = 'Arial 10'
11
-
12
15
  MAX_PASSWORD_LENGTH = 20
13
16
  DEFAULT_PASSWORD_LENGTH = 7
14
17
  MIN_PASSWORD_LENGTH = 3
@@ -36,7 +39,9 @@ module Configuration
36
39
  }
37
40
  $stderr.puts "Browser remote command: #{BROWSER}" if $trace
38
41
 
39
- LOGO_IMAGE = USER_CONF_DIR+'/gifs/logo.gif'
42
+ FONT = Pango::FontDescription.new('Arial 10')
43
+ RED = Gdk::Color.parse("#A00000")
44
+ BLACK = Gdk::Color.parse("#000000")
40
45
  end
41
46
 
42
47
  def puts_bang!(h=nil, t=nil)
@@ -1,4 +1,4 @@
1
- # $Date: 2009/02/14 16:30:05 $
1
+ # $Date: 2009/02/25 20:41:15 $
2
2
  GEM_LIB_DIR = File.expand_path( File.dirname(__FILE__) )
3
3
  GEM = GEM_LIB_DIR.split(/[\/\\]/)[-2]
4
4
  USER_CONF_DIR = ENV['HOME'] + "/.#{GEM}"
@@ -1,6 +1,5 @@
1
- # $Date: 2009/02/22 16:20:51 $
1
+ # $Date: 2009/02/26 01:03:00 $
2
2
  require 'lib/passwords_data'
3
- require 'gtk2'
4
3
  require 'find'
5
4
 
6
5
  class Gtk2PasswordApp
@@ -13,8 +12,8 @@ class Gtk2PasswordApp
13
12
  'website' => 'http://ruby-gnome-apps.blogspot.com/search/label/Passwords',
14
13
  'website-label' => 'Ruby Gnome Password Manager',
15
14
  'license' => 'GPL',
16
- 'copyright' => '$Date: 2009/02/22 16:20:51 $'.gsub(/\s*\$\s*/,''),
17
- 'logo' => Gdk::Pixbuf.new(LOGO_IMAGE),
15
+ 'copyright' => '$Date: 2009/02/26 01:03:00 $'.gsub(/\s*\$\s*/,''),
16
+ 'logo' => Gdk::Pixbuf.new(GEM_ROOT_DIR+'/gifs/logo.gif'),
18
17
  }
19
18
 
20
19
  BUTTONS = [[ :username, :current, :url, ],[ :note, :edit, :quit, ],]
@@ -61,10 +60,6 @@ class Gtk2PasswordApp
61
60
  :delete => 'Delete Account',
62
61
  }
63
62
 
64
- FONT = Pango::FontDescription.new(FONT_NAME)
65
- RED = Gdk::Color.parse("#A00000")
66
- BLACK = Gdk::Color.parse("#000000")
67
-
68
63
  def quit_windows
69
64
  if @editing
70
65
  @editing.hide
@@ -176,7 +171,7 @@ class Gtk2PasswordApp
176
171
  @pph = get_passphrase
177
172
  @passwords = PasswordsData.new(@pwd+@pph)
178
173
  # Password file exist?
179
- if @passwords.exist? # then
174
+ if @passwords.online? || @passwords.exist? # then
180
175
  # Yes, load passwords file.
181
176
  @passwords.load
182
177
  else
@@ -404,6 +399,7 @@ class Gtk2PasswordApp
404
399
  if verify_user then
405
400
  @pph = get_passphrase(true) # mv old passphrase? true
406
401
  @passwords.save(@pwd+@pph)
402
+ quick_message('Passphrase Changed.', window)
407
403
  else
408
404
  quit_windows
409
405
  end
@@ -482,6 +478,7 @@ class Gtk2PasswordApp
482
478
  BUTTONS.each{ |row|
483
479
  hbox = Gtk::HBox.new
484
480
  row.each{|b|
481
+ next if b == :edit && @passwords.online?
485
482
  button[b] = Gtk::Button.new(TEXT[b])
486
483
  button[b].modify_font(FONT)
487
484
  button[b].width_request = LABEL_WIDTH
@@ -494,10 +491,14 @@ class Gtk2PasswordApp
494
491
  combo_box.append_text( account )
495
492
  }
496
493
  combo_box.active = 0
497
- button[:edit].child.modify_fg(Gtk::STATE_NORMAL, (@passwords.expired?(combo_box.active_text.strip))? RED: BLACK) if combo_box.active_text
498
- combo_box.signal_connect('changed'){
499
- button[:edit].child.modify_fg(Gtk::STATE_NORMAL, (@passwords.expired?(combo_box.active_text.strip))? RED: BLACK)
500
- }
494
+
495
+ if !@passwords.online? then
496
+ button[:edit].child.modify_fg(Gtk::STATE_NORMAL, (@passwords.expired?(combo_box.active_text.strip))? RED: BLACK) if combo_box.active_text
497
+ combo_box.signal_connect('changed'){
498
+ button[:edit].child.modify_fg(Gtk::STATE_NORMAL, (@passwords.expired?(combo_box.active_text.strip))? RED: BLACK)
499
+ }
500
+ end
501
+
501
502
  button[:username].signal_connect('clicked'){
502
503
  primary = Gtk::Clipboard.get(Gdk::Selection::PRIMARY)
503
504
  clipboard = Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD)
@@ -523,17 +524,21 @@ class Gtk2PasswordApp
523
524
  note = '*** empty note ***' if note.length == 0
524
525
  quick_message(note,window)
525
526
  }
526
- button[:edit].signal_connect('clicked'){
527
- if !@editing then
528
- account = (combo_box.active_text)? combo_box.active_text.strip: ''
529
- i = @passwords.accounts.index(account)
530
- @editing = Gtk::Window.new
531
- edit(combo_box,i)
532
- end
533
- }
527
+
528
+ if !@passwords.online? then
529
+ button[:edit].signal_connect('clicked'){
530
+ if !@editing then
531
+ account = (combo_box.active_text)? combo_box.active_text.strip: ''
532
+ i = @passwords.accounts.index(account)
533
+ @editing = Gtk::Window.new
534
+ edit(combo_box,i)
535
+ end
536
+ }
537
+ end
538
+
534
539
  button[:quit].signal_connect('clicked'){ quit_windows }
535
540
 
536
- if !@passwords.exist? then
541
+ if !@passwords.online? && !@passwords.exist? then
537
542
  @editing = Gtk::Window.new
538
543
  edit(combo_box,0)
539
544
  end
@@ -602,7 +607,7 @@ class Gtk2PasswordApp
602
607
  end
603
608
  end
604
609
  }
605
- run if !@passwords.exist?
610
+ run if !@passwords.online? && !@passwords.exist?
606
611
  Gtk.main
607
612
  end
608
613
  end
@@ -1,15 +1,10 @@
1
- # $Date: 2009/02/22 21:40:43 $
1
+ # $Date: 2009/02/26 00:26:57 $
2
2
  require 'lib/passwords_data'
3
- require 'gtk2'
4
3
  require 'find'
5
4
 
6
5
  class Gtk2PasswordMenu
7
6
  include Configuration
8
7
 
9
- FONT = Pango::FontDescription.new(FONT_NAME)
10
- RED = Gdk::Color.parse("#A00000")
11
- BLACK = Gdk::Color.parse("#000000")
12
-
13
8
  def get_salt(title='Short Password')
14
9
  dialog = Gtk::Dialog.new(
15
10
  title,
@@ -70,7 +65,7 @@ class Gtk2PasswordMenu
70
65
  @pph = get_passphrase
71
66
  @passwords = PasswordsData.new(@pwd+@pph)
72
67
  # Password file exist?
73
- if @passwords.exist? # then
68
+ if @passwords.online? || @passwords.exist? # then
74
69
  # Yes, load passwords file.
75
70
  @passwords.load
76
71
  else
@@ -145,7 +140,6 @@ class Gtk2PasswordMenu
145
140
  end
146
141
  end
147
142
  }
148
- run if !@passwords.exist?
149
143
  Gtk.main
150
144
  end
151
145
  end
data/lib/iocrypt.rb CHANGED
@@ -1,9 +1,11 @@
1
- # $Date: 2009/02/18 00:41:54 $
1
+ # $Date: 2009/02/26 00:43:37 $
2
2
  require 'yaml'
3
3
  require 'rubygems'
4
4
  require 'crypt/blowfish'
5
5
 
6
6
  class IOCrypt
7
+ HTTPX = Regexp.new('^https?:\/\/')
8
+
7
9
  def initialize(passphrase)
8
10
  @blowfish = Crypt::Blowfish.new(passphrase[0..55])
9
11
  end
@@ -11,15 +13,23 @@ class IOCrypt
11
13
  def load(dumpfile)
12
14
  data = nil
13
15
 
14
- File.open(dumpfile,'r'){|fh|
15
- data = YAML.load( @blowfish.decrypt_string( fh.read ) )
16
- }
16
+ if dumpfile =~ HTTPX then
17
+ require 'open-uri'
18
+ open(dumpfile){|fh|
19
+ data = YAML.load( @blowfish.decrypt_string( fh.read ) )
20
+ }
21
+ else
22
+ File.open(dumpfile,'r'){|fh|
23
+ data = YAML.load( @blowfish.decrypt_string( fh.read ) )
24
+ }
25
+ end
17
26
 
18
27
  return data
19
28
  end
20
29
 
21
30
  def dump(dumpfile, data)
22
31
  count = nil
32
+ raise "Http PUT not supported" if dumpfile =~ HTTPX
23
33
 
24
34
  File.open(dumpfile,'w') do |fh|
25
35
  count = fh.write( @blowfish.encrypt_string( YAML.dump( data ) ) )
@@ -1,4 +1,4 @@
1
- # $Date: 2009/02/18 16:07:01 $
1
+ # $Date: 2009/02/26 00:27:18 $
2
2
  require 'lib/iocrypt'
3
3
  require 'digest/md5'
4
4
 
@@ -17,7 +17,12 @@ class PasswordsData
17
17
  def _reset(passphrase)
18
18
  raise "Need a good passphrase" if !passphrase || passphrase.length < 7
19
19
  @passphrase = passphrase[0..55]
20
- @dumpfile = USER_CONF_DIR + '/' + Digest::MD5.hexdigest(@passphrase) + '.dat'
20
+ @dumpfile = PASSWORDS_DATA_DIR + '/' + Digest::MD5.hexdigest(@passphrase) + '.dat'
21
+ @online = (@dumpfile =~ /^http:\/\//)? true: false
22
+ end
23
+
24
+ def online?
25
+ @online
21
26
  end
22
27
 
23
28
  def initialize(passphrase)
@@ -26,17 +31,19 @@ class PasswordsData
26
31
  end
27
32
 
28
33
  def exist?
34
+ raise "n/a online" if @online
29
35
  File.exist?(@dumpfile)
30
36
  end
31
37
 
32
38
  def load(passphrase = nil)
33
39
  _reset(passphrase) if passphrase
34
- raise "Wrong passphrase" if !exist?
40
+ raise "Wrong passphrase" if !@online && !exist?
35
41
  iocrypt = IOCrypt.new(@passphrase)
36
42
  @data = iocrypt.load(@dumpfile)
37
43
  end
38
44
 
39
45
  def save(passphrase = nil)
46
+ raise "n/a online" if @online
40
47
  # just in case, keep a backup
41
48
  File.rename(@dumpfile, @dumpfile+'.bak') if File.exist?(@dumpfile)
42
49
  _reset(passphrase) if passphrase
@@ -46,6 +53,7 @@ class PasswordsData
46
53
  end
47
54
 
48
55
  def add(account)
56
+ raise "n/a online" if @online
49
57
  raise "Pre-existing" if @data[account]
50
58
  raise "Can't have nil account" if !account
51
59
  @data[account] = ['','','','','']
@@ -64,6 +72,7 @@ class PasswordsData
64
72
  end
65
73
 
66
74
  def delete(account)
75
+ raise "n/a online" if @online
67
76
  raise "#{account} not found" if !@data[account]
68
77
  @data.delete(account)
69
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtk2passwordapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64@gmail.com
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-22 00:00:00 -08:00
12
+ date: 2009-02-25 00:00:00 -08:00
13
13
  default_executable: gtk2youtubeapp
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency