Class: BrowserID::Identity
- Inherits:
-
Object
- Object
- BrowserID::Identity
- Defined in:
- lib/browserid-provider/identity.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Identity
constructor
Options == :key_path where to store the OpenSSL private key.
- #private_key ⇒ Object
- #public_key ⇒ Object
-
#to_json ⇒ Object
Return BrowserID Identity JSON.
Constructor Details
#initialize(options = {}) ⇒ Identity
Options ==
:key_path where to store the OpenSSL private key
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/browserid-provider/identity.rb', line 10 def initialize( = {}) @config = BrowserID::Config.new() keypath = @config.private_key_path if File.exists?(keypath) File.open(keypath) {|f| @privkey = OpenSSL::PKey::RSA.new(f.read) } @pubkey = @privkey.public_key else require 'fileutils' FileUtils.mkdir_p keypath.sub(File.basename(keypath),'') @privkey = OpenSSL::PKey::RSA.new(2048) @pubkey = @privkey.public_key File.open(keypath, "w") {|f| f.write(@privkey) } end end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/browserid-provider/identity.rb', line 6 def config @config end |
Instance Method Details
#private_key ⇒ Object
31 32 33 |
# File 'lib/browserid-provider/identity.rb', line 31 def private_key @privkey end |
#public_key ⇒ Object
27 28 29 |
# File 'lib/browserid-provider/identity.rb', line 27 def public_key @pubkey end |
#to_json ⇒ Object
Return BrowserID Identity JSON
36 37 38 39 40 41 42 |
# File 'lib/browserid-provider/identity.rb', line 36 def to_json { "public-key" => { "algorithm"=> "RS", "n" => public_key.n.to_s, "e" => public_key.e.to_s }, "authentication" => @config.login_path, "provisioning" => @config.provision_path }.to_json end |