/** * Constructs a new instance of <AmazonEC2>. If the <code>AWS_DEFAULT_CACHE_CONFIG</code> configuration * option is set, requests will be authenticated using a session token. Otherwise, requests will use * the older authentication method. * * @param string $key (Optional) Your AWS key, or a session key. If blank, it will look for the <code>AWS_KEY</code> constant. * @param string $secret_key (Optional) Your AWS secret key, or a session secret key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant. * @param string $token (optional) An AWS session token. If blank, a request will be made to the AWS Secure Token Service to fetch a set of session credentials. * @return boolean A value of <code>false</code> if no valid values are set, otherwise <code>true</code>. */ public function __construct($key = null, $secret_key = null, $token = null) { $this->api_version = '2011-02-28'; $this->hostname = self::DEFAULT_URL; if (!$key && !defined('AWS_KEY')) { // @codeCoverageIgnoreStart throw new EC2_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.'); // @codeCoverageIgnoreEnd } if (!$secret_key && !defined('AWS_SECRET_KEY')) { // @codeCoverageIgnoreStart throw new EC2_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.'); // @codeCoverageIgnoreEnd } if (defined('AWS_DEFAULT_CACHE_CONFIG') && AWS_DEFAULT_CACHE_CONFIG) { return parent::session_based_auth($key, $secret_key, $token); } return parent::__construct($key, $secret_key); }
/** * Constructs a new instance of <AmazonS3>. If the <code>AWS_DEFAULT_CACHE_CONFIG</code> configuration * option is set, requests will be authenticated using a session token. Otherwise, requests will use * the older authentication method. * * @param string $key (Optional) Your AWS key, or a session key. If blank, it will look for the <code>AWS_KEY</code> constant. * @param string $secret_key (Optional) Your AWS secret key, or a session secret key. If blank, it will look for the <code>AWS_SECRET_KEY</code> constant. * @param string $token (optional) An AWS session token. If blank, a request will be made to the AWS Secure Token Service to fetch a set of session credentials. * @return boolean A value of <code>false</code> if no valid values are set, otherwise <code>true</code>. */ public function __construct($key = null, $secret_key = null, $token = null) { $this->vhost = null; $this->api_version = '2006-03-01'; $this->hostname = self::DEFAULT_URL; $this->base_acp_xml = '<?xml version="1.0" encoding="UTF-8"?><AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/latest/"></AccessControlPolicy>'; $this->base_location_constraint = '<?xml version="1.0" encoding="UTF-8"?><CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/' . $this->api_version . '/"><LocationConstraint></LocationConstraint></CreateBucketConfiguration>'; $this->base_logging_xml = '<?xml version="1.0" encoding="utf-8"?><BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/' . $this->api_version . '"></BucketLoggingStatus>'; $this->base_notification_xml = '<?xml version="1.0" encoding="utf-8"?><NotificationConfiguration></NotificationConfiguration>'; $this->base_versioning_xml = '<?xml version="1.0" encoding="utf-8"?><VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/' . $this->api_version . '/"></VersioningConfiguration>'; $this->complete_mpu_xml = '<?xml version="1.0" encoding="utf-8"?><CompleteMultipartUpload></CompleteMultipartUpload>'; $this->website_config_xml = '<?xml version="1.0" encoding="utf-8"?><WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/' . $this->api_version . '/"><IndexDocument><Suffix>index.html</Suffix></IndexDocument><ErrorDocument><Key>error.html</Key></ErrorDocument></WebsiteConfiguration>'; if (!$key && !defined('AWS_KEY')) { // @codeCoverageIgnoreStart throw new S3_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.'); // @codeCoverageIgnoreEnd } if (!$secret_key && !defined('AWS_SECRET_KEY')) { // @codeCoverageIgnoreStart throw new S3_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.'); // @codeCoverageIgnoreEnd } if (defined('AWS_DEFAULT_CACHE_CONFIG') && AWS_DEFAULT_CACHE_CONFIG) { return parent::session_based_auth($key, $secret_key, $token); } return parent::__construct($key, $secret_key); }