<commit_before><?php

class EngineBlock_Corto_Module_Service_SingleSignOn extends EngineBlock_Corto_Module_Service_Abstract
{
    const RESPONSE_CACHE_TYPE_IN  = 'in';
    const RESPONSE_CACHE_TYPE_OUT = 'out';

    public function serve($serviceName)
    {
        $isUnsolicited = ($serviceName === 'unsolicitedSingleSignOnService');

        if (!$isUnsolicited) {
            // create unsolicited request object
            $request = $this->_createUnsolicitedRequest();

        }
        else if ($serviceName === 'debugSingleSignOnService') {
            if (isset($_SESSION['debugIdpResponse']) && !isset($_POST['clear'])) {
                $response = $_SESSION['debugIdpResponse'];
                $response['saml:Assertion']['saml:AttributeStatement'][0]['saml:Attribute'][7]['saml:AttributeValue'][] = array(
                    '__v' => 'dark side of the force',
                );

                if (isset($_POST['mail'])) {
                    $this->_sendDebugMail($response);
                }

                $this->_server->sendOutput($this->_server->renderTemplate(
                    'debugidpresponse',
                    array(
                        'idp'       => $this->_server->getRemoteEntity($response['saml:Issuer']['__v']),
                        'response'  => $response,
                        'attributes'=> EngineBlock_Corto_XmlToArray::attributes2array(
                            $response['saml:Assertion']['saml:AttributeStatement'][0]['saml:Attribute']
                        ),
                    )
                ));
                return;
            }
            else {
                unset($_SESSION['debugIdpResponse']);
                $request = $this->_createDebugRequest();
            }

        } else {
            // parse SAML request
            $request = $this->_server->getBindingsModule()->receiveRequest();

            // set transparant proxy mode
            $request[EngineBlock_Corto_XmlToArray::PRIVATE_PFX]['Transparent'] = $this->_server->getConfig(
                'TransparentProxy',
                false
            );
        }


        $requestIssuer = $request['saml:Issuer'][EngineBlock_Corto_XmlToArray::VALUE_PFX];
        $remoteEntity = $this->_server->getRemoteEntity($requestIssuer);
        if (!empty($remoteEntity['AdditionalLogging'])) {
            $queue = EngineBlock_ApplicationSingleton::getInstance()
                ->getLogInstance()
                ->getQueueWriter();

            $queue->getSessionStorage()
                  ->setForceFlush(true);<commit_msg>BACKLOG-705: Idp Debugging - fix merge errors and remove debugging<commit_after><?php

class EngineBlock_Corto_Module_Service_SingleSignOn extends EngineBlock_Corto_Module_Service_Abstract
{
    const RESPONSE_CACHE_TYPE_IN  = 'in';
    const RESPONSE_CACHE_TYPE_OUT = 'out';

    public function serve($serviceName)
    {
        $isUnsolicited = ($serviceName === 'unsolicitedSingleSignOnService');

        if ($isUnsolicited) {
            // create unsolicited request object
            $request = $this->_createUnsolicitedRequest();
        }
        else if ($serviceName === 'debugSingleSignOnService') {
            if (isset($_SESSION['debugIdpResponse']) && !isset($_POST['clear'])) {
                $response = $_SESSION['debugIdpResponse'];

                if (isset($_POST['mail'])) {
                    $this->_sendDebugMail($response);
                }

                $this->_server->sendOutput($this->_server->renderTemplate(
                    'debugidpresponse',
                    array(
                        'idp'       => $this->_server->getRemoteEntity($response['saml:Issuer']['__v']),
                        'response'  => $response,
                        'attributes'=> EngineBlock_Corto_XmlToArray::attributes2array(
                            $response['saml:Assertion']['saml:AttributeStatement'][0]['saml:Attribute']
                        ),
                    )
                ));
                return;
            }
            else {
                unset($_SESSION['debugIdpResponse']);
                $request = $this->_createDebugRequest();
            }
        } else {
            // parse SAML request
            $request = $this->_server->getBindingsModule()->receiveRequest();

            // set transparant proxy mode
            $request[EngineBlock_Corto_XmlToArray::PRIVATE_PFX]['Transparent'] = $this->_server->getConfig(
                'TransparentProxy',
                false
            );
        }

        $requestIssuer = $request['saml:Issuer'][EngineBlock_Corto_XmlToArray::VALUE_PFX];
        $remoteEntity = $this->_server->getRemoteEntity($requestIssuer);
        if (!empty($remoteEntity['AdditionalLogging'])) {
            $queue = EngineBlock_ApplicationSingleton::getInstance()
                ->getLogInstance()
                ->getQueueWriter();

            $queue->getSessionStorage()
                  ->setForceFlush(true);
{'fraction_non_alphanumeric': 0.12690152121697357, 'fraction_numerical': 0.001801441152922338, 'mean_word_length': 1.9256440281030445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 50, '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': '5041548', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1245, 'n_words': 171}