xml-kit 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -2
- data/.travis.yml +4 -3
- data/CHANGELOG.md +13 -2
- data/bin/cibuild +1 -1
- data/lib/xml/kit.rb +8 -2
- data/lib/xml/kit/crypto/oaep_cipher.rb +1 -1
- data/lib/xml/kit/crypto/rsa_cipher.rb +1 -1
- data/lib/xml/kit/crypto/symmetric_cipher.rb +1 -1
- data/lib/xml/kit/encrypted_data.rb +11 -13
- data/lib/xml/kit/encrypted_key.rb +9 -8
- data/lib/xml/kit/encryption.rb +7 -8
- data/lib/xml/kit/key_info.rb +32 -1
- data/lib/xml/kit/key_info/key_value.rb +2 -0
- data/lib/xml/kit/key_info/retrieval_method.rb +2 -0
- data/lib/xml/kit/key_info/rsa_key_value.rb +2 -0
- data/lib/xml/kit/key_pair.rb +4 -6
- data/lib/xml/kit/namespaces.rb +12 -12
- data/lib/xml/kit/self_signed_certificate.rb +4 -6
- data/lib/xml/kit/signature.rb +5 -7
- data/lib/xml/kit/signatures.rb +4 -6
- data/lib/xml/kit/templatable.rb +20 -13
- data/lib/xml/kit/version.rb +1 -1
- data/xml-kit.gemspec +3 -2
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92595d5d43bb4007e57571a20debb1834216a6d0de1e36dfa32468e191c52a8d
|
4
|
+
data.tar.gz: 4e14e3bbe4117db3644e07de0ce66024d4f5a5f413966beb8a645b5f580843ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb268742b91d95fea4f68f7b33de0dab19b01b6e7e443d8c1c5772c3ae1191e6f98821ba80bf60a80cf8bffea257b87bd7897885bd562ad1a3c6fd9d990f115
|
7
|
+
data.tar.gz: dfe550c8a027fa240d53d9237e10d41c943679a2321dadaffd42a3ea3d97f25e1173718e12a13ae6bbd79c93e2421254096048a94c6c46d7487286fe826c7982
|
data/.rubocop.yml
CHANGED
@@ -9,7 +9,7 @@ AllCops:
|
|
9
9
|
- 'spec/fixtures/**/*'
|
10
10
|
- 'tmp/**/*'
|
11
11
|
- 'vendor/**/*'
|
12
|
-
TargetRubyVersion: 2.
|
12
|
+
TargetRubyVersion: 2.4
|
13
13
|
|
14
14
|
Layout/ClassStructure:
|
15
15
|
Enabled: true
|
@@ -30,12 +30,15 @@ Layout/ClassStructure:
|
|
30
30
|
Layout/EndOfLine:
|
31
31
|
EnforcedStyle: lf
|
32
32
|
|
33
|
-
Layout/
|
33
|
+
Layout/IndentFirstArrayElement:
|
34
34
|
EnforcedStyle: consistent
|
35
35
|
|
36
36
|
Layout/IndentHeredoc:
|
37
37
|
EnforcedStyle: active_support
|
38
38
|
|
39
|
+
Layout/MultilineOperationIndentation:
|
40
|
+
EnforcedStyle: indented
|
41
|
+
|
39
42
|
Lint/AmbiguousBlockAssociation:
|
40
43
|
Exclude:
|
41
44
|
- 'spec/**/*.rb'
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Version 0.
|
1
|
+
Version 0.4.0
|
2
|
+
|
2
3
|
# Changelog
|
3
4
|
All notable changes to this project will be documented in this file.
|
4
5
|
|
@@ -6,9 +7,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
7
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
8
|
|
8
9
|
## [Unreleased]
|
9
|
-
### Changed
|
10
10
|
- nil
|
11
11
|
|
12
|
+
## [0.4.0] - 2019-04-30
|
13
|
+
### Added
|
14
|
+
- provide stable API for specifying the digest method and signature method.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- drop support for ruby 2.2
|
18
|
+
- drop support for ruby 2.3
|
19
|
+
- use bundler 2.0
|
20
|
+
|
12
21
|
## [0.3.1] - 2019-04-01
|
13
22
|
### Changed
|
14
23
|
- provide default symmetric cipher for `EncryptedData` element.
|
@@ -26,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
26
35
|
- errors are merged together instead of overwritten during attribute validation.
|
27
36
|
|
28
37
|
[Unreleased]: https://github.com/saml-kit/xml-kit/compare/v0.3.1...HEAD
|
38
|
+
[Unreleased]: https://github.com/saml-kit/xml-kit/compare/v0.4.0...HEAD
|
39
|
+
[0.4.0]: https://github.com/saml-kit/xml-kit/compare/v0.3.1...v0.4.0
|
29
40
|
[0.3.1]: https://github.com/saml-kit/xml-kit/compare/v0.3.0...v0.3.1
|
30
41
|
[0.3.0]: https://github.com/saml-kit/xml-kit/compare/v0.2.0...v0.3.0
|
31
42
|
[0.2.0]: https://github.com/saml-kit/xml-kit/compare/v0.1.14...v0.2.0
|
data/bin/cibuild
CHANGED
data/lib/xml/kit.rb
CHANGED
@@ -35,6 +35,8 @@ require 'xml/kit/version'
|
|
35
35
|
|
36
36
|
module Xml
|
37
37
|
module Kit
|
38
|
+
class Error < StandardError; end
|
39
|
+
|
38
40
|
class << self
|
39
41
|
def logger
|
40
42
|
@logger ||= Logger.new(STDOUT)
|
@@ -42,9 +44,13 @@ module Xml
|
|
42
44
|
|
43
45
|
attr_writer :logger
|
44
46
|
|
45
|
-
def deprecate(
|
47
|
+
def deprecate(name, alternative: nil)
|
46
48
|
@deprecation ||= ActiveSupport::Deprecation.new('1.0.0', 'xml-kit')
|
47
|
-
|
49
|
+
if alternative
|
50
|
+
@deprecation.deprecation_warning(name, "Use `#{alternative}` instead")
|
51
|
+
else
|
52
|
+
@deprecation.deprecation_warning(name)
|
53
|
+
end
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
@@ -4,7 +4,7 @@ module Xml
|
|
4
4
|
module Kit
|
5
5
|
module Crypto
|
6
6
|
class SymmetricCipher
|
7
|
-
DEFAULT_ALGORITHM = "#{::Xml::Kit::Namespaces::XMLENC}aes256-cbc"
|
7
|
+
DEFAULT_ALGORITHM = "#{::Xml::Kit::Namespaces::XMLENC}aes256-cbc"
|
8
8
|
ALGORITHMS = {
|
9
9
|
"#{::Xml::Kit::Namespaces::XMLENC}tripledes-cbc" => 'DES-EDE3-CBC',
|
10
10
|
"#{::Xml::Kit::Namespaces::XMLENC}aes128-cbc" => 'AES-128-CBC',
|
@@ -12,22 +12,20 @@ module Xml
|
|
12
12
|
attr_reader :symmetric_cipher
|
13
13
|
attr_reader :symmetric_cipher_value
|
14
14
|
|
15
|
-
def initialize(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
key_info: nil
|
21
|
-
)
|
15
|
+
def initialize(raw_xml,
|
16
|
+
id: Id.generate,
|
17
|
+
symmetric_cipher: nil,
|
18
|
+
asymmetric_cipher: nil,
|
19
|
+
key_info: nil)
|
22
20
|
@id = id
|
23
|
-
@symmetric_cipher = symmetric_cipher
|
21
|
+
@symmetric_cipher = symmetric_cipher ||
|
22
|
+
key_info.try(:symmetric_cipher) ||
|
23
|
+
Xml::Kit::Crypto::SymmetricCipher.new
|
24
24
|
@symmetric_cipher_value = Base64.strict_encode64(
|
25
|
-
symmetric_cipher.encrypt(raw_xml)
|
26
|
-
)
|
27
|
-
@key_info = key_info || create_key_info_for(
|
28
|
-
symmetric_cipher,
|
29
|
-
asymmetric_cipher
|
25
|
+
@symmetric_cipher.encrypt(raw_xml)
|
30
26
|
)
|
27
|
+
@key_info = key_info ||
|
28
|
+
create_key_info_for(@symmetric_cipher, asymmetric_cipher)
|
31
29
|
end
|
32
30
|
|
33
31
|
def to_xml(xml: ::Builder::XmlMarkup.new)
|
@@ -14,15 +14,16 @@ module Xml
|
|
14
14
|
attr_reader :asymmetric_cipher, :symmetric_cipher
|
15
15
|
attr_accessor :key_info
|
16
16
|
|
17
|
-
def initialize(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
key_info: nil
|
22
|
-
)
|
17
|
+
def initialize(id: Id.generate,
|
18
|
+
asymmetric_cipher: nil,
|
19
|
+
symmetric_cipher: nil,
|
20
|
+
key_info: nil)
|
23
21
|
@id = id
|
24
|
-
@asymmetric_cipher = asymmetric_cipher
|
25
|
-
|
22
|
+
@asymmetric_cipher = asymmetric_cipher ||
|
23
|
+
key_info.try(:asymmetric_cipher)
|
24
|
+
@symmetric_cipher = symmetric_cipher ||
|
25
|
+
key_info.try(:symmetric_cipher) ||
|
26
|
+
Xml::Kit::Crypto::SymmetricCipher.new
|
26
27
|
@key_info = key_info
|
27
28
|
end
|
28
29
|
|
data/lib/xml/kit/encryption.rb
CHANGED
@@ -4,21 +4,20 @@ module Xml
|
|
4
4
|
module Kit
|
5
5
|
# @deprecated Use {#Xml::Kit::EncryptedData} class instead of this
|
6
6
|
class Encryption < EncryptedData
|
7
|
+
DEFAULT_SYMMETRIC = Crypto::SymmetricCipher::DEFAULT_ALGORITHM
|
8
|
+
DEFAULT_ASYMMETRIC = Crypto::RsaCipher::ALGORITHM
|
9
|
+
|
7
10
|
attr_reader :asymmetric_algorithm
|
8
11
|
attr_reader :symmetric_algorithm
|
9
12
|
attr_reader :symmetric_cipher_value
|
10
13
|
attr_reader :key_info
|
11
14
|
|
12
|
-
def initialize(
|
13
|
-
|
14
|
-
|
15
|
-
symmetric_algorithm: Crypto::SymmetricCipher::DEFAULT_ALGORITHM,
|
16
|
-
asymmetric_algorithm: Crypto::RsaCipher::ALGORITHM,
|
17
|
-
key_info: nil
|
18
|
-
)
|
15
|
+
def initialize(raw_xml, public_key,
|
16
|
+
symmetric_algorithm: DEFAULT_SYMMETRIC,
|
17
|
+
asymmetric_algorithm: DEFAULT_ASYMMETRIC, key_info: nil)
|
19
18
|
@symmetric_algorithm = symmetric_algorithm
|
20
19
|
@asymmetric_algorithm = asymmetric_algorithm
|
21
|
-
Xml::Kit.deprecate('Encryption
|
20
|
+
Xml::Kit.deprecate('Encryption', alternative: 'EncryptedData')
|
22
21
|
super(raw_xml,
|
23
22
|
symmetric_cipher: symmetric(symmetric_algorithm),
|
24
23
|
asymmetric_cipher: asymmetric(asymmetric_algorithm, public_key),
|
data/lib/xml/kit/key_info.rb
CHANGED
@@ -16,11 +16,31 @@ module Xml
|
|
16
16
|
attr_accessor :x509_data
|
17
17
|
attr_accessor :encrypted_key
|
18
18
|
|
19
|
-
def initialize(x509: nil)
|
19
|
+
def initialize(x509: nil, encrypted_key: nil)
|
20
|
+
@encrypted_key = encrypted_key
|
20
21
|
@x509_data = x509
|
21
22
|
yield self if block_given?
|
22
23
|
end
|
23
24
|
|
25
|
+
def asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM)
|
26
|
+
return encrypted_key.asymmetric_cipher if encrypted_key
|
27
|
+
|
28
|
+
if x509_data
|
29
|
+
return Crypto.cipher_for(
|
30
|
+
derive_algorithm_from(x509_data.public_key),
|
31
|
+
x509_data.public_key
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
super(algorithm: algorithm)
|
36
|
+
end
|
37
|
+
|
38
|
+
def symmetric_cipher
|
39
|
+
return super if encrypted_key.nil?
|
40
|
+
|
41
|
+
encrypted_key.symmetric_cipher
|
42
|
+
end
|
43
|
+
|
24
44
|
def key_value
|
25
45
|
@key_value ||= KeyValue.new
|
26
46
|
end
|
@@ -35,6 +55,17 @@ module Xml
|
|
35
55
|
|
36
56
|
Base64.strict_encode64(ski.value)
|
37
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def derive_algorithm_from(key)
|
62
|
+
case key
|
63
|
+
when OpenSSL::PKey::RSA
|
64
|
+
"#{::Xml::Kit::Namespaces::XMLENC}rsa-1_5"
|
65
|
+
else
|
66
|
+
raise ::Xml::Kit::Error, "#{key.try(:class)} is not supported"
|
67
|
+
end
|
68
|
+
end
|
38
69
|
end
|
39
70
|
end
|
40
71
|
end
|
data/lib/xml/kit/key_pair.rb
CHANGED
@@ -30,12 +30,10 @@ module Xml
|
|
30
30
|
# @param use [Symbol] Can be either `:signing` or `:encryption`.
|
31
31
|
# @param passphrase [String] the passphrase to use to encrypt the private key.
|
32
32
|
# @param algorithm [String] the symmetric algorithm to use for encrypting the private key.
|
33
|
-
def self.generate(
|
34
|
-
|
35
|
-
|
36
|
-
algorithm
|
37
|
-
)
|
38
|
-
algorithm = ::Xml::Kit::Crypto::SymmetricCipher::ALGORITHMS[algorithm]
|
33
|
+
def self.generate(use:,
|
34
|
+
passphrase: SecureRandom.uuid,
|
35
|
+
algorithm: Crypto::SymmetricCipher::DEFAULT_ALGORITHM)
|
36
|
+
algorithm = Crypto::SymmetricCipher::ALGORITHMS[algorithm]
|
39
37
|
certificate, private_key = SelfSignedCertificate.new.create(
|
40
38
|
algorithm: algorithm,
|
41
39
|
passphrase: passphrase
|
data/lib/xml/kit/namespaces.rb
CHANGED
@@ -3,18 +3,18 @@
|
|
3
3
|
module Xml
|
4
4
|
module Kit
|
5
5
|
module Namespaces
|
6
|
-
CANONICALIZATION = 'http://www.w3.org/2001/10/xml-exc-c14n#'
|
7
|
-
ENVELOPED_SIG = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'
|
8
|
-
RSA_SHA1 = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
|
9
|
-
RSA_SHA256 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
|
10
|
-
RSA_SHA384 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'
|
11
|
-
RSA_SHA512 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512'
|
12
|
-
SHA1 = 'http://www.w3.org/2000/09/xmldsig#sha1'
|
13
|
-
SHA256 = 'http://www.w3.org/2001/04/xmlenc#sha256'
|
14
|
-
SHA384 = 'http://www.w3.org/2001/04/xmldsig-more#sha384'
|
15
|
-
SHA512 = 'http://www.w3.org/2001/04/xmlenc#sha512'
|
16
|
-
XMLDSIG = 'http://www.w3.org/2000/09/xmldsig#'
|
17
|
-
XMLENC = 'http://www.w3.org/2001/04/xmlenc#'
|
6
|
+
CANONICALIZATION = 'http://www.w3.org/2001/10/xml-exc-c14n#'
|
7
|
+
ENVELOPED_SIG = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'
|
8
|
+
RSA_SHA1 = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
|
9
|
+
RSA_SHA256 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
|
10
|
+
RSA_SHA384 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'
|
11
|
+
RSA_SHA512 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512'
|
12
|
+
SHA1 = 'http://www.w3.org/2000/09/xmldsig#sha1'
|
13
|
+
SHA256 = 'http://www.w3.org/2001/04/xmlenc#sha256'
|
14
|
+
SHA384 = 'http://www.w3.org/2001/04/xmldsig-more#sha384'
|
15
|
+
SHA512 = 'http://www.w3.org/2001/04/xmlenc#sha512'
|
16
|
+
XMLDSIG = 'http://www.w3.org/2000/09/xmldsig#'
|
17
|
+
XMLENC = 'http://www.w3.org/2001/04/xmlenc#'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -3,13 +3,11 @@
|
|
3
3
|
module Xml
|
4
4
|
module Kit
|
5
5
|
class SelfSignedCertificate
|
6
|
-
SUBJECT = '/C=CA/ST=AB/L=Calgary/O=XmlKit/OU=XmlKit/CN=XmlKit'
|
6
|
+
SUBJECT = '/C=CA/ST=AB/L=Calgary/O=XmlKit/OU=XmlKit/CN=XmlKit'
|
7
7
|
|
8
|
-
def create(
|
9
|
-
|
10
|
-
|
11
|
-
key_pair: OpenSSL::PKey::RSA.new(2048)
|
12
|
-
)
|
8
|
+
def create(algorithm: 'AES-256-CBC',
|
9
|
+
passphrase: nil,
|
10
|
+
key_pair: OpenSSL::PKey::RSA.new(2048))
|
13
11
|
certificate = certificate_for(key_pair.public_key)
|
14
12
|
certificate.sign(key_pair, OpenSSL::Digest::SHA256.new)
|
15
13
|
[certificate.to_pem, export(key_pair, algorithm, passphrase)]
|
data/lib/xml/kit/signature.rb
CHANGED
@@ -15,7 +15,7 @@ module Xml
|
|
15
15
|
SHA512: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512',
|
16
16
|
}.freeze
|
17
17
|
DIGEST_METHODS = {
|
18
|
-
SHA1: 'http://www.w3.org/2000/09/xmldsig#
|
18
|
+
SHA1: 'http://www.w3.org/2000/09/xmldsig#sha1',
|
19
19
|
SHA224: 'http://www.w3.org/2001/04/xmldsig-more#sha224',
|
20
20
|
SHA256: 'http://www.w3.org/2001/04/xmlenc#sha256',
|
21
21
|
SHA384: 'http://www.w3.org/2001/04/xmldsig-more#sha384',
|
@@ -27,12 +27,10 @@ module Xml
|
|
27
27
|
attr_reader :reference_id
|
28
28
|
attr_reader :signature_method
|
29
29
|
|
30
|
-
def initialize(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
certificate:
|
35
|
-
)
|
30
|
+
def initialize(reference_id,
|
31
|
+
signature_method: :SH256,
|
32
|
+
digest_method: :SHA256,
|
33
|
+
certificate:)
|
36
34
|
@certificate = certificate
|
37
35
|
@digest_method = DIGEST_METHODS[digest_method]
|
38
36
|
@reference_id = reference_id
|
data/lib/xml/kit/signatures.rb
CHANGED
@@ -39,12 +39,10 @@ module Xml
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# @!visibility private
|
42
|
-
def self.sign(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
digest_method: :SHA256
|
47
|
-
)
|
42
|
+
def self.sign(xml: ::Builder::XmlMarkup.new,
|
43
|
+
key_pair:,
|
44
|
+
signature_method: :SHA256,
|
45
|
+
digest_method: :SHA256)
|
48
46
|
signatures = new(
|
49
47
|
key_pair: key_pair,
|
50
48
|
signature_method: signature_method,
|
data/lib/xml/kit/templatable.rb
CHANGED
@@ -17,6 +17,14 @@ module Xml
|
|
17
17
|
# The [Xml::Kit::Certificate] that contains the public key to use for encrypting the document.
|
18
18
|
attr_accessor :encryption_certificate
|
19
19
|
|
20
|
+
# Allows you to specify the digest method algorithm. (Default: SHA256)
|
21
|
+
# A list of digest methods can be found in [Xml::Kit::Signature].
|
22
|
+
attr_accessor :digest_method
|
23
|
+
|
24
|
+
# Allows you to specify the signature method algorithm. (Default: SHA256)
|
25
|
+
# A list of signature methods can be found in [Xml::Kit::Signature].
|
26
|
+
attr_accessor :signature_method
|
27
|
+
|
20
28
|
# Returns the generated XML document with an XML Digital Signature and XML Encryption.
|
21
29
|
def to_xml(xml: ::Builder::XmlMarkup.new, pretty: false)
|
22
30
|
result = signatures.complete(render(self, xml: xml))
|
@@ -28,11 +36,12 @@ module Xml
|
|
28
36
|
# @since 0.3.0
|
29
37
|
# @param xml [Builder::XmlMarkup] the xml builder instance
|
30
38
|
# @param id [String] the id of EncryptedKey element
|
31
|
-
def encrypt_key_for(xml:, id:)
|
39
|
+
def encrypt_key_for(xml:, id:, key_info: nil)
|
32
40
|
::Xml::Kit::EncryptedKey.new(
|
33
41
|
id: id,
|
34
42
|
asymmetric_cipher: asymmetric_cipher,
|
35
|
-
symmetric_cipher: symmetric_cipher
|
43
|
+
symmetric_cipher: symmetric_cipher,
|
44
|
+
key_info: key_info
|
36
45
|
).to_xml(xml: xml)
|
37
46
|
end
|
38
47
|
|
@@ -67,6 +76,10 @@ module Xml
|
|
67
76
|
# @abstract
|
68
77
|
# @since 0.3.0
|
69
78
|
def asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM)
|
79
|
+
unless encryption_certificate
|
80
|
+
raise Xml::Kit::Error, 'encryption_certificate is not specified.'
|
81
|
+
end
|
82
|
+
|
70
83
|
@asymmetric_cipher ||= Crypto.cipher_for(
|
71
84
|
algorithm,
|
72
85
|
encryption_certificate.public_key
|
@@ -94,9 +107,11 @@ module Xml
|
|
94
107
|
# Allows you to specify which key pair to use for generating an XML digital signature.
|
95
108
|
#
|
96
109
|
# @param key_pair [Xml::Kit::KeyPair] the key pair to use for signing.
|
97
|
-
def sign_with(key_pair)
|
110
|
+
def sign_with(key_pair, signature_method: :SHA256, digest_method: :SHA256)
|
98
111
|
self.signing_key_pair = key_pair
|
99
112
|
self.embed_signature = true
|
113
|
+
self.signature_method = signature_method
|
114
|
+
self.digest_method = digest_method
|
100
115
|
signatures.sign_with(key_pair)
|
101
116
|
end
|
102
117
|
|
@@ -118,19 +133,11 @@ module Xml
|
|
118
133
|
def signatures
|
119
134
|
@signatures ||= ::Xml::Kit::Signatures.new(
|
120
135
|
key_pair: signing_key_pair,
|
121
|
-
digest_method: digest_method,
|
122
|
-
signature_method: signature_method
|
136
|
+
digest_method: digest_method || :SHA256,
|
137
|
+
signature_method: signature_method || :SHA256
|
123
138
|
)
|
124
139
|
end
|
125
140
|
|
126
|
-
def digest_method
|
127
|
-
:SHA256
|
128
|
-
end
|
129
|
-
|
130
|
-
def signature_method
|
131
|
-
:SHA256
|
132
|
-
end
|
133
|
-
|
134
141
|
# @!visibility private
|
135
142
|
def encrypt?
|
136
143
|
encrypt && encryption_certificate
|
data/lib/xml/kit/version.rb
CHANGED
data/xml-kit.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'A simple toolkit for working with XML.'
|
15
15
|
spec.homepage = 'https://github.com/saml-kit/xml-kit'
|
16
16
|
spec.license = 'MIT'
|
17
|
-
spec.required_ruby_version = '
|
17
|
+
spec.required_ruby_version = '~> 2.4'
|
18
18
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
20
|
f.match(%r{^(test|spec|features)/})
|
@@ -26,9 +26,10 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.add_dependency 'activemodel', '>= 4.2.0'
|
28
28
|
spec.add_dependency 'builder', '~> 3.2'
|
29
|
-
spec.add_dependency 'nokogiri', '
|
29
|
+
spec.add_dependency 'nokogiri', '~> 1.10'
|
30
30
|
spec.add_dependency 'tilt', '>= 1.4.1'
|
31
31
|
spec.add_dependency 'xmldsig', '~> 0.6'
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
33
|
spec.add_development_dependency 'bundler-audit', '~> 0.6'
|
33
34
|
spec.add_development_dependency 'ffaker', '~> 2.7'
|
34
35
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xml-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: '1.10'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: '1.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: tilt
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: bundler-audit
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +206,7 @@ files:
|
|
192
206
|
- ".travis.yml"
|
193
207
|
- CHANGELOG.md
|
194
208
|
- Gemfile
|
209
|
+
- Gemfile.lock
|
195
210
|
- LICENSE.txt
|
196
211
|
- README.md
|
197
212
|
- Rakefile
|
@@ -249,16 +264,16 @@ require_paths:
|
|
249
264
|
- lib
|
250
265
|
required_ruby_version: !ruby/object:Gem::Requirement
|
251
266
|
requirements:
|
252
|
-
- - "
|
267
|
+
- - "~>"
|
253
268
|
- !ruby/object:Gem::Version
|
254
|
-
version: 2.
|
269
|
+
version: '2.4'
|
255
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
271
|
requirements:
|
257
272
|
- - ">="
|
258
273
|
- !ruby/object:Gem::Version
|
259
274
|
version: '0'
|
260
275
|
requirements: []
|
261
|
-
rubygems_version: 3.0.
|
276
|
+
rubygems_version: 3.0.3
|
262
277
|
signing_key:
|
263
278
|
specification_version: 4
|
264
279
|
summary: A simple toolkit for working with XML.
|