Class: RSAML::SubjectLocality

Inherits:
Object
  • Object
show all
Defined in:
lib/rsaml/subject_locality.rb

Overview

This element is entirely advisory, since both of these fields are quite easily “spoofed,” but may be useful information in some applications.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

The network address of the system from which the principal identified by the subject was authenticated.



7
8
9
# File 'lib/rsaml/subject_locality.rb', line 7

def address
  @address
end

#dns_nameObject

The DNS name of the system from which the principal identified by the subject was authenticated.



10
11
12
# File 'lib/rsaml/subject_locality.rb', line 10

def dns_name
  @dns_name
end

Instance Method Details

#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object

Construct an XML fragment representing the subject locality



20
21
22
23
24
25
# File 'lib/rsaml/subject_locality.rb', line 20

def to_xml(xml=Builder::XmlMarkup.new)
  attributes = {}
  attributes['Address'] = address unless address.nil?
  attributes['DNSName'] = dns_name unless dns_name.nil?
  xml.tag!('saml:SubjectLocality', attributes)
end

#validateObject

Raise an error if the subject locality is structurally invalid.



13
14
15
16
17
# File 'lib/rsaml/subject_locality.rb', line 13

def validate
  unless address =~ /^(\d{1,3}\.){3}\d{1,3}$/
    raise ValidationError, "Invalid address"
  end
end