# Xml::Kit [![Gem Version](https://badge.fury.io/rb/xml-kit.svg)](https://rubygems.org/gems/xml-kit) [![Code Climate](https://codeclimate.com/github/saml-kit/xml-kit.svg)](https://codeclimate.com/github/saml-kit/xml-kit) [![Build Status](https://travis-ci.org/saml-kit/xml-kit.svg?branch=master)](https://travis-ci.org/saml-kit/xml-kit) [![Security](https://hakiri.io/github/saml-kit/xml-kit/master.svg)](https://hakiri.io/github/saml-kit/xml-kit/master) Xml::Kit is a toolkit for working with XML. It supports adding [XML Digital Signatures](https://www.w3.org/TR/xmldsig-core/) and [XML Encryption](https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/Overview.html). ## Installation Add this line to your application's Gemfile: ```ruby gem 'xml-kit' ``` And then execute: $ bundle Or install it yourself as: $ gem install xml-kit ## Usage ```builder # ./templates/item.builder xml.instruct! xml.Item ID: id do signature_for reference_id: id, xml: xml xml.Encrypted do encryption_for xml: xml do |encrypted_xml| encrypted_xml.EncryptMe do encrypted_xml.Secret "secret" end end end end ``` ```ruby require 'xml/kit' class Item include ::Xml::Kit::Templatable def initialize @id = ::Xml::Kit::Id.generate @signing_key_pair = ::Xml::Kit::KeyPair.generate(use: :signing) @embed_signature = true @encrypt = true @encryption_certificate = ::Xml::Kit::KeyPair.generate(use: :encryption).certificate end def template_path current_path = File.expand_path(File.dirname(__FILE__)) File.join(current_path, "./templates/item.builder") end end puts Item.new.to_xml ``` This will produce something like the following: ```xml 3cH13yM8oR0sgWbhAx0mo536KMJDkVBynbPo7ehwJPE= ZCSx4dad704jz0Z6rCMsnOs/oyVH3YBeEF9wtk2UFmWBW+VfhoBKw7N50GnzmAGCHyI6zajRPdff5i6UMDz3fOzh7rlROnqW0TXoG77xPiIfqJswCKE/4LzzBLrEHVbdUz90U8n0M1Ahbesrt+pbf/NkJghpvDhJW+w6oho7dyU6k57C5D//kTaSb7DvKte3a7/o8xWvPRztQhYekK+RyWjK9k/lU4WEXk5rGbx+QrD9rgIXBQOdcSjOtUosZJADz7uFod6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aGP 8OG/fOgtBKkZnNF8gx7wuodbYSmKAfFGx8+CGtnkwNr4/hXgd1qg5KmsAx+9VYozCjGKSkVUIqC5khy6N+1Pb5jMKrMQ+QU9zGhylWoJ2jiK65hzUUVUESIB rBJwm+gmL6eUHBZDXs2swIL3DiZ+MfmBPpM52eF0RWFtZv/gutY02KlsFLlm jc+DO7X5p9l1Br67FjGJrTdfSSqHf35cS1cioyaKLtgniSrD7Hf9d8qIuWt5 6dLWjmCi21cePMJHhNiFe5yRjFHNp5LZ9dX5hvNXjbn0+p90fj8zlO2TWZv9 atooON3BaYGCezZlmG0bWyEmloqKHiGjqaKtkdeSKJDzoo/AvubDEgz56rin Cpw26rEOg8BBd/KNfSXyDUifOOzXmn6myq+8+W/FFQ+6y+5SgtsbONRCqe2c KkNi3fYhilwLxWCaXFjONimEOkeG03yR5QnWhzEOpw== 45rM0phzM/S/vpiq8Ev+uQZ6WL5qZ8av0UDVzWAlHn6Qr7zWYjHea+NF94lK pvmTPWQDEnfv2UW8l0VdCLc+51zHjluRE/xJh31Gk3rVuRJtLioSge/N9UM4 5g901rE9 ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/saml-kit/xml-kit. ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).