/**
  * Stores the credentials for re-use.
  *
  * @param array $credential_sets (Required) The named credential sets that should be made available to the application.
  * @return void
  */
 public static function set(array $credential_sets)
 {
     // Make sure a default credential set is specified or can be inferred
     if (count($credential_sets) === 1) {
         $credential_sets[self::DEFAULT_KEY] = reset($credential_sets);
     } elseif (!isset($credential_sets[self::DEFAULT_KEY])) {
         throw new CFCredentials_Exception('If more than one credential set is provided, a default credential set (identified by the key "' . self::DEFAULT_KEY . '") must be specified.');
     }
     // Resolve any @inherit tags
     foreach ($credential_sets as $credential_name => &$credential_set) {
         if (is_array($credential_set)) {
             foreach ($credential_set as $credential_key => &$credential_value) {
                 if ($credential_key === self::INHERIT_KEY) {
                     if (!isset($credential_sets[$credential_value])) {
                         throw new CFCredentials_Exception('The credential set, "' . $credential_value . '", does not exist and cannot be inherited.');
                     }
                     $credential_set = array_merge($credential_sets[$credential_value], $credential_set);
                     unset($credential_set[self::INHERIT_KEY]);
                 }
             }
         }
     }
     // Normalize the value of the @default credential set
     $default = $credential_sets[self::DEFAULT_KEY];
     if (is_string($default)) {
         if (!isset($credential_sets[$default])) {
             throw new CFCredentials_Exception('The credential set, "' . $default . '", does not exist and cannot be used as the default credential set.');
         }
         $credential_sets[self::DEFAULT_KEY] = $credential_sets[$default];
     }
     // Store the credentials
     self::$credentials = $credential_sets;
 }
 /**
  * @see sfPluginConfiguration
  */
 public function initialize()
 {
     // Include the Altumo loader.
     //require_once( dirname(__FILE__) . '/../lib/vendor/altumo/source/php/loader.php' );
     //set default timezone
     date_default_timezone_set('America/Los_Angeles');
     //symfony 2 autoloader (for classes with namespaces only)
     $altumo_php_source_path = __DIR__ . '/../lib/vendor/altumo/source/php';
     require_once $altumo_php_source_path . '/Utils/UniversalClassLoader.php';
     $loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
     $loader->registerNamespaces(array('sfAltumoPlugin' => __DIR__ . '/../lib', 'Altumo' => $altumo_php_source_path));
     $loader->register();
     // Add altumo paths to sfConfig
     sfConfig::set('altumo_plugin_dir', realpath(dirname(__FILE__) . '/../'));
     sfConfig::set('altumo_javascript_lib_dir', sfConfig::get('altumo_plugin_dir') . '/lib/vendor/altumo/lib/javascript');
     sfConfig::set('altumo_javascript_src_dir', sfConfig::get('altumo_plugin_dir') . '/lib/vendor/altumo/source/javascript');
     /**
      * If the AWS module is enabled, set credentials for sdk
      * 
      * To enable, add a section to settings.yml, like so:
      *   sfAltumoPlugin:
      *      aws:
      *        enable: true
      *        key: "MY_AWS_KE_HERE"
      *        secret: "MY_AWS_SECRET_HERE" 
      */
     $aws_configuration = sfConfig::get('sf_sfAltumoPlugin_aws', array('enable' => false));
     if ($aws_configuration['enable']) {
         CFCredentials::set(array('default' => array('key' => $aws_configuration['key'], 'secret' => $aws_configuration['secret'], 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'default'));
     }
     // Add altumo Api Settings (Add this in your api app's config)
     //sfConfig::set( 'altumo_api_session_cookie_name',  'api_session' );
     /**
      * Execute any commands that the plugin needs when the framework loads, but
      * before an action is executed.
      * 
      * Note: this is here because it was used before to load JS and CSS, but
      * that was relocated to Frontend\Controller
      */
     /*
     $this->dispatcher->connect(
         'context.load_factories', 
         function(){
             
             // this code gets execute when the framework loads.
             
         }
     );
     */
 }
Beispiel #3
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAIKVHFXPE7FYFMTBA', 'secret' => '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', 'default_cache_config' => '..\\cache', 'certificate_authority' => true), '@default' => 'development'));
date_default_timezone_set('America/New_York');
 /**
  * The constructor. This class should not be instantiated directly. Rather, a service-specific class
  * should be instantiated.
  *
  * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
  * 	<li><code>certificate_authority</code> - <code>boolean</code> - Optional - Determines which Cerificate Authority file to use. A value of boolean <code>false</code> will use the Certificate Authority file available on the system. A value of boolean <code>true</code> will use the Certificate Authority provided by the SDK. Passing a file system path to a Certificate Authority file (chmodded to <code>0755</code>) will use that. Leave this set to <code>false</code> if you're not sure.</li>
  * 	<li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
  * 	<li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
  * 	<li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
  * 	<li><code>instance_profile_timeout</code> - <code>integer</code> - Optional - When retrieving IAM instance profile credentials, there is a hard connection timeout that defaults to 2 seconds to prevent unnecessary on non-EC2 systems. This setting allows you to change that timeout if needed.</li>
  * 	<li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
  * 	<li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li>
  * 	<li><code>use_instance_profile_credentials</code> - <code>boolean</code> - Optional - Forces the use of IAM Instance Profile credentials, even when regular credentials are provided.</li></ul>
  * @return void
  */
 public function __construct(array $options = array())
 {
     // Instantiate the utilities class.
     $this->util = new $this->utilities_class();
     // Determine the current service.
     $this->service = get_class($this);
     // Create credentials based on the options
     $runtime_credentials = new CFCredential($options);
     $credentials_provided = false;
     // Retrieve a credential set from config.inc.php if it exists
     if (isset($options['credentials'])) {
         // Use a specific credential set and merge with the runtime credentials
         $this->credentials = CFCredentials::get($options['credentials'])->merge($runtime_credentials);
     } else {
         try {
             // Use the default credential set and merge with the runtime credentials
             $this->credentials = CFCredentials::get(CFCredentials::DEFAULT_KEY)->merge($runtime_credentials);
         } catch (CFCredentials_Exception $e) {
             // Only the runtime credentials were provided
             $this->credentials = $runtime_credentials;
         }
     }
     // Check if keys were actually provided
     if (isset($this->credentials['key']) && isset($this->credentials['secret'])) {
         $credentials_provided = true;
     }
     // Check for an instance profile credentials override
     if (isset($this->credentials['use_instance_profile_credentials']) && $this->credentials['use_instance_profile_credentials']) {
         $credentials_provided = false;
     }
     // Automatically enable whichever caching mechanism is set to default.
     $this->set_cache_config($this->credentials->default_cache_config);
     // If no credentials were provided, try to get them from the EC2 instance profile
     if (!$credentials_provided) {
         // Default caching mechanism is required
         if (!$this->credentials->default_cache_config) {
             // @codeCoverageIgnoreStart
             throw new CFCredentials_Exception('No credentials were provided. The SDK attempts to retrieve Instance ' . 'Profile credentials from the EC2 Instance Metadata Service, but doing this requires the ' . '"default_cache_config" option to be set in the config.inc.php file or constructor. In order to ' . 'cache the retrieved credentials.');
             // @codeCoverageIgnoreEnd
         }
         // Instantiate and invoke the cache for instance profile credentials
         $cache = new $this->cache_class('instance_profile_credentials', $this->cache_location, 0, $this->cache_compress);
         if ($data = $cache->read()) {
             $cache->expire_in((strtotime($data['expires']) - time()) * 0.85);
         }
         $instance_profile_credentials = $cache->response_manager(array($this, 'cache_instance_profile_credentials'), array($cache, $options));
         $this->credentials->key = $instance_profile_credentials['key'];
         $this->credentials->secret = $instance_profile_credentials['secret'];
         $this->credentials->token = $instance_profile_credentials['token'];
     }
     // Set internal credentials after they are resolved
     $this->key = $this->credentials->key;
     $this->secret_key = $this->credentials->secret;
     $this->auth_token = $this->credentials->token;
 }
Beispiel #5
0
 /**
  * The constructor. This class should not be instantiated directly. Rather, a service-specific class
  * should be instantiated.
  *
  * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
  * 	<li><code>certificate_authority</code> - <code>boolean</code> - Optional - Determines which Cerificate Authority file to use. A value of boolean <code>false</code> will use the Certificate Authority file available on the system. A value of boolean <code>true</code> will use the Certificate Authority provided by the SDK. Passing a file system path to a Certificate Authority file (chmodded to <code>0755</code>) will use that. Leave this set to <code>false</code> if you're not sure.</li>
  * 	<li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
  * 	<li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
  * 	<li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
  * 	<li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
  * 	<li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
  * @return void
  */
 public function __construct(array $options = array())
 {
     // Instantiate the utilities class.
     $this->util = new $this->utilities_class();
     // Determine the current service.
     $this->service = get_class($this);
     // Create credentials based on the options
     $instance_credentials = new CFCredential($options);
     // Retreive a credential set from config.inc.php if it exists
     if (isset($options['credentials'])) {
         // Use a specific credential set and merge with the instance credentials
         $this->credentials = CFCredentials::get($options['credentials'])->merge($instance_credentials);
     } else {
         try {
             // Use the default credential set and merge with the instance credentials
             $this->credentials = CFCredentials::get(CFCredentials::DEFAULT_KEY)->merge($instance_credentials);
         } catch (CFCredentials_Exception $e) {
             if (isset($options['key']) && isset($options['secret'])) {
                 // Only the instance credentials were provided
                 $this->credentials = $instance_credentials;
             } else {
                 // No credentials provided in the config file or constructor
                 throw new CFCredentials_Exception('No credentials were provided to ' . $this->service . '.');
             }
         }
     }
     // Set internal credentials after they are resolved
     $this->key = $this->credentials->key;
     $this->secret_key = $this->credentials->secret;
     $this->auth_token = $this->credentials->token;
     // Automatically enable whichever caching mechanism is set to default.
     $this->set_cache_config($this->credentials->default_cache_config);
 }
Beispiel #6
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => WH_AWS_PAGEDATA_ACCESS_KEY, 'secret' => WH_AWS_PAGEDATA_SECRET_KEY, 'default_cache_config' => 'apc', 'certificate_authority' => true), '@default' => 'development'));
Beispiel #7
0
 /**
  * Gets CloudFront object
  *
  * @param  array     $options connection options
  * @return \AmazonCF CloudFront object
  */
 private function _cf($options = array())
 {
     if (empty($this->_cf) || !empty($options)) {
         // This is workaround to composer autoloader
         if (!class_exists('CFLoader')) {
             throw new ClassNotFoundException('CloudFront: autoload failed');
         }
         $key = !empty($options['key']) ? $options['key'] : $this->getOption('key');
         $secret = !empty($options['secret']) ? $options['secret'] : $this->getOption('secret');
         \CFCredentials::set(array('@default' => array('key' => $key, 'secret' => $secret)));
         $this->_cf = new \AmazonCloudFront();
         $this->_cf->use_ssl = false;
     }
     return $this->_cf;
 }
Beispiel #8
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAJDRQ5N4HYEUWQZRA', 'secret' => 'eiZV6ZhwN2ZcAeP/f0EgnlFvYn6+TKFaQVE/mWY5', 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'development'));
Beispiel #9
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAIXI5YSN6JJRSPGSQ', 'secret' => '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', 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'development'));
Beispiel #10
0
 private static function s3_connect()
 {
     CFCredentials::set(array('development' => array('key' => self::$api_key, 'secret' => self::$secret_key, 'default_cache_config' => 'apc', 'certificate_authority' => false), '@default' => 'development'));
     $s3 = new AmazonS3();
     return $s3;
 }
Beispiel #11
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAJQHBMP5GWSPCC5BA', 'secret' => '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', 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'development'));
 /**
  * The constructor. This class should not be instantiated directly. Rather, a service-specific class
  * should be instantiated.
  *
  * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
  * 	<li><code>certificate_authority</code> - <code>boolean</code> - Optional - Determines which Cerificate Authority file to use. A value of boolean <code>false</code> will use the Certificate Authority file available on the system. A value of boolean <code>true</code> will use the Certificate Authority provided by the SDK. Passing a file system path to a Certificate Authority file (chmodded to <code>0755</code>) will use that. Leave this set to <code>false</code> if you're not sure.</li>
  * 	<li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
  * 	<li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
  * 	<li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
  * 	<li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
  * 	<li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
  * @return void
  */
 public function __construct(array $options = array())
 {
     // Instantiate the utilities class.
     $this->util = new $this->utilities_class();
     // Determine the current service.
     $this->service = get_class($this);
     // Store the requested credentials
     $this->credentials = CFCredentials::get(isset($options['credentials']) ? $options['credentials'] : CFCredentials::DEFAULT_KEY);
     $this->credentials = new CFCredential(array_merge($this->credentials->to_array(), $options));
     // Automatically enable whichever caching mechanism is set to default.
     $this->set_cache_config($this->credentials->default_cache_config);
     if (isset($options['key']) && isset($options['secret'])) {
         $this->key = $options['key'];
         $this->secret_key = $options['secret'];
         $this->auth_token = isset($options['token']) ? $options['token'] : null;
         return;
     } else {
         $this->key = $this->credentials->key;
         $this->secret_key = $this->credentials->secret;
         $this->auth_token = $this->credentials->token;
         return;
     }
 }
 /**
  * @return \AmazonS3
  */
 protected function initializeS3()
 {
     $extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cicbase');
     require_once $extensionPath . 'Vendor/awssdk/sdk.class.php';
     \CFCredentials::set(array('production' => array('key' => $this->cicbaseConfiguration['AWSKey'], 'secret' => $this->cicbaseConfiguration['AWSSecret'], 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'production'));
     $s3 = new \AmazonS3();
     return $s3;
 }
 function remove_amazons3_backup_bwd_comp($args)
 {
     if ($this->iwp_mmb_function_exists('curl_init')) {
         require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/amazon_s3_bwd_comp/sdk.class.php';
         extract($args);
         if (!is_array($backup_file)) {
             $temp_backup_file = $backup_file;
             $backup_file = array();
             $backup_file[] = $temp_backup_file;
         }
         if ($as3_site_folder == true) {
             if (!empty($as3_directory)) {
                 $as3_directory .= '/' . $this->site_name;
             } else {
                 $as3_directory = $this->site_name;
             }
         }
         try {
             CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'development'));
             $s3 = new AmazonS3();
             foreach ($backup_file as $single_backup_file) {
                 if (empty($as3_directory)) {
                     $single_as3_file = $single_backup_file;
                 } else {
                     $single_as3_file = $as3_directory . '/' . $single_backup_file;
                 }
                 $s3->delete_object($as3_bucket, $single_as3_file);
             }
         } catch (Exception $e) {
         }
     }
 }
Beispiel #15
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAIATBDDDFRGLWQTBQ', 'secret' => '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', 'default_cache_config' => dirname(BASEPATH) . '/system/cache', 'certificate_authority' => false), '@default' => 'development'));
Beispiel #16
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'development-key', 'secret' => 'development-secret', 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'development'));
 /**
  * Constructor
  *
  * @param array $parameters An array of configuration options
  */
 public function __construct(array $parameters)
 {
     $this->parameters = $parameters;
     \CFCredentials::set(array('runtime' => $parameters, '@default' => 'runtime'));
 }
Beispiel #18
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAJK43Z3GIIF3XRIJQ', 'secret' => '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', 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'development'));
 /**
  * Constructs a new instance of <AmazonCloudFront>.
  *
  * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
  * 	<li><code>certificate_authority</code> - <code>boolean</code> - Optional - Determines which Cerificate Authority file to use. A value of boolean <code>false</code> will use the Certificate Authority file available on the system. A value of boolean <code>true</code> will use the Certificate Authority provided by the SDK. Passing a file system path to a Certificate Authority file (chmodded to <code>0755</code>) will use that. Leave this set to <code>false</code> if you're not sure.</li>
  * 	<li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
  * 	<li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
  * 	<li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
  * 	<li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
  * 	<li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
  * @return void
  */
 public function __construct(array $options = array())
 {
     $this->api_version = '2010-11-01';
     $this->hostname = self::DEFAULT_URL;
     $this->auth_class = 'AuthV2REST';
     $this->base_xml = '<?xml version="1.0" encoding="UTF-8"?><%s xmlns="http://cloudfront.amazonaws.com/doc/' . $this->api_version . '/"></%1$s>';
     // Set a default key pair ID and private key
     if (isset($options['credentials'])) {
         $this->key_pair_id = CFCredentials::get($options['credentials'])->cloudfront_keypair;
         $this->private_key = CFCredentials::get($options['credentials'])->cloudfront_pem;
     } else {
         $this->key_pair_id = CFCredentials::get()->cloudfront_keypair;
         $this->private_key = CFCredentials::get()->cloudfront_pem;
     }
     return parent::__construct($options);
 }
Beispiel #20
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAJMD23UOQ6JVJT44A', 'secret' => 'GSEmaSrz2Kg6R5T72jfrXBJSK0bysCVpDs1YbWOj', 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'development'));
Beispiel #21
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'MYKEY', 'secret' => 'MYSECRET', 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'development'));
Beispiel #22
0
 /**
  * Gets s3 object
  *
  * @param  boolean   $debug return error message instead of script stop
  * @return \AmazonS3 s3 object
  */
 public function s3($debug = false)
 {
     // This is workaround to composer autoloader
     if (!class_exists('CFLoader')) {
         throw new ClassNotFoundException('Amazon: autoload failed');
     }
     if (empty($this->_s3)) {
         \CFCredentials::set(array('@default' => array('key' => $this->getOption('key'), 'secret' => $this->getOption('secret'))));
         $this->_s3 = new \AmazonS3();
         $this->_s3->use_ssl = false;
         $this->_buckets = fn_array_combine($this->_s3->get_bucket_list(), true);
     }
     $message = '';
     $bucket = $this->getOption('bucket');
     if (empty($this->_buckets[$bucket])) {
         $res = $this->_s3->create_bucket($bucket, $this->getOption('region'));
         if ($res->isOK()) {
             $res = $this->_s3->create_cors_config($bucket, array('cors_rule' => array(array('allowed_origin' => '*', 'allowed_method' => 'GET'))));
             if ($res->isOK()) {
                 $this->_buckets[$bucket] = true;
             } else {
                 $message = (string) $res->body->Message;
             }
         } else {
             $message = (string) $res->body->Message;
         }
     }
     if (!empty($message)) {
         if ($debug == true) {
             return $message;
         }
         throw new ExternalException('Amazon: ' . $message);
     }
     return $this->_s3;
 }
<?php

require_once 'Plans.php';
require_once 'lib/aws/sdk.class.php';
if (defined('AWS_KEY')) {
    CFCredentials::set(array('default' => array('key' => AWS_KEY, 'secret' => AWS_SECRET_KEY)));
}
function send_mail($to, $subject, $text, $from = MAILER_ADDRESS, $reply_to = ADMIN_ADDRESS)
{
    if (USE_NATIVE_MAIL) {
        if (is_array($to)) {
            $to = implode(', ', $to);
        }
        return mail($to, $subject, $text, "From:{$from}\nReply-to:{$reply_to}");
    } else {
        $message = array('Subject' => array('Data' => $subject), 'Body' => array('Text' => array('Data' => $text)));
        $opt = array('ReplyToAddresses' => $reply_to);
        if (!is_array($to)) {
            $to = array($to);
        }
        $ses = new AmazonSES();
        $ret = $ses->send_email($from, array('ToAddresses' => $to), $message, $opt);
        return $ret->isOK();
    }
}
     try {
         CFCredentials::set(array('backwpup' => array('key' => $_POST['awsAccessKey'], 'secret' => $_POST['awsSecretKey'], 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'backwpup'));
         $s3 = new AmazonS3();
         $s3->create_bucket($_POST['newawsBucket'], $_POST['awsRegion']);
         $jobvalues['awsBucket'] = $_POST['newawsBucket'];
     } catch (Exception $e) {
         $backwpup_message .= __($e->getMessage(), 'backwpup') . '<br />';
     }
 }
 if (!empty($_POST['GStorageAccessKey']) and !empty($_POST['GStorageSecret']) and !empty($_POST['newGStorageBucket'])) {
     //create new google storage bucket if needed
     if (!class_exists('CFRuntime')) {
         require_once dirname(__FILE__) . '/../libs/aws/sdk.class.php';
     }
     try {
         CFCredentials::set(array('backwpup' => array('key' => $_POST['GStorageAccessKey'], 'secret' => $_POST['GStorageSecret'], 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'backwpup'));
         $gstorage = new AmazonS3();
         $gstorage->set_hostname('storage.googleapis.com');
         $gstorage->allow_hostname_override(false);
         $gstorage->create_bucket($_POST['newGStorageBucket'], '');
         $jobvalues['GStorageBucket'] = $_POST['newGStorageBucket'];
         sleep(1);
         //creation take a moment
     } catch (Exception $e) {
         $backwpup_message .= __($e->getMessage(), 'backwpup') . '<br />';
     }
 }
 if (!empty($_POST['newmsazureContainer']) and !empty($_POST['msazureHost']) and !empty($_POST['msazureAccName']) and !empty($_POST['msazureKey'])) {
     //create new s3 bucket if needed
     if (!class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
         require_once dirname(__FILE__) . '/../libs/Microsoft/WindowsAzure/Storage/Blob.php';
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'development-key', 'secret' => 'development-secret', 'default_cache_config' => $_SERVER['DOCUMENT_ROOT'] . '/cache/', 'certificate_authority' => false), '@default' => 'development'));
 function get_amazons3_backup_bwd_comp($args)
 {
     if ($this->iwp_mmb_function_exists('curl_init')) {
         require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/amazon_s3_bwd_comp/sdk.class.php';
         extract($args);
         $temp = '';
         try {
             CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'development'));
             $s3 = new AmazonS3();
             if ($as3_site_folder == true) {
                 if (!empty($as3_directory)) {
                     $as3_directory .= '/' . $this->site_name;
                 } else {
                     $as3_directory = $this->site_name;
                 }
             }
             if (empty($as3_directory)) {
                 $single_as3_file = $backup_file;
             } else {
                 $single_as3_file = $as3_directory . '/' . $backup_file;
             }
             //$temp = ABSPATH . 'iwp_temp_backup.zip';
             $temp = wp_tempnam('iwp_temp_backup.zip');
             $s3->get_object($as3_bucket, $single_as3_file, array("fileDownload" => $temp));
         } catch (Exception $e) {
             return false;
         }
         return $temp;
     } else {
         return array('error' => 1);
     }
 }
 /**
  * Recieves all configuration values and sets up this instance
  *
  * All configuration should be handled here
  *
  * @param array $config
  */
 protected function configure($config)
 {
     // Configurable instance variables (if not set, use the instance default)
     $this->debug = isset($config['enable-debug-mode']) ? $config['enable-debug-mode'] : $this->debug;
     $this->folderIcon = $config['icons']['path'] . $config['icons']['directory'];
     $this->bucket = isset($config['s3-bucket']) ? $config['s3-bucket'] : $this->bucket;
     $this->rootDirectory = isset($config['doc_root']) ? trim($config['doc_root'], '/ ') : $this->rootDirectory;
     $this->createRootDir = isset($config['create-root-dir']) ? $config['create-root-dir'] : $this->createRootDir;
     $this->domain = isset($config['s3-public-domain']) ? $config['s3-public-domain'] : $this->domain;
     $this->cacheScheme = isset($config['aws-cache-scheme']) ? $config['aws-cache-scheme'] : $this->cacheScheme;
     $this->cacheExpire = isset($config['aws-cache-expirein']) ? $config['aws-cache-expirein'] : $this->cacheExpire;
     $this->uploadMaxMb = isset($config['upload']['size']) ? (int) $config['upload']['size'] : $this->uploadMaxMb;
     // if we are in debug mode, auto-expire cache
     $this->cacheExpire = $this->debug ? self::DEFAULT_CACHE_EXPIRE : $this->cacheExpire;
     // set global static credentials
     CFCredentials::set(array('@default' => array('key' => $config['aws-access-key'], 'secret' => $config['aws-secret-key'], 'default_cache_config' => $this->cacheScheme, 'certificate_authority' => false)));
     // Instantiate the AmazonS3 class (we should probably be injecting this)
     $this->s3 = new AmazonS3();
     // if we are in debug mode put the http-client into debug mode
     $this->s3->enable_debug_mode($this->debug);
 }
Beispiel #28
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'PUT_YOURS_HERE', 'secret' => 'PUT_YOURS_HERE', 'default_cache_config' => '', 'certificate_authority' => false), '@default' => 'development'));
Beispiel #29
0
	Some example uses are noted at https://gist.github.com/1478912

	Notes:

	* You can define one or more credential sets.

	* Credential sets can be named anything that PHP allows for an associative array key;
	  "production", "staging", etc., are just sample values. Feel free to rename them.

	* A credential set only has four required entries: key, secret, default_cache_config and
	  certificate_authority. Aside from these, you can add any additional bits of information
	  you'd like to keep easily accessible (e.g., multi-factor authentication device key, your
	  AWS Account ID, your canonical identifiers).

	* Additional credential sets can inherit the properties of another credential set using the
	  @inherit keyword.

	* If more than one credential set is provided, a default credential set must be specified
	  using the @default keyword.

	* If you only have one credential set, you can set it to the @default keyword.

	* View the documentation for the CFCredentials::set() method to view usage examples.

###################################################################################################*/
/**
 * Create a list of credential sets that can be used with the SDK.
 */
CFCredentials::set(array('development' => array('key' => 'AKIAIFJIYCMOKM2UFDAA', 'secret' => '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', 'default_cache_config' => '/home/saasbook/CC/cache/', 'certificate_authority' => false), '@default' => 'development'));