Exemplo n.º 1
0
 /**
  * Method to instantiate the file-based api call.
  *
  * @param   mixed  $options  Optional custom options to load. JRegistry or array format
  *
  * @throws Exception
  * @since   1.4
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     JPluginHelper::importPlugin('redcore');
     $this->webservice = new RApiHalHal($options);
     $this->webservice->authorizationCheck = 'joomla';
     // Init Environment
     $this->triggerFunction('setApiOperation');
     // Set initial status code
     $this->setStatusCode($this->statusCode);
 }
Exemplo n.º 2
0
 /**
  * Method to instantiate the file-based api call.
  *
  * @param   mixed  $options  Optional custom options to load. JRegistry or array format
  *
  * @throws Exception
  * @since   1.5
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     JPluginHelper::importPlugin('redcore');
     JPluginHelper::importPlugin('redpayment');
     // Init Environment
     $this->triggerFunction('setApiOperation');
     $dataGet = $this->options->get('dataGet', array());
     $this->paymentName = isset($dataGet->payment_name) ? $dataGet->payment_name : null;
     $this->extensionName = isset($dataGet->extension_name) ? $dataGet->extension_name : null;
     $this->ownerName = isset($dataGet->owner_name) ? $dataGet->owner_name : null;
     $this->orderId = isset($dataGet->order_id) ? $dataGet->order_id : null;
     $this->paymentId = isset($dataGet->payment_id) ? (int) $dataGet->payment_id : 0;
     // Set initial status code
     $this->setStatusCode($this->statusCode);
     $this->requestData = $this->options->get('data', array());
     if (is_object($this->requestData)) {
         $this->requestData = JArrayHelper::fromObject($this->requestData);
     }
 }
Exemplo n.º 3
0
 /**
  * Method to instantiate the file-based api call.
  *
  * @param   mixed  $options  Optional custom options to load. JRegistry or array format
  *
  * @since   1.2
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     // Get the global JAuthentication object.
     jimport('joomla.user.authentication');
     // Register OAuth2 classes
     require_once dirname(__FILE__) . '/Autoloader.php';
     OAuth2\Autoloader::register();
     // OAuth2 Server config from plugin
     $this->serverConfig = array('use_jwt_access_tokens' => (bool) RBootstrap::getConfig('oauth2_use_jwt_access_tokens', false), 'store_encrypted_token_string' => (bool) RBootstrap::getConfig('oauth2_store_encrypted_token_string', true), 'use_openid_connect' => (bool) RBootstrap::getConfig('oauth2_use_openid_connect', false), 'id_lifetime' => RBootstrap::getConfig('oauth2_id_lifetime', 3600), 'access_lifetime' => RBootstrap::getConfig('oauth2_access_lifetime', 3600), 'www_realm' => 'Service', 'token_param_name' => RBootstrap::getConfig('oauth2_token_param_name', 'access_token'), 'token_bearer_header_name' => RBootstrap::getConfig('oauth2_token_bearer_header_name', 'Bearer'), 'enforce_state' => (bool) RBootstrap::getConfig('oauth2_enforce_state', true), 'require_exact_redirect_uri' => (bool) RBootstrap::getConfig('oauth2_require_exact_redirect_uri', true), 'allow_implicit' => (bool) RBootstrap::getConfig('oauth2_allow_implicit', false), 'allow_credentials_in_request_body' => (bool) RBootstrap::getConfig('oauth2_allow_credentials_in_request_body', true), 'allow_public_clients' => (bool) RBootstrap::getConfig('oauth2_allow_public_clients', true), 'always_issue_new_refresh_token' => (bool) RBootstrap::getConfig('oauth2_always_issue_new_refresh_token', false));
     // Set database names to Redcore DB tables
     $prefix = JFactory::getDbo()->getPrefix();
     $databaseConfig = array('client_table' => $prefix . 'redcore_oauth_clients', 'access_token_table' => $prefix . 'redcore_oauth_access_tokens', 'refresh_token_table' => $prefix . 'redcore_oauth_refresh_tokens', 'code_table' => $prefix . 'redcore_oauth_authorization_codes', 'user_table' => $prefix . 'redcore_oauth_users', 'jwt_table' => $prefix . 'redcore_oauth_jwt', 'jti_table' => $prefix . 'redcore_oauth_jti', 'scope_table' => $prefix . 'redcore_oauth_scopes', 'public_key_table' => $prefix . 'redcore_oauth_public_keys');
     $conf = JFactory::getConfig();
     $dsn = 'mysql:dbname=' . $conf->get('db') . ';host=' . $conf->get('host');
     $username = $conf->get('user');
     $password = $conf->get('password');
     $storage = new OAuth2\Storage\Pdoredcore(array('dsn' => $dsn, 'username' => $username, 'password' => $password), $databaseConfig);
     $this->server = new OAuth2\Server($storage, $this->serverConfig);
     // Add the "Authorization Code" grant type (this is where the oauth magic happens)
     $this->server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage, $this->serverConfig));
     // Add the "Client Credentials" grant type (it is the simplest of the grant types)
     $this->server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage, $this->serverConfig));
     // Add the "User Credentials" grant type (this is modified to suit Joomla authorization)
     $this->server->addGrantType(new OAuth2\GrantType\UserCredentials($storage, $this->serverConfig));
     // Add the "Refresh Token" grant type (this is great for extending expiration time on tokens)
     $this->server->addGrantType(new OAuth2\GrantType\RefreshToken($storage, $this->serverConfig));
     /*
      * @todo Implement JwtBearer Grant type with public_key
     // Typically, the URI of the oauth server
     $audience = rtrim(JUri::base(), '/');
     
     // Add the "Refresh Token" grant type (this is great for extending expiration time on tokens)
     $this->server->addGrantType(new OAuth2\GrantType\JwtBearer($storage, $audience));
     */
     // Init Environment
     $this->setApiOperation();
 }
Exemplo n.º 4
0
 /**
  * Method to instantiate the file-based api call.
  *
  * @param   mixed  $options  Optional custom options to load. JRegistry or array format
  *
  * @throws Exception
  * @since   1.2
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     JPluginHelper::importPlugin('redcore');
     $this->setWebserviceName();
     $this->client = $this->options->get('webserviceClient', 'site');
     $this->webserviceVersion = $this->options->get('webserviceVersion', '');
     $this->hal = new RApiHalDocumentResource('');
     if (!empty($this->webserviceName)) {
         if (empty($this->webserviceVersion)) {
             $this->webserviceVersion = RApiHalHelper::getNewestWebserviceVersion($this->client, $this->webserviceName);
         }
         $this->webservice = RApiHalHelper::getInstalledWebservice($this->client, $this->webserviceName, $this->webserviceVersion);
         if (empty($this->webservice)) {
             throw new Exception(JText::sprintf('LIB_REDCORE_API_HAL_WEBSERVICE_NOT_INSTALLED', $this->webserviceName, $this->webserviceVersion));
         }
         if (empty($this->webservice['state'])) {
             throw new Exception(JText::sprintf('LIB_REDCORE_API_HAL_WEBSERVICE_UNPUBLISHED', $this->webserviceName, $this->webserviceVersion));
         }
         $this->webservicePath = $this->webservice['path'];
         $this->configuration = RApiHalHelper::loadWebserviceConfiguration($this->webserviceName, $this->webserviceVersion, 'xml', $this->webservicePath, $this->client);
         // Set option and view name
         $this->setOptionViewName($this->webserviceName, $this->configuration);
         // Set base data
         $this->setBaseDataValues();
     }
     // Init Environment
     $this->triggerFunction('setApiOperation');
     // Set initial status code
     $this->setStatusCode($this->statusCode);
     // Check for defined constants
     if (!defined('JSON_UNESCAPED_SLASHES')) {
         define('JSON_UNESCAPED_SLASHES', 64);
     }
     // OAuth2 check
     if (RBootstrap::getConfig('webservices_authorization_check', 0) == 0) {
         $this->authorizationCheck = 'oauth2';
     } elseif (RBootstrap::getConfig('webservices_authorization_check', 0) == 1) {
         $this->authorizationCheck = 'joomla';
     }
 }