class SamlTool::Validator
Attributes
saml[R]
Public Class Methods
new(saml)
click to toggle source
# File lib/saml_tool/validator.rb, line 5 def initialize(saml) @saml = saml end
Public Instance Methods
errors()
click to toggle source
# File lib/saml_tool/validator.rb, line 14 def errors @errors ||= [] end
saml_document()
click to toggle source
# File lib/saml_tool/validator.rb, line 35 def saml_document @saml_document ||= Nokogiri::XML(saml) end
schema_path()
click to toggle source
# File lib/saml_tool/validator.rb, line 31 def schema_path File.expand_path('../schema/', File.dirname(__FILE__)) end
valid?()
click to toggle source
# File lib/saml_tool/validator.rb, line 9 def valid? validate errors.empty? end
validate()
click to toggle source
# File lib/saml_tool/validator.rb, line 19 def validate # Need to load schema with other schemas in path # see http://ktulu.com.ar/blog/2011/06/26/resolving-validation-errors-using-nokogiri-and-schemas/ Dir.chdir(schema_path) do schema = Nokogiri::XML::Schema(File.read('localised-saml-schema-protocol-2.0.xsd')) schema.validate(saml_document).each do |error| errors << error.message unless errors.include? error.message end end end