xmlenc 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94efb101ace03f35e40da6184f97496ca05cdf9c
4
- data.tar.gz: aa624f1dbaaff306a098c52df5f65b8e2f9b6e12
3
+ metadata.gz: 80959c76fdd31d7d40f3d1d5bb83ffda5d783b0b
4
+ data.tar.gz: a768a769b244114f6051a718fd3ae30c082cd785
5
5
  SHA512:
6
- metadata.gz: 09db7cf98de7814559c9634362c1edfedb833c5876ca9fd60b2f96a49f2b68c2e9e3fb91702525909bc4f0a53384053416261e707cfa07094d4f49e4c0fa0a7f
7
- data.tar.gz: 9f06d1d39d9cee75aa5879b05ab86784face57a37b5f857c540e67196513a4db794772c0d12f0755de09f81af5bbf27047cc1e0be0320d710340266508d737c6
6
+ metadata.gz: 09762e2cfa2bb910535b8a7eb89ee6b7dd052683ab5f1e41adff4c80c11bb8166da21bc69e827b2122c5230c62a8f1a65eabb163630d520d3f58664184ccbc1e
7
+ data.tar.gz: b7dde51da4ba68ef9df4026b37d87ca630ccf60077cd9bd735f23ff433a12c9e2730df160964c718c916cf29c9d6ccca2fb30eb5ef010cd3831397191dbe1be4
data/README.md CHANGED
@@ -25,7 +25,8 @@ key_pem = File.read('path/to/key.pem')
25
25
  xml = File.read('path/to/file.xml')
26
26
 
27
27
  private_key = OpenSSL::PKey::RSA.new(key_pem)
28
- decrypted_document = Xmlenc::EncryptedDocument.decrypt(private_key)
28
+ encrypted_document = Xmlenc::EncryptedDocument.new(xml)
29
+ decrypted_document = encrypted_document.decrypt(private_key)
29
30
  ```
30
31
 
31
32
  ### Supported algorithms
@@ -7,8 +7,8 @@ require 'nokogiri'
7
7
 
8
8
  module Xmlenc
9
9
  NAMESPACES = {
10
- xenc: 'http://www.w3.org/2001/04/xmlenc#',
11
- ds: 'http://www.w3.org/2000/09/xmldsig#'
10
+ :xenc => 'http://www.w3.org/2001/04/xmlenc#',
11
+ :ds => 'http://www.w3.org/2000/09/xmldsig#'
12
12
  }
13
13
 
14
14
  class UnsupportedError < StandardError
@@ -8,7 +8,7 @@ module Xmlenc
8
8
  register_namespace "xenc", Xmlenc::NAMESPACES[:xenc]
9
9
  namespace "xenc"
10
10
 
11
- element :cipher_value, String, namespace: "xenc", tag: "CipherValue"
11
+ element :cipher_value, String, :namespace => "xenc", :tag => "CipherValue"
12
12
  end
13
13
  end
14
14
  end
@@ -8,11 +8,11 @@ module Xmlenc
8
8
  included do
9
9
  register_namespace "xenc", Xmlenc::NAMESPACES[:xenc]
10
10
 
11
- has_one :encryption_method, Xmlenc::Builder::EncryptionMethod, xpath: "./"
12
- has_one :key_info, Xmlenc::Builder::KeyInfo, xpath: "./"
13
- has_one :cipher_data, Xmlenc::Builder::CipherData, xpath: "./"
11
+ has_one :encryption_method, Xmlenc::Builder::EncryptionMethod, :xpath => "./"
12
+ has_one :key_info, Xmlenc::Builder::KeyInfo, :xpath => "./"
13
+ has_one :cipher_data, Xmlenc::Builder::CipherData, :xpath => "./"
14
14
 
15
- validates :cipher_data, presence: true
15
+ validates :cipher_data, :presence => true
16
16
  end
17
17
 
18
18
  def initialize(attributes = {})
@@ -8,7 +8,7 @@ module Xmlenc
8
8
  register_namespace "xenc", Xmlenc::NAMESPACES[:xenc]
9
9
  namespace "xenc"
10
10
 
11
- attribute :uri, String, tag: "URI"
11
+ attribute :uri, String, :tag => "URI"
12
12
  end
13
13
  end
14
14
  end
@@ -8,9 +8,9 @@ module Xmlenc
8
8
  register_namespace "ds", Xmlenc::NAMESPACES[:ds]
9
9
  namespace "ds"
10
10
 
11
- attribute :algorithm, String, tag: "Algorithm"
11
+ attribute :algorithm, String, :tag => "Algorithm"
12
12
 
13
- validates :algorithm, presence: true
13
+ validates :algorithm, :presence => true
14
14
  end
15
15
  end
16
16
  end
@@ -16,8 +16,8 @@ module Xmlenc
16
16
  tag "EncryptedData"
17
17
  namespace "xenc"
18
18
 
19
- attribute :id, String, tag: "Id"
20
- attribute :type, String, tag: "Type"
19
+ attribute :id, String, :tag => "Id"
20
+ attribute :type, String, :tag => "Type"
21
21
 
22
22
  def type
23
23
  'http://www.w3.org/2001/04/xmlenc#Element'
@@ -30,10 +30,10 @@ module Xmlenc
30
30
 
31
31
  def encrypt(data)
32
32
  encryptor = algorithm.setup
33
- encrypted = encryptor.encrypt(data, node: encryption_method)
33
+ encrypted = encryptor.encrypt(data, :node => encryption_method)
34
34
  cipher_data.cipher_value = Base64.encode64(encrypted)
35
35
 
36
- encrypted_key = EncryptedKey.new(data: encryptor.key)
36
+ encrypted_key = EncryptedKey.new(:data => encryptor.key)
37
37
  encrypted_key.add_data_reference(id)
38
38
  encrypted_key
39
39
  end
@@ -11,7 +11,7 @@ module Xmlenc
11
11
  tag "EncryptedKey"
12
12
  namespace "xenc"
13
13
 
14
- has_one :reference_list, Xmlenc::Builder::ReferenceList, xpath: "./"
14
+ has_one :reference_list, Xmlenc::Builder::ReferenceList, :xpath => "./"
15
15
 
16
16
  attr_accessor :data
17
17
 
@@ -8,14 +8,14 @@ module Xmlenc
8
8
  register_namespace "xenc", Xmlenc::NAMESPACES[:xenc]
9
9
  namespace "xenc"
10
10
 
11
- attribute :algorithm, String, tag: "Algorithm"
11
+ attribute :algorithm, String, :tag => "Algorithm"
12
12
  has_one :digest_method, Xmlenc::Builder::DigestMethod
13
13
 
14
- validates :algorithm, presence: true
14
+ validates :algorithm, :presence => true
15
15
 
16
16
  def initialize(attributes = {})
17
17
  digest_method_algorithm = attributes.delete(:digest_method_algorithm)
18
- attributes[:digest_method] = Xmlenc::Builder::DigestMethod.new(algorithm: digest_method_algorithm)
18
+ attributes[:digest_method] = Xmlenc::Builder::DigestMethod.new(:algorithm => digest_method_algorithm)
19
19
  super
20
20
  end
21
21
  end
@@ -8,9 +8,9 @@ module Xmlenc
8
8
  register_namespace "ds", Xmlenc::NAMESPACES[:ds]
9
9
  namespace "ds"
10
10
 
11
- element :key_name, String, namespace: "ds", tag: "KeyName"
11
+ element :key_name, String, :namespace => "ds", :tag => "KeyName"
12
12
 
13
- has_one :encrypted_key, Xmlenc::Builder::EncryptedKey, xpath: "./"
13
+ has_one :encrypted_key, Xmlenc::Builder::EncryptedKey, :xpath => "./"
14
14
  end
15
15
  end
16
16
  end
@@ -8,11 +8,11 @@ module Xmlenc
8
8
  register_namespace "xenc", Xmlenc::NAMESPACES[:xenc]
9
9
  namespace "xenc"
10
10
 
11
- has_many :data_references, Xmlenc::Builder::DataReference, xpath: "./"
11
+ has_many :data_references, Xmlenc::Builder::DataReference, :xpath => "./"
12
12
 
13
13
  def add_data_reference(data_id)
14
14
  self.data_references ||= []
15
- self.data_references << DataReference.new(uri: "##{data_id}")
15
+ self.data_references << DataReference.new(:uri => "##{data_id}")
16
16
  end
17
17
  end
18
18
  end
@@ -35,14 +35,14 @@ module Xmlenc
35
35
 
36
36
  def decrypt(key)
37
37
  decryptor = algorithm.setup(key)
38
- decrypted = decryptor.decrypt(Base64.decode64(cipher_value), node: encryption_method)
38
+ decrypted = decryptor.decrypt(Base64.decode64(cipher_value), :node => encryption_method)
39
39
  @node.replace(decrypted) unless @node == document.root
40
40
  decrypted
41
41
  end
42
42
 
43
43
  def encrypt(data)
44
44
  encryptor = algorithm.setup
45
- encrypted = encryptor.encrypt(data, node: encryption_method)
45
+ encrypted = encryptor.encrypt(data, :node => encryption_method)
46
46
  self.cipher_value = Base64.encode64(encrypted)
47
47
  encryptor.key
48
48
  end
@@ -31,12 +31,12 @@ module Xmlenc
31
31
 
32
32
  def decrypt(key)
33
33
  decryptor = algorithm.new(key)
34
- decryptor.decrypt(Base64.decode64(cipher_value), node: encryption_method)
34
+ decryptor.decrypt(Base64.decode64(cipher_value), :node => encryption_method)
35
35
  end
36
36
 
37
37
  def encrypt(key, data)
38
38
  encryptor = algorithm.new(key)
39
- encrypted = encryptor.encrypt(data, node: encryption_method)
39
+ encrypted = encryptor.encrypt(data, :node => encryption_method)
40
40
  self.cipher_value = Base64.encode64(encrypted)
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module Xmlenc
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -9,7 +9,7 @@ end
9
9
  describe BaseDummy do
10
10
  describe "parse override" do
11
11
  it "sets the from_xml flag" do
12
- BaseDummy.parse("<tag></tag>", single: true).from_xml?.should be_true
12
+ BaseDummy.parse("<tag></tag>", :single => true).from_xml?.should be_true
13
13
  end
14
14
 
15
15
  it "raises an error if the message cannot be parsed" do
@@ -9,7 +9,7 @@ end
9
9
  describe Xmlenc::Builder::ComplexTypes::EncryptedType do
10
10
 
11
11
  let(:xml) { File.read File.join("spec", "fixtures", "encrypted_document.xml") }
12
- subject { EncryptedTypeDummy.new.parse(xml, single: true) }
12
+ subject { EncryptedTypeDummy.new.parse(xml, :single => true) }
13
13
 
14
14
  describe "required fields" do
15
15
  it "should have the cipher data field" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Xmlenc::Builder::DataReference do
4
4
 
5
5
  let(:xml) { File.read File.join("spec", "fixtures", "template2.xml") }
6
- subject { described_class.parse(xml, single: true) }
6
+ subject { described_class.parse(xml, :single => true) }
7
7
 
8
8
  describe "#parse" do
9
9
  it "should have uri attribute" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Xmlenc::Builder::DigestMethod do
4
4
 
5
5
  let(:xml) { File.read File.join("spec", "fixtures", "template2.xml") }
6
- subject { described_class.parse(xml, single: true) }
6
+ subject { described_class.parse(xml, :single => true) }
7
7
 
8
8
  describe "#parse" do
9
9
  it "should have one algorithm" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Xmlenc::Builder::EncryptedData do
4
4
 
5
5
  let(:xml) { File.read File.join("spec", "fixtures", "encrypted_document.xml") }
6
- subject { described_class.parse(xml, single: true) }
6
+ subject { described_class.parse(xml, :single => true) }
7
7
 
8
8
  describe "required fields" do
9
9
  it "should have the cipher data field" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Xmlenc::Builder::EncryptedKey do
4
4
 
5
5
  let(:xml) { File.read File.join("spec", "fixtures", "encrypted_document.xml") }
6
- subject { described_class.parse(xml, single: true) }
6
+ subject { described_class.parse(xml, :single => true) }
7
7
 
8
8
  describe "required fields" do
9
9
  it "should have the cipher data field" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Xmlenc::Builder::EncryptionMethod do
4
4
 
5
5
  let(:xml) { File.read File.join("spec", "fixtures", "encrypted_document.xml") }
6
- subject { described_class.parse(xml, single: true) }
6
+ subject { described_class.parse(xml, :single => true) }
7
7
 
8
8
  describe "required fields" do
9
9
  it "should have the algorithm field" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Xmlenc::Builder::ReferenceList do
4
4
 
5
5
  let(:xml) { File.read File.join("spec", "fixtures", "template2.xml") }
6
- subject { described_class.parse(xml, single: true) }
6
+ subject { described_class.parse(xml, :single => true) }
7
7
 
8
8
  describe "#parse" do
9
9
  it "has data" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmlenc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-12 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.2.2
196
+ rubygems_version: 2.4.5
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: A (partial)implementation of the XMLENC specificiation