forked from Azure/azure-sdk-for-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ogail/dev
Add configuration for service bus using connection strings
- Loading branch information
Showing
25 changed files
with
692 additions
and
495 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
<?php | ||
|
||
/** | ||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* PHP version 5 | ||
* | ||
* @category Microsoft | ||
* @package WindowsAzure\Common\Internal | ||
* @author Azure PHP SDK <azurephpsdk@microsoft.com> | ||
* @copyright 2012 Microsoft Corporation | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://github.com/windowsazure/azure-sdk-for-php | ||
*/ | ||
|
||
namespace WindowsAzure\Common\Internal; | ||
use WindowsAzure\Common\Internal\Resources; | ||
|
||
/** | ||
* Represents the settings used to sign and access a request against the service | ||
* bus. | ||
* | ||
* @category Microsoft | ||
* @package WindowsAzure\Common\Internal | ||
* @author Azure PHP SDK <azurephpsdk@microsoft.com> | ||
* @copyright 2012 Microsoft Corporation | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @version Release: @package_version@ | ||
* @link https://github.com/windowsazure/azure-sdk-for-php | ||
*/ | ||
class ServiceBusSettings extends ServiceSettings | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $_serviceBusEndpointUri; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $_wrapEndpointUri; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $_wrapName; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $_wrapPassword; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $_namespace; | ||
|
||
/** | ||
* Validator for the SharedSecretValue setting. It has to be provided. | ||
* | ||
* @var array | ||
*/ | ||
private static $_wrapPasswordSetting; | ||
|
||
/** | ||
* Validator for the SharedSecretIssuer setting. It has to be provided. | ||
* | ||
* @var array | ||
*/ | ||
private static $_wrapNameSetting; | ||
|
||
/** | ||
* Validator for the Endpoint setting. Must be a valid Uri. | ||
* | ||
* @var array | ||
*/ | ||
private static $_serviceBusEndpointSetting; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected static $isInitialized = false; | ||
|
||
/** | ||
* Holds the expected setting keys. | ||
* | ||
* @var array | ||
*/ | ||
protected static $validSettingKeys = array(); | ||
|
||
/** | ||
* Initializes static members of the class. | ||
* | ||
* @return none | ||
*/ | ||
protected static function init() | ||
{ | ||
self::$_serviceBusEndpointSetting = self::settingWithFunc( | ||
Resources::SERVICE_BUS_ENDPOINT_NAME, | ||
Validate::getIsValidUri() | ||
); | ||
|
||
self::$_wrapNameSetting = self::setting( | ||
Resources::SHARED_SECRET_ISSUER_NAME | ||
); | ||
|
||
self::$_wrapPasswordSetting = self::setting( | ||
Resources::SHARED_SECRET_VALUE_NAME | ||
); | ||
|
||
self::$validSettingKeys[] = Resources::SERVICE_BUS_ENDPOINT_NAME; | ||
self::$validSettingKeys[] = Resources::SHARED_SECRET_ISSUER_NAME; | ||
self::$validSettingKeys[] = Resources::SHARED_SECRET_VALUE_NAME; | ||
} | ||
|
||
/** | ||
* Creates new service bus settings instance. | ||
* | ||
* @param string $serviceBusEndpoint The service bus endpoint uri. | ||
* @param string $namespace The service namespace. | ||
* @param string $wrapName The wrap name. | ||
* @param string $wrapPassword The wrap password. | ||
*/ | ||
public function __construct( | ||
$serviceBusEndpoint, | ||
$namespace, | ||
$wrapName, | ||
$wrapPassword | ||
) { | ||
$this->_namespace = $namespace; | ||
$this->_serviceBusEndpointUri = $serviceBusEndpoint; | ||
$this->_wrapEndpointUri = sprintf( | ||
Resources::WRAP_ENDPOINT_URI_FORMAT, | ||
$namespace | ||
); | ||
$this->_wrapName = $wrapName; | ||
$this->_wrapPassword = $wrapPassword; | ||
} | ||
|
||
/** | ||
* Creates a ServiceBusSettings object from the given connection string. | ||
* | ||
* @param string $connectionString The storage settings connection string. | ||
* | ||
* @return ServiceBusSettings | ||
*/ | ||
public static function createFromConnectionString($connectionString) | ||
{ | ||
$tokenizedSettings = self::parseAndValidateKeys($connectionString); | ||
|
||
$matchedSpecs = self::matchedSpecification( | ||
$tokenizedSettings, | ||
self::allRequired( | ||
self::$_serviceBusEndpointSetting, | ||
self::$_wrapNameSetting, | ||
self::$_wrapPasswordSetting | ||
) | ||
); | ||
if ($matchedSpecs) { | ||
// Parse the namespace part from the URI | ||
$namespace = explode( | ||
'.', | ||
parse_url( | ||
$tokenizedSettings[Resources::SERVICE_BUS_ENDPOINT_NAME], | ||
PHP_URL_HOST | ||
) | ||
); | ||
$namespace = $namespace[0]; | ||
return new ServiceBusSettings( | ||
$tokenizedSettings[Resources::SERVICE_BUS_ENDPOINT_NAME], | ||
$namespace, | ||
$tokenizedSettings[Resources::SHARED_SECRET_ISSUER_NAME], | ||
$tokenizedSettings[Resources::SHARED_SECRET_VALUE_NAME] | ||
); | ||
} | ||
|
||
self::noMatch($connectionString); | ||
} | ||
|
||
/** | ||
* Gets the service bus endpoint uri. | ||
* | ||
* @return string | ||
*/ | ||
public function getServiceBusEndpointUri() | ||
{ | ||
return $this->_serviceBusEndpointUri; | ||
} | ||
|
||
/** | ||
* Gets the wrap endpoint uri. | ||
* | ||
* @return string | ||
*/ | ||
public function getWrapEndpointUri() | ||
{ | ||
return $this->_wrapEndpointUri; | ||
} | ||
|
||
/** | ||
* Gets the wrap name. | ||
* | ||
* @return string | ||
*/ | ||
public function getWrapName() | ||
{ | ||
return $this->_wrapName; | ||
} | ||
|
||
/** | ||
* Gets the wrap password. | ||
* | ||
* @return string | ||
*/ | ||
public function getWrapPassword() | ||
{ | ||
return $this->_wrapPassword; | ||
} | ||
|
||
/** | ||
* Gets the namespace name. | ||
* | ||
* @return string | ||
*/ | ||
public function getNamespace() | ||
{ | ||
return $this->_namespace; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.