@param bool   $mustunderstand
@param string $actor
@param string $envelopeNamespace

@return WsSecurity
779121
protected function initSecurity($mustunderstand = false, $actor = null, $envelopeNamespace = Security::ENV_NAMESPACE)
    {
        $this->security = new Security($mustunderstand, $actor, Security::NS_WSSE, $envelopeNamespace);

        return $this;
    }
369195
public function administrator($actor)
    {
        if ($this->_mixer->eql($actor)) {
            return true;
        }

        return $this->administratingIds->offsetExists($actor->id);
    }
1221000
protected function consume(Message $message, Envelope $envelope = null) : bool
    {
        if (!$envelope instanceof Job) {
            throw new InvalidException(sprintf("Invalid class '%s'", get_class($envelope)));
        }

        try {
            $job = $envelope->getCommand();

            $options = json_encode($job->getInput()->getOptions());
            $arguments = json_encode($job->getInput()->getArguments());

            if (!$this->output->isDebug()) {
                $arguments = strlen($arguments) > 50 ? substr($arguments, 0, 50) . '...' : $arguments;
                $options = strlen($options) > 50 ? substr($options, 0, 50) . '...' : $options;
            }

            $this->output->writeln(sprintf(
                "New job with options '%s' and arguments '%s'",
                $envelope->getClass(),
                $options,
                $arguments
            ), OutputInterface::VERBOSITY_VERY_VERBOSE);

            $job->setOutput($this->output);

            $return = $job->execute($job->input, $this->output) == 0;

            return $return;
        } catch (\Throwable $exception) {
            if (!$exception instanceof \Exception) {
                $exception = new FatalThrowableError($exception);
            }

            $this->output->writeError(sprintf(
                "%s on job '%s' with message '%s'",
                get_class($exception),
                $envelope->getClass(),
                $exception->getMessage()
            ));

            Application::writeException($exception, $this->output, ConsoleOutputInterface::VERBOSITY_VERBOSE);

            self::emit(new ErrorEvent($exception));

            if ($this->input->getOption('retry') && !$exception instanceof FailureException) {
                if ($this->input->getOption('retry') > count($envelope->getHistory())) {
                    if ($this->input->getOption('stop-on-error')) {
                        $this->exitCode = 1;
                    }

                    $this->queue()->publish($envelope->serialize());
                    throw new ManualRequeueException($this->input->getOption('stop-on-error') === 1);
                } else {
                    $errorMessage = sprintf(
                        "Max retries %s reach for %s on job '%s' with message '%s'",
                        $this->input->getOption('retry'),
                        get_class($exception),
                        $envelope->getClass(),
                        $exception->getMessage()
                    );

                    $this->output->writeError($errorMessage);
                    throw new FailureException($message, $errorMessage, $exception);
                }
            }

            if ($this->input->getOption('stop-on-error') && !$exception instanceof FailureException) {
                $this->exitCode = 1;
                throw $exception;
            }

            return true;
        }
    }
134702
@Override
    public boolean checkAliasAccess(Subject authenticatedSubject, String destination, String aliasDestination, int destinationType, String operationType,
                                    boolean logWarning) throws MessagingAuthorizationException {
        SibTr.entry(tc, CLASS_NAME + "checkAliasAccess", new Object[] { authenticatedSubject, aliasDestination, operationType });

        String busName = null;
        String messagingEngine = null;
        String[] roles = null;
        
        if (auditManager != null) {
            if (auditManager.getJMSBusName() != null)
                busName = auditManager.getJMSBusName();
            if (auditManager.getJMSMessagingEngine() != null)
                messagingEngine = auditManager.getJMSMessagingEngine();
        }

        roles = new String[] {MessagingSecurityConstants.OPERATION_TYPE_RECEIVE};
        if (operationType.equalsIgnoreCase(MessagingSecurityConstants.OPERATION_TYPE_BROWSE)) {
            if (checkAliasAccess(authenticatedSubject, destination, aliasDestination, destinationType, MessagingSecurityConstants.OPERATION_TYPE_RECEIVE, false)) {
                return true;
            }
        }
        String destinationName = destination + ":" + aliasDestination;

        checkIfUserIsAuthenticated(authenticatedSubject);
        String userName = null;
        String user = authenticatedSubject.getPrincipals().iterator().next().getName();
        try {
            userName = MessagingSecurityUtility.getUniqueUserName(authenticatedSubject);
        } catch (MessagingSecurityException e) {
            if (auditManager != null && auditManager.getJMSConversationMetaData() != null) {
                ConversationMetaData cmd = (ConversationMetaData) auditManager.getJMSConversationMetaData();

                Audit.audit(Audit.EventID.SECURITY_JMS_AUTHZ_01, user, cmd.getRemoteAddress().getHostAddress(), new Integer(cmd.getRemotePort()).toString(),
                            cmd.getChainName(), busName, messagingEngine, destinationName, operationType, roles, "aliasDestination",
                            Integer.valueOf("201"));
            } else {
                Audit.audit(Audit.EventID.SECURITY_JMS_AUTHZ_01, user, null, null, null, busName, messagingEngine, destinationName, operationType, 
                            roles, "aliasDestination", Integer.valueOf("201"));
            }

            throw new MessagingAuthorizationException(Tr.formatMessage(tc, "USER_NOT_AUTHORIZED_MSE1010", userName, operationType, aliasDestination), e);
        }
        Permission permission = null;
        if (destinationType == MessagingSecurityConstants.DESTINATION_TYPE_QUEUE) {
            Map<String, QueuePermission> destinationPermission = messagingSecurityService.getQueuePermissions();
            permission = destinationPermission.get(destination);
        } else if (destinationType == MessagingSecurityConstants.DESTINATION_TYPE_TOPICSPACE) {
            Map<String, TopicPermission> destinationPermission = messagingSecurityService.getTopicPermissions();
            permission = destinationPermission.get(destination);
        }
        boolean result = checkPermission(permission, operationType, userName);
        if (!result) {
            if (auditManager != null && auditManager.getJMSConversationMetaData() != null) {
                ConversationMetaData cmd = (ConversationMetaData) auditManager.getJMSConversationMetaData();

                Audit.audit(Audit.EventID.SECURITY_JMS_AUTHZ_01, user, cmd.getRemoteAddress().getHostAddress(), new Integer(cmd.getRemotePort()).toString(),
                            cmd.getChainName(), busName, messagingEngine, destinationName, operationType, roles, "aliasDestination",
                            Integer.valueOf("201"));
            } else {
                Audit.audit(Audit.EventID.SECURITY_JMS_AUTHZ_01, user, null, null, null, busName, messagingEngine, destinationName, operationType, 
                            roles, "aliasDestination", Integer.valueOf("201"));
            }
            if (logWarning) {
                SibTr.debug(tc, "USER_NOT_AUTHORIZED_MSE1010",
                            new Object[] { userName, operationType, aliasDestination });
                throw new MessagingAuthorizationException(Tr.formatMessage(tc, "USER_NOT_AUTHORIZED_MSE1010", userName, operationType, aliasDestination));               
            }

        } else {
            if (auditManager != null && auditManager.getJMSConversationMetaData() != null) {
                ConversationMetaData cmd = (ConversationMetaData) auditManager.getJMSConversationMetaData();

                Audit.audit(Audit.EventID.SECURITY_JMS_AUTHZ_01, user, cmd.getRemoteAddress().getHostAddress(), new Integer(cmd.getRemotePort()).toString(),
                            cmd.getChainName(), busName, messagingEngine, destinationName, operationType, roles, "aliasDestination",
                            Integer.valueOf("200"));
            } else {
                Audit.audit(Audit.EventID.SECURITY_JMS_AUTHZ_01, user, null, null, null, busName, messagingEngine, destinationName, operationType, 
                            roles, "aliasDestination", Integer.valueOf("200"));
            }

 
        }
        SibTr.exit(tc, CLASS_NAME + "checkAliasAccess", result);
        return result;
    }
765729
public function createAction($workspaceName, Workspace $baseWorkspace, $ownerAccountIdentifier = null)
    {
        $existingWorkspace = $this->workspaceRepository->findByIdentifier($workspaceName);
        if ($existingWorkspace !== null) {
            $this->throwStatus(409, 'Workspace already exists', '');
        }

        if ($ownerAccountIdentifier !== null) {
            $owner = $this->userService->getUser($ownerAccountIdentifier);
            if ($owner === null) {
                $this->throwStatus(422, 'Requested owner account does not exist', '');
            }
        } else {
            $owner = null;
        }

        $workspace = new Workspace($workspaceName, $baseWorkspace, $owner);
        $this->workspaceRepository->add($workspace);
        $this->throwStatus(201, 'Workspace created', '');
    }
821977
public function possessiveNoune($story, $actor)
    {
        if (is_array($actor) || empty($actor)) {
            $value = AnTranslator::_('LIB-AN-THEIR');
        } else {
            if ($actor->eql($story->subject)) {
                $value = AnTranslator::_(AnService::get('com:actors.template.helper')->noune($actor, array('type' => 'possessive')));
            } elseif ($actor->eql(get_viewer())) {
                $value = AnTranslator::_('LIB-AN-YOUR');
            } else {
                $value = sprintf(AnTranslator::_('LIB-AN-THIRD-PERSON\'S'), $this->actorName($actor));
            }
        }

        return $value;
    }
1251345
public function action($action, $parameters = array(), $absolute = true)
	{
		if ($this->rootNamespace && ! (strpos($action, '\\') === 0))
		{
			$action = $this->rootNamespace.'\\'.$action;
		}
		else
		{
			$action = trim($action, '\\');
		}

		if ( ! is_null($route = $this->routes->getByAction($action)))
		{
			 return $this->toRoute($route, $parameters, $absolute);
		}

		throw new InvalidArgumentException("Action {$action} not defined.");
	}
524338
protected String safeGetMessage(MessageEnvelope envelope) {
		if (envelope != null && envelope.getMessage() != null
				&& envelope.getMessage().getText() != null
				&& envelope.getMessage().getQuickReply() == null) {
			return envelope.getMessage().getText();
		}
		return "";
	}
954644
@Override
  public <T> Completes<T> actorOf(final Class<T> protocol, final Address address) {
    return completes().with(internalActorOf(protocol, address));
  }
407392
protected function urlMakeSecure($sUrl, $bIsProcessing = true)
    {
        if (Functions::isPageSecure()) {
            if ($bIsProcessing) {
                $sSearch  = $this->getUri('process');
                $sReplace = $this->getUri('process_secure');
            } else {
                $sSearch  = $this->getUri('serve');
                $sReplace = $this->getUri('serve_secure');
            }
            $sUrl = str_replace($sSearch, $sReplace, $sUrl);
        }

        return preg_match('#^https?://#', $sUrl) ? $sUrl : site_url($sUrl);
    }
1091956
public function invoke(Envelope $envelope, Queue $queue)
    {
        try {
            $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue));

            $receiver = $this->router->route($envelope);
            $receiver->receive($envelope->getMessage());

            // We successfully processed the message.
            $queue->acknowledge($envelope);

            $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue));
        } catch (\Throwable $error) {
            $this->rejectDispatch($error, $envelope, $queue);
        } catch (\Exception $exception) {
            $this->rejectDispatch($exception, $envelope, $queue);
        }
    }
258039
private function handleRequest(Envelope $envelope, Request $request, PbjxRequest $pbjxRequest): Envelope
    {
        try {
            $response = $this->pbjx->request($pbjxRequest);
        } catch (\Throwable $e) {
            return $this->handleException($envelope, $request, $pbjxRequest, $e);
        }

        return $envelope
            ->set('code', Code::OK)
            ->set('http_code', HttpCode::HTTP_OK())
            ->set('etag', $response->get('etag'))
            ->set('message_ref', $response->generateMessageRef())
            ->set('message', $response);
    }
1228725
public function getLeadCommand($actor, $person)
    {
        if (!$actor->isFollowable() || !$person->isLeadable()) {
            return;
        }

        if ($actor->eql($person)) {
            return;
        }

        if ($actor->blocking($person)) {
            return;
        }

        if ($person->following($actor) && $actor->authorize('administration')) {
            $command = $this->getCommand('lead', array('receiver' => $person, 'actor' => $actor, 'action' => 'unlead'));
            $command->name = 'unlead';
        } elseif (!$person->following($actor) && $actor->authorize('lead')) {
            $command = $this->getCommand('lead', array('receiver' => $person, 'actor' => $actor, 'action' => 'lead'));
            $command->name = 'lead';
        } else {
            return;
        }

        return $command;
    }
446838
protected <T> T selfAs(final Class<T> protocol) {
    return lifeCycle.environment.stage.actorProxyFor(protocol, this, lifeCycle.environment.mailbox);
  }
656227
public function securedAction(string $connectorName, string $webserviceId, string $action)
    {
        //====================================================================//
        // NO Secured Actions for Non Connected Users
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
        //====================================================================//
        // Seach for This Connector in Local Configuration
        $connector = $this->getConnectorFromManager($webserviceId);
        //====================================================================//
        // Safety Check => Connector Exists
        if (!$connector) {
            return self::getDefaultResponse();
        }
        //====================================================================//
        // Safety Check => Action Exists
        $controllerAction = self::hasSecuredAction($connector, $connectorName, $action);
        if (!$controllerAction) {
            return self::getDefaultResponse();
        }
        //====================================================================//
        // Redirect to Requested Conroller Action
        return $this->forwardToConnector($controllerAction, $connector);
//        //====================================================================//
//        // NO Secured Actions for Symfony Internal Connector
//        // Whatever, we skip the Action Redirect
//        return self::getDefaultResponse();
    }
1331940
public static void assertOpenAndActive(@NonNull String ws, @NonNull String errorMsg) throws ND4JWorkspaceException {
        if (!Nd4j.getWorkspaceManager().checkIfWorkspaceExistsAndActive(ws)) {
            throw new ND4JWorkspaceException(errorMsg);
        }
    }
949638
public function validateAssetsPath(ExtensionContract $extension) {
        $targetPath = $this->configRepository->getPublicPath() . '/packages/antares';

        if( ! File::isWritable($targetPath) ) {
            throw new ExtensionException('The package [' . $extension->getPackage()->getName() . '] cannot access to the public assets path in [' . $targetPath . '].');
        }
    }