/** * {@inheritdoc} */ public function writeEncryptDictionary(ObjectWriter $objectWriter) { $objectWriter->startDictionary(); $objectWriter->writeName('Filter'); $objectWriter->writeName('Standard'); $objectWriter->writeName('V'); $objectWriter->writeNumber($this->getAlgorithm()); $objectWriter->writeName('R'); $objectWriter->writeNumber($this->getRevision()); $objectWriter->writeName('O'); $objectWriter->writeNumber($this->ownerEntry); $objectWriter->writeName('U'); $objectWriter->writeNumber($this->userEntry); $objectWriter->writeName('P'); if (null === $this->userPermissions) { $objectWriter->writeNumber(0); } else { $objectWriter->writeNumber($this->userPermissions->toInt($this->getRevision())); } $this->writeAdditionalEncryptDictionaryEntries($objectWriter); $objectWriter->endDictionary(); }
/** * {@inheritdoc} */ protected function createEncryption($userPassword, $ownerPassword = null, Permissions $userPermissions = null) { return new Pdf16Encryption(md5('test', true), $userPassword, $ownerPassword ?: $userPassword, $userPermissions ?: Permissions::allowNothing()); }
public function testAbstractReturnsInvalidKeyLength() { $this->setExpectedException(UnexpectedValueException::class, 'Key length must be either 40 or 128'); $this->getAbstractEncryption(100)->__construct('', '', '', Permissions::allowNothing()); }
/** * @param string $userPassword * @param string|null $ownerPassword * @param Permissions|null $userPermissions */ public function __construct($userPassword, $ownerPassword = null, Permissions $userPermissions = null) { $this->userPassword = $userPassword; $this->ownerPassword = null !== $ownerPassword ? $ownerPassword : $userPassword; $this->userPermissions = null !== $userPermissions ? $userPermissions : Permissions::allowEverything(); }
public function testFullPermissions() { $permissions = Permissions::allowEverything(); $this->assertSame(60, $permissions->toInt(2)); $this->assertSame(3900, $permissions->toInt(3)); }