ebics_credentials 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/ebics_credentials.gemspec +25 -0
- data/lib/ebics_credentials.rb +71 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2b991f1d111e10b409ca1a4394e1e29e6a654fc8
|
4
|
+
data.tar.gz: bd730f1e6093f02a70912449206108eb2b35ddeb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55b8e569e3fba9779c66afbb3eee6b6fa316c82bdf0b7a93e583f03ec9727aca38f30185cecacd58513fa90f765fa26e43352d873fa60c4273d2a2623bcf9cb8
|
7
|
+
data.tar.gz: d74f1774e95a545dc9fe505e4894ec81bf0a7c70c0ed5a036d42d1175d5937f0e0c1d0e84bd76e3b3fcd339d785138e4a3a605f60c2e3b34d96ef69becdb00e5
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ebics_credentials (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
byebug (5.0.0)
|
10
|
+
columnize (= 0.9.0)
|
11
|
+
columnize (0.9.0)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
rake (10.4.2)
|
14
|
+
rspec (3.3.0)
|
15
|
+
rspec-core (~> 3.3.0)
|
16
|
+
rspec-expectations (~> 3.3.0)
|
17
|
+
rspec-mocks (~> 3.3.0)
|
18
|
+
rspec-core (3.3.2)
|
19
|
+
rspec-support (~> 3.3.0)
|
20
|
+
rspec-expectations (3.3.1)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.3.0)
|
23
|
+
rspec-mocks (3.3.2)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.3.0)
|
26
|
+
rspec-support (3.3.0)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bundler (~> 1.10)
|
33
|
+
byebug (~> 5)
|
34
|
+
ebics_credentials!
|
35
|
+
rake (~> 10.0)
|
36
|
+
rspec (~> 3)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.10.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Roman Lehnert
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# EbicsCredentials
|
2
|
+
|
3
|
+
EbicsCredentials is a tiny wrapper for keeping together ebics credentials.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ebics_credentials'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ebics_credentials
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Feeding with a credentials hash
|
24
|
+
Take a credentials hash and initialize an `EbicsCredentials` instance with it.
|
25
|
+
```ruby
|
26
|
+
credential_hash = {
|
27
|
+
key: "key",
|
28
|
+
url: "url",
|
29
|
+
host_id: "host_id",
|
30
|
+
user_id: "user_id",
|
31
|
+
partner_id: "partner_id"
|
32
|
+
passphrase: "passphrase",
|
33
|
+
}
|
34
|
+
|
35
|
+
credentials = EbicsCredentials.new(credential_hash)
|
36
|
+
```
|
37
|
+
At initialization, the completeness of the attributes will be validated. If they are invalid, `EbicsCredentials::Error::Invalid` will be raised.
|
38
|
+
|
39
|
+
|
40
|
+
### Feeding with a base64 encoded json hash
|
41
|
+
To create an instance from a base64 encoded json string, use `.from_encoded_json`:
|
42
|
+
```ruby
|
43
|
+
credential_hash = {
|
44
|
+
key: "key",
|
45
|
+
url: "url",
|
46
|
+
host_id: "host_id",
|
47
|
+
user_id: "user_id",
|
48
|
+
partner_id: "partner_id"
|
49
|
+
passphrase: "passphrase",
|
50
|
+
}
|
51
|
+
|
52
|
+
encoded_json = Base64.decode64(credential_hash.to_json)
|
53
|
+
|
54
|
+
credentials = EbicsCredentials.from_encoded_json(encoded_json)
|
55
|
+
```
|
56
|
+
When the given argument is not valid json, `EbicsCredentials::Errors::Invalid` will be raised.
|
57
|
+
|
58
|
+
Attribute accessors are provided:
|
59
|
+
```ruby
|
60
|
+
credentials.key # => "key"
|
61
|
+
credentials.host_id # => "host_id"
|
62
|
+
credentials.partner_id # => "partner_id"
|
63
|
+
credentials.user_id # => "user_id"
|
64
|
+
credentials.passphrase # => "passphrase"
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
## Development
|
70
|
+
|
71
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/romanlehnert/ebics_credentials.
|
76
|
+
|
77
|
+
|
78
|
+
## License
|
79
|
+
|
80
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
81
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ebics_credentials"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ebics_credentials"
|
7
|
+
spec.version = "0.1.0"
|
8
|
+
spec.authors = ["Roman Lehnert"]
|
9
|
+
spec.email = ["roman.lehnert@googlemail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{A ruby container for ebics credentials}
|
12
|
+
spec.description = %q{Encapsulates and validates the completeness of ebics credentials}
|
13
|
+
spec.homepage = "http://github.com/romanlehnert/ebics_credentials"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
24
|
+
spec.add_development_dependency "byebug", '~> 5'
|
25
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class EbicsCredentials
|
5
|
+
|
6
|
+
module Errors
|
7
|
+
class Base < StandardError; end
|
8
|
+
class Empty < Base
|
9
|
+
def to_s
|
10
|
+
"empty ebics credentials"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
class Invalid < Base
|
14
|
+
def to_s
|
15
|
+
"invalid ebics credentials"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
extend Forwardable
|
21
|
+
def_delegator :@credentials, :key
|
22
|
+
def_delegator :@credentials, :passphrase
|
23
|
+
def_delegator :@credentials, :url
|
24
|
+
def_delegator :@credentials, :host_id
|
25
|
+
def_delegator :@credentials, :partner_id
|
26
|
+
def_delegator :@credentials, :user_id
|
27
|
+
|
28
|
+
def self.from_encoded_json(encoded_json)
|
29
|
+
raise Errors::Empty if encoded_json.nil? || encoded_json.empty?
|
30
|
+
raise Errors::Invalid if !encoded_json.is_a?(String)
|
31
|
+
|
32
|
+
begin
|
33
|
+
credential_hash = JSON.parse(Base64.decode64(encoded_json), symbolize_names: true)
|
34
|
+
rescue => error
|
35
|
+
if error.is_a?(JSON::ParserError)
|
36
|
+
raise Errors::Invalid
|
37
|
+
else
|
38
|
+
raise error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
self.new(credential_hash)
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(credential_hash, options = {})
|
46
|
+
@credentials = OpenStruct.new(credential_hash)
|
47
|
+
validate! unless !options[:validate]
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_h
|
51
|
+
@credentials.to_h
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_json
|
55
|
+
to_h.to_json
|
56
|
+
end
|
57
|
+
|
58
|
+
def keys
|
59
|
+
[:key, :passphrase, :user_id, :host_id, :partner_id, :url]
|
60
|
+
end
|
61
|
+
|
62
|
+
def valid?
|
63
|
+
keys.each do |key|
|
64
|
+
return false if @credentials[key].nil? || @credentials[key].empty?
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def validate!
|
69
|
+
raise Errors::Invalid unless valid?
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ebics_credentials
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roman Lehnert
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5'
|
69
|
+
description: Encapsulates and validates the completeness of ebics credentials
|
70
|
+
email:
|
71
|
+
- roman.lehnert@googlemail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".rspec"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- ebics_credentials.gemspec
|
86
|
+
- lib/ebics_credentials.rb
|
87
|
+
homepage: http://github.com/romanlehnert/ebics_credentials
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.4.6
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: A ruby container for ebics credentials
|
111
|
+
test_files: []
|
112
|
+
has_rdoc:
|