<commit_before>require 'saml_idp/name_id_formatter'
require 'saml_idp/attribute_decorator'
require 'saml_idp/algorithmable'
require 'saml_idp/signable'
module SamlIdp
  class MetadataBuilder
    include Algorithmable
    include Signable
    attr_accessor :configurator

    def initialize(
      configurator = SamlIdp.config,
      x509_certificate = nil,
      secret_key = nil,
      cloudhsm_key_label = nil
    )
      self.configurator = configurator
      self.x509_certificate = x509_certificate
      self.secret_key = secret_key
      self.cloudhsm_key_label = cloudhsm_key_label
    end

    def fresh
      builder = Builder::XmlMarkup.new
      generated_reference_id do
        builder.EntityDescriptor ID: reference_string,
          xmlns: Saml::XML::Namespaces::METADATA,
          "xmlns:saml" => Saml::XML::Namespaces::ASSERTION,
          "xmlns:ds" => Saml::XML::Namespaces::SIGNATURE,
          entityID: entity_id do |entity|
            sign entity

            entity.IDPSSODescriptor protocolSupportEnumeration: protocol_enumeration do |descriptor|
              build_key_descriptor descriptor
              build_name_id_formats descriptor
              descriptor.SingleLogoutService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
                Location: single_logout_service_post_location
              descriptor.SingleSignOnService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
                Location: single_service_post_location
              build_attribute descriptor
            end

            entity.AttributeAuthorityDescriptor protocolSupportEnumeration: protocol_enumeration do |authority_descriptor|
              build_key_descriptor authority_descriptor
              build_organization authority_descriptor
              build_contact authority_descriptor
              authority_descriptor.AttributeService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
                Location: attribute_service_location
              build_name_id_formats authority_descriptor
              build_attribute authority_descriptor<commit_msg>Updated metadata to include POST SSO descriptor and redirect SLO descriptor<commit_after>require 'saml_idp/name_id_formatter'
require 'saml_idp/attribute_decorator'
require 'saml_idp/algorithmable'
require 'saml_idp/signable'
module SamlIdp
  class MetadataBuilder
    include Algorithmable
    include Signable
    attr_accessor :configurator

    def initialize(
      configurator = SamlIdp.config,
      x509_certificate = nil,
      secret_key = nil,
      cloudhsm_key_label = nil
    )
      self.configurator = configurator
      self.x509_certificate = x509_certificate
      self.secret_key = secret_key
      self.cloudhsm_key_label = cloudhsm_key_label
    end

    def fresh
      builder = Builder::XmlMarkup.new
      generated_reference_id do
        builder.EntityDescriptor ID: reference_string,
          xmlns: Saml::XML::Namespaces::METADATA,
          "xmlns:saml" => Saml::XML::Namespaces::ASSERTION,
          "xmlns:ds" => Saml::XML::Namespaces::SIGNATURE,
          entityID: entity_id do |entity|
            sign entity

            entity.IDPSSODescriptor protocolSupportEnumeration: protocol_enumeration do |descriptor|
              build_key_descriptor descriptor
              build_name_id_formats descriptor
              descriptor.SingleLogoutService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
                Location: single_logout_service_post_location
              descriptor.SingleLogoutService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
                Location: single_logout_service_post_location
              descriptor.SingleSignOnService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
                Location: single_service_post_location
              descriptor.SingleSignOnService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
                Location: single_service_post_location
              build_attribute descriptor
            end

            entity.AttributeAuthorityDescriptor protocolSupportEnumeration: protocol_enumeration do |authority_descriptor|
              build_key_descriptor authority_descriptor
              build_organization authority_descriptor
              build_contact authority_descriptor
              authority_descriptor.AttributeService Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
                Location: attribute_service_location
              build_name_id_formats authority_descriptor
              build_attribute authority_descriptor
{'fraction_non_alphanumeric': 0.062055591467356175, 'fraction_numerical': 0.007326007326007326, 'mean_word_length': 3.0826737027264732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5264500', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1243, 'n_words': 219}