rest_pki 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +2 -0
- data/lib/rest_pki.rb +35 -0
- data/lib/rest_pki/authentication.rb +43 -0
- data/lib/rest_pki/cades_signature_finisher.rb +48 -0
- data/lib/rest_pki/cades_signature_starter.rb +148 -0
- data/lib/rest_pki/full_xml_signature_starter.rb +51 -0
- data/lib/rest_pki/namespace_manager.rb +16 -0
- data/lib/rest_pki/object.rb +126 -0
- data/lib/rest_pki/pades_signature_finisher.rb +50 -0
- data/lib/rest_pki/pades_signature_starter.rb +110 -0
- data/lib/rest_pki/pades_visual_positioning_presets.rb +32 -0
- data/lib/rest_pki/resources/authentication_model.rb +5 -0
- data/lib/rest_pki/resources/cades_model.rb +5 -0
- data/lib/rest_pki/resources/pades_model.rb +5 -0
- data/lib/rest_pki/resources/response_model.rb +5 -0
- data/lib/rest_pki/resources/xml_model.rb +5 -0
- data/lib/rest_pki/rest_base_error.rb +12 -0
- data/lib/rest_pki/rest_error.rb +16 -0
- data/lib/rest_pki/rest_unreachable_error.rb +13 -0
- data/lib/rest_pki/restpki_client.rb +95 -0
- data/lib/rest_pki/restpki_error.rb +16 -0
- data/lib/rest_pki/signature_finisher.rb +33 -0
- data/lib/rest_pki/signature_starter.rb +59 -0
- data/lib/rest_pki/standard_security_contexts.rb +10 -0
- data/lib/rest_pki/standard_signature_policies.rb +25 -0
- data/lib/rest_pki/validation_error.rb +11 -0
- data/lib/rest_pki/validation_item.rb +33 -0
- data/lib/rest_pki/validation_results.rb +107 -0
- data/lib/rest_pki/version.rb +3 -0
- data/lib/rest_pki/xml_element_signature_starter.rb +68 -0
- data/lib/rest_pki/xml_id_resolution_table.rb +40 -0
- data/lib/rest_pki/xml_insertion_options.rb +11 -0
- data/lib/rest_pki/xml_signature_finisher.rb +52 -0
- data/lib/rest_pki/xml_signature_starter.rb +84 -0
- data/rest_pki.gemspec +30 -0
- metadata +146 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module RestPki
|
4
|
+
class XmlSignatureStarter < SignatureStarter
|
5
|
+
|
6
|
+
def initialize(restpki_client)
|
7
|
+
super(restpki_client)
|
8
|
+
@xml_content_base64 = nil
|
9
|
+
@signature_element_id = nil
|
10
|
+
@xpath = nil
|
11
|
+
@insertion_option = nil
|
12
|
+
@namespace_manager = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
#region set_xml_tosign
|
16
|
+
|
17
|
+
def set_xml_tosign_from_path(xml_path)
|
18
|
+
file = File.open(xml_path, 'rb')
|
19
|
+
@xml_content_base64 = Base64.encode64(file.read)
|
20
|
+
file.close
|
21
|
+
|
22
|
+
@xml_content_base64
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_xml_tosign_from_raw(content_raw)
|
26
|
+
@xml_content_base64 = Base64.encode64(content_raw)
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_xml_tosign_from_base64(content_base64)
|
30
|
+
@xml_content_base64 = content_base64
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_xml_content_tosign(content_raw)
|
34
|
+
set_xml_tosign_from_raw(content_raw)
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_xml_file_tosign(xml_path)
|
38
|
+
set_xml_tosign_from_path(xml_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
#endregion
|
42
|
+
|
43
|
+
def set_signature_element_location(xpath, insertion_option, namespace_manager=nil)
|
44
|
+
@xpath = xpath
|
45
|
+
@insertion_option = insertion_option
|
46
|
+
@namespace_manager = namespace_manager
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
def verify_common_parameters(is_with_webpki=false)
|
51
|
+
unless is_with_webpki
|
52
|
+
if @signer_certificate_base64.to_s.blank?
|
53
|
+
raise 'The certificate was not set'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if @signature_policy_id.to_s.blank?
|
58
|
+
raise 'The signature policy was not set'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_request
|
63
|
+
request = {
|
64
|
+
signatureElementId: @signature_element_id,
|
65
|
+
signaturePolicyId: @signature_policy_id,
|
66
|
+
securityContextId: @security_context_id,
|
67
|
+
ignoreRevocationStatusUnknown: @ignore_revocation_status_unknown
|
68
|
+
}
|
69
|
+
unless @xml_content_base64.to_s.blank?
|
70
|
+
request['xml'] = @xml_content_base64
|
71
|
+
end
|
72
|
+
unless @xpath.nil? or @insertion_option.nil?
|
73
|
+
request['signatureElementLocation'] = {
|
74
|
+
xPath: @xpath,
|
75
|
+
insertionOption: @insertion_option
|
76
|
+
}
|
77
|
+
unless @namespace_manager.nil?
|
78
|
+
request['signatureElementLocation']['namespaces'] = @namespace_manager.namespaces
|
79
|
+
end
|
80
|
+
end
|
81
|
+
request
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/rest_pki.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require_relative 'lib/rest_pki/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'rest_pki'
|
6
|
+
spec.version = RestPki::VERSION
|
7
|
+
spec.license = 'MIT'
|
8
|
+
spec.authors = ['Murilo Zaffalon', 'Ismael Medeiros']
|
9
|
+
spec.email = %w{mzaffalon@hotmail.com IsmaelM@lacunasoftware.com}
|
10
|
+
spec.homepage = 'https://pki.rest/'
|
11
|
+
spec.summary = 'Client lib for REST PKI'
|
12
|
+
spec.description = 'Classes to consume Lacuna Software REST PKI'
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.metadata = {
|
19
|
+
'bug_tracker_uri' => 'https://github.com/LacunaSoftware/RestPkiRubyClient/issues',
|
20
|
+
'changelog_uri' => 'https://github.com/LacunaSoftware/RestPkiRubyClient/blob/master/CHANGELOG.md',
|
21
|
+
'documentation_uri' => 'http://docs.lacunasoftware.com/articles/rest-pki/ruby/index.html',
|
22
|
+
'source_code_uri' => 'https://github.com/LacunaSoftware/RestPkiRubyClient'
|
23
|
+
}
|
24
|
+
|
25
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
26
|
+
spec.add_dependency 'multi_json', '~> 1.12'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rest_pki
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Murilo Zaffalon
|
8
|
+
- Ismael Medeiros
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-04-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: multi_json
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.12'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.12'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.7'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.7'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
description: Classes to consume Lacuna Software REST PKI
|
71
|
+
email:
|
72
|
+
- mzaffalon@hotmail.com
|
73
|
+
- IsmaelM@lacunasoftware.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/rest_pki.rb
|
85
|
+
- lib/rest_pki/authentication.rb
|
86
|
+
- lib/rest_pki/cades_signature_finisher.rb
|
87
|
+
- lib/rest_pki/cades_signature_starter.rb
|
88
|
+
- lib/rest_pki/full_xml_signature_starter.rb
|
89
|
+
- lib/rest_pki/namespace_manager.rb
|
90
|
+
- lib/rest_pki/object.rb
|
91
|
+
- lib/rest_pki/pades_signature_finisher.rb
|
92
|
+
- lib/rest_pki/pades_signature_starter.rb
|
93
|
+
- lib/rest_pki/pades_visual_positioning_presets.rb
|
94
|
+
- lib/rest_pki/resources/authentication_model.rb
|
95
|
+
- lib/rest_pki/resources/cades_model.rb
|
96
|
+
- lib/rest_pki/resources/pades_model.rb
|
97
|
+
- lib/rest_pki/resources/response_model.rb
|
98
|
+
- lib/rest_pki/resources/xml_model.rb
|
99
|
+
- lib/rest_pki/rest_base_error.rb
|
100
|
+
- lib/rest_pki/rest_error.rb
|
101
|
+
- lib/rest_pki/rest_unreachable_error.rb
|
102
|
+
- lib/rest_pki/restpki_client.rb
|
103
|
+
- lib/rest_pki/restpki_error.rb
|
104
|
+
- lib/rest_pki/signature_finisher.rb
|
105
|
+
- lib/rest_pki/signature_starter.rb
|
106
|
+
- lib/rest_pki/standard_security_contexts.rb
|
107
|
+
- lib/rest_pki/standard_signature_policies.rb
|
108
|
+
- lib/rest_pki/validation_error.rb
|
109
|
+
- lib/rest_pki/validation_item.rb
|
110
|
+
- lib/rest_pki/validation_results.rb
|
111
|
+
- lib/rest_pki/version.rb
|
112
|
+
- lib/rest_pki/xml_element_signature_starter.rb
|
113
|
+
- lib/rest_pki/xml_id_resolution_table.rb
|
114
|
+
- lib/rest_pki/xml_insertion_options.rb
|
115
|
+
- lib/rest_pki/xml_signature_finisher.rb
|
116
|
+
- lib/rest_pki/xml_signature_starter.rb
|
117
|
+
- rest_pki.gemspec
|
118
|
+
homepage: https://pki.rest/
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata:
|
122
|
+
bug_tracker_uri: https://github.com/LacunaSoftware/RestPkiRubyClient/issues
|
123
|
+
changelog_uri: https://github.com/LacunaSoftware/RestPkiRubyClient/blob/master/CHANGELOG.md
|
124
|
+
documentation_uri: http://docs.lacunasoftware.com/articles/rest-pki/ruby/index.html
|
125
|
+
source_code_uri: https://github.com/LacunaSoftware/RestPkiRubyClient
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.7.6
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Client lib for REST PKI
|
146
|
+
test_files: []
|