public function addAssertion(Assertion $assertion) { $this->assertions[] = $assertion; if (!$assertion->isSuccessful()) { $this->successful = false; } }
function __construct($dataPropertyExpression, $sourceIndividual, $targetValue, $negative = false) { parent::__construct($sourceIndividual); $this->dataPropertyExpression = $dataPropertyExpression; $this->targetValue = $targetValue; $this->negative = $negative; }
function __construct($objectPropertyExpression, $sourceIndividual, $targetIndividual, $negative = false) { parent::__construct($sourceIndividual); $this->addElement($targetIndividual); $this->objectPropertyExpression = $objectPropertyExpression; $this->negative = $negative; }
/** * MakeUserSubAdminOfGroup constructor. * * @param string $userName * @param string $groupId */ public function __construct($userName = '', $groupId = '') { Assertion::notEmpty($userName, 'Username is a required field to add a user to a group'); Assertion::notEmpty($groupId, 'Group id is a required field to add a user to a group'); $this->userName = $userName; $this->groupId = $groupId; }
/** * @param LetterGuessedCorrectly $event */ public function applyLetterGuessedCorrectly(LetterGuessedCorrectly $event) { $readModel = $this->repository->findBy(["gameId" => $event->getGameId()]); Assertion::notNull($readModel, "Readmodel doesn't hold an object"); $lastResult = end($readModel); $readModel = $lastResult->setLetterCorrectlyGuessed($event->getLetters()); $this->repository->save($readModel); }
/** * Verify * * Checks if the parameters are valid. * * @access public * @param int $now Unix timestamp in milliseconds * @return boolean true, if the instance is valid */ public function verify($now) { if (!$this->assertion->verify($now)) { throw new \Exception("cert assertion is not valid"); } if (!$this->certParams->verify($now)) { throw new \Exception("cert params are not valid"); } return true; }
/** * Retrieve Access Token * @return array response from access token request */ public function retrieve() { // parse token and get the tenant id. array key tid in response $parsedToken = $this->parse(); $tenantId = $parsedToken['tid']; if ($tenantId) { // if we have a tenant id built the token url and generate the assertion $this->tokenUrl = $this->authorizationBaseUrl . '/' . $tenantId . '/oauth2/token'; $assertion = new Assertion(); $getAssertion = $assertion->get($this->tokenUrl); //build the post data array $queryParams = array('resource' => $this->resource, 'client_id' => Office365::getClientId(), 'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer', 'client_assertion' => $getAssertion, 'grant_type' => 'client_credentials', 'redirect_uri' => $this->redirectUri); //generate a new API request using the tokenUrl and post_form array $request = new HttpPost($this->tokenUrl); $request->setPostData($queryParams); $request->send(); $responseObj = json_decode($request->getHttpResponse()); return $responseObj; } }
/** * Verify the bundled assertion * * Verifies if the bundled assertion is valid. * * @access public * @param int $now Unix timestamp in milliseconds * @return array Containing the array of certificates as 'certChain', the additional assertion payload as 'payload' and an assertion object as 'assertion' */ public function verify($now) { // no certs? not okay if (sizeof($this->certs) == 0) { throw new \Exception("no certificates provided"); } // simplify error message try { // verify the chain $certChain = $this->verifyChain($now); } catch (Exception $e) { $err = $e->getMessage(); // allow through the malformed signature if ($err == 'malformed signature' || $err == "assertion issued later than verification date" || $err == "assertion has expired") { throw $e; } else { throw new \Exception("bad signature in chain"); } } // what was the last PK in the successful chain? $lastPK = $certChain[sizeof($certChain) - 1]->getCertParams()->getPublicKey(); $token = WebToken::parse($this->signedAssertion); if (!$token->verify($lastPK)) { throw new \Exception("signed assertion was not valid signed"); } // now verify the assertion $payload = $token->getPayload(); $assertion = Assertion::deserialize($payload); if (!$assertion->verify($now)) { throw new \Exception("assertion is not valid"); } return array("certChain" => $certChain, "payload" => $payload, "assertion" => $assertion); }
private function addAssertionToCurrentTest(Assertion $assertion) { if (empty($this->current_test)) { $this->start_new_test($assertion->getName()); } $this->current_test->addAssertion($assertion); }
function __construct($individual, $classExpression) { parent::__construct($individual); $this->classExpression = $classExpression; }
/** * FindGroups constructor. * * @param string $searchGroup */ public function __construct($searchGroup = '') { Assertion::notEmpty($searchGroup, 'Group to search for is a required field to find a group'); $this->searchGroup = $searchGroup; }
/** * FindGroup constructor. * * @param string $groupId */ public function __construct($groupId = '') { Assertion::notEmpty($groupId, 'Group id is a required field to get a group'); $this->groupId = $groupId; }
/** * @Then I should see (an) element :element with (an) file :file */ public function iSeeElementFile($element, $file) { $url = $this->getFileUrl($element, '.ez-fieldview-label'); $fileContentActual = file_get_contents($url); $file = rtrim(realpath($this->getMinkParameter('files_path')), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file; $fileContentExpected = file_get_contents($file); Assertion::assertEquals($fileContentActual, $fileContentExpected); }
/** * @param string $reason */ static function assertSubscriptionDropReason(string $reason) { Assertion::inArray($reason, [self::USER_INITIATED, self::NOT_AUTHENTICATED, self::ACCESS_DENIED, self::SUBSCRIBING_ERROR, self::SERVER_ERROR, self::CONNECTION_CLOSED, self::CATCH_UP_ERROR, self::PROCESSING_QUEUE_OVERFLOW, self::EVENT_HANDLER_EXCEPTION, self::MAX_SUBSCRIBERS_REACHED, self::PERSISTENT_SUBSCRIPTION_DELETED, self::UNKNOWN, self::NOT_FOUND], sprintf('\'%s\' is not a valid subscription drop reason', $reason)); }
/** * Create signed assertion * * Create a signed assertion using the users secret key. * * @access public * @static * @param string $audience The audience this assertion is signed for * @param AbstractSecretkey $secretKeyIdentity An instance of the secret key matching the users certificate identity * @param array $additionalPayload Additional fields to assert * @param int $now Unix timestamp in milliseconds or null for now * @return string The serialized signed assertion */ public static function createAssertion($audience, $secretKeyIdentity, $additionalPayload = null, $now = null) { if ($now == null) { $now = time() * 1000; } $expires = $now + Configuration::getInstance()->get('assertion_validity') * 1000; $assertion = new Assertion(null, $expires, null, $audience); return $assertion->sign($secretKeyIdentity, $additionalPayload); }
/** * FindSubAdminGroupsOfUser constructor. * * @param string $userName */ public function __construct($userName = '') { Assertion::notEmpty($userName, 'Username is a required field to find a user'); $this->userName = $userName; }