Signed/Encrypted Message

@param \Swift_Signers_SMimeSigner $smimeSigner

@return $this
548615
public function signCertificate($smimeSigner)
    {
        if ($smimeSigner instanceof \Closure) {
            $signer = \Swift_Signers_SMimeSigner::newInstance();
            call_user_func_array($smimeSigner, [& $signer]);
            $this->message->attachSigner($signer);
        }

        return $this;
    }
253494
public function setMailSender(\Parable\Mail\Sender\SenderInterface $mailSender)
    {
        $this->mailSender = $mailSender;
        return $this;
    }
1201335
public function withBaseCertificateID(IssuerSerial $issuer): self
    {
        $obj = clone $this;
        $obj->_baseCertificateID = $issuer;
        return $obj;
    }
643896
public static function createForApp(string $appIdentifier, string $appSecret)
    {
        $httpClientConfigurator = new HttpClientConfigurator();
        $httpClientConfigurator
            ->setApiAppIdentifier($appIdentifier)
            ->setApiAppSecret($appSecret);

        return static::configure($httpClientConfigurator);
    }
827330
public function setSecret(string $secret):Authenticator{

		if(!preg_match('/^['.Base32::RFC3548.']+$/', $secret)){
			throw new AuthenticatorException('Invalid secret phrase');
		}

		$this->secret = $this->base32->toString($secret);

		return $this;
	}
48106
public function setEncryption(string $encryption): self
    {
        $encryption = strtolower($encryption);
        if ('tls' === $encryption) {
            $this->protocol = 'tcp';
            $this->tls = true;
        } else {
            $this->protocol = $encryption;
            $this->tls = false;
        }

        return $this;
    }
1118220
public function setLogger(LoggerInterface $logger)
	{
		$this->logger = $logger;

		foreach ($this->services as $name) {
			if ($this->$name && $this->$name instanceof \Psr\Log\LoggerAwareInterface) {
				$this->$name->setLogger($logger);
			}
		}

		return $this;
	}
230550
protected function setNonce($addNonce)
    {
        if ($addNonce) {
            $nonceValue = $this->getPassword()->getNonceValue();
            if (!empty($nonceValue)) {
                $this->getUsernameToken()->setNonce(new Nonce($nonceValue));
            }
        }

        return $this;
    }
678215
public function setEncryption($encryption)
    {
        $encryption = strtolower($encryption);
        if ('tls' == $encryption) {
            $this->params['protocol'] = 'tcp';
            $this->params['tls'] = true;
        } else {
            $this->params['protocol'] = $encryption;
            $this->params['tls'] = false;
        }

        return $this;
    }
628511
public function AddrFormat($addr) {
    if (empty($addr[1])) {
      return $this->SecureHeader($addr[0]);
    } else {
      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
    }
  }
329966
private function migrateAnnotationEncryption(SymfonyStyle $helper)
    {
        $helper->note('The encrypted annotation uses mcrypt and therefore is deprecated. This migration will identify all entities using the old annotation, decrpyting with the old method and encrypt the value for the encryption annotation. After execution you have to replace the annotation.');

        /** @var \ReflectionProperty[] $todo */
        $todo = [];
        $classesWithoutNewAnnotation = [];

        $annotationsReader = $this->getContainer()->get('annotations.reader');

        /* Get entites */
        $classes = DoctrineHelper::getAllEntityClassNames($this->getDoctrineManager());
        $helper->comment(sprintf('Found %d entities', count($classes)));

        /* Search for annotation */
        foreach ($classes as $className) {
            $properties = DoctrineHelper::getPropertiesByAnnotation($className, Encrypted::class, $annotationsReader);

            if (0 < count($properties)) {
                $todo[$className] = $properties;
            }
        }

        if (0 === count($todo)) {
            $helper->success('Nothing to do.');

            return true;
        }

        $helper->comment(sprintf('%d entities use the encrypted annotation', count($todo)));

        /* Disable Listener */
        $subscriber = DoctrineHelper::getEventListener(EncryptionSubscriber::class, $this->getDoctrineManager());
        if (null === $subscriber) {
            throw new \LogicException('Event Subscriber not found.');
        }

        $this->getDoctrineManager()->getEventManager()->removeEventSubscriber($subscriber);

        $secret = $this->getContainer()->getParameter('pm__tool.configuration.doctrine.encryption');
        $helper->comment(sprintf('Secret: %s', $secret));

        $secretKey = substr(hash('sha256', $secret), 1, 32);

        /* Get Values */
        foreach ($todo as $className => $properties) {
            $helper->section($className);

            $tableHeader = [
                '#',
            ];
            /** @var \ReflectionProperty $property */
            foreach ($properties as $property) {
                $tableHeader[] = $property->getName();

                if (false === DoctrineHelper::hasPropertyAnnotation($property, Encryption::class, $annotationsReader) && false === in_array($className, $classesWithoutNewAnnotation)) {
                    $classesWithoutNewAnnotation[] = $className;
                }
            }

            $tableValues = [];

            $entites = $this->getDoctrine()->getRepository($className)->findAll();
            foreach ($entites as $entity) {
                $tableRow = [
                    $entity->getId(),
                ];

                foreach ($properties as $property) {
                    $tableRow[] = CryptUtility::decrypt($property->getValue($entity), $secretKey);
                }

                $tableValues[] = $tableRow;
            }

            $helper->table($tableHeader, $tableValues);
        }

        /* Warnings for missing new annotation */
        if (0 < count($classesWithoutNewAnnotation)) {
            $helper->warning(
                array_merge(
                    [
                        'The following classes have properties without the new annotation:',
                    ],
                    $classesWithoutNewAnnotation
                )
            );
        }

        /* Are you sure? */
        if (false === $helper->confirm('Are you sure to reencrypt the shown values?', false)) {
            $helper->warning('Cancelled');

            return false;
        }

        /* Encrypt values */
        foreach ($todo as $className => $properties) {
            $entites = $this->getDoctrine()->getRepository($className)->findAll();
            foreach ($entites as $entity) {

                foreach ($properties as $property) {
                    /** @var Encryption|null $annotation */
                    $annotation = DoctrineHelper::getPropertyAnnotation($property, Encryption::class, $annotationsReader);
                    if (null === $annotation) {
                        $cipher = OpenSSLHelper::CIPHER_AES_256_CBC;
                    } else {
                        $cipher = $annotation->cipher;
                    }

                    $value = CryptUtility::decrypt($property->getValue($entity), $secretKey);

                    $property->setValue($entity, OpenSSLHelper::encrypt($value, $secretKey, $cipher));
                }

                $this->getDoctrineManager()->persist($entity);
            }
        }

        $this->getDoctrineManager()->flush();

        $helper->success('Values changed. Please remove the old annotations now.');

        return true;
    }
448350
public static function create(array $config, $signer = null)
    {
        if (null === $signer) {
            $signer = new HmacSha1Signer();
        }

        if (! $signer instanceof SignerInterface) {
            throw new InvalidArgumentException('The signer must implement the \Risan\OAuth1\Signature\SignerInterface.');
        }

        $configFactory = new ConfigFactory();

        $protocolParameter = new ProtocolParameter(
            $configFactory->createFromArray($config),
            $signer,
            new NonceGenerator()
        );

        $authorizationHeader = new AuthorizationHeader($protocolParameter);

        $requestFactory = new RequestFactory($authorizationHeader, new UriParser());

        return new OAuth1(new HttpClient(), $requestFactory, new CredentialsFactory());
    }
638174
public function encrypt()
    {
        if ($this->encryption == 'XOR') {
            $this->encrypted_data = $this->simplexor();
        } elseif ($this->encryption == 'MCRYPT') {
            $this->encrypted_data = $this->mcrypt();
        }

        return $this;
    }
991801
public function registerDetector(DetectorInterface $spamDetector)
	{
		$detectorId = $this->classSimpleName($spamDetector);

		if (isset($this->detectors[$detectorId]))
		{
			throw new RuntimeException(
				sprintf('Spam Detector [%s] already registered', $detectorId)
			);
		}

		$this->detectors[$detectorId] = $spamDetector;

		return $this;
	}
1040804
public function addSignature(Swift_Mime_SimpleHeaderSet $headers)
    {
        // Prepare the DomainKey-Signature Header
        $params = ['a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash()), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector];
        $string = '';
        foreach ($params as $k => $v) {
            $string .= $k.'='.$v.'; ';
        }
        $string = trim($string);
        $headers->addTextHeader('DomainKey-Signature', $string);

        return $this;
    }
495156
public function set($sType, $sMessage)
    {
        $sType    = strtoupper(trim($sType));
        $sMessage = trim($sMessage);

        $this->aMessages[$sType] = $sMessage;

        return $this;
    }
1053114
public function sign(Signer $signer, $key)
    {
        $signer->modifyHeader($this->headers);

        $this->signature = $signer->sign(
            $this->getToken()->getPayload(),
            $key
        );

        return $this;
    }