Class: SamlIdpMetadata::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/saml_idp_metadata/parser.rb

Overview

SAML IdP metadata parser

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml:) ⇒ Parser

Returns a new instance of Parser.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/saml_idp_metadata/parser.rb', line 14

def initialize(xml:)
  @xml = xml
  @hash = Hash.from_xml(xml)

  @xmlns = nil
  @entity_id = nil
  @sso_http_redirect_url = nil
  @sso_http_post_url = nil
  @slo_url = nil
  @nameid_format = nil
  @x509_certificate = nil
end

Instance Attribute Details

#entity_idObject (readonly)

Returns the value of attribute entity_id.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def entity_id
  @entity_id
end

#nameid_formatObject (readonly)

Returns the value of attribute nameid_format.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def nameid_format
  @nameid_format
end

#slo_urlObject (readonly)

Returns the value of attribute slo_url.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def slo_url
  @slo_url
end

#sso_http_post_urlObject (readonly)

Returns the value of attribute sso_http_post_url.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def sso_http_post_url
  @sso_http_post_url
end

#sso_http_redirect_urlObject (readonly)

Returns the value of attribute sso_http_redirect_url.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def sso_http_redirect_url
  @sso_http_redirect_url
end

#x509_certificateObject (readonly)

Returns the value of attribute x509_certificate.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def x509_certificate
  @x509_certificate
end

#xmlObject (readonly)

Returns the value of attribute xml.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def xml
  @xml
end

#xmlnsObject (readonly)

Returns the value of attribute xmlns.



11
12
13
# File 'lib/saml_idp_metadata/parser.rb', line 11

def xmlns
  @xmlns
end

Class Method Details

.call(xml:) ⇒ Object



27
28
29
# File 'lib/saml_idp_metadata/parser.rb', line 27

def self.call(xml:)
  new(xml: xml).call
end

Instance Method Details

#build_paramsObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/saml_idp_metadata/parser.rb', line 52

def build_params
  {
    entity_id: entity_id,
    sso_http_redirect_url: sso_http_redirect_url,
    sso_http_post_url: sso_http_post_url,
    certificate: x509_certificate,
    slo_url: slo_url,
    nameid_format: nameid_format,
    metadata: xml
  }
end

#callObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/saml_idp_metadata/parser.rb', line 31

def call
  @xmlns = parse_xmlns

  @entity_id = parse_entity_id
  @sso_http_redirect_url = parse_sso_http_redirect_url
  @sso_http_post_url = parse_sso_http_post_url
  @slo_url = parse_slo_url
  @nameid_format = parse_nameid_format
  @x509_certificate = parse_x509_certificate

  self
end

#ensure_params?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/saml_idp_metadata/parser.rb', line 48

def ensure_params?
  entity_id.present? && (sso_http_redirect_url.present? && sso_http_post_url.present?) && x509_certificate.present?
end

#validate_xmlnsObject



44
45
46
# File 'lib/saml_idp_metadata/parser.rb', line 44

def validate_xmlns
  xmlns == 'urn:oasis:names:tc:SAML:2.0:metadata'
end