Add the optional token details to the base data.
The returnUrl is supported for legacy applications not using the notifyUrl.

@return array
770716
public function getData()
    {
        if (! $this->getReturnUrl()) {
            $this->validate('notifyUrl');
        }

        $data = $this->getBaseAuthorizeData();

        // If a token is being used, then include the token data.
        // With a valid token or card reference, the user is just asked
        // for the CVV and not any remaining card details.

        $data = $this->getTokenData($data);

        // ReturnUrl is for legacy usage.

        $data['NotificationURL'] = $this->getNotifyUrl() ?: $this->getReturnUrl();

        // Set the profile only if it is LOW (for iframe use) or NORMAL (for full-page redirects)

        $profile = strtoupper($this->getProfile());

        if ($profile === static::PROFILE_NORMAL || $profile === static::PROFILE_LOW) {
            $data['Profile'] = $this->getProfile();
        }

        $createCard = $this->getCreateToken() ?: $this->getCreateCard();

        if ($createCard !== null) {
            $data['CreateToken'] = $createCard ? static::CREATE_TOKEN_YES : static::CREATE_TOKEN_NO;
        }

        return $data;
    }
1288888
public function getDefaults()
    {
        return [
            'activation_token_expire' => self::SECONDS_ACTIVATION_TOKEN_EXPIRE,
            'allow_polls' => self::FLAG_ALLOW_POLLS,
            'email_token_expire' => self::SECONDS_EMAIL_TOKEN_EXPIRE,
            'from_email' => self::DEFAULT_FROM_EMAIL,
            'from_name' => self::DEFAULT_FROM_NAME,
            'hot_minimum' => self::HOT_MINIMUM,
            'maintenance_mode' => self::MAINTENANCE_MODE,
            'max_attempts' => self::MAX_SEND_ATTEMPTS,
            'members_visible' => self::FLAG_MEMBERS_VISIBLE,
            'merge_posts' => self::FLAG_MERGE_POSTS,
            'meta_description' => self::META_DESCRIPTION,
            'meta_keywords' => self::META_KEYWORDS,
            'name' => self::PODIUM_NAME,
            'password_reset_token_expire' => self::SECONDS_PASSWORD_RESET_TOKEN_EXPIRE,
            'recaptcha_secretkey' => '',
            'recaptcha_sitekey' => '',
            'registration_off' => self::REGISTRATION_OFF,
            'use_captcha' => self::FLAG_USE_CAPTCHA,
            'use_wysiwyg' => self::FLAG_USE_WYSIWYG,
            'version' => Podium::getInstance()->version,
        ];
    }
1295318
public function addSignature() {

        $signature = [
            "PARAMETERS" => [],
            "RETURNTYPE" => 'undefined'
        ];

        array_push($this->signatures, $signature);

        $this->current_signature = max(array_keys($this->signatures));

        return $this;

    }
835873
public function serialize()
	{
		$it = new SerializedTokenIterator([]);

		$this->preSerialize($it);

		foreach($this->tokens as $token)
		{
			$token->serialize($it);
		}

		$this->postSerialize($it);
		
 		return json_encode($it->getArrayCopy());
	}
87277
public function add() {
        $user = $this->Users->newEntity();
        if ($this->request->is('post')) {
            $user = $this->Users->patchEntity($user, $this->request->data);
            if ($this->Users->save($user)) {
                $this->Flash->success(__('The user has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The user could not be saved. Please, try again.'));
            }
        }
        $this->set(compact('user'));
        $this->set('_serialize', ['user']);
        $this->filteredSelectOptions();
    }
1130548
public function getSurveyApplicationValues()
    {
        static $data;

        if (! $data) {
            $data = array(
                self::APPLY_NOT  => $this->_('No'),
                self::APPLY_DO   => $this->_('Yes (for individual tokens)'),
                self::APPLY_STOP => $this->_('Stop (for tokens in uncompleted tracks)'));
        }

        return $data;
    }
312627
private function add()
    {
        // skip if it's a key
        if ((null !== ($check = $this->tokens->getToken($this->tokens->key() + 1)))
            && ((DocLexer::T_COLON === $check[0])
                || (DocLexer::T_EQUALS === $check[0]))) {
            return;
        }

        $token = $this->tokens->current();
        $value = $this->result->createElement('value');

        if (null !== ($key = $this->key())) {
            $value->setAttribute('key', $key);
        }

        $this->current->appendChild($value);

        $text = null;
        $type = null;

        switch ($token[0]) {
            case DocLexer::T_FALSE:
                $text = '0';
                $type = 'boolean';

                break;
            case DocLexer::T_FLOAT:
                $text = $token[1];
                $type = 'float';

                break;
            case DocLexer::T_IDENTIFIER:
                $text = $token[1];
                $type = 'constant';

                break;
            case DocLexer::T_INTEGER:
                $text = $token[1];
                $type = 'integer';

                break;
            case DocLexer::T_NULL:
                $type = 'null';

                break;
            case DocLexer::T_STRING:
                $text = $token[1];
                $type = 'string';

                break;
            case DocLexer::T_TRUE:
                $text = '1';
                $type = 'boolean';

                break;
        }

        $value->setAttribute('type', $type);

        if (null !== $text) {
            $value->appendChild(new DOMText($text));
        }
    }
25273
protected function getSingleTokenData()
    {
        $this->otherTokenData = $this->multipleTokenData;
        $singleTokenData = array_shift($this->otherTokenData);
        return $singleTokenData;
    }
842087
private function _addDefaultValues()
    {
        if (!isset($this->_sp['assertionConsumerService']['binding'])) {
            $this->_sp['assertionConsumerService']['binding'] = OneLogin_Saml2_Constants::BINDING_HTTP_POST;
        }
        if (isset($this->_sp['singleLogoutService']) && !isset($this->_sp['singleLogoutService']['binding'])) {
            $this->_sp['singleLogoutService']['binding'] = OneLogin_Saml2_Constants::BINDING_HTTP_REDIRECT;
        }

        if (!isset($this->_compress['requests'])) {
            $this->_compress['requests'] = true;
        }

        if (!isset($this->_compress['responses'])) {
            $this->_compress['responses'] = true;
        }

        // Related to nameID
        if (!isset($this->_sp['NameIDFormat'])) {
            $this->_sp['NameIDFormat'] = OneLogin_Saml2_Constants::NAMEID_UNSPECIFIED;
        }
        if (!isset($this->_security['nameIdEncrypted'])) {
            $this->_security['nameIdEncrypted'] = false;
        }
        if (!isset($this->_security['requestedAuthnContext'])) {
            $this->_security['requestedAuthnContext'] = true;
        }

        // sign provided
        if (!isset($this->_security['authnRequestsSigned'])) {
            $this->_security['authnRequestsSigned'] = false;
        }
        if (!isset($this->_security['logoutRequestSigned'])) {
            $this->_security['logoutRequestSigned'] = false;
        }
        if (!isset($this->_security['logoutResponseSigned'])) {
            $this->_security['logoutResponseSigned'] = false;
        }
        if (!isset($this->_security['signMetadata'])) {
            $this->_security['signMetadata'] = false;
        }

        // sign expected
        if (!isset($this->_security['wantMessagesSigned'])) {
            $this->_security['wantMessagesSigned'] = false;
        }
        if (!isset($this->_security['wantAssertionsSigned'])) {
            $this->_security['wantAssertionsSigned'] = false;
        }

        // NameID element expected
        if (!isset($this->_security['wantNameId'])) {
            $this->_security['wantNameId'] = true;
        }

        // Relax Destination validation
        if (!isset($this->_security['relaxDestinationValidation'])) {
            $this->_security['relaxDestinationValidation'] = false;
        }

        // encrypt expected
        if (!isset($this->_security['wantAssertionsEncrypted'])) {
            $this->_security['wantAssertionsEncrypted'] = false;
        }
        if (!isset($this->_security['wantNameIdEncrypted'])) {
            $this->_security['wantNameIdEncrypted'] = false;
        }

        // XML validation
        if (!isset($this->_security['wantXMLValidation'])) {
            $this->_security['wantXMLValidation'] = true;
        }

        // SignatureAlgorithm
        if (!isset($this->_security['signatureAlgorithm'])) {
            $this->_security['signatureAlgorithm'] = XMLSecurityKey::RSA_SHA1;
        }

        // DigestAlgorithm
        if (!isset($this->_security['digestAlgorithm'])) {
            $this->_security['digestAlgorithm'] = XMLSecurityDSig::SHA1;
        }

        if (!isset($this->_security['lowercaseUrlencoding'])) {
            $this->_security['lowercaseUrlencoding'] = false;
        }

        // Certificates / Private key /Fingerprint
        if (!isset($this->_idp['x509cert'])) {
            $this->_idp['x509cert'] = '';
        }
        if (!isset($this->_idp['certFingerprint'])) {
            $this->_idp['certFingerprint'] = '';
        }
        if (!isset($this->_idp['certFingerprintAlgorithm'])) {
            $this->_idp['certFingerprintAlgorithm'] = 'sha1';
        }

        if (!isset($this->_sp['x509cert'])) {
            $this->_sp['x509cert'] = '';
        }
        if (!isset($this->_sp['privateKey'])) {
            $this->_sp['privateKey'] = '';
        }
    }
1194145
public function getDefaultUploadDestinations()
    {
        $user = $this->container->get('security.token_storage')->getToken()->getUser();
        if ($user == 'anon.') return array();

        $pws = $user->getPersonalWorkspace();
        $defaults = [];

        if ($pws) {
            $defaults = array_merge(
                $defaults,
                $this->directoryRepo->findDefaultUploadDirectories($pws)
            );
        }

        $node = $this->container->get('request')->getSession()->get('current_resource_node');

        if ($node && $node->getWorkspace()) {
            $root = $this->directoryRepo->findDefaultUploadDirectories($node->getWorkspace());
            
            if ($this->container->get('security.authorization_checker')->isGranted('CREATE', $root)) {
                $defaults = array_merge($defaults, $root);
            }
        }

        return $defaults;
    }
1027778
protected function buildBasePageIndexerRequest()
    {
        $request = $this->getPageIndexerRequest();
        $request->setParameter('loggingEnabled', $this->loggingEnabled);

        if (!empty($this->options['authorization.'])) {
            $request->setAuthorizationCredentials(
                $this->options['authorization.']['username'],
                $this->options['authorization.']['password']
            );
        }

        if (!empty($this->options['frontendDataHelper.']['headers.'])) {
            foreach ($this->options['frontendDataHelper.']['headers.'] as $headerValue) {
                $request->addHeader($headerValue);
            }
        }

        if (!empty($this->options['frontendDataHelper.']['requestTimeout'])) {
            $request->setTimeout((float)$this->options['frontendDataHelper.']['requestTimeout']);
        }

        return $request;
    }
282018
public function add()
    {
        if (!$this->request->is(['get', 'post'])) {
            throw new MethodNotAllowedException();
        }

        /** @var User $user */
        $user = $this->Users->newEntity(null, ['associated' => 'Groups']);

        if ($this->request->is('post')) {
            $user = $this->Users->patchEntity($user, $this->request->data, ['associated' => 'Groups']);
            $user->set('password', Text::uuid());

            if ($this->Users->save($user, ['associated' => 'Groups'])) {
                $this->Users->Tokens->invalidateExistingTokens($user->id, TokensTable::TYPE_EMAIL_VERIFICATION);
                $token = $this->Users->Tokens->generateToken($user, TokensTable::TYPE_EMAIL_VERIFICATION);
                $this->getMailer('Wasabi/Core.User')->send('verifyAndResetPasswordEmail', [$user, $token]);
                $this->Flash->success(__d('pb', 'The user <strong>{0}</strong> has been created.', $user->fullName()));
                $this->redirect(['action' => 'index']);
                return;
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }

        $groups = $this->Users->Groups->find('list')->order('id ASC');

        // users that are no admin, may not select the super admin group
        if (Wasabi::user()->hasAccessLevel(Permission::OWN)) {
            $groups->where(['id <>' => 1]);
        }

        $this->set([
            'user' => $user,
            'groups' => $groups,
            'languages' => Hash::map(Configure::read('languages.backend'), '{n}', function ($language) {
                return [
                    'value' => $language->id,
                    'text' => $language->name
                ];
            })
        ]);
    }
127376
public function attach()
    {
        $this->detectReturnType();

        if (empty($_REQUEST['broker'])) {
            return $this->fail("No broker specified", 400);
        }

        if (empty($_REQUEST['token'])) {
            return $this->fail("No token specified", 400);
        }

        if (!$this->returnType) {
            return $this->fail("No return url specified", 400);
        }

        $checksum = $this->generateAttachChecksum($_REQUEST['broker'], $_REQUEST['token']);

        if (empty($_REQUEST['checksum']) || $checksum != $_REQUEST['checksum']) {
            return $this->fail("Invalid checksum", 400);
        }

        $this->startUserSession();
        $sid = $this->generateSessionId($_REQUEST['broker'], $_REQUEST['token']);

        $this->cache->set($sid, $this->getSessionData('id'));
        $this->outputAttachSuccess();
    }
966497
public function getExtraFields()
    {
        $extraFields = new FieldList();

        $token = $this->getSecurityToken();
        if ($token) {
            $tokenField = $token->updateFieldSet($this->fields);
            if ($tokenField) {
                $tokenField->setForm($this);
            }
        }
        $this->securityTokenAdded = true;

        // add the "real" HTTP method if necessary (for PUT, DELETE and HEAD)
        if (strtoupper($this->FormMethod()) != $this->FormHttpMethod()) {
            $methodField = new HiddenField('_method', '', $this->FormHttpMethod());
            $methodField->setForm($this);
            $extraFields->push($methodField);
        }

        return $extraFields;
    }
931478
protected function setTokenSettings()
    {
        // Set token lifetime
        $this->tokenLifetime = config('nodes.api.auth.userToken.lifetime', null);

        // Set token table
        $this->tokenTable = $tokenTable = config('nodes.api.auth.userToken.table', 'user_tokens');

        // Set token columns used in condition
        $columns = config('nodes.api.auth.userToken.columns', [
            'user_id' => 'user_id',
            'token' => 'token',
            'expire' => 'expire',
        ]);

        // Prepend token table name to token columns
        foreach ($columns as $key => $field) {
            $this->tokenColumns[$key] = $tokenTable.'.'.$field;
        }

        return $this;
    }
83777
protected function requestToken()
    {
        $this->logger->debug('Requesting a new token');

        $data = [
            'auth' => [
                'passwordCredentials' => [
                    'password' => $this->tenant->getPassword(),
                    'username' => $this->tenant->getUsername(),
                ],
            ],
        ];

        if ($name = $this->tenant->getTenantName()) {
            $data['auth']['tenantName'] = $name;
        }

        try {
            $response = $this->client->request('POST', $this->tenant->getTokenUrl(), [
                RequestOptions::JSON => $data,
            ]);

            return $this->createToken($response->getBody()->getContents());
        } catch (RequestException $e) {
            $this->logger->error(sprintf('Error requesting token: %s', $e->getMessage()));

            throw new TokenException($e->getMessage(), $e->getCode(), $e);
        }
    }
782547
protected function getTokens()
    {
        if ($this->tokens === null) {
            $this->tokens = $this->parsePattern($this->pattern);
        }

        return $this->tokens;
    }