xmlenc 0.6.8 → 0.6.9

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: ddb636923d7131d4b738212dc45113fb43141e95
4
- data.tar.gz: a30f0fce4a2bf4acd5163fa1d478046a557a6a98
3
+ metadata.gz: 9bd6b427526017614daaa55dabf68ae2a39bae85
4
+ data.tar.gz: cc5c4813f5758495e514aed426fb98d9dd45ac4d
5
5
  SHA512:
6
- metadata.gz: 79124669c3bdd0dc63f6cb185f42e980c7cb466c6c645e50c28dd249310b2189ca011a4f16fe4d563cd8e22759f5b55e4c3567c70a37641050a3518b428723ba
7
- data.tar.gz: 1c0826bb77cf4d5781dcbb9310c14748230d5088b8c331b8de2e0a08469ab2b9c64f6c5de2f2ec7ec8777f51d0b9c5892c90630494ff05abcd3e35cc383c5806
6
+ metadata.gz: a2c81dbb86bd5f99e014252110984cbb2b4d450d73ad8b31f6f8f2375503a7c5bd63950821fbe4dae85d78eb8209098aedd587690e6135a5c689a73df9f75c94
7
+ data.tar.gz: 5cba8f5ba6f103b57504b0ef3e9f7dea2fc192dc4c6ff44b06b1b09eea3a3dc3afb0440b695d85c38f4812bf3e38bd7d759d57f530f306ebbefee9448ba186e2
@@ -37,9 +37,16 @@ module Xmlenc
37
37
  encryptor = algorithm.setup
38
38
  encrypted = encryptor.encrypt(data, :node => encryption_method)
39
39
  cipher_data.cipher_value = Base64.encode64(encrypted)
40
+
40
41
  key_params = { :data => encryptor.key }
42
+
41
43
  encrypted_key = EncryptedKey.new(key_params.merge(key_options))
42
44
  encrypted_key.add_data_reference(id)
45
+
46
+ if key_options[:carried_key_name].present?
47
+ encrypted_key.carried_key_name = key_options[:carried_key_name]
48
+ end
49
+
43
50
  encrypted_key
44
51
  end
45
52
 
@@ -50,6 +57,13 @@ module Xmlenc
50
57
  end
51
58
  end
52
59
 
60
+ def set_key_name(key_name)
61
+ if key_name
62
+ self.key_info ||= KeyInfo.new
63
+ self.key_info.key_name = key_name
64
+ end
65
+ end
66
+
53
67
  private
54
68
 
55
69
  def algorithm
@@ -1,3 +1,3 @@
1
1
  module Xmlenc
2
- VERSION = "0.6.8"
2
+ VERSION = "0.6.9"
3
3
  end
@@ -112,23 +112,39 @@ describe Xmlenc::Builder::EncryptedData do
112
112
  expect(Xmlenc::Builder::EncryptedKey).to receive(:new).with(hash_including(key_options))
113
113
  subject.encrypt('TEST', key_options)
114
114
  end
115
+
116
+ context 'when a "carried_key_name" is passed' do
117
+ let(:key_options) { { :id => '_SOME_ID', :recipient => 'SOME_RECIPIENT', :carried_key_name => 'CARRIED_KEY_NAME' } }
118
+
119
+ it 'sets the carried key name' do
120
+ expect(subject.encrypt('TEST', key_options).carried_key_name).to eq 'CARRIED_KEY_NAME'
121
+ end
122
+ end
115
123
  end
116
124
  end
117
125
 
118
- describe "#set_key_retrieval_method" do
119
- it "sets the key info with the key name" do
126
+ describe '#set_key_retrieval_method' do
127
+ it 'sets the key info with the retrieval method' do
120
128
  subject.set_key_retrieval_method 'retrieval_method'
121
- expect(subject.key_info.retrieval_method).to eq "retrieval_method"
129
+ expect(subject.key_info.retrieval_method).to eq 'retrieval_method'
130
+ end
131
+
132
+ it 'does not set the key info element if the "retrieval_method" is nil' do
133
+ subject.key_info = nil
134
+ subject.set_key_retrieval_method(nil)
135
+ expect(subject.key_info).to be_nil
122
136
  end
137
+ end
123
138
 
124
- it "does not override old key info data" do
125
- subject.set_key_retrieval_method("key retrieval_method")
126
- expect(subject.key_info.encrypted_key).not_to be_nil
139
+ describe '#set_key_name' do
140
+ it 'sets the key info with the key name' do
141
+ subject.set_key_name 'key_name'
142
+ expect(subject.key_info.key_name).to eq 'key_name'
127
143
  end
128
144
 
129
- it "does not set the key info element if the key retrieval_method is nil" do
145
+ it 'does not set the key info element if the "key_name" is nil' do
130
146
  subject.key_info = nil
131
- subject.set_key_retrieval_method(nil)
147
+ subject.set_key_name(nil)
132
148
  expect(subject.key_info).to be_nil
133
149
  end
134
150
  end
@@ -65,10 +65,4 @@ describe Xmlenc::EncryptedDocument do
65
65
  end
66
66
  end
67
67
 
68
- describe 'parsing documents' do
69
- let(:encrypted_xml) { File.read('spec/fixtures/artifact_response.xml') }
70
- fit 'finds the correct data' do
71
- puts subject.encrypted_keys.count
72
- end
73
- end
74
68
  end
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.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-22 00:00:00.000000000 Z
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport