esteid 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 672562dea02e6e9b88e7033f37859c7b2baf2473
4
- data.tar.gz: 857f4eb96f0006232b95004f13f4ba31f4c41049
3
+ metadata.gz: fbb4a4c40badbfdb6a038a81afec01a1a1e214b3
4
+ data.tar.gz: 99fedb381bf95c531142edff6a3c74d7a00edd4c
5
5
  SHA512:
6
- metadata.gz: 241aebde16323d30d412426fde0c75edd99c54183c2120dd6eb9eef8b0e1737e341d54f0c7861554fc2eb6df4f39a25c1d439cf181b85cee1553772ab87e815f
7
- data.tar.gz: ac572eaa3b41dcfef513af065a2a986a3fa7a27d33bc69d7c81b8d7fe00955fd914757595ebfa1709643b89704f7b7594037d7d590efee8b115769f4f5fd5ef2
6
+ metadata.gz: 2996ce97e8353af523743f8961a3c00d374606ac414752d4c4d9f85f65aba596a2240636824ccb2bad88e0e17636463739a544056bc51d2cb68673eaff7c0684
7
+ data.tar.gz: 6e5e1482780f1004855f4edd293a381ae25ca2e0e1c88ed2a67cb349c3818e64923ec7d36248d959425cb760b705631fdecdb5bc6942153edc5712eacb96c2f7
data/esteid.gemspec CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
+ spec.add_dependency "savon", ">= 2.4.0"
24
+
23
25
  spec.add_development_dependency "bundler", "~> 1.15"
24
26
  spec.add_development_dependency "rake", "~> 10.0"
25
27
  spec.add_development_dependency "rspec", "~> 3.2"
@@ -11,9 +11,13 @@ module EstEID
11
11
 
12
12
  class Configuration
13
13
  attr_accessor :certificate_header
14
+ attr_accessor :public_key_header
15
+ attr_accessor :digidoc_endpoint_url
14
16
 
15
17
  def initialize
16
18
  @certificate_header = nil
19
+ @public_key_header = nil
20
+ @digidoc_endpoint_url = nil
17
21
  end
18
22
  end
19
23
  end
@@ -0,0 +1,80 @@
1
+ require "savon"
2
+
3
+ module EstEID
4
+ class Validation
5
+ attr_reader :eid_public_key
6
+
7
+ STATUSES = {
8
+ 'REVOKED' => 'cert_revoked',
9
+ 'UNKNOWN' => 'cert_unknown',
10
+ 'EXPIRED' => 'cert_expired',
11
+ 'SUSPENDED' => 'cert_suspended',
12
+ '100' => '100',
13
+ '101' => '101',
14
+ '102' => '102',
15
+ '103' => '103',
16
+ '200' => '200',
17
+ '201' => '201',
18
+ '202' => '202',
19
+ '203' => '203',
20
+ '300' => '300',
21
+ '301' => '301',
22
+ '302' => '302',
23
+ '303' => '303',
24
+ '304' => '304',
25
+ '305' => '305',
26
+ '413' => '413',
27
+ '503' => '503'
28
+ }
29
+
30
+ def initialize(request)
31
+ @eid_public_key = request.headers[EstEID.config.public_key_header]
32
+ end
33
+
34
+ def valid?
35
+ status == "GOOD"
36
+ end
37
+
38
+ def status
39
+ return soap_error_code if soap_fault?
40
+ response.body.dig(:check_certificate_response, :status)
41
+ end
42
+
43
+ private
44
+
45
+ def client
46
+ @client ||= ::Savon.client(
47
+ endpoint: EstEID.config.digidoc_endpoint_url,
48
+ namespace: "http://www.sk.ee/DigiDocService/DigiDocService_2_3.wsdl",
49
+ raise_errors: false,
50
+ open_timeout: 10,
51
+ ssl_version: :TLSv1,
52
+ ssl_verify_mode: :none
53
+ )
54
+ end
55
+
56
+ def response
57
+ @response ||= client.call("CheckCertificate") do |locals|
58
+ locals.message "Certificate" => @certificate
59
+ end
60
+ end
61
+
62
+ def soap_fault?
63
+ response.http.body =~ /<*Fault>/
64
+ end
65
+
66
+ def soap_error_code
67
+ response.body[:fault][:faultstring]
68
+ end
69
+
70
+ def error_status(status)
71
+ return if valid?
72
+
73
+ if STATUSES.include?(status)
74
+ STATUSES[status]
75
+ else
76
+ status
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,3 +1,3 @@
1
1
  module EstEID
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
data/lib/esteid.rb CHANGED
@@ -6,3 +6,4 @@ end
6
6
  require "rubygems"
7
7
  require "esteid/version"
8
8
  require "esteid/authentication"
9
+ require "esteid/validation"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esteid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Pakk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-13 00:00:00.000000000 Z
11
+ date: 2017-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.4.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.4.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +86,7 @@ files:
72
86
  - lib/esteid.rb
73
87
  - lib/esteid/authentication.rb
74
88
  - lib/esteid/configuration.rb
89
+ - lib/esteid/validation.rb
75
90
  - lib/esteid/version.rb
76
91
  homepage: https://github.com/deskrock/esteid
77
92
  licenses: