Class: SAML2::Entity::Group

Inherits:
Base
  • Object
show all
Includes:
Enumerable
Defined in:
lib/saml2/entity.rb

Instance Attribute Summary

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

from_xml, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml

Constructor Details

#initializeGroup

Returns a new instance of Group.



39
40
41
42
# File 'lib/saml2/entity.rb', line 39

def initialize
  @entities = []
  @valid_until = nil
end

Instance Method Details

#from_xml(node) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/saml2/entity.rb', line 44

def from_xml(node)
  super
  remove_instance_variable(:@valid_until)
  @entities = Base.load_object_array(xml, "md:EntityDescriptor|md:EntitiesDescriptor",
          'EntityDescriptor' => Entity,
          'EntitiesDescriptor' => Group)
end

#signatureObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/saml2/entity.rb', line 56

def signature
  unless instance_variable_defined?(:@signature)
    @signature = xml.at_xpath('dsig:Signature', Namespaces::ALL)
    signed_node = @signature.at_xpath('dsig:SignedInfo/dsig:Reference', Namespaces::ALL)['URI']
    # validating the schema will automatically add ID attributes, so check that first
    xml.set_id_attribute('ID') unless xml.document.get_id(xml['ID'])
    @signature = nil unless signed_node == "##{xml['ID']}"
  end
  @signature
end

#signed?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/saml2/entity.rb', line 67

def signed?
  !!signature
end

#valid_schema?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/saml2/entity.rb', line 52

def valid_schema?
  Schemas.federation.valid?(xml.document)
end

#valid_signature?(*args) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/saml2/entity.rb', line 71

def valid_signature?(*args)
  signature.verify_with(*args)
end

#valid_untilObject



75
76
77
78
79
80
# File 'lib/saml2/entity.rb', line 75

def valid_until
  unless instance_variable_defined?(:@valid_until)
    @valid_until = xml['validUntil'] && Time.parse(xml['validUntil'])
  end
  @valid_until
end