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.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/saml_idp_metadata/parser.rb', line 11

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
  @x509_certificate = nil
end

Instance Attribute Details

#entity_idObject (readonly)

Returns the value of attribute entity_id.



9
10
11
# File 'lib/saml_idp_metadata/parser.rb', line 9

def entity_id
  @entity_id
end

#slo_urlObject (readonly)

Returns the value of attribute slo_url.



9
10
11
# File 'lib/saml_idp_metadata/parser.rb', line 9

def slo_url
  @slo_url
end

#sso_http_post_urlObject (readonly)

Returns the value of attribute sso_http_post_url.



9
10
11
# File 'lib/saml_idp_metadata/parser.rb', line 9

def sso_http_post_url
  @sso_http_post_url
end

#sso_http_redirect_urlObject (readonly)

Returns the value of attribute sso_http_redirect_url.



9
10
11
# File 'lib/saml_idp_metadata/parser.rb', line 9

def sso_http_redirect_url
  @sso_http_redirect_url
end

#x509_certificateObject (readonly)

Returns the value of attribute x509_certificate.



9
10
11
# File 'lib/saml_idp_metadata/parser.rb', line 9

def x509_certificate
  @x509_certificate
end

#xmlObject (readonly)

Returns the value of attribute xml.



9
10
11
# File 'lib/saml_idp_metadata/parser.rb', line 9

def xml
  @xml
end

#xmlnsObject (readonly)

Returns the value of attribute xmlns.



9
10
11
# File 'lib/saml_idp_metadata/parser.rb', line 9

def xmlns
  @xmlns
end

Class Method Details

.call(xml:) ⇒ Object



23
24
25
# File 'lib/saml_idp_metadata/parser.rb', line 23

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

Instance Method Details

#build_paramsObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/saml_idp_metadata/parser.rb', line 47

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,
    metadata: xml
  }
end

#callObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/saml_idp_metadata/parser.rb', line 27

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
  @x509_certificate = parse_x509_certificate

  self
end

#ensure_params?Boolean

Returns:

  • (Boolean)


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

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

#validate_xmlnsObject



39
40
41
# File 'lib/saml_idp_metadata/parser.rb', line 39

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