Method: RSAML::Assertion#validate

Defined in:
lib/rsaml/assertion.rb

#validateObject

Validate the assertion. This validates the structural integrity of the assertion, not the validity of the assertion itself. To “assert” the assertion use the assert method.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/rsaml/assertion.rb', line 141

def validate
  # rule: if there are no statements there must be a subject
  if statements.length == 0 && subject.nil?
    raise ValidationError, "An assertion with no statements must have a subject"
  end
  
  # rule: if there is an authentication then there must be a subject
  statements.each do |statement|           
    if statement_classes.include?(statement.class)
      if subject.nil?
        raise ValidationError, "An assertion with an #{statement.class.name} must have a subject"
      else
        break
      end
    end
  end
end