getTranslation() public method

Temporary wrapper for \SimpleSAML\Locale\Translate::getPreferredTranslation().
Deprecation: This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::getPreferredTranslation() instead.
public getTranslation ( $translations )
/**
 * Gets the name value from an entry array.
 *
 * @param  SimpleSAML_XHTML_Template $view  The view object.
 * @param  array $entry The entry array.
 *
 * @return string The resulting name value.
 */
function simplesamlphp_get_entry_name($view, $entry = array())
{
    $result = $entry['entityid'];
    if (!empty($entry['name'])) {
        $name = SimpleSAML\Utils\Arrays::arrayize($entry['name'], 'en');
        $result = $view->getTranslation($name);
    } elseif (!empty($entry['OrganizationDisplayName'])) {
        $name = SimpleSAML\Utils\Arrays::arrayize($entry['OrganizationDisplayName'], 'en');
        $result = $view->getTranslation($name);
    }
    return htmlspecialchars($result);
}
Exemplo n.º 2
0
function updateslostatus()
{
    SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutServiceiFrame: Accessing SAML 2.0 IdP endpoint SingleLogoutService (iFrame version) within updateslostatus() ');
    $config = SimpleSAML_Configuration::getInstance();
    $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
    $session = SimpleSAML_Session::getInstance();
    $idpentityid = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
    $templistofsps = $session->get_sp_list(SimpleSAML_Session::STATE_ONLINE);
    $listofsps = array();
    foreach ($templistofsps as $spentityid) {
        if (!empty($_COOKIE['spstate-' . sha1($spentityid)])) {
            $listofsps[] = $spentityid;
            continue;
        }
        try {
            $spmetadata = $metadata->getMetaData($spentityid, 'saml20-sp-remote');
        } catch (Exception $e) {
            /*
             * For some reason, the metadata for this SP is no longer available. Most
             * likely it was deleted from the IdP while the user had a session to it.
             * In any case - skip this SP.
             */
            $listofsps[] = $spentityid;
            continue;
        }
        if (!isset($spmetadata['SingleLogoutService'])) {
            /* No logout endpoint. */
            $listofsps[] = $spentityid;
            continue;
        }
        /* This SP isn't ready yet. */
    }
    SimpleSAML_Logger::debug('SAML2.0 - IdP.SingleLogoutServiceiFrame: templistofsps ' . join(',', $templistofsps));
    SimpleSAML_Logger::debug('SAML2.0 - IdP.SingleLogoutServiceiFrame:     listofsps ' . join(',', $listofsps));
    // Using template object to be able to translate name of service provider.
    $t = new SimpleSAML_XHTML_Template($config, 'logout-iframe.php');
    // Instantiate the xajaxResponse object
    $objResponse = new xajaxResponse();
    foreach ($listofsps as $spentityid) {
        SimpleSAML_Logger::debug('SAML2.0 - IdP.SingleLogoutServiceiFrame: Completed ' . $spentityid);
        // add a command to the response to assign the innerHTML attribute of
        // the element with id="SomeElementId" to whatever the new content is
        try {
            $spmetadata = $metadata->getMetaData($spentityid, 'saml20-sp-remote');
        } catch (Exception $e) {
            /*
             * For some reason, the metadata for this SP is no longer available. Most
             * likely it was deleted from the IdP while the user had a session to it.
             * In any case - skip this SP.
             */
            continue;
        }
        $name = array_key_exists('name', $spmetadata) ? $spmetadata['name'] : $spentityid;
        $spname = is_array($name) ? $t->getTranslation($name) : $name;
        $objResponse->addScriptCall('slocompletesp', 'e' . sha1($spentityid));
    }
    if (count($templistofsps) === count($listofsps)) {
        $templistofsps = $session->get_sp_list(SimpleSAML_Session::STATE_ONLINE);
        foreach ($templistofsps as $spentityid) {
            $session->set_sp_logout_completed($spentityid);
            setcookie('spstate-' . sha1($spentityid), '', time() - 3600);
            // Delete cookie
        }
        $objResponse->addScriptCall('slocompleted');
        /**
         * Clean up session object to save storage.
         */
        if ($config->getBoolean('debug', false)) {
            SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size before cleaning: ' . $session->getSize());
        }
        $session->clean();
        if ($config->getBoolean('debug', false)) {
            SimpleSAML_Logger::info('SAML2.0 - IdP.SingleLogoutService: Session Size after cleaning: ' . $session->getSize());
        }
    } else {
        SimpleSAML_Logger::debug('SAML2.0 - sp_logout_completed FALSE');
    }
    //return the  xajaxResponse object
    return $objResponse;
}