Skip to content

Commit

Permalink
The conditions element and it's attributes are not mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Pedersen committed Jun 4, 2011
1 parent 58e2291 commit 2bc58d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/onelogin/saml/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def check_conditions
return true if self.bypass_conditions_check

cond_element = REXML::XPath.first(document,"/p:Response/a:Assertion[@ID='#{document.signed_element_id[1,document.signed_element_id.size]}']/a:Conditions", { "p" => PROTOCOL, "a" => ASSERTION })
return false unless cond_element
return false unless parseXsDateTime(cond_element.attribute('NotBefore').to_s) < Time.now.utc
return false unless parseXsDateTime(cond_element.attribute('NotOnOrAfter').to_s) >= Time.now.utc
return true unless cond_element
return false if cond_element.attribute('NotBefore') and Time.now.utc < parseXsDateTime(cond_element.attribute('NotBefore'))
return false if cond_element.attribute('NotOnOrAfter') and Time.now.utc >= parseXsDateTime(cond_element.attribute('NotOnOrAfter'))
true
end

Expand Down Expand Up @@ -76,7 +76,7 @@ def session_expires_at
private

def parseXsDateTime(xsDatetime)
return nil unless xsDatetime =~ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/
return nil unless xsDatetime.to_s =~ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/
Time.utc($1, $2, $3, $4, $5, $6)
end
end
Expand Down

0 comments on commit 2bc58d1

Please sign in to comment.