Class: Kiji::Zipper
- Inherits:
-
Object
- Object
- Kiji::Zipper
- Defined in:
- lib/kiji/zipper.rb
Instance Attribute Summary collapse
-
#cert ⇒ Object
Returns the value of attribute cert.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Zipper
constructor
A new instance of Zipper.
-
#sign(kousei_base_file_path, app_file_paths) ⇒ Object
構成管理ファイル(kouse.xml)に署名を施す.
Constructor Details
#initialize {|_self| ... } ⇒ Zipper
Returns a new instance of Zipper.
5 6 7 |
# File 'lib/kiji/zipper.rb', line 5 def initialize yield(self) if block_given? end |
Instance Attribute Details
#cert ⇒ Object
Returns the value of attribute cert.
3 4 5 |
# File 'lib/kiji/zipper.rb', line 3 def cert @cert end |
#private_key ⇒ Object
Returns the value of attribute private_key.
3 4 5 |
# File 'lib/kiji/zipper.rb', line 3 def private_key @private_key end |
Instance Method Details
#sign(kousei_base_file_path, app_file_paths) ⇒ Object
構成管理ファイル(kouse.xml)に署名を施す
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kiji/zipper.rb', line 10 def sign(kousei_base_file_path, app_file_paths) fail 'Please specify cert & private_key' if @cert.nil? || @private_key.nil? kousei_data = Nokogiri::XML(File.read(kousei_base_file_path)) kousei_doc = kousei_data.to_xml(save_with: 0) signer = Signer.new(kousei_doc) do |s| s.cert = @cert s.private_key = @private_key s.digest_algorithm = :sha256 s.signature_digest_algorithm = :sha256 end # 構成情報のハッシュ値を求める signer.security_node = signer.document.root node = signer.document.at_xpath('//構成情報') signer.digest!(node, id: '#構成情報') # 申請書のハッシュ値を求める app_file_paths.each do |app_file_path| app_doc = File.read(app_file_path) app_file_name = File.basename(app_file_path) signer.digest_file!(app_doc, id: app_file_name) end # 署名の付与 signer.sign!(issuer_serial: true) signer.document.xpath('//ns:Signature', ns: 'http://www.w3.org/2000/09/xmldsig#').wrap('<署名情報></署名情報>') # 構成情報 - 署名情報 - その他という順序 kousei_node = signer.document.at_xpath('//構成情報') signature_node = signer.document.at_xpath('//署名情報') kousei_node.add_next_sibling(signature_node) signer end |