Get a certificate instance.

@param  integer $serverId
@param  integer $siteId
@param  integer $certificateId
@return Certificate
176382
public function certificate($serverId, $siteId, $certificateId)
    {
        return new Certificate(
            $this->get("servers/$serverId/sites/$siteId/certificates/$certificateId")['certificate']
            + ['server_id' => $serverId, 'site_id' => $siteId], $this
        );
    }
125181
protected function getConnectedUserMediaPerimeter($siteId)
    {
        $user = $this->get('security.token_storage')->getToken()->getUser();
        if ($user->hasRole(ContributionRoleInterface::PLATFORM_ADMIN)
            || $user->hasRole(ContributionRoleInterface::DEVELOPER)
        ) {
            return null;
        }

        $userGroups = $user->getGroups();
        $folderIds = array();

        foreach ($userGroups as $group) {
            if ($group->hasRole(MediaContributionRoleInterface::MEDIA_CONTRIBUTOR) && $group->getSite()->getSiteId() == $siteId) {
                foreach ($group->getPerimeter(MediaFolderInterface::ENTITY_TYPE)->getItems() as $path) {
                    foreach ($this->get('open_orchestra_media.repository.media_folder')->findSubTreeByPath($path) as $folder) {
                        $folderIds[$folder->getId()] = $folder->getId();
                    }
                }
            }
        }

        return $folderIds;
    }
1356027
public function activateCertificate($serverId, $siteId, $certificateId, $wait = true)
    {
        $this->post("servers/$serverId/sites/$siteId/certificates/$certificateId/activate");

        if ($wait) {
            $this->retry(30, function () use ($serverId, $siteId, $certificateId) {
                $certificate = $this->certificate($serverId, $siteId, $certificateId);

                return $certificate->activationStatus == 'activated';
            });
        }
    }
432192
def create(gandi, private_key, certificate, certificate_id):
    
    if not certificate and not certificate_id:
        gandi.echo('One of --certificate or --certificate-id is needed.')
        return
    if certificate and certificate_id:
        gandi.echo('Only one of --certificate or --certificate-id is needed.')

    if os.path.isfile(private_key):
        with open(private_key) as fhandle:
            private_key = fhandle.read()

    if certificate:
        if os.path.isfile(certificate):
            with open(certificate) as fhandle:
                certificate = fhandle.read()
    else:
        cert = gandi.certificate.info(certificate_id)
        certificate = gandi.certificate.pretty_format_cert(cert)

    result = gandi.hostedcert.create(private_key, certificate)

    output_keys = ['id', 'subject', 'date_created', 'date_expire',
                   'fqdns', 'vhosts']

    output_hostedcert(gandi, result, output_keys)

    return result
1131986
public static function setupServerId(string $serverId)
    {
        //====================================================================//
        // Setup Local Splash Module for Current Server
        /** @var Local $local */
        $local = Splash::local();
        $local->setServerId($serverId);
        //====================================================================//
        // Reboot Splash Core Module
        Splash::reboot();
    }
1213274
@Override
  public ServerHeartbeat getServer(String serverId)
  {
    ServerHeartbeat server = _serverMap.get(serverId);
    
    return server;
  }
892446
def delete_certificate(self, certificate_id):
        
        api = self._get_api(iam.DeveloperApi)
        api.delete_certificate(certificate_id)
        return
194550
public function createCertificate($serverId, $siteId, array $data, $wait = true)
    {
        $certificate = $this->post("servers/$serverId/sites/$siteId/certificates", $data)['certificate'];

        if ($wait) {
            return $this->retry($this->getTimeout(), function () use ($serverId, $siteId, $certificate) {
                $certificate = $this->certificate($serverId, $siteId, $certificate['id']);

                return $certificate->status == 'installed' ? $certificate : null;
            });
        }

        return new Certificate($certificate + ['server_id' => $serverId, 'site_id' => $siteId], $this);
    }
834981
protected function retrieveCertificate($certificateId)
    {
        // Retrieve from cache if a cache handler has been set.
        $cacheKey = 'store-receipt-validate.windowsstore.' . $certificateId;
        $certificate = $this->cache !== null ? $this->cache->get($cacheKey) : null;

        if ($certificate === null) {
            $maxCertificateSize = 10000;

            // We are attempting to retrieve the following url. The getAppReceiptAsync website at
            // http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.store.currentapp.getappreceiptasync.aspx
            // lists the following format for the certificate url.
            $certificateUrl = '/fwlink/?LinkId=246509&cid=' . $certificateId;

            // Make an HTTP GET request for the certificate.
            $client = new \GuzzleHttp\Client(['base_uri' => 'https://go.microsoft.com']);
            $response = $client->request('GET', $certificateUrl);

            // Retrieve the certificate out of the response.
            $certificate = $response->getBody();

            // Write back to cache.
            if ($this->cache !== null) {
                $this->cache->put($cacheKey, $certificate, 3600);
            }
        }

        return openssl_x509_read($certificate);
    }
402633
public function getSiteInfo($siteId)
    {
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select(
            'partial site.{
                owner,
                theme,
                status,
                favIcon,
                loginPage,
                notAuthorizedPage,
                siteLayout,
                siteTitle,
                siteId
            },
            language,
            country'
        )->from(\Rcm\Entity\Site::class, 'site')
            ->join('site.country', 'country')
            ->join('site.language', 'language')
            ->where('site.siteId = :siteId')
            ->setParameter('siteId', $siteId);

        try {
            return $queryBuilder->getQuery()->getSingleResult(
                Query::HYDRATE_ARRAY
            );
        } catch (NoResultException $e) {
            return null;
        }
    }
1063334
public Certificate get(KeyStoreChooser keyStoreChooser, CertificateChooserByAlias certificateChooserByAlias) {
        CacheCert cacheCert = new CacheCert(keyStoreChooser.getKeyStoreName(), certificateChooserByAlias.getAlias());
        Certificate retrievedCertificate = cache.get(cacheCert);

        if (retrievedCertificate != null) {
            return retrievedCertificate;
        }

        KeyStore keyStore = keyStoreRegistry.get(keyStoreChooser);

        if (keyStore != null) {
            CertificateFactoryBean factory = new CertificateFactoryBean();
            factory.setKeystore(keyStore);
            factory.setAlias(certificateChooserByAlias.getAlias());
            try {
                factory.afterPropertiesSet();
                Certificate certificate = (Certificate) factory.getObject();

                if (certificate != null) {
                    cache.put(cacheCert, certificate);
                }
                return certificate;
            } catch (Exception e) {
                throw new CertificateException("error initializing the certificate factory bean", e);
            }
        }

        return null;
    }
743856
public function installCertificate($serverId, $siteId, $certificateId, array $data, $wait = true)
    {
        $this->post("servers/$serverId/sites/$siteId/certificates/$certificateId/install", $data);

        if ($wait) {
            $this->retry(30, function () use ($serverId, $siteId, $certificateId) {
                $certificate = $this->certificate($serverId, $siteId, $certificateId);

                return $certificate->status == 'installed';
            });
        }
    }
348892
public static function get_competency($courseid, $competencyid) {
        global $DB;

        $sql = 'SELECT comp.*
                  FROM {' . competency::TABLE . '} comp
                  JOIN {' . self::TABLE . '} crscomp
                    ON crscomp.competencyid = comp.id
                 WHERE crscomp.courseid = ? AND crscomp.competencyid = ?';
        $params = array($courseid, $competencyid);

        $result = $DB->get_record_sql($sql, $params);
        if (!$result) {
            throw new coding_exception('The competency does not belong to this course: ' . $competencyid . ', ' . $courseid);
        }

        return new competency(0, $result);
    }
448213
public function deploySite($serverId, $siteId, $wait = true)
    {
        $this->post("servers/$serverId/sites/$siteId/deployment/deploy");

        if ($wait) {
            $this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
                return is_null($this->site($serverId, $siteId)->deploymentStatus);
            });
        }
    }
1133641
public function getSitePages($siteId)
    {
        $results = array();
        
        // Event parameters prepare
        $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
        
        // Sending service start event
        $arrayParameters = $this->sendEvent('meliscmssite_service_get_site_pages_start', $arrayParameters);
        
        // Service implementation start
        
        $siteTable = $this->getServiceLocator()->get('MelisEngineTableSite');
        
        $site = $siteTable->getEntryById($arrayParameters['siteId'])->current();
        
        if (!empty($site))
        {
            $pages = $siteTable->getSiteSavedPagesById($site->site_id)->toArray();
            
            if (!empty($pages))
            {
                $site->pages = $pages;
            }
            
            $results = $site;
        }
        
        // Service implementation end
         
        // Adding results to parameters for events treatment if needed
        $arrayParameters['results'] = $results;
        // Sending service end event
        $arrayParameters = $this->sendEvent('meliscmssite_service_get_site_pages_start', $arrayParameters);
        
        return $arrayParameters['results'];
        
    }
1161601
public function getConnectorName(string $serverId)
    {
        if (!$this->hasServerConfiguration($serverId)) {
            return null;
        }

        return $this->configuration['connections'][$serverId]['connector'];
    }
338756
public function findCacheById(int $id, int $siteId = null)
    {

        // Resolve siteId
        $siteId = SiteHelper::resolveSiteId($siteId);

        // Check if already in addToCache
        if ($this->isCachedById($id, $siteId)) {
            return $this->cacheById[$siteId][$id];
        }

        return null;
    }