Create a Payload instance.

@param mixed $subject
@param array $customClaims

@return \Lia\Addons\JWTAuth\Payload
323922
protected function makePayload($subject, array $customClaims = [])
    {
        return $this->manager->getPayloadFactory()->make(
            array_merge($customClaims, ['sub' => $subject])
        );
    }
512000
protected function _save(Subject $subject)
    {
        $entity = $this->_table()->patchEntity(
            $subject->entity,
            $this->_request()->data,
            $this->saveOptions()
        );
        $subject->set(['entity' => $entity]);

        $this->_trigger('beforeSave', $subject);

        $success = call_user_func(
            [$this->_table(), $this->saveMethod()],
            $entity,
            $this->saveOptions()
        );

        $this->_trigger('afterSave', $subject);

        return $success;
    }
77470
public static function create(
        array $customHeaders = [],
        ApiContext $apiContext = null
    ): BunqResponseSandboxUser {
        if (is_null($apiContext)) {
            throw new BunqException(self::ERROR_API_CONTEXT_IS_NULL);
        }

        $apiClient = new ApiClient($apiContext);
        $responseRaw = $apiClient->post(
            vsprintf(
                self::ENDPOINT_URL_CREATE,
                []
            ),
            [],
            $customHeaders
        );

        return BunqResponseSandboxUser::castFromBunqResponse(
            static::fromJson($responseRaw, self::OBJECT_TYPE_POST)
        );
    }
1196474
protected function addClaims(array $claims)
    {
        foreach ($claims as $name => $value) {
            $this->addClaim($name, $value);
        }

        return $this;
    }
522953
protected function getSignedJwt(ISubject $subject) : SignedJwt
    {
        $jwtPayload = new JwtPayload();
        $jwtPayload->setIssuer($this->issuer);
        $jwtPayload->setAudience($this->audience);
        $jwtPayload->setSubject($subject->getPrimaryPrincipal()->getId());
        $jwtPayload->setValidFrom((new DateTimeImmutable)->add($this->validFromInterval));
        $jwtPayload->setValidTo((new DateTimeImmutable)->add($this->validToInterval));
        $jwtPayload->setIssuedAt(new DateTimeImmutable());
        $this->addCustomClaims($jwtPayload, $subject);
        $unsignedJwt = new UnsignedJwt(new JwtHeader(), $jwtPayload);

        return SignedJwt::createFromUnsignedJwt($unsignedJwt, $this->signer->sign($unsignedJwt->getUnsignedValue()));
    }
939558
public function setSubject(NotificationInterface $notification, $subject, $flush = false)
    {
        $notification->setSubject($subject);
        $this->flush($flush);

        $event = new NotificationEvent($notification);
        $this->dispatcher->dispatch(MgiletNotificationEvents::MODIFIED, $event);

        return $notification;
    }
871993
public static function getSubjectIdentity($subject)
    {
        if ($subject instanceof SubjectIdentityInterface) {
            return $subject;
        }

        if (\is_string($subject)) {
            return SubjectIdentity::fromClassname($subject);
        }

        if (\is_object($subject)) {
            return SubjectIdentity::fromObject($subject);
        }

        throw new UnexpectedTypeException($subject, SubjectIdentityInterface::class.'|object|string');
    }
478739
protected function generateToken(SubjectContract $user)
    {
        $tokenGenerator = $this->getGenerator();
        $claims = $user->getJWTClaims();
        $claims['sub'] = $user->getJWTSubject();
        $claims[static::JWT_GUARD_CLAIM] = $this->id;
        if (!($token = $tokenGenerator($claims))) {
            throw new InvalidTokenException("Unable to generate token");
        }
        return $token;
    }
1355330
public static function create(array $cards, array $customHeaders = []): BunqResponseCardBatch
    {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->post(
            vsprintf(
                self::ENDPOINT_URL_CREATE,
                [static::determineUserId()]
            ),
            [self::FIELD_CARDS => $cards],
            $customHeaders
        );

        return BunqResponseCardBatch::castFromBunqResponse(
            static::fromJson($responseRaw, self::OBJECT_TYPE_POST)
        );
    }
739447
public function openSubjectAction(Subject $subject)
    {
        $forum = $subject->getCategory()->getForum();
        $this->checkAccess($forum);
        $this->manager->openSubject($subject);

        return new RedirectResponse(
            $this->generateUrl('claro_forum_subjects', array('category' => $subject->getCategory()->getId()))
        );
    }
1024281
protected function buildRefreshClaims(Payload $payload)
    {
        // assign the payload values as variables for use later
        extract($payload->toArray());

        // persist the relevant claims
        return array_merge(
            $this->customClaims,
            compact($this->persistentClaims, 'sub', 'iat')
        );
    }
365772
public function create(string $payload, array $signatures, string $jws_serialization_mode, array $jweSharedProtectedHeader, array $jweSharedHeader, array $recipients, string $jwe_serialization_mode, ?string $aad = null): string
    {
        $jws = $this->jwsBuilder->create()->withPayload($payload);
        foreach ($signatures as $signature) {
            if (!\is_array($signature) || !\array_key_exists('key', $signature)) {
                throw new \InvalidArgumentException('The signatures must be an array of arrays containing a key, a protected header and a header');
            }
            $signature['protected_header'] = \array_key_exists('protected_header', $signature) ? $signature['protected_header'] : [];
            $signature['header'] = \array_key_exists('header', $signature) ? $signature['header'] : [];
            $jws = $jws->addSignature($signature['key'], $signature['protected_header'], $signature['header']);
        }
        $jws = $jws->build();
        $token = $this->jwsSerializerManager->serialize($jws_serialization_mode, $jws);

        $jweSharedProtectedHeader['cty'] = 'JWT';

        $jwe = $this->jweBuilder
            ->create()
            ->withPayload($token)
            ->withSharedProtectedHeader($jweSharedProtectedHeader)
            ->withSharedHeader($jweSharedHeader)
            ->withAAD($aad);
        foreach ($recipients as $recipient) {
            if (!\is_array($recipient) || !\array_key_exists('key', $recipient)) {
                throw new \InvalidArgumentException('The recipients must be an array of arrays containing a key and a header');
            }
            $recipient['header'] = \array_key_exists('header', $recipient) ? $recipient['header'] : [];
            $jwe = $jwe->addRecipient($recipient['key'], $recipient['header']);
        }
        $jwe = $jwe->build();
        $token = $this->jweSerializerManager->serialize($jwe_serialization_mode, $jwe);

        return $token;
    }
337331
public function setCustomValue(string $key, $value): Payload
    {
        if ($key === self::PAYLOAD_ROOT_KEY) {
            throw InvalidPayloadException::reservedKey();
        }

        $this->customValues[$key] = $value;

        return $this;
    }
42342
public static function create(array $certificateChain, array $customHeaders = []): BunqResponseInt
    {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->post(
            vsprintf(
                self::ENDPOINT_URL_CREATE,
                [static::determineUserId()]
            ),
            [self::FIELD_CERTIFICATE_CHAIN => $certificateChain],
            $customHeaders
        );

        return BunqResponseInt::castFromBunqResponse(
            static::processForId($responseRaw)
        );
    }
720175
public function generatePublicAlias($subject, $currentAlias = '')
    {
        if (is_object($subject)) {
            if ($subject instanceof Aliasable) {
                $subject = (string)$subject->getAliasTitle();
            } elseif (method_exists($subject, 'getTitle')) {
                $subject = (string)$subject->getTitle();
            } else {
                $subject = (string)$subject;
            }
        }
        if (!is_string($subject)) {
            throw new \InvalidArgumentException('Expected a string or object as subject, got ' . gettype($subject));
        }

        if ($alias = $this->toAlias($subject)) {
            return $this->basePath . $alias;
        }
        return null;
    }
1316940
public static function create(int $year, array $customHeaders = []): BunqResponseInt
    {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->post(
            vsprintf(
                self::ENDPOINT_URL_CREATE,
                [static::determineUserId()]
            ),
            [self::FIELD_YEAR => $year],
            $customHeaders
        );

        return BunqResponseInt::castFromBunqResponse(
            static::processForId($responseRaw)
        );
    }
59777
public function initialize($subject, $callback=null)
    {
        $class = is_string($subject) ? ltrim($subject,'\\') : $subject::className();

        // initialize the object if needed
        if (!isset($this->_schema[$class])) {
            $builder = new \Pheasant\SchemaBuilder($this);
            $initializer = $callback ? $callback : $class.'::initialize';

            $this->events()->trigger('beforeInitialize', $builder);
            call_user_func($initializer, $builder, $this);
            $schema = $builder->build($class);

            $this->_schema[$class] = $schema;
            $this->events()->trigger('afterInitialize', $schema);
        }

        return $class;
    }