Redirect to Connectors Public Actions

@param string $connectorName
@param string $webserviceId
@param string $action

@return Response
331669
public function publicAction(string $connectorName, string $webserviceId, string $action)
    {
        //====================================================================//
        // Seach for This Connector in Local Configuration
        $connector = $this->getConnectorFromManager($webserviceId);
        //====================================================================//
        // Safety Check => Connector Exists
        if (!$connector) {
            return self::getDefaultResponse();
        }
        //====================================================================//
        // Safety Check => Action Exists
        if (!($controllerAction = self::hasPublicAction($connector, $connectorName, $action))) {
            return self::getDefaultResponse();
        }
        //====================================================================//
        // Redirect to Requested Conroller Action
        return $this->forwardToConnector($controllerAction, $connector);
    }
355473
public function linkAction($action, $title = null, $parameters = [], $attributes = [])
    {
        return $this->link($this->url->action($action, $parameters), $title, $attributes);
    }
1345466
public function __soapCall($methodName, $arguments, $options = null, $inputHeaders = null, &$outputHeaders = null)
    {
        if ($this->isFinancialMethod($methodName, $arguments)) {
            $usedMethod = $methodName;

            if ($methodName === 'AccountManagement') {
                $usedMethod .= $arguments[0]->getAction();
            }

            $operationNum = time();
            $financeToken = $this->user->createFinanceToken($usedMethod, $operationNum);

            if (!is_array($inputHeaders)) {
                $inputHeaders = [];
            }

            $inputHeaders[] = new \SoapHeader('API', 'finance_token', $financeToken);
            $inputHeaders[] = new \SoapHeader('API', 'operation_num', $operationNum);
        }

        return parent::__soapCall($methodName, $arguments, $options, $inputHeaders, $outputHeaders);
    }
892920
public static function getServiceFilters(
        $action,
        $service,
        $component = null,
        $requestor = ServiceRequestorTypes::API
    ) {
        if (static::isSysAdmin()) {
            return null;
        }

        $services = (array)static::get('role.services');
        $service = strval($service);
        $component = strval($component);
        if ((false !== $parenStart = strpos($component, '(')) && (false !== $parenEnd = strpos($component, ')'))) {
            $component = substr_replace($component, '', $parenStart, $parenEnd - $parenStart + 1);
        }
        $action = VerbsMask::toNumeric(static::cleanAction($action));

        $serviceAllowed = null;
        $serviceFound = false;
        $componentAllowed = null;
        $componentFound = false;
        $exactAllowed = null;
        $exactFound = false;
        foreach ($services as $svcInfo) {
            $tempRequestors = array_get($svcInfo, 'requestor_mask', ServiceRequestorTypes::API);
            if (!($requestor & $tempRequestors)) {
                //  Requestor type not found in allowed requestors, skip access setting
                continue;
            }

            $tempVerbs = array_get($svcInfo, 'verb_mask');
            if (!($tempVerbs & $action)) {
                continue;
            }

            $tempService = strval(array_get($svcInfo, 'service'));
            if (0 !== strcasecmp($service, $tempService)) {
                continue; // filters only available starting at the service
            }

            $tempComponent = strval(array_get($svcInfo, 'component'));

            if (!empty($component)) {
                if (0 == strcasecmp($component, $tempComponent)) {
                    // exact match
                    $exactAllowed = $svcInfo;
                    $exactFound = true;
                } elseif ((false !== $tempCompStarPos = strpos($tempComponent, '*')) &&
                    (0 == strcasecmp(substr($component . '/', 0, $tempCompStarPos) . '*', $tempComponent))
                ) {
                    $componentAllowed = $svcInfo;
                    $componentFound = true;
                } elseif ('*' == $tempComponent) {
                    $serviceAllowed = $svcInfo;
                    $serviceFound = true;
                } elseif ((false !== $wildcardStart = strpos($component, '{')) &&
                    (false !== $wildcardEnd = strpos($component, '}'))) {
                    $compReg = '^' . substr_replace($component, '[a-zA-Z0-9_]{1,}$', $wildcardStart,
                            $wildcardEnd - $wildcardStart + 1);
                    $compReg = str_replace('/', '\/', $compReg);
                    if ((false !== preg_match("/$compReg/", $tempComponent, $matches)) && !empty($matches)) {
                        $componentAllowed = $svcInfo;
                        $componentFound = true;
                    }
                }
            } else {
                if (empty($tempComponent)) {
                    // exact match
                    $exactAllowed = $svcInfo;
                    $exactFound = true;
                } elseif ('*' == $tempComponent) {
                    $serviceAllowed = $svcInfo;
                    $serviceFound = true;
                }
            }
        }

        $info = null;
        if ($exactFound) {
            $info = $exactAllowed;
        } elseif ($componentFound) {
            $info = $componentAllowed;
        } elseif ($serviceFound) {
            $info = $serviceAllowed;
        }

        if ($info) {
            if (empty($filters = array_get($info, 'filters'))) {
                return null;
            }

            return ['filters' => $filters, 'filter_op' => array_get($info, 'filter_op', 'AND')];
        }

        return null;
    }
1366075
public function masterAction(string $connectorName)
    {
        //====================================================================//
        // Seach for This Connection in Local Configuration
        $connector = $this->get('splash.connectors.manager')->getRawConnector($connectorName);
        //====================================================================//
        // Safety Check => Connector Exists
        if (!$connector) {
            return self::getDefaultResponse();
        }
        //====================================================================//
        // Safety Check => Master Action Exists
        $controllerAction = $connector->getMasterAction();
        if (!$controllerAction) {
            return self::getDefaultResponse();
        }
        //====================================================================//
        // Redirect to Requested Conroller Action
        return $this->forwardToConnector($controllerAction, $connector);
    }
1126339
@Override
    public void dispose() {
        LOG.ok("Dispose connector resources");

        config = null;

        if (connection != null) {
            connection.dispose();
            connection = null;
        }
        WebServiceConnection.shutdownBus();
    }
901229
def request(action, data = nil)
      session.request(
        Endpoint.new.soap_action_name(entity_class, action),
        data
      )
    end
489438
public function __doRequest($request, $location, $action, $version, $one_way = 0) {

		$this->__last_request = $request;

		if(empty($this->headers)) {
			$headers = array( 'Connection: Close', 'Content-Type: application/soap+xml' );
		}
		else {
			$headers = $this->headers;
		}

		$soapHeaders = array(
			sprintf('SOAPAction: "%s"', $action),
			sprintf('Content-Length: %d', strlen($request))
		);

		$headers = array_merge($headers, $soapHeaders);

		$this->logger->debug('Request: '.$request, $headers);

		$ch = curl_init($location);

		$options = $this->curlOptions + array(
			CURLOPT_FOLLOWLOCATION => true,
			CURLOPT_SSL_VERIFYHOST => 2,
			CURLOPT_SSL_VERIFYPEER => true,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_HTTPHEADER     => $headers,
			CURLOPT_POSTFIELDS     => $request
		);

		if($this->logger->isHandling(Logger::DEBUG)) {
			$tmp = fopen('php://temp', 'r+');
			$options[CURLOPT_VERBOSE] = true;
			$options[CURLOPT_STDERR]  = $tmp;
		}

		curl_setopt_array($ch, $options);

		$output = curl_exec($ch);

		if(isset($tmp) && is_resource($tmp)) {
			rewind($tmp);
			$this->logger->debug(stream_get_contents($tmp));
			fclose($tmp);
		}

		$this->logger->debug('Response: '.$output);

		return $output;
	}
1192300
protected function redirectToAction(
        $action,
        array $parameters = [],
        $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH,
        $status = 302
    ) {
        $url = $this->container->get(AdminRouter::class)
            ->generateAdminPath($this->admin, $action, $parameters, $referenceType);

        return new RedirectResponse($url, $status);
    }
395980
public static function isValidURL($url,
                                      $message = '',
                                      ConnectorInterface $connector = null)
    {
        // Check that $url is a string.
        if (empty($url) || !is_string($url)) {
            throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
        }

        // Check that $url is a valid url.
        if (filter_var($url, FILTER_VALIDATE_URL) === false) {
            throw new \PHPUnit_Framework_Exception("Url is not valid.\n");
        }

        // Assign connector if there isn't one already.
        if ($connector === null) {
            $connector = new HTML5ValidatorNuConnector();
        }

        // Parse the html.
        $connector->setInput($url);
        $response = $connector->execute('url');

        // Tell PHPUnit of the results.
        $constraint = new GenericConstraint($connector);
        self::assertThat($response, $constraint, $message);
    }
454801
public function callService($serviceName, $action, array $parameters = array(), array $files = array())
    {
        $httpClient = $this->getHTTPClient();

        $url = $this->getServiceUrl($serviceName, $action);
        $request = new Request('POST', $url, $this->getRequestHeaders($url, $parameters), $this->getRequestBody($parameters, $files));

        try {
            $response = $httpClient->send($request);
        } catch (GuzzleRequestException $exception) {
            $response = $exception->getResponse();
        }

        $this->validateAPIResponseCode($request, $response);

        return $response;
    }
994975
public void redirectCall(String connId, String destination) throws WorkspaceApiException {
        this.redirectCall(connId, destination, null, null);
    }
863411
public function forwardToConnector(string $controller, AbstractConnector $connector)
    {
        //====================================================================//
        // Safety Check
        if (empty($connector) || empty($controller)) {
            return self::getDefaultResponse();
        }

        //====================================================================//
        // Load Current Request Query
        $request = $this->get('request_stack')->getCurrentRequest();
        $query = is_null($request) ? array() : $request->query->all();

        //====================================================================//
        // Redirect to Requested Controller Action
        try {
            $response = $this->forward($controller, array('connector' => $connector), $query);
        } catch (InvalidArgumentException $e) {
            return new Response($e->getMessage(), 500);
        }

        return $response;
    }
151567
private void sendSolutionActions(String action, String reqId){
        if(reqId!=null && !reqId.equals("")) {
            Map<String, String> map = Maps.newHashMap();
            map.put("action", action);
            map.put("reqid", reqId);
            this.sendEvent(map);
        }
    }
286130
public function socialCallback(Request $request, $serviceName)
    {
        try {
            $this->setDynamicRedirectUrl($serviceName);
            $user = $this->socialite->driver($serviceName)->user();
            $this->authService->login($serviceName, $user);
            return redirect(session('url.intended', '/'));
        } catch (\Exception $e) {
            Log::error('Social login failed: ' . $e->getMessage() . ' - ' . print_r($request->all(), true));
            if (session()->has('url.intended')) { // If redirect url exists show translated error to the user
                $reditectUrl = session('url.intended');
                session()->forget('url.intended'); // remove intended url
                // Set flash message
                session()->flash(
                    'messages',
                    [
                        [
                            'code' => 'error',
                            'text' => $e->getMessage()
                        ]
                    ]
                );
                return redirect($reditectUrl);
            } else {
                return app()->abort(500, $e->getMessage());
            }
        }
    }
353253
public function sendRequest($action, $data)
    {
        if (!$this->connected) {
            $this->connect();
        }
        try {
            $result = $this->client->__soapCall($action, $data);
        } catch (SoapFault $fault) {
            $this->handleError($fault->faultstring);
        }

        return $result;
    }
1238048
protected function RedirectAfterEvent($iRequestRedirectNodeId)
    {
        if (is_null($iRequestRedirectNodeId)) {
            $this->RedirectToCallingPage();
        } else {
            $checkoutSystemPage = $this->getSystemPageService()->getSystemPage('checkout');
            if (null !== $checkoutSystemPage && $checkoutSystemPage->fieldCmsTreeId == $iRequestRedirectNodeId) {
                $this->JumpToBasketPage();
            } else {
                $oNode = new TdbCmsTree();
                if ($oNode->Load($iRequestRedirectNodeId)) {
                    $url = $this->getTreeService()->getLinkToPageForTreeRelative($oNode);
                    $this->getRedirect()->redirect($url);
                } else {
                    $this->RedirectToCallingPage();
                }
            }
        }
    }