Exemplo n.º 1
0
 /**
  * Constructs dynamic node type
  *
  * @param string
  */
 public function __construct($label)
 {
     $this->label = $label;
     if (empty($this->uuid)) {
         $this->uuid = $label . Algorithms::generateRandomString(6);
     }
 }
 /**
  * After returning advice, making sure we have an UUID for each and every entity.
  *
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  * @Flow\Before("TYPO3\Flow\Persistence\Aspect\PersistenceMagicAspect->isEntity && method(.*->(__construct|__clone)()) && filter(TYPO3\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver)")
  */
 public function generateUuid(JoinPointInterface $joinPoint)
 {
     /** @var $proxy \TYPO3\Flow\Persistence\Aspect\PersistenceMagicInterface */
     $proxy = $joinPoint->getProxy();
     ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', Algorithms::generateUUID(), true);
     $this->persistenceManager->registerNewObject($proxy);
 }
 /**
  * @param Schema $schema
  * @return void
  */
 public function down(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event DROP CONSTRAINT fk_30ab3a75b684c08");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event DROP CONSTRAINT typo3_neos_eventlog_domain_model_event_pkey");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ADD persistence_object_identifier VARCHAR(40) NULL");
     $result = $this->connection->executeQuery("SELECT installed_version FROM pg_available_extensions WHERE name = 'uuid-ossp'");
     if ($result->fetchColumn() !== NULL) {
         $this->addSql("UPDATE typo3_neos_eventlog_domain_model_event SET persistence_object_identifier = uuid_generate_v4()");
     } else {
         $result = $this->connection->executeQuery("SELECT uid FROM typo3_neos_eventlog_domain_model_event");
         while ($uid = $result->fetchColumn()) {
             $this->addSql("UPDATE typo3_neos_eventlog_domain_model_event SET persistence_object_identifier = '" . \TYPO3\Flow\Utility\Algorithms::generateUUID() . "' WHERE uid = " . $uid);
         }
     }
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ALTER COLUMN persistence_object_identifier SET NOT NULL");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ALTER uid DROP NOT NULL");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ALTER parentevent TYPE VARCHAR(40) USING (parentevent::varchar)");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ALTER parentevent DROP DEFAULT");
     $this->addSql("WITH p AS (SELECT DISTINCT uid, persistence_object_identifier FROM typo3_neos_eventlog_domain_model_event) UPDATE typo3_neos_eventlog_domain_model_event SET parentevent = p.persistence_object_identifier FROM p WHERE parentevent IS NOT NULL AND p.uid = parentevent::integer");
     $this->addSql("SELECT setval('typo3_neos_eventlog_domain_model_event_uid_seq', (SELECT MAX(uid) FROM typo3_neos_eventlog_domain_model_event)+1);");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ALTER uid SET DEFAULT nextval('typo3_neos_eventlog_domain_model_event_uid_seq')");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ADD PRIMARY KEY (persistence_object_identifier)");
     $this->addSql("ALTER TABLE typo3_neos_eventlog_domain_model_event ADD CONSTRAINT fk_30ab3a75b684c08 FOREIGN KEY (parentevent) REFERENCES typo3_neos_eventlog_domain_model_event (persistence_object_identifier) NOT DEFERRABLE INITIALLY IMMEDIATE");
 }
Exemplo n.º 4
0
 /**
  * @param \TYPO3\Flow\Security\Account $login
  * @param string $name
  * @param string $imageId
  * @param string $imageId
  */
 public function __construct($login, $name, $imageId)
 {
     $this->accountId = \TYPO3\Flow\Utility\Algorithms::generateUUID();
     $this->creationDate = new \DateTime();
     $this->login = $login;
     $this->name = trim($name);
     $this->imageId = trim($imageId);
 }
 /**
  * Redirects to the Neos backend on the given site, passing a one-time login token
  *
  * @param Site $site
  * @return void
  */
 public function switchSiteAction($site)
 {
     $token = Algorithms::generateRandomToken(32);
     $this->loginTokenCache->set($token, $this->currentSession->getId());
     $siteUri = $this->linkingService->createSiteUri($this->controllerContext, $site);
     $loginUri = $this->controllerContext->getUriBuilder()->reset()->uriFor('tokenLogin', ['token' => $token], 'Login', 'TYPO3.Neos');
     $this->redirectToUri($siteUri . $loginUri);
 }
 /**
  * Generates a new key & saves it encrypted with a hashing strategy
  *
  * @param string $name
  * @return string
  * @throws \TYPO3\Flow\Security\Exception
  */
 public function generateKey($name)
 {
     if (strlen($name) === 0) {
         throw new \TYPO3\Flow\Security\Exception('Required name argument was empty', 1334215474);
     }
     $password = \TYPO3\Flow\Utility\Algorithms::generateRandomString($this->passwordGenerationLength);
     $this->persistKey($name, $password);
     return $password;
 }
 public function getMockFileResource($filename = 'test.jpg')
 {
     $hash = sha1(Algorithms::generateRandomBytes(40));
     $resourcePointer = new \TYPO3\Flow\Resource\ResourcePointer($hash);
     $mockResource = $this->getAccessibleMock('TYPO3\\Flow\\Resource\\Resource', array('getResourcePointer'));
     $mockResource->expects($this->any())->method('getResourcePointer')->will($this->returnValue($resourcePointer));
     $mockResource->_set('filename', $filename);
     return $mockResource;
 }
Exemplo n.º 8
0
 /**
  * Fetch the token or generate a new random token
  *
  * @return string
  */
 public function getToken()
 {
     $token = $this->cache->get($this->tokenName);
     if ($token === FALSE) {
         $token = Algorithms::generateRandomToken(20);
         $this->storeToken($token);
     }
     return $token;
 }
 /**
  * Generate a number of random identifiers
  *
  * @param integer $count
  * @return void
  */
 public function generateRandomIdentifiersCommand($count = 10)
 {
     $this->outputLine('Here are your random identifiers:');
     $this->outputLine('');
     for ($i = 0; $i < 10; $i++) {
         $this->outputLine(Algorithms::generateUUID());
     }
     $this->outputLine('');
     $this->outputLine('Make sure you always use an identifier once ;-)');
 }
Exemplo n.º 10
0
 /**
  * Constructs dynamic property
  *
  * @param string $label
  * @param DynamicNodeType $dynamicNodeType
  * @param string $placeholder
  * @param string $defaultValue
  */
 public function __construct($label, $dynamicNodeType, $placeholder, $defaultValue)
 {
     $this->label = $label;
     $this->dynamicNodeType = $dynamicNodeType;
     $this->placeholder = $placeholder;
     $this->defaultValue = $defaultValue;
     if (empty($this->uuid)) {
         $this->uuid = $label . Algorithms::generateRandomString(6);
     }
 }
 /**
  * Redirects to the Neos backend on the given hostname, passing a one-time login token
  *
  * @param string $hostname
  * @return void
  */
 public function switchSiteAction($hostname)
 {
     $token = Algorithms::generateRandomToken(32);
     $this->loginTokenCache->set($token, $this->currentSession->getId());
     $requestUri = $this->controllerContext->getRequest()->getHttpRequest()->getUri();
     $baseUri = $this->controllerContext->getRequest()->getHttpRequest()->getBaseUri();
     $uri = $this->controllerContext->getUriBuilder()->reset()->uriFor('tokenLogin', ['token' => $token], 'Login', 'TYPO3.Neos');
     $uri = sprintf('%s://%s%s%s', $requestUri->getScheme(), $hostname, rtrim($baseUri->getPath(), '/'), $uri);
     $this->redirectToUri($uri);
 }
Exemplo n.º 12
0
 /**
  * @test
  */
 public function createNodeFromTemplateUsesIdentifierFromTemplate()
 {
     $identifier = \TYPO3\Flow\Utility\Algorithms::generateUUID();
     $template = new \TYPO3\TYPO3CR\Domain\Model\NodeTemplate();
     $template->setName('new-node');
     $template->setIdentifier($identifier);
     $rootNode = $this->context->getRootNode();
     $newNode = $rootNode->createNodeFromTemplate($template);
     $this->assertSame($identifier, $newNode->getIdentifier());
 }
 /**
  * Generate UUIDs in PHP if the uuid-ossp extension is not installed.
  *
  * @param Schema $schema
  * @return void
  */
 public function preDown(Schema $schema)
 {
     $result = $this->connection->executeQuery("SELECT installed_version FROM pg_available_extensions WHERE name = 'uuid-ossp'");
     if ($result->fetchColumn() === NULL) {
         $this->connection->executeUpdate("ALTER TABLE typo3_typo3cr_domain_model_workspace ADD persistence_object_identifier VARCHAR(40)");
         $result = $this->connection->executeQuery('SELECT name FROM typo3_typo3cr_domain_model_workspace');
         foreach ($result->fetchAll() as $workspace) {
             $this->connection->update('typo3_typo3cr_domain_model_workspace', array('persistence_object_identifier' => \TYPO3\Flow\Utility\Algorithms::generateUUID()), array('name' => $workspace['name']));
         }
     }
 }
Exemplo n.º 14
0
 /**
  * Initialize
  */
 protected function initialize()
 {
     $this->logPrefix = $this->logPrefix ?: Algorithms::generateRandomString(12);
     $contextConfiguration = ['workspaceName' => 'live', 'invisibleContentShown' => TRUE];
     $context = $this->contextFactory->create($contextConfiguration);
     $this->rootNode = $context->getRootNode();
     $siteNodePath = $this->options['siteNodePath'];
     $this->siteNode = $this->rootNode->getNode($siteNodePath);
     if ($this->siteNode === NULL) {
         throw new Exception(sprintf('Site node not found (%s)', $siteNodePath), 1425077201);
     }
 }
Exemplo n.º 15
0
 /**
  * Sends an email to a user with the new password
  *
  * @param \TYPO3\Flow\Security\Account $account
  * @param array $settings
  * @param string $newEnteredPassword
  * @return boolean $success
  */
 public function sendMail(Account $account, $settings, $newEnteredPassword = NULL)
 {
     if ($newEnteredPassword !== NULL) {
         $newPassword = $newEnteredPassword;
     } else {
         $newPassword = $this->algorithms->generateRandomString(10);
         $account->setCredentialsSource($this->hashService->hashPassword($newPassword, 'default'));
         $this->accountRepository->update($account);
     }
     // @TODO: Localize the email format
     $mailBody[] = 'Dear %1$s';
     $mailBody[] = '';
     $mailBody[] = 'Your password for First Visit.';
     $mailBody[] = 'The password is %2$s';
     $mailBody[] = '';
     $mailBody[] = 'If you haven\'t requested this information, please change your password at once';
     $mailBody[] = 'as others might be able to access your account';
     $success = FALSE;
     $message = new SwiftMessage();
     if ($message->setTo(array($account->getAccountIdentifier() => $account->getParty()->getName()))->setFrom(array($settings['PasswordRecovery']['Sender']['Email'] => $settings['PasswordRecovery']['Sender']['Name']))->setSubject($settings['PasswordRecovery']['Subject'])->setBody(vsprintf(implode(PHP_EOL, $mailBody), array($account->getParty()->getName(), $newPassword)))->send()) {
         $success = TRUE;
     }
     return $success;
 }
 /**
  * Hash a password for storage using PBKDF2 and the configured parameters.
  * Will use a combination of a random dynamic salt and the given static salt.
  *
  * @param string $password Cleartext password that should be hashed
  * @param string $staticSalt Static salt that will be appended to the random dynamic salt
  * @return string A Base64 encoded string with the derived key (hashed password) and dynamic salt
  */
 public function hashPassword($password, $staticSalt = null)
 {
     $dynamicSalt = UtilityAlgorithms::generateRandomString($this->dynamicSaltLength);
     $result = Algorithms::pbkdf2($password, $dynamicSalt . $staticSalt, $this->iterationCount, $this->derivedKeyLength, $this->algorithm);
     return base64_encode($dynamicSalt) . ',' . base64_encode($result);
 }
 /**
  * Creates a BCrypt hash
  *
  * @param string $password   The plaintext password to hash
  * @param string $staticSalt Optional static salt that will not be stored in the hashed password
  * @return string the result of the crypt() call
  */
 public function hashPassword($password, $staticSalt = NULL)
 {
     $dynamicSalt = \TYPO3\Flow\Utility\Algorithms::generateRandomString(22, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./');
     return crypt($password, '$2a$' . $this->cost . '$' . $dynamicSalt);
 }
 /**
  * @param array $setting
  * @param string $logPrefix
  * @throws InvalidArgumentException
  */
 public function __construct(array $setting, $logPrefix = NULL)
 {
     if (!isset($setting['__currentPresetName'])) {
         throw new InvalidArgumentException('Missing or invalid "__currentPresetName" in preset part settings', 1426156156);
     }
     $this->currentPresetName = $setting['__currentPresetName'];
     if (!isset($setting['__currentPartName'])) {
         throw new InvalidArgumentException('Missing or invalid "__currentPartName" in preset part settings', 1426156155);
     }
     $this->currentPartName = $setting['__currentPartName'];
     if (!isset($setting['label']) || !is_string($setting['label'])) {
         throw new InvalidArgumentException('Missing or invalid "Label" in preset part settings', 1426156157);
     }
     $this->label = (string) $setting['label'];
     if (!isset($setting['dataProviderClassName']) || !is_string($setting['dataProviderClassName'])) {
         throw new InvalidArgumentException('Missing or invalid "dataProviderClassName" in preset part settings', 1426156158);
     }
     $this->dataProviderClassName = (string) $setting['dataProviderClassName'];
     if (!isset($setting['importerClassName']) || !is_string($setting['importerClassName'])) {
         throw new InvalidArgumentException('Missing or invalid "dataProviderClassName" in preset part settings', 1426156159);
     }
     $this->importerClassName = (string) $setting['importerClassName'];
     $this->batchSize = isset($setting['batchSize']) ? (int) $setting['batchSize'] : NULL;
     $this->offset = isset($setting['batchSize']) ? 0 : NULL;
     $this->dataProviderOptions = isset($setting['dataProviderOptions']) ? $setting['dataProviderOptions'] : [];
     $this->currentBatch = 1;
     $this->logPrefix = $logPrefix ?: Algorithms::generateRandomString(12);
 }
 /**
  * @test
  */
 public function nodeWithRelatedEntitiesWillTakeCareOfAddingToPersistence()
 {
     $identifier = Algorithms::generateUUID();
     $template = new NodeTemplate();
     $template->setName('new-node');
     $template->setIdentifier($identifier);
     $newEntity = new Fixtures\RelatedEntity();
     $newEntity->setFavoritePlace('Reykjavik');
     $anotherNewEntity = new Fixtures\RelatedEntity();
     $anotherNewEntity->setFavoritePlace('Japan');
     $template->setProperty('entity', array($newEntity, $anotherNewEntity));
     $rootNode = $this->context->getRootNode();
     $newNode = $rootNode->createNodeFromTemplate($template);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $this->inject($this->contextFactory, 'contextInstances', array());
     $newLiveContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $newNodeAgain = $newLiveContext->getNode('/new-node');
     $entityArray = $newNodeAgain->getProperty('entity');
     $this->assertCount(2, $entityArray);
     $this->assertEquals('Japan', $entityArray[1]->getFavoritePlace());
 }
 /**
  * Batch process of the given preset
  *
  * @param string $preset
  * @param string $parts
  */
 public function batchCommand($preset, $parts = NULL)
 {
     $this->startTime = microtime(TRUE);
     $parts = Arrays::trimExplode(',', $parts);
     $this->outputLine('Start import ...');
     $logPrefix = Algorithms::generateRandomString(12);
     $presetSettings = Arrays::getValueByPath($this->settings, array('presets', $preset));
     if (!is_array($presetSettings)) {
         $this->outputLine(sprintf('Preset "%s" not found ...', $preset));
         $this->quit(1);
     }
     array_walk($presetSettings, function ($partSetting, $partName) use($preset, $logPrefix, $parts) {
         $this->elapsedTime = 0;
         $this->batchCounter = 0;
         $this->outputLine();
         $this->outputFormatted(sprintf('<b>%s</b>', $partSetting['label']));
         $partSetting['__currentPresetName'] = $preset;
         $partSetting['__currentPartName'] = $partName;
         $partSetting = new PresetPartDefinition($partSetting, $logPrefix);
         if ($parts !== array() && !in_array($partName, $parts)) {
             $this->outputLine('Skipped');
             return;
         }
         if ($partSetting->getBatchSize()) {
             while (($count = $this->executeCommand($partSetting)) > 0) {
                 $partSetting->nextBatch();
             }
         } else {
             $this->executeCommand($partSetting);
         }
     });
     $this->outputLine();
     $this->outputLine('Import finished');
 }
 /**
  * Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new
  * encryption key will be generated and stored in the cache.
  *
  * @return string The configured encryption key stored in Data/Persistent/EncryptionKey
  */
 protected function getEncryptionKey()
 {
     if ($this->encryptionKey === NULL) {
         $this->encryptionKey = $this->cache->get('encryptionKey');
     }
     if ($this->encryptionKey === FALSE && file_exists(FLOW_PATH_DATA . 'Persistent/EncryptionKey')) {
         $this->encryptionKey = file_get_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey');
     }
     if ($this->encryptionKey === FALSE) {
         $this->encryptionKey = bin2hex(\TYPO3\Flow\Utility\Algorithms::generateRandomBytes(96));
         $this->cache->set('encryptionKey', $this->encryptionKey);
     }
     return $this->encryptionKey;
 }
 /**
  * Saves the given array as a node data entity without using the ORM.
  *
  * If the node data already exists (same dimensions, same identifier, same workspace)
  * it is replaced.
  *
  * @param array $nodeData node data to save as an associative array ( $column_name => $value )
  * @throws ImportException
  * @return void
  */
 protected function persistNodeData($nodeData)
 {
     if ($nodeData['workspace'] !== 'live') {
         throw new ImportException('Saving NodeData with workspace != "live" using direct SQL not supported yet. Workspace is "' . $nodeData['workspace'] . '".');
     }
     if ($nodeData['path'] === '/') {
         return;
     }
     // cleanup old data
     /** @var \Doctrine\DBAL\Connection $connection */
     $connection = $this->entityManager->getConnection();
     // prepare node dimensions
     $dimensionValues = $nodeData['dimensionValues'];
     $dimensionsHash = Utility::sortDimensionValueArrayAndReturnDimensionsHash($dimensionValues);
     $jsonPropertiesDataTypeHandler = JsonArrayType::getType(JsonArrayType::FLOW_JSON_ARRAY);
     // post-process node data
     $nodeData['dimensionsHash'] = $dimensionsHash;
     $nodeData['dimensionValues'] = $jsonPropertiesDataTypeHandler->convertToDatabaseValue($dimensionValues, $connection->getDatabasePlatform());
     $nodeData['properties'] = $jsonPropertiesDataTypeHandler->convertToDatabaseValue($nodeData['properties'], $connection->getDatabasePlatform());
     $nodeData['accessRoles'] = $jsonPropertiesDataTypeHandler->convertToDatabaseValue($nodeData['accessRoles'], $connection->getDatabasePlatform());
     $connection->executeQuery('DELETE FROM typo3_typo3cr_domain_model_nodedimension' . ' WHERE nodedata IN (' . '   SELECT persistence_object_identifier FROM typo3_typo3cr_domain_model_nodedata' . '   WHERE identifier = :identifier' . '   AND workspace = :workspace' . '   AND dimensionshash = :dimensionsHash' . ' )', array('identifier' => $nodeData['identifier'], 'workspace' => $nodeData['workspace'], 'dimensionsHash' => $nodeData['dimensionsHash']));
     /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
     $queryBuilder = $this->entityManager->createQueryBuilder();
     $queryBuilder->delete()->from('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData', 'n')->where('n.identifier = :identifier')->andWhere('n.dimensionsHash = :dimensionsHash')->andWhere('n.workspace = :workspace')->setParameter('identifier', $nodeData['identifier'])->setParameter('workspace', $nodeData['workspace'])->setParameter('dimensionsHash', $nodeData['dimensionsHash']);
     $queryBuilder->getQuery()->execute();
     // insert new data
     // we need to use executeUpdate to execute the INSERT -- else the data types are not taken into account.
     // That's why we build a DQL INSERT statement which is then executed.
     $queryParts = array();
     $queryArguments = array();
     $queryTypes = array();
     foreach ($this->nodeDataPropertyNames as $propertyName => $propertyConfig) {
         if (isset($nodeData[$propertyName])) {
             $queryParts[$propertyName] = ':' . $propertyName;
             $queryArguments[$propertyName] = $nodeData[$propertyName];
             if (isset($propertyConfig['columnType'])) {
                 $queryTypes[$propertyName] = $propertyConfig['columnType'];
             }
         }
     }
     $connection->executeUpdate('INSERT INTO typo3_typo3cr_domain_model_nodedata (' . implode(', ', array_keys($queryParts)) . ') VALUES (' . implode(', ', $queryParts) . ')', $queryArguments, $queryTypes);
     foreach ($dimensionValues as $dimension => $values) {
         foreach ($values as $value) {
             $nodeDimension = array('persistence_object_identifier' => Algorithms::generateUUID(), 'nodedata' => $nodeData['Persistence_Object_Identifier'], 'name' => $dimension, 'value' => $value);
             $connection->insert('typo3_typo3cr_domain_model_nodedimension', $nodeDimension);
         }
     }
 }
 /**
  * @test
  * @dataProvider randomStringCharactersDataProvider
  */
 public function generateRandomStringGeneratesOnlyDefinedCharactersRange($regularExpression, $charactersClass)
 {
     $this->assertRegExp($regularExpression, Algorithms::generateRandomString(64, $charactersClass));
 }
 /**
  * Generates and propagates a new session ID and transfers all existing data
  * to the new session.
  *
  * @return string The new session ID
  * @throws \TYPO3\Flow\Session\Exception\SessionNotStartedException
  * @throws \TYPO3\Flow\Session\Exception\OperationNotSupportedException
  * @api
  */
 public function renewId()
 {
     if ($this->started !== true) {
         throw new \TYPO3\Flow\Session\Exception\SessionNotStartedException('Tried to renew the session identifier, but the session has not been started yet.', 1351182429);
     }
     if ($this->remote === true) {
         throw new \TYPO3\Flow\Session\Exception\OperationNotSupportedException(sprintf('Tried to renew the session identifier on a remote session (%s).', $this->sessionIdentifier), 1354034230);
     }
     $this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
     $this->sessionIdentifier = Algorithms::generateRandomString(32);
     $this->writeSessionMetaDataCacheEntry();
     $this->sessionCookie->setValue($this->sessionIdentifier);
     return $this->sessionIdentifier;
 }
 /**
  * Constructs this node data container
  *
  * Creating new nodes by instantiating NodeData is not part of the public API!
  * The content repository needs to properly integrate new nodes into the node
  * tree and therefore you must use createNode() or createNodeFromTemplate()
  * in a Node object which will internally create a NodeData object.
  *
  * @param string $path Absolute path of this node
  * @param \TYPO3\TYPO3CR\Domain\Model\Workspace $workspace The workspace this node will be contained in
  * @param string $identifier The node identifier (not the persistence object identifier!). Specifying this only makes sense while creating corresponding nodes
  * @param array $dimensions An array of dimension name to dimension values
  */
 public function __construct($path, Workspace $workspace, $identifier = null, array $dimensions = null)
 {
     parent::__construct();
     $this->creationDateTime = new \DateTime();
     $this->lastModificationDateTime = new \DateTime();
     $this->setPath($path, false);
     $this->workspace = $workspace;
     $this->identifier = $identifier === null ? Algorithms::generateUUID() : $identifier;
     $this->dimensions = new ArrayCollection();
     if ($dimensions !== null) {
         foreach ($dimensions as $dimensionName => $dimensionValues) {
             foreach ($dimensionValues as $dimensionValue) {
                 $this->dimensions->add(new NodeDimension($this, $dimensionName, $dimensionValue));
             }
         }
     }
     $this->buildDimensionValues();
 }
 /**
  * @return string The configured encryption key stored in Data/Persistent/EncryptionKey
  * @throws \TYPO3\Flow\Security\Exception\MissingConfigurationException
  */
 protected function getEncryptionKey()
 {
     if ($this->encryptionKey === NULL) {
         if (!file_exists(FLOW_PATH_DATA . 'Persistent/EncryptionKey')) {
             file_put_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey', bin2hex(\TYPO3\Flow\Utility\Algorithms::generateRandomBytes(96)));
         }
         $this->encryptionKey = file_get_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey');
         if ($this->encryptionKey === FALSE || $this->encryptionKey === '') {
             throw new \TYPO3\Flow\Security\Exception\MissingConfigurationException('No encryption key for the HashService was found and none could be created at "' . FLOW_PATH_DATA . 'Persistent/EncryptionKey"', 1258991855);
         }
     }
     return $this->encryptionKey;
 }
 /**
  * Returns the current CSRF protection token. A new one is created when needed, depending on the  configured CSRF
  * protection strategy.
  *
  * @return string
  * @Flow\Session(autoStart=true)
  */
 public function getCsrfProtectionToken()
 {
     if ($this->initialized === false) {
         $this->initialize();
     }
     if (count($this->csrfProtectionTokens) === 1 && $this->csrfProtectionStrategy !== self::CSRF_ONE_PER_URI) {
         reset($this->csrfProtectionTokens);
         return key($this->csrfProtectionTokens);
     }
     $newToken = Algorithms::generateRandomToken(16);
     $this->csrfProtectionTokens[$newToken] = true;
     return $newToken;
 }
 /**
  * @param BadgeClass $badgeClass The badge class where this step is needed for an assertion
  * @param string $identifier An identifier for this step (unique per badge class), used to reference steps client- and server-side
  */
 public function __construct(BadgeClass $badgeClass, $identifier)
 {
     $this->badgeClass = $badgeClass;
     $this->identifier = $identifier;
     $this->token = \TYPO3\Flow\Utility\Algorithms::generateUUID();
 }
 /**
  */
 protected function createAndPersistTestEntity()
 {
     $testEntity = new Tweet();
     $testEntity->setDate(new \DateTime());
     $testEntity->setMessage('This is a test message ' . \TYPO3\Flow\Utility\Algorithms::generateRandomString(8));
     $testEntity->setUsername('Zak McKracken' . \TYPO3\Flow\Utility\Algorithms::generateRandomString(8));
     $this->testEntityRepository->add($testEntity);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     return $testEntity;
 }
 /**
  * Hash a password for storage using PBKDF2 and the configured parameters.
  * Will use a combination of a random dynamic salt and the given static salt.
  *
  * @param string $password Cleartext password that should be hashed
  * @param string $staticSalt Static salt that will be appended to the random dynamic salt
  * @return string A Base64 encoded string with the derived key (hashed password) and dynamic salt
  */
 public function hashPassword($password, $staticSalt = null)
 {
     $dynamicSalt = \TYPO3\Flow\Utility\Algorithms::generateRandomBytes($this->dynamicSaltLength);
     $result = \TYPO3\Flow\Security\Cryptography\Algorithms::pbkdf2($password, $dynamicSalt . $staticSalt, $this->iterationCount, $this->derivedKeyLength, $this->algorithm);
     return base64_encode($dynamicSalt) . ',' . base64_encode($result);
 }