x_road 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - '2.2.0'
4
+ - '1.9.3'
5
+ - 'ree'
6
+
7
+ before_install:
8
+ 'gem install bundler'
9
+ script: bundle exec rspec
10
+ addons:
11
+ code_climate:
12
+ repo_token: cc0cf605911730965fe587c050ec9f5eba1dc0cc6cf250a698264b1afd221af9
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in x_road.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Janno Siilbek
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 all
13
+ 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 THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # XRoad
2
+
3
+ [![Build Status](https://travis-ci.org/jannosiilbek/x_road.svg)](https://travis-ci.org/jannosiilbek/x_road)
4
+ [![Code Climate](https://codeclimate.com/github/jannosiilbek/x_road/badges/gpa.svg)](https://codeclimate.com/github/jannosiilbek/x_road)
5
+ [![Test Coverage](https://codeclimate.com/github/jannosiilbek/x_road/badges/coverage.svg)](https://codeclimate.com/github/jannosiilbek/x_road/coverage)
6
+ [![Dependency Status](https://gemnasium.com/jannosiilbek/x_road.svg)](https://gemnasium.com/jannosiilbek/x_road)
7
+
8
+ This gem simplifies the usage of X-Road services. Feel free to add new service classes.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'x_road'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install x_road
25
+
26
+ ## Usage
27
+
28
+ require 'x_road'
29
+
30
+ XRoad.configure do |config|
31
+ config.host = 'https://<security server ip>/cgi-bin/consumer_proxy'
32
+ config.client_cert = '/path/server.crt'
33
+ config.client_key = '/path/server.key'
34
+ config.log_level = :info
35
+ config.consumer = '12345678'
36
+ end
37
+
38
+ lms = XRoad::MyServiceName.find('1234567890')
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it ( https://github.com/[my-github-username]/x_road/fork )
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "x_road"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+ module XRoad
2
+ class ActiveXRoad
3
+ def self.create_header(producer, user_id, service)
4
+ id = UUIDTools::UUID.random_create.to_s
5
+ id.delete! '-'
6
+ {
7
+ "xtee:id" => id,
8
+ "xtee:nimi" => service,
9
+ "xtee:asutus" => XRoad.configuration.consumer,
10
+ "xtee:andmekogu" => producer,
11
+ "xtee:isikukood" => user_id
12
+ }
13
+ end
14
+
15
+ def self.request(action, namespace, header, body)
16
+ client = create_client(namespace)
17
+ response = client.call(
18
+ action,
19
+ :soap_header => header,
20
+ :message => body
21
+ )
22
+ response.body
23
+ end
24
+
25
+ def self.create_client(ns)
26
+ config = XRoad.configuration
27
+ Savon.client do
28
+ endpoint config.host
29
+ ssl_cert_file config.client_cert
30
+ ssl_cert_key_file config.client_key
31
+ pretty_print_xml true
32
+ ssl_verify_mode config.ssl_verify
33
+ log true
34
+ log_level config.log_level
35
+ namespace_identifier "prdcr"
36
+ namespace ns
37
+ namespaces(
38
+ "xmlns:xtee" => "http://x-tee.riik.ee/xsd/xtee.xsd",
39
+ "xmlns:prdcr" => ns
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,32 @@
1
+ module XRoad
2
+ module Kpr
3
+ class LaekumisedMaksuametist < XRoad::ActiveXRoad
4
+ def self.find(identity_code)
5
+ header = create_header(
6
+ 'kpr', identity_code, 'kpr.laekumised_maksuametist.v1'
7
+ )
8
+ body = create_body(identity_code)
9
+ response = request(
10
+ "laekumised_maksuametist",
11
+ "http://producers.kpr.xtee.riik.ee/producer/kpr",
12
+ header,
13
+ body
14
+ )
15
+
16
+ response[:laekumised_maksuametist_response][:keha]
17
+ end
18
+
19
+ def to_json
20
+ end
21
+
22
+ private
23
+ def self.create_body(identity_code)
24
+ {
25
+ "keha" => {
26
+ "ISIKUKOOD" => identity_code
27
+ }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module XRoad
2
+ VERSION = "0.1.0"
3
+ end
data/lib/x_road.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'require_all'
2
+ require 'x_road/version'
3
+ require 'uuidtools'
4
+ require 'savon'
5
+ require 'x_road/active_x_road'
6
+ require 'x_road/kpr/laekumised_maksuametist.rb'
7
+
8
+ module XRoad
9
+ class << self
10
+ attr_writer :configuration
11
+ end
12
+
13
+ def self.configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ def self.configure
18
+ yield(configuration)
19
+ end
20
+
21
+ class Configuration
22
+ attr_accessor :host
23
+ attr_accessor :client_cert
24
+ attr_accessor :client_key
25
+ attr_accessor :log_level
26
+ attr_accessor :consumer
27
+ attr_accessor :ssl_verify
28
+
29
+ def initialize
30
+ @log_level = :info
31
+ @ssl_verify = :none
32
+ end
33
+ end
34
+ end
data/x_road.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'x_road/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "x_road"
8
+ spec.version = XRoad::VERSION
9
+ spec.authors = ["Janno Siilbek"]
10
+ spec.email = ["janno.siilbek@gmail.com"]
11
+
12
+ spec.summary = %q{Communication with X-Road security server}
13
+ spec.description = %q{Feel free to add producer service classes}
14
+ spec.homepage = "https://github.com/jannosiilbek/x_road"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = '>= 1.8.7'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency 'uuidtools', '~> 2.1.5'
24
+ spec.add_dependency 'require_all', '~> 1.3.2'
25
+
26
+ if RUBY_VERSION < '1.9'
27
+ spec.add_dependency 'wasabi', '~> 3.3.0'
28
+ spec.add_dependency 'nori', '~> 2.4.0'
29
+ spec.add_dependency 'httpi', '~> 2.2.7'
30
+ spec.add_dependency 'akami', '~> 1.2.2'
31
+ spec.add_dependency 'nokogiri', '~> 1.5.10'
32
+ spec.add_dependency 'gyoku', '~> 1.1.0'
33
+ spec.add_dependency 'savon', '~> 2.7.2'
34
+ else
35
+ spec.add_dependency 'savon', '~> 2.11.1'
36
+ spec.add_development_dependency 'codeclimate-test-reporter'
37
+ end
38
+ spec.add_development_dependency "bundler", "~> 1.8"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency 'rspec'
41
+ end
metadata ADDED
@@ -0,0 +1,267 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: x_road
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Janno Siilbek
14
+ autorequire:
15
+ bindir: exe
16
+ cert_chain: []
17
+
18
+ date: 2015-07-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ hash: 1
27
+ segments:
28
+ - 2
29
+ - 1
30
+ - 5
31
+ version: 2.1.5
32
+ type: :runtime
33
+ name: uuidtools
34
+ version_requirements: *id001
35
+ prerelease: false
36
+ - !ruby/object:Gem::Dependency
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 31
43
+ segments:
44
+ - 1
45
+ - 3
46
+ - 2
47
+ version: 1.3.2
48
+ type: :runtime
49
+ name: require_all
50
+ version_requirements: *id002
51
+ prerelease: false
52
+ - !ruby/object:Gem::Dependency
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 11
59
+ segments:
60
+ - 3
61
+ - 3
62
+ - 0
63
+ version: 3.3.0
64
+ type: :runtime
65
+ name: wasabi
66
+ version_requirements: *id003
67
+ prerelease: false
68
+ - !ruby/object:Gem::Dependency
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 31
75
+ segments:
76
+ - 2
77
+ - 4
78
+ - 0
79
+ version: 2.4.0
80
+ type: :runtime
81
+ name: nori
82
+ version_requirements: *id004
83
+ prerelease: false
84
+ - !ruby/object:Gem::Dependency
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 9
91
+ segments:
92
+ - 2
93
+ - 2
94
+ - 7
95
+ version: 2.2.7
96
+ type: :runtime
97
+ name: httpi
98
+ version_requirements: *id005
99
+ prerelease: false
100
+ - !ruby/object:Gem::Dependency
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ~>
105
+ - !ruby/object:Gem::Version
106
+ hash: 27
107
+ segments:
108
+ - 1
109
+ - 2
110
+ - 2
111
+ version: 1.2.2
112
+ type: :runtime
113
+ name: akami
114
+ version_requirements: *id006
115
+ prerelease: false
116
+ - !ruby/object:Gem::Dependency
117
+ requirement: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ hash: 23
123
+ segments:
124
+ - 1
125
+ - 5
126
+ - 10
127
+ version: 1.5.10
128
+ type: :runtime
129
+ name: nokogiri
130
+ version_requirements: *id007
131
+ prerelease: false
132
+ - !ruby/object:Gem::Dependency
133
+ requirement: &id008 !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ hash: 19
139
+ segments:
140
+ - 1
141
+ - 1
142
+ - 0
143
+ version: 1.1.0
144
+ type: :runtime
145
+ name: gyoku
146
+ version_requirements: *id008
147
+ prerelease: false
148
+ - !ruby/object:Gem::Dependency
149
+ requirement: &id009 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ~>
153
+ - !ruby/object:Gem::Version
154
+ hash: 23
155
+ segments:
156
+ - 2
157
+ - 7
158
+ - 2
159
+ version: 2.7.2
160
+ type: :runtime
161
+ name: savon
162
+ version_requirements: *id009
163
+ prerelease: false
164
+ - !ruby/object:Gem::Dependency
165
+ requirement: &id010 !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ~>
169
+ - !ruby/object:Gem::Version
170
+ hash: 31
171
+ segments:
172
+ - 1
173
+ - 8
174
+ version: "1.8"
175
+ type: :development
176
+ name: bundler
177
+ version_requirements: *id010
178
+ prerelease: false
179
+ - !ruby/object:Gem::Dependency
180
+ requirement: &id011 !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ~>
184
+ - !ruby/object:Gem::Version
185
+ hash: 35
186
+ segments:
187
+ - 10
188
+ - 0
189
+ version: "10.0"
190
+ type: :development
191
+ name: rake
192
+ version_requirements: *id011
193
+ prerelease: false
194
+ - !ruby/object:Gem::Dependency
195
+ requirement: &id012 !ruby/object:Gem::Requirement
196
+ none: false
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ hash: 3
201
+ segments:
202
+ - 0
203
+ version: "0"
204
+ type: :development
205
+ name: rspec
206
+ version_requirements: *id012
207
+ prerelease: false
208
+ description: Feel free to add producer service classes
209
+ email:
210
+ - janno.siilbek@gmail.com
211
+ executables: []
212
+
213
+ extensions: []
214
+
215
+ extra_rdoc_files: []
216
+
217
+ files:
218
+ - .gitignore
219
+ - .travis.yml
220
+ - Gemfile
221
+ - LICENSE
222
+ - README.md
223
+ - Rakefile
224
+ - bin/console
225
+ - bin/setup
226
+ - lib/x_road.rb
227
+ - lib/x_road/active_x_road.rb
228
+ - lib/x_road/kpr/laekumised_maksuametist.rb
229
+ - lib/x_road/version.rb
230
+ - x_road.gemspec
231
+ homepage: https://github.com/jannosiilbek/x_road
232
+ licenses:
233
+ - MIT
234
+ post_install_message:
235
+ rdoc_options: []
236
+
237
+ require_paths:
238
+ - lib
239
+ required_ruby_version: !ruby/object:Gem::Requirement
240
+ none: false
241
+ requirements:
242
+ - - ">="
243
+ - !ruby/object:Gem::Version
244
+ hash: 57
245
+ segments:
246
+ - 1
247
+ - 8
248
+ - 7
249
+ version: 1.8.7
250
+ required_rubygems_version: !ruby/object:Gem::Requirement
251
+ none: false
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ hash: 3
256
+ segments:
257
+ - 0
258
+ version: "0"
259
+ requirements: []
260
+
261
+ rubyforge_project:
262
+ rubygems_version: 1.8.25
263
+ signing_key:
264
+ specification_version: 3
265
+ summary: Communication with X-Road security server
266
+ test_files: []
267
+