class Shibkit::MetaMeta::Entity

Class to represent the metadata of a Shibboleth IDP or SP

Constants

HR_CHAR
LINE_END
LINE_START
REQUIRED_QUACKS
ROOT_ELEMENT

Element and attribute used to select XML for new objects

TARGET_ATTR

Attributes

accountable[RW]

Is the entity accountable?

accountable?[RW]

Is the entity accountable?

admin_contact[RW]

Contact object containing technical contact details

athens[RW]

Is the entity using Athens?

athens?[RW]

Is the entity using Athens?

entity_id[RW]

The URI of the entity

entity_uri[RW]

The URI of the entity

hide[RW]

Show in normal WAYFs?

hide?[RW]

Show in normal WAYFs?

idp[RW]

Is the entity an IDP?

metadata_id[RW]

The ID of the entity with the metadata file (not globally unique)

organisation[RW]

Organisation object for the owner of the entity

organization[RW]

Organisation object for the owner of the entity

other_federation_uris[RW]

The URI of the entity’s parent federation

primary[RW]

Has this entity object been selected to represent the service?

primary_federation_uri[RW]

The URI of the entity’s parent federation

scopes[RW]
secondary_federation_uris[RW]

The URI of the entity’s parent federation

sp[RW]

Is the entity an SP?

support_contact[RW]

Contact object containing user support contact details

technical_contact[RW]

Contact object containing technical contact details

ukfm[RW]

Is the entity part of the UK Access Management Federation?

ukfm?[RW]

Is the entity part of the UK Access Management Federation?

uri[RW]

The URI of the entity

Public Instance Methods

federation_uris() click to toggle source

All federations that this entity is a member of

# File lib/shibkit/meta_meta/entity.rb, line 133
def federation_uris

  ## All unique federations, making sure we include primary
  all_fed_uris = [primary_federation_uri].concat other_federation_uris 
  
  return all_fed_uris.uniq

end
idp?() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 101
def idp? 
  
  return idp.kind_of?(::Shibkit::MetaMeta::IDP)
  
end
multi_federated?() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 126
def multi_federated?
  
  return other_federation_uris.size > 0 ? true : false
  
end
primary?() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 120
def primary?
  
  return @primary ? true : false
  
end
sp?() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 107
def sp?
  
  return sp.kind_of?(::Shibkit::MetaMeta::SP)
  
end
tags() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 157
def tags
  
  return @tags.nil? ? [] : @tags.collect { |t| t.to_sym }
  
end
tags=(tags) click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 142
def tags=(tags)
  
  @tags ||= []
  
  if Shibkit::MetaMeta.config.auto_tag?
    
    @tags << :idp if idp?
    @tags << :sp  if sp?
    
  end
  
  @tags = @tags.concat([tags].flatten).uniq
 
end
to_s() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 95
def to_s
  
  return uri
  
end
urn?() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 113
def urn?

  return uri.strip.downcase[0..3] == 'urn:'
  
end
xml_comment() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 163
def xml_comment

  out = "\n" + LINE_START + (HR_CHAR * 71) + LINE_END + "\n"
  out << LINE_START + " " + uri + " "  + LINE_END  + "\n"
  out << LINE_START + (HR_CHAR * 71) + LINE_END + "\n\n"
  
  return out
  
end

Private Instance Methods

parse_xml() click to toggle source
# File lib/shibkit/meta_meta/entity.rb, line 175
def parse_xml
  
  self.entity_uri     = @noko['entityID'].to_s.strip
  self.metadata_id    = @noko['ID'].to_s.strip
   
  @other_federation_uris        ||= Array.new
        
  ## Boolean flags for common/useful info
  self.accountable = @noko.xpath('xmlns:Extensions/ukfedlabel:AccountableUsers').size   > 0 ? true : false
  self.ukfm        = @noko.xpath('xmlns:Extensions/ukfedlabel:UKFederationMember').size > 0 ? true : false
  self.athens      = @noko.xpath('xmlns:Extensions/elab:AthensPUIDAuthority').size      > 0 ? true : false
  self.hide        = @noko.xpath('xmlns:Extensions/wayf:HideFromWAYF').size             > 0 ? true : false
  
  @scopes = @noko.xpath('xmlns:Extensions/shibmd:Scope').collect do |sx|
  
   sx['regexp'] == 'true' ? Regexp.new(sx.text) : sx.text  
    
  end
  
  ## IDP and SP objects, if available. Based on the same XML as their parent/entity object
  self.idp         = Shibkit::MetaMeta::IDP.new(@noko).filter
  self.sp          =  Shibkit::MetaMeta::SP.new(@noko).filter
  
  ## Include Contact objects
  self.support_contact   = Contact.new(@noko.xpath("xmlns:ContactPerson[@contactType='support'][1]")[0]).filter
  self.technical_contact = Contact.new(@noko.xpath("xmlns:ContactPerson[@contactType='technical'][1]")[0]).filter
  self.admin_contact     = Contact.new(@noko.xpath("xmlns:ContactPerson[@contactType='administrative'][1]")[0]).filter
  
  ## Include an organisation object
  self.organisation     = Organisation.new(@noko.xpath("xmlns:Organization[1]")[0]).filter
  self.idp.organisation = self.organisation if idp?
  self.sp.organisation  = self.organisation if sp?
  
  self.tags ||= []
 
  log.debug " Derived entity #{self.uri} from XML"
  
end