Sha256: 5fd20678f618cebc16d9bc076deb5326032d37f0ade9b4b2f3205545cdacb4c5

Contents?: true

Size: 726 Bytes

Versions: 19

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

module Saml
  module Kit
    class Conditions
      include XmlParseable

      attr_reader :content

      def initialize(node)
        @to_nokogiri = node
        @content = node.to_s
      end

      def started_at
        parse_iso8601(at_xpath('./@NotBefore').try(:value))
      end

      def expired_at
        parse_iso8601(at_xpath('./@NotOnOrAfter').try(:value))
      end

      def audiences
        search('./saml:AudienceRestriction/saml:Audience').map(&:text)
      end

      private

      def parse_iso8601(value)
        DateTime.parse(value)
      rescue StandardError => error
        Saml::Kit.logger.error(error)
        Time.at(0).to_datetime
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
saml-kit-1.3.0 lib/saml/kit/conditions.rb
saml-kit-1.2.0 lib/saml/kit/conditions.rb
saml-kit-1.1.0 lib/saml/kit/conditions.rb
saml-kit-1.0.31 lib/saml/kit/conditions.rb
saml-kit-1.0.30 lib/saml/kit/conditions.rb
saml-kit-1.0.29 lib/saml/kit/conditions.rb
saml-kit-1.0.28 lib/saml/kit/conditions.rb
saml-kit-1.0.27 lib/saml/kit/conditions.rb
saml-kit-1.0.26 lib/saml/kit/conditions.rb
saml-kit-1.0.25 lib/saml/kit/conditions.rb
saml-kit-1.0.24 lib/saml/kit/conditions.rb
saml-kit-1.0.23 lib/saml/kit/conditions.rb
saml-kit-1.0.22 lib/saml/kit/conditions.rb
saml-kit-1.0.21 lib/saml/kit/conditions.rb
saml-kit-1.0.20 lib/saml/kit/conditions.rb
saml-kit-1.0.19 lib/saml/kit/conditions.rb
saml-kit-1.0.18 lib/saml/kit/conditions.rb
saml-kit-1.0.17 lib/saml/kit/conditions.rb
saml-kit-1.0.16 lib/saml/kit/conditions.rb