Class: SAML2::Entity
  
  
  
Defined Under Namespace
  
    
  
    
      Classes: Group
    
  
  Instance Attribute Summary collapse
  
  
  
  
  #contacts, #organization
  
  
  Attributes inherited from Base
  #xml
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  Methods inherited from Base
  from_xml, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml
  Constructor Details
  
    
  
  
    #initialize  ⇒ Entity 
  
  
  
  
    
Returns a new instance of Entity.
   
 
  
  
    
      
83
84
85
86
87
88 
     | 
    
      # File 'lib/saml2/entity.rb', line 83
def initialize
  super
  @valid_until = nil
  @entity_id = nil
  @roles = []
end 
     | 
  
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #entity_id  ⇒ Object 
  
  
  
  
    
      
100
101
102 
     | 
    
      # File 'lib/saml2/entity.rb', line 100
def entity_id
  @entity_id || xml && xml['entityID']
end 
     | 
  
 
    
   
  
    Class Method Details
    
      
  
  
    .parse(xml)  ⇒ Object 
  
  
  
  
    
      
14
15
16
17
18
19
20
21
22
23
24
25
26
27 
     | 
    
      # File 'lib/saml2/entity.rb', line 14
def self.parse(xml)
  document = Nokogiri::XML(xml)
    entities = document.at_xpath("/md:EntitiesDescriptor", Namespaces::ALL)
  entity = document.at_xpath("/md:EntityDescriptor", Namespaces::ALL)
  if entities
    Group.from_xml(entities)
  elsif entity
    from_xml(entity)
  else
    nil
  end
end
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #build(builder)  ⇒ Object 
  
  
  
  
    
      
124
125
126
127
128
129
130
131
132
133
134
135 
     | 
    
      # File 'lib/saml2/entity.rb', line 124
def build(builder)
  builder['md'].EntityDescriptor('entityID' => entity_id,
                                 'xmlns:md' => Namespaces::METADATA,
                                 'xmlns:dsig' => Namespaces::DSIG,
                                 'xmlns:xenc' => Namespaces::XENC) do |entity_descriptor|
    roles.each do |role|
      role.build(entity_descriptor)
    end
    super
  end
end
     | 
  
 
    
      
  
  
    #from_xml(node)  ⇒ Object 
  
  
  
  
    
      
90
91
92
93
94 
     | 
    
      # File 'lib/saml2/entity.rb', line 90
def from_xml(node)
  super
  remove_instance_variable(:@valid_until)
  @roles = nil
end 
     | 
  
 
    
      
  
  
    #identity_providers  ⇒ Object 
  
  
  
  
    
      
111
112
113 
     | 
    
      # File 'lib/saml2/entity.rb', line 111
def identity_providers
  roles.select { |r| r.is_a?(IdentityProvider) }
end
     | 
  
 
    
      
  
  
    #roles  ⇒ Object 
  
  
  
  
    
      
119
120
121
122 
     | 
    
      # File 'lib/saml2/entity.rb', line 119
def roles
  @roles ||= load_object_array(xml, 'md:IDPSSODescriptor', IdentityProvider) +
      load_object_array(xml, 'md:SPSSODescriptor', ServiceProvider)
end
     | 
  
 
    
      
  
  
    #service_providers  ⇒ Object 
  
  
  
  
    
      
115
116
117 
     | 
    
      # File 'lib/saml2/entity.rb', line 115
def service_providers
  roles.select { |r| r.is_a?(ServiceProvider) }
end
     | 
  
 
    
      
  
  
    #valid_schema?  ⇒ Boolean 
  
  
  
  
    
      
96
97
98 
     | 
    
      # File 'lib/saml2/entity.rb', line 96
def valid_schema?
  Schemas.federation.valid?(xml.document)
end 
     | 
  
 
    
      
  
  
    #valid_until  ⇒ Object 
  
  
  
  
    
      
104
105
106
107
108
109 
     | 
    
      # File 'lib/saml2/entity.rb', line 104
def valid_until
  unless instance_variable_defined?(:@valid_until)
    @valid_until = xml['validUntil'] && Time.parse(xml['validUntil'])
  end
  @valid_until
end
     |