<commit_before>#!/usr/bin/env python
import os 
from saml2 import utils, md, samlp, BINDING_HTTP_POST, BINDING_HTTP_REDIRECT
from saml2 import BINDING_SOAP
from saml2.time_util import in_a_while
from saml2.utils import parse_attribute_map
from saml2.saml import NAME_FORMAT_URI

def do_sp_sso_descriptor(sp, cert, backward_map):
    desc = {
        "protocol_support_enumeration": samlp.NAMESPACE,
        "want_assertions_signed": True,
        "authn_requests_signed": False,
        "assertion_consumer_service": {
            "binding": BINDING_HTTP_POST ,
            "location": sp["url"],
            "index": 0,
            },
        "key_descriptor":{
            "key_info": {
                "x509_data": {
                    "x509_certificate": cert
                    }
                }
            },
        }
        
    requested_attribute = []
    if "required_attributes" in sp:
        for attr in sp["required_attributes"]:
            requested_attribute.append({
                "is_required": "true",
                "friendly_name": attr,
                "name_format": NAME_FORMAT_URI,
                "name": backward_map[attr]
            })
        
    if "optional_attributes" in sp:
        for attr in sp["optional_attributes"]:
            requested_attribute.append({
                "friendly_name": attr,
                "name_format": NAME_FORMAT_URI,
                "name": backward_map[attr]
            })
    
    if requested_attribute:
        desc["attribute_consuming_service"] = {
            "requested_attribute": requested_attribute,
            "service_name": {
                "lang":"en",
                "text":sp["my_name"],
            }
        }
        
    return desc

def do_idp_sso_descriptor(idp, cert):
    return {
        "protocol_support_enumeration": samlp.NAMESPACE,
        "want_authn_requests_signed": True,
        "single_sign_on_service": {
            "binding": BINDING_HTTP_REDIRECT ,
            "location": idp["url"],
            },
        "key_descriptor":{
            "key_info": {
                "x509_data": {
                    "x509_certificate": cert
                    }
                }
            },
        }

def do_aa_descriptor(aa, cert):
    return {
        "protocol_support_enumeration": samlp.NAMESPACE,
        "attribute_service": {
            "binding": BINDING_SOAP ,<commit_msg>Wrong attribute name<commit_after>#!/usr/bin/env python
import os 
from saml2 import utils, md, samlp, BINDING_HTTP_POST, BINDING_HTTP_REDIRECT
from saml2 import BINDING_SOAP
from saml2.time_util import in_a_while
from saml2.utils import parse_attribute_map
from saml2.saml import NAME_FORMAT_URI

def do_sp_sso_descriptor(sp, cert, backward_map):
    desc = {
        "protocol_support_enumeration": samlp.NAMESPACE,
        "want_assertions_signed": True,
        "authn_requests_signed": False,
        "assertion_consumer_service": {
            "binding": BINDING_HTTP_POST ,
            "location": sp["url"],
            "index": 0,
            },
        "key_descriptor":{
            "key_info": {
                "x509_data": {
                    "x509_certificate": cert
                    }
                }
            },
        }
        
    requested_attribute = []
    if "required_attributes" in sp:
        for attr in sp["required_attributes"]:
            requested_attribute.append({
                "is_required": "true",
                "friendly_name": attr,
                "name_format": NAME_FORMAT_URI,
                "name": backward_map[attr]
            })
        
    if "optional_attributes" in sp:
        for attr in sp["optional_attributes"]:
            requested_attribute.append({
                "friendly_name": attr,
                "name_format": NAME_FORMAT_URI,
                "name": backward_map[attr]
            })
    
    if requested_attribute:
        desc["attribute_consuming_service"] = {
            "requested_attribute": requested_attribute,
            "service_name": {
                "lang":"en",
                "text":sp["name"],
            }
        }
        
    return desc

def do_idp_sso_descriptor(idp, cert):
    return {
        "protocol_support_enumeration": samlp.NAMESPACE,
        "want_authn_requests_signed": True,
        "single_sign_on_service": {
            "binding": BINDING_HTTP_REDIRECT ,
            "location": idp["url"],
            },
        "key_descriptor":{
            "key_info": {
                "x509_data": {
                    "x509_certificate": cert
                    }
                }
            },
        }

def do_aa_descriptor(aa, cert):
    return {
        "protocol_support_enumeration": samlp.NAMESPACE,
        "attribute_service": {
            "binding": BINDING_SOAP ,
{'fraction_non_alphanumeric': 0.09945900957136912, 'fraction_numerical': 0.00749063670411985, 'mean_word_length': 1.7142857142857142, 'pattern_counts': {'":': 68, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1644135', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1365, 'n_words': 244}