@param \SAML2\Utilities\ArrayCollection $assertions Collection of decrypted assertions

@return \SAML2\Utilities\ArrayCollection Collection of processed assertions
769212
public function processAssertions(ArrayCollection $assertions) : ArrayCollection
    {
        $processed = new ArrayCollection();
        foreach ($assertions->getIterator() as $assertion) {
            $processed->add($this->process($assertion));
        }

        return $processed;
    }
698648
private function assertHeaders(array $headers)
    {
        foreach ($headers as $name => $headerValues) {
            HeaderSecurity::assertValidName($name);
            array_walk($headerValues, __NAMESPACE__ . '\HeaderSecurity::assertValid');
        }
    }
510729
public function createSuccess(array $events = []): EventCollection
    {
        $suiteClass = $this->suiteClass;
        $suiteClass::current()->assert($this->successConfig);

        return new EventSequence($events, $this->callVerifierFactory);
    }
949566
protected function _queryAssertion($assertionXpath)
    {
        if ($this->encrypted) {
            $xpath = new DOMXPath($this->decryptedDocument);
        } else {
            $xpath = new DOMXPath($this->document);
        }

        $xpath->registerNamespace('samlp', OneLogin_Saml2_Constants::NS_SAMLP);
        $xpath->registerNamespace('saml', OneLogin_Saml2_Constants::NS_SAML);
        $xpath->registerNamespace('ds', OneLogin_Saml2_Constants::NS_DS);
        $xpath->registerNamespace('xenc', OneLogin_Saml2_Constants::NS_XENC);

        $assertionNode = '/samlp:Response/saml:Assertion';
        $signatureQuery = $assertionNode . '/ds:Signature/ds:SignedInfo/ds:Reference';
        $assertionReferenceNode = $xpath->query($signatureQuery)->item(0);
        if (!$assertionReferenceNode) {
            // is the response signed as a whole?
            $signatureQuery = '/samlp:Response/ds:Signature/ds:SignedInfo/ds:Reference';
            $responseReferenceNode = $xpath->query($signatureQuery)->item(0);
            if ($responseReferenceNode) {
                $uri = $responseReferenceNode->attributes->getNamedItem('URI')->nodeValue;
                if (empty($uri)) {
                    $id = $responseReferenceNode->parentNode->parentNode->parentNode->attributes->getNamedItem('ID')->nodeValue;
                } else {
                    $id = substr($responseReferenceNode->attributes->getNamedItem('URI')->nodeValue, 1);
                }
                $nameQuery = "/samlp:Response[@ID='$id']/saml:Assertion" . $assertionXpath;
            } else {
                $nameQuery = "/samlp:Response/saml:Assertion" . $assertionXpath;
            }
        } else {
            $uri = $assertionReferenceNode->attributes->getNamedItem('URI')->nodeValue;
            if (empty($uri)) {
                $id = $assertionReferenceNode->parentNode->parentNode->parentNode->attributes->getNamedItem('ID')->nodeValue;
            } else {
                $id = substr($assertionReferenceNode->attributes->getNamedItem('URI')->nodeValue, 1);
            }
            $nameQuery = $assertionNode."[@ID='$id']" . $assertionXpath;
        }

        return $xpath->query($nameQuery);
    }
559034
public function fromCalls(array $calls): array
    {
        $verifiers = [];

        foreach ($calls as $call) {
            $verifiers[] = new CallVerifier(
            $call,
                $this->matcherFactory,
                $this->matcherVerifier,
                $this->generatorVerifierFactory,
                $this->iterableVerifierFactory,
                $this->assertionRecorder,
                $this->assertionRenderer
            );
        }

        return $verifiers;
    }
206465
public function checkAnyOrder(...$events): ?EventCollection
    {
        if (!count($events)) {
            return null;
        }

        return $this->assertionRecorder
            ->createSuccess($this->mergeEvents($events));
    }
451294
public function validateNumAssertions()
    {
        $encryptedAssertionNodes = $this->document->getElementsByTagName('EncryptedAssertion');
        $assertionNodes = $this->document->getElementsByTagName('Assertion');

        $valid = $assertionNodes->length + $encryptedAssertionNodes->length == 1;

        if ($this->encrypted) {
            $assertionNodes = $this->decryptedDocument->getElementsByTagName('Assertion');
            $valid = $valid && $assertionNodes->length == 1;
        }

        return $valid;
    }
791009
public function refreshTokenWithAssertion($assertionCredentials = null) {
    if (!$assertionCredentials) {
      $assertionCredentials = $this->assertionCredentials;
    }

    $this->refreshTokenRequest(array(
        'grant_type' => 'assertion',
        'assertion_type' => $assertionCredentials->assertionType,
        'assertion' => $assertionCredentials->generateAssertion(),
    ));
  }
481813
protected function storeCollection($entities)
    {
        $this->adapter->beginTransaction();

        foreach ($entities as $entity) {
            $this->storeEntity($entity);
        }

        $this->adapter->commit();

        return $entities;
    }
746109
@SneakyThrows
    protected SAMLObject encryptAssertion(final Assertion assertion,
                                          final HttpServletRequest request,
                                          final HttpServletResponse response,
                                          final SamlRegisteredService service,
                                          final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) throws SamlException {

        if (service.isEncryptAssertions()) {
            LOGGER.debug("SAML service [{}] requires assertions to be encrypted", adaptor.getEntityId());
            return samlResponseBuilderConfigurationContext.getSamlObjectEncrypter().encode(assertion, service, adaptor);
        }
        LOGGER.debug("SAML registered service [{}] does not require assertions to be encrypted", adaptor.getEntityId());
        return assertion;

    }
671132
public function retrieveUserFromAssertion(Assertion $assertion)
    {
        $user = null;
        $role = null;

        foreach ($assertion->getAllAttributeStatements() as $attributeStatement) {
            foreach ($attributeStatement->getAllAttributes() as $attribute) {
                switch ($attribute->getName()) {
                    case 'user_entity':
                        $user = new User(\json_decode($attribute->getFirstAttributeValue(), true));
                        break;
                    case ClaimTypes::ROLE:
                        $role = $attribute->getFirstAttributeValue();
                }
            }
        }

        if ($user instanceof User) {
            $user->setCurrentRole($role);
        }

        return $user;
    }
1291831
public function getClientCredentialsToken(array $scopes = null):AccessToken{
		$params = [
			'client_id'     => $this->options->key,
			'client_secret' => $this->options->secret,
			'grant_type'    => 'client_credentials',
		];

		if($scopes !== null){
			$params['scope'] = implode($this->scopesDelimiter, $scopes);
		}

		$request = $this->requestFactory
			->createRequest('POST', $this->clientCredentialsTokenURL ?? $this->accessTokenURL)
			->withHeader('Content-Type', 'application/x-www-form-urlencoded')
			->withBody($this->streamFactory->createStream(http_build_query($params, '', '&', PHP_QUERY_RFC1738)))
		;

		foreach($this->authHeaders as $header => $value){
			$request = $request->withAddedHeader($header, $value);
		}

		$token = $this->parseTokenResponse($this->http->sendRequest($request));

		$this->storage->storeAccessToken($this->serviceName, $token);

		return $token;
	}
34575
public function getAssertionAction(Assertion $assertion)
    {
        return new JsonResponse($this->serializer->serialize($assertion, [Options::ENFORCE_OPEN_BADGE_JSON]));
    }
831196
public function registerInAssets(Asserts $asserts)
    {
        foreach ($this->validators as $validator) {
            $validator->registerInAssets($asserts);
        }
    }
440332
public function verify($credentials)
    {
        if(!array_key_exists("jwt", $credentials) || empty($credentials["jwt"])) {
            throw new \Exception("JWT is required");
        }

        // Make sure we have a secret key to decode the JWT
        if(!array_key_exists("secret_key", $credentials) || empty($credentials["secret_key"])) {
            throw new \Exception("Secret Key is required to decode this JWT");
        }

        // Get hash alg from params, default to HS256
        $hashAlgs = array("HS256");
        if(array_key_exists("hash_alg", $credentials) && !empty($credentials["hash_alg"])) {
            $hashAlgs[] = $credentials["hash_alg"];
            $hashAlgs = array_unique($hashAlgs);
        }

        $token = JWT::decode($credentials["jwt"], $credentials["secret_key"], $hashAlgs);

        // User ID is a good checksum to make sure we have a valid JWT
        if(empty($token) || empty($token->id)) {
            throw new \Exception("JWT Token invalid");
        }

        return $token;
    }
211276
public function unserializeConditionCollection($serializedConditions)
    {
        $unserializedConditions = json_decode(base64_decode($serializedConditions));

        $collection = new ConditionCollection();

        if (!empty($unserializedConditions)) {
            /** @var SerializableCondition $condition */
            foreach ($unserializedConditions as $condition) {
                if ($this->container->has($condition->conditionServiceId)) {
                    /** @var ConditionInterface $conditionManager */
                    $conditionManager = $this->build(
                        $condition->conditionServiceId,
                        (array) $condition->operators,
                        (array) $condition->values
                    );
                    $collection[] = clone $conditionManager;
                }
            }
        }

        return $collection;
    }
654513
public function validateSignedElements($signedElements)
    {
        if (count($signedElements) > 2) {
            return false;
        }

        $responseTag = '{'.OneLogin_Saml2_Constants::NS_SAMLP.'}Response';
        $assertionTag = '{'.OneLogin_Saml2_Constants::NS_SAML.'}Assertion';

        $ocurrence = array_count_values($signedElements);
        if ((in_array($responseTag, $signedElements) && $ocurrence[$responseTag] > 1) ||
            (in_array($assertionTag, $signedElements) && $ocurrence[$assertionTag] > 1) ||
            !in_array($responseTag, $signedElements) && !in_array($assertionTag, $signedElements)
        ) {
            return false;
        }

        // Check that the signed elements found here, are the ones that will be verified
        // by OneLogin_Saml2_Utils->validateSign()
        if (in_array($responseTag, $signedElements)) {
            $expectedSignatureNodes = OneLogin_Saml2_Utils::query($this->document, OneLogin_Saml2_Utils::RESPONSE_SIGNATURE_XPATH);
            if ($expectedSignatureNodes->length != 1) {
                throw new OneLogin_Saml2_ValidationError(
                    "Unexpected number of Response signatures found. SAML Response rejected.",
                    OneLogin_Saml2_ValidationError::WRONG_NUMBER_OF_SIGNATURES_IN_RESPONSE
                );
            }
        }

        if (in_array($assertionTag, $signedElements)) {
            $expectedSignatureNodes = $this->_query(OneLogin_Saml2_Utils::ASSERTION_SIGNATURE_XPATH);
            if ($expectedSignatureNodes->length != 1) {
                throw new OneLogin_Saml2_ValidationError(
                    "Unexpected number of Assertion signatures found. SAML Response rejected.",
                    OneLogin_Saml2_ValidationError::WRONG_NUMBER_OF_SIGNATURES_IN_ASSERTION
                );
            }
        }

        return true;
    }