Exemplo n.º 1
0
 /**
  * Get service.
  *
  * @return VhostBuilderService
  */
 public function serviceProvider()
 {
     $service = $this->getVhostBuilderService();
     $certificate = new Certificate();
     $user = new User();
     $defaultIpSsl = new IpAddress();
     $defaultIp = new IpAddress();
     $certificate->setName('normal')->setCertificateFile('asd')->setCertificateKeyFile('dodooodood');
     $user->setName('jeff')->setGroupname('jeff')->setUid(1000)->setGid(1000);
     $defaultIp->setAlias('default, no ssl')->setHasSsl(false)->setIp('127.0.0.1')->setPort(80);
     $defaultIpSsl->setAlias('default, ssl')->setHasSsl(true)->setIp('127.0.0.1')->setPort(443);
     $domain1 = new Domain();
     $domain2 = new Domain();
     $domain3 = new Domain();
     $domain1->setDomain('lampcp1.de')->setPath('/var/www/lampcp1.de')->setParsePhp(true)->setUser($user)->setWebroot('htdocs')->setCertificate($certificate);
     $domain2->setDomain('lampcp2.de')->setPath('/var/www/lampcp2.de')->setParsePhp(true)->setUser($user)->setWebroot('htdocs');
     $domain3->setDomain('lampcp3.de')->setPath('/var/www/lampcp3.de')->setParsePhp(false)->setUser($user)->setWebroot('htdocs')->setCertificate($certificate);
     $domain1->getIpaddress()->add($defaultIp);
     $domain2->getIpaddress()->add($defaultIpSsl);
     $domain2->getIpaddress()->add($defaultIp);
     $domain3->getIpaddress()->add($defaultIpSsl);
     $subdomain1 = new Subdomain($domain1);
     $subdomain2 = new Subdomain($domain2);
     $subdomain1->setSubdomain('nopaste');
     $subdomain2->setSubdomain('wiki');
     $domain1->getSubdomain()->add($subdomain1);
     $domain2->getSubdomain()->add($subdomain2);
     $service->setDomains(array($domain1, $domain2, $domain3));
     return array(array($service));
 }
 /**
  * Provide test-certificates.
  *
  * @return array
  */
 public function certificateProvider()
 {
     $domain = new Domain();
     $certificate1 = new Certificate();
     $certificate1->setId(1)->setName('test1')->setCertificateFile('certTest1')->setCertificateKeyFile('keyTest1');
     $certificate2 = new Certificate();
     $certificate2->setId(2)->setName('test2')->setCertificateFile('certTest2')->setCertificateKeyFile('keyTest2')->setCACertificateFile('caTest2')->setCertificateChainFile('chainTest2');
     $certificate1->getDomain()->add($domain);
     return array(array($certificate1), array($certificate2));
 }
Exemplo n.º 3
0
 /**
  * Provide test subdomains.
  */
 public function subdomainProvider()
 {
     $domains = array();
     $certRoot = new Certificate();
     $certAlias = new Certificate();
     $certRoot->setName('root');
     $certAlias->setName('alias');
     /*
      * Collect test domains from provider.
      */
     foreach ($this->domainProvider() as $arrDomain) {
         $domains[] = array_pop($arrDomain);
     }
     $alias = new Subdomain(array_pop($domains));
     $root = new Subdomain(array_pop($domains));
     $alias->setSubdomain('alias')->setPath('/var/www/alias/alias')->setCertificate($certAlias)->setParent($root);
     $root->setSubdomain('root')->setPath('/var/www/root/root')->setCertificate($certRoot);
     return array(array($alias), array($root));
 }
Exemplo n.º 4
0
 /**
  * Test getForceSSL().
  */
 public function testGetForceSSL()
 {
     $domain = new Domain();
     $vhost = new Vhost();
     $certificate = new Certificate();
     $subdomain = new Subdomain($domain);
     $ip = new IpAddress();
     $certificate->setName('test')->setCertificateFile('asdasdasdds');
     $domain->setCertificate($certificate)->setForceSsl(true);
     $subdomain->setCertificate($certificate)->setForceSsl(true);
     $vhost->setDomain($domain);
     $this->assertTrue($vhost->getForceSSL());
     $vhost->setSubdomain($subdomain);
     $this->assertTrue($vhost->getForceSSL());
     $ip->setHasSsl(true);
     $vhost->setIpaddress($ip);
     $this->assertFalse($vhost->getForceSSL());
 }
Exemplo n.º 5
0
 /**
  * Remove certificate from storage dir.
  *
  * @param Certificate $certificate
  */
 public function deleteCertificate(Certificate $certificate)
 {
     $fs = new Filesystem();
     $filename = $this->getStorageDir() . '/' . $certificate->getId();
     $method = '';
     foreach ($this->_getExtensions() as $ext) {
         $fullfilename = $filename . $ext;
         switch ($ext) {
             case self::_EXTENSION_CERTIFICATE:
                 $method = 'CertificateFile';
                 break;
             case self::_EXTENSION_PRIVATEKEY:
                 $method = 'CertificateKeyFile';
                 break;
             case self::_EXTENSION_CACERTIFICATE:
                 $method = 'CACertificateFile';
                 break;
             case self::_EXTENSION_CACHAIN:
                 $method = 'CertificateChainFile';
                 break;
         }
         $mSetPath = 'set' . $method . 'Path';
         if ($fs->exists($fullfilename)) {
             $fs->remove($fullfilename);
             $certificate->{$mSetPath}('');
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Displays a form to edit an existing Certificate entity.
  *
  * @Route("/{entity}/edit", name="config_certificate_edit")
  * @Template()
  */
 public function editAction(Certificate $entity)
 {
     try {
         $privKey = $entity->getCertificateKeyFile();
         if (!empty($privKey)) {
             $entity->setCertificateKeyFile($this->_getCryptService()->decrypt($privKey));
         }
     } catch (\Exception $e) {
     }
     $editForm = $this->createForm(new CertificateType(), $entity);
     return array('entity' => $entity, 'edit_form' => $editForm->createView());
 }
 /**
  * Test buildCertificates().
  *
  * @param Certificate $certificate
  *
  * @dataProvider certificateProvider
  */
 public function testBuildCertificates(Certificate $certificate)
 {
     $this->_builder->setCertificates(array($certificate))->buildCertificates();
     if ($certificate->getDomain()->count() < 1) {
         $this->assertEmpty($certificate->getCertificateFilePath());
     } else {
         $this->assertNotEmpty($certificate->getCertificateFilePath());
     }
 }