Add Certificate to the Role

@param string $roleName
@param RemoteDesktopCertificate $certificate
480482
public function addCertificate($roleName, RemoteDesktopCertificate $certificate)
    {
        $namespaceUri = $this->dom->lookupNamespaceUri($this->dom->namespaceURI);
        $xpath = new \DOMXpath($this->dom);
        $xpath->registerNamespace('sc', $namespaceUri);

        $xpathExpression = '//sc:Role[@name="' . $roleName . '"]//sc:Certificates';
        $certificateList = $xpath->evaluate($xpathExpression);

        if ($certificateList->length == 1) {
            $certificatesNode = $certificateList->item(0);
            $certificateNodeToDelete = null;
            foreach ($certificatesNode->childNodes as $certificateNode) {
                if (!$certificateNode instanceof \DOMElement) {
                    continue;
                }

                if ('Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption' == $certificateNode->getAttribute('name')) {
                    $certificateNodeToDelete = $certificateNode;
                }
            }
            if (!is_null($certificateNodeToDelete)) {
                $certificatesNode->removeChild($certificateNodeToDelete);
            }
        } else {
            $certificatesNode = $this->dom->createElementNS($namespaceUri, 'Certificates');

            $roleNodeList = $xpath->evaluate('//sc:Role[@name="' . $roleName . '"]');

            if ($roleNodeList->length == 0) {
                throw new \RuntimeException("No Role found with name '" . $roleName . "'.");
            }

            $roleNode = $roleNodeList->item(0);
            $roleNode->appendChild($certificatesNode);
        }

        $certificateNode = $this->dom->createElementNS($namespaceUri, 'Certificate');
        $certificateNode->setAttribute('name', 'Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption');
        $certificateNode->setAttribute('thumbprint', $certificate->getThumbprint());
        $certificateNode->setAttribute('thumbprintAlgorithm', 'sha1');

        $certificatesNode->appendChild($certificateNode);

        $this->save();
    }
778366
protected function createRole($roleName)
    {
        // No need to check is_null($role) as create() throwsException
        $role = $this->roleRepository->create($roleName);

        $this->info('Role created successfully');

        return $role;
    }
150130
public function setSSLCert($certPath, $passPhrase = null)
    {
        $this->soapOptions['local_cert'] = realpath($certPath);
        if (isset($passPhrase) && trim($passPhrase) != "") {
            $this->soapOptions['passphrase'] = $passPhrase;
        }
    }
1089010
public function clientSideCert($cert, $key, $passphrase = null, $encoding = 'PEM')
    {
        $this->client_cert          = $cert;
        $this->client_key           = $key;
        $this->client_passphrase    = $passphrase;
        $this->client_encoding      = $encoding;

        return $this;
    }
992549
public function setCertificateStatus(\AgentSIB\Diadoc\Api\Proto\CertificateVerificationResult $value = null)
    {
        $this->CertificateStatus = $value;
    }
1098915
public function updateRole($roleId, Request $request)
    {
        $createStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        return $this->roleService->updateRole(
            $this->roleService->loadRole($roleId),
            $this->mapToUpdateStruct($createStruct)
        );
    }
25529
public function addPolicy($roleId, Request $request)
    {
        $createStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        try {
            // First try to treat $roleId as a role draft ID.
            $role = $this->roleService->addPolicyByRoleDraft(
                $this->roleService->loadRoleDraft($roleId),
                $createStruct
            );
        } catch (NotFoundException $e) {
            // Then try to treat $roleId as a role ID.
            $role = $this->roleService->addPolicy(
                $this->roleService->loadRole($roleId),
                $createStruct
            );
        } catch (LimitationValidationException $e) {
            throw new BadRequestException($e->getMessage());
        }

        return new Values\CreatedPolicy(
            array(
                'policy' => $this->getLastAddedPolicy($role),
            )
        );
    }
912291
protected function addPolicy(Role $role, RoleService $roleService, array $policy)
    {
        $policyCreateStruct = $roleService->newPolicyCreateStruct($policy['module'], $policy['function']);

        if (array_key_exists('limitations', $policy)) {
            foreach ($policy['limitations'] as $limitation) {
                $limitationObject = $this->createLimitation($roleService, $limitation);
                $policyCreateStruct->addLimitation($limitationObject);
            }
        }

        $roleService->addPolicy($role, $policyCreateStruct);
    }
722383
protected function addPermissionsToSU(Role $roleSu)
    {
        $this->stdout("Init SU assigning permissions\n",  Console::FG_YELLOW);
        foreach ($this->authManager->getPermissions() as $permission) {
            try {
                $this->authManager->addChild($roleSu, $permission);
                $this->stdout("\tAssign to SU permission: {$permission->name} - success\n", Console::FG_GREEN);
            } catch(\Exception $e) {
                $this->stdout("\t- already exist\n", Console::FG_RED);
            }
        };
    }
412137
public function add($roleUri, $accessUri)
    {
		$uri = explode('#', $accessUri);
		list($type, $ext, $mod, $act) = explode('_', $uri[1]);
		
		$role = new \core_kernel_classes_Resource($roleUri);
		$module = new \core_kernel_classes_Resource($this->makeEMAUri($ext, $mod));
		$actionAccessProperty = new \core_kernel_classes_Property(static::PROPERTY_ACL_GRANTACCESS);
		$moduleAccessProperty = new \core_kernel_classes_Property(static::PROPERTY_ACL_GRANTACCESS);
		
		$values = $role->getPropertyValues($actionAccessProperty);
		if (!in_array($accessUri, $values)) {
		    $role->setPropertyValue($actionAccessProperty, $accessUri);
            $this->getEventManager()->trigger(new AccessRightAddedEvent($roleUri, $accessUri));
            $controllerClassName = MapHelper::getControllerFromUri($module->getUri());
		    CacheHelper::flushControllerAccess($controllerClassName);
		} else {
		    \common_Logger::w('Tried to regrant access for role '.$role->getUri().' to action '.$accessUri);
		}
    }
1178758
public function addCertificate($certificate, $key, array $chain = [])
    {
        $options = ['key' => $key, 'certificate' => $certificate, 'chain' => $chain];

        return Certificate::create($options, $this->getUri() . '/certificates', $this->client);
    }
1225361
public function addCloudCertificates(\AgentSIB\Diadoc\Api\Proto\CertificateInfo $value)
    {
        if ($this->CloudCertificates === null) {
            $this->CloudCertificates = new \Protobuf\MessageCollection();
        }

        $this->CloudCertificates->add($value);
    }
1185105
public function deactivateRole($featureName, $roleName)
    {
        $feature = $this->getFeature($featureName);
        $feature->removeRole($roleName);
        $this->saveFeature($feature);
    }
684921
public function addRoleByObject(BridgeRole $role_obj)
    {
        if (! $role_obj->exists)
            $role_obj->save();

        $role_id = $role_obj->getKey();

        return $this->addRoleById($role_id);
    }
1192127
public function assignRole($roleName, $userId)
    {
        $role = $this->role->findByName($roleName);
        $user = $this->model->find($userId);

        $user->roles()->attach($role);
    }
156118
function setClientCert($crtFile, $keyFile)
    {
        if(!file_exists($crtFile)) {
            $this->debugMessage("Client certificate not found");
            return;
        }

        if(!file_exists($keyFile)) {
            $this->debugMessage("Client key not found");
            return;
        }

        $this->clientCrt = $crtFile;
        $this->clientKey = $keyFile;
    }
1236110
public function addCertification(\Librinfo\SeedBatchBundle\Entity\Certification $certifications)
    {
        $this->certifications[] = $certifications;

        return $this;
    }