Module: EasyAI::Base::SystemKeychain

Defined in:
lib/easyai/base/system_keychain.rb

Constant Summary collapse

SERVICE_NAME =
"easyai"
ACCOUNT_NAME =
"config_password"

Class Method Summary collapse

Class Method Details

.delete_stored_passwordObject

跨平台密码删除



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/easyai/base/system_keychain.rb', line 40

def self.delete_stored_password
  case detect_platform
  when :macos
    delete_password_macos
  when :windows
    delete_password_windows
  when :linux
    delete_password_linux
  else
    true
  end
end

.detect_platformObject

检测操作系统平台



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/easyai/base/system_keychain.rb', line 54

def self.detect_platform
  os = RbConfig::CONFIG['host_os']
  case os
  when /darwin/i
    :macos
  when /mswin|mingw|cygwin/i
    :windows
  when /linux/i
    :linux
  else
    :unknown
  end
end

.get_stored_passwordObject

跨平台密码获取



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/easyai/base/system_keychain.rb', line 26

def self.get_stored_password
  case detect_platform
  when :macos
    get_password_macos
  when :windows
    get_password_windows
  when :linux
    get_password_linux
  else
    nil
  end
end

.store_password(password) ⇒ Object

跨平台密码存储



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/easyai/base/system_keychain.rb', line 11

def self.store_password(password)
  case detect_platform
  when :macos
    store_password_macos(password)
  when :windows
    store_password_windows(password)
  when :linux
    store_password_linux(password)
  else
    puts "⚠ 当前平台不支持密码自动存储,将在会话中临时保存"
    false
  end
end