public static function getNameIdData($request, $key = null)
    {
        if ($request instanceof DOMDocument) {
            $dom = $request;
        } else {
            $dom = new DOMDocument();
            $dom = OneLogin_Saml2_Utils::loadXML($dom, $request);
        }

        $encryptedEntries = OneLogin_Saml2_Utils::query($dom, '/samlp:LogoutRequest/saml:EncryptedID');

        if ($encryptedEntries->length == 1) {
            $encryptedDataNodes = $encryptedEntries->item(0)->getElementsByTagName('EncryptedData');
            $encryptedData = $encryptedDataNodes->item(0);

            if (empty($key)) {
                throw new OneLogin_Saml2_Error(
                    "Private Key is required in order to decrypt the NameID, check settings",
                    OneLogin_Saml2_Error::PRIVATE_KEY_NOT_FOUND
                );
            }

            $seckey = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'private'));
            $seckey->loadKey($key);

            $nameId = OneLogin_Saml2_Utils::decryptElement($encryptedData, $seckey);

        } else {
            $entries = OneLogin_Saml2_Utils::query($dom, '/samlp:LogoutRequest/saml:NameID');
            if ($entries->length == 1) {
                $nameId = $entries->item(0);
            }
        }

        if (!isset($nameId)) {
            throw new OneLogin_Saml2_ValidationError(
                "NameID not found in the Logout Request",
                OneLogin_Saml2_ValidationError::NO_NAMEID
            );
        }

        $nameIdData = array();
        $nameIdData['Value'] = $nameId->nodeValue;
        foreach (array('Format', 'SPNameQualifier', 'NameQualifier') as $attr) {
            if ($nameId->hasAttribute($attr)) {
                $nameIdData[$attr] = $nameId->getAttribute($attr);
            }
        }

        return $nameIdData;
    }
public static function getNameIdData($request, $key = null)
    {
        if ($request instanceof DOMDocument) {
            $dom = $request;
        } else {
            $dom = new DOMDocument();
            $dom = OneLogin_Saml2_Utils::loadXML($dom, $request);
        }

        $encryptedEntries = OneLogin_Saml2_Utils::query($dom, '/samlp:LogoutRequest/saml:EncryptedID');

        if ($encryptedEntries->length == 1) {
            $encryptedDataNodes = $encryptedEntries->item(0)->getElementsByTagName('EncryptedData');
            $encryptedData = $encryptedDataNodes->item(0);

            if (empty($key)) {
                throw new OneLogin_Saml2_Error(
                    "Private Key is required in order to decrypt the NameID, check settings",
                    OneLogin_Saml2_Error::PRIVATE_KEY_NOT_FOUND
                );
            }

            $seckey = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'private'));
            $seckey->loadKey($key);

            $nameId = OneLogin_Saml2_Utils::decryptElement($encryptedData, $seckey);

        } else {
            $entries = OneLogin_Saml2_Utils::query($dom, '/samlp:LogoutRequest/saml:NameID');
            if ($entries->length == 1) {
                $nameId = $entries->item(0);
            }
        }

        if (!isset($nameId)) {
            throw new OneLogin_Saml2_ValidationError(
                "NameID not found in the Logout Request",
                OneLogin_Saml2_ValidationError::NO_NAMEID
            );
        }

        $nameIdData = array();
        $nameIdData['Value'] = $nameId->nodeValue;
        foreach (array('Format', 'SPNameQualifier', 'NameQualifier') as $attr) {
            if ($nameId->hasAttribute($attr)) {
                $nameIdData[$attr] = $nameId->getAttribute($attr);
            }
        }

        return $nameIdData;
    }
public static function getNameIdData ( $ request , $ key = null ) { if ( $ request instanceof DOMDocument ) { $ dom = $ request ; } else { $ dom = new DOMDocument ( ) ; $ dom = OneLogin_Saml2_Utils :: loadXML ( $ dom , $ request ) ; } $ encryptedEntries = OneLogin_Saml2_Utils :: query ( $ dom , '/samlp:LogoutRequest/saml:EncryptedID' ) ; if ( $ encryptedEntries -> length == 1 ) { $ encryptedDataNodes = $ encryptedEntries -> item ( 0 ) -> getElementsByTagName ( 'EncryptedData' ) ; $ encryptedData = $ encryptedDataNodes -> item ( 0 ) ; if ( empty ( $ key ) ) { throw new OneLogin_Saml2_Error ( "Private Key is required in order to decrypt the NameID, check settings" , OneLogin_Saml2_Error :: PRIVATE_KEY_NOT_FOUND ) ; } $ seckey = new XMLSecurityKey ( XMLSecurityKey :: RSA_1_5 , array ( 'type' => 'private' ) ) ; $ seckey -> loadKey ( $ key ) ; $ nameId = OneLogin_Saml2_Utils :: decryptElement ( $ encryptedData , $ seckey ) ; } else { $ entries = OneLogin_Saml2_Utils :: query ( $ dom , '/samlp:LogoutRequest/saml:NameID' ) ; if ( $ entries -> length == 1 ) { $ nameId = $ entries -> item ( 0 ) ; } } if ( ! isset ( $ nameId ) ) { throw new OneLogin_Saml2_ValidationError ( "NameID not found in the Logout Request" , OneLogin_Saml2_ValidationError :: NO_NAMEID ) ; } $ nameIdData = array ( ) ; $ nameIdData [ 'Value' ] = $ nameId -> nodeValue ; foreach ( array ( 'Format' , 'SPNameQualifier' , 'NameQualifier' ) as $ attr ) { if ( $ nameId -> hasAttribute ( $ attr ) ) { $ nameIdData [ $ attr ] = $ nameId -> getAttribute ( $ attr ) ; } } return $ nameIdData ; }
Gets the NameID Data of the the Logout Request.

@param string|DOMDocument $request Logout Request Message
@param string|null $key The SP key

@return array Name ID Data (Value, Format, NameQualifier, SPNameQualifier)

@throws OneLogin_Saml2_Error
@throws OneLogin_Saml2_ValidationError
Gets the NameID Data of the the Logout Request .