web/lib/Zend/Service/WindowsAzure/CommandLine/Certificate.php
changeset 1230 68c69c656a2c
parent 808 6b6c2214f778
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Service_Console
    16  * @package    Zend_Service_Console
    17  * @subpackage Exception
    17  * @subpackage Exception
    18  * @version    $Id$
    18  * @version    $Id$
    19  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  */
    21  */
    22 
    22 
       
    23 /**
       
    24 * @see Zend_Service_Console_Command
       
    25 */
       
    26 require_once 'Zend/Service/Console/Command.php';
       
    27 
       
    28 
       
    29 /**
       
    30  * @see Zend_Service_WindowsAzure_Management_Client
       
    31  */
       
    32 require_once 'Zend/Service/WindowsAzure/Management/Client.php';
    23 
    33 
    24 /**
    34 /**
    25  * Certificate commands
    35  * Certificate commands
    26  * 
    36  *
    27  * @category   Zend
    37  * @category   Zend
    28  * @package    Zend_Service_WindowsAzure_CommandLine
    38  * @package    Zend_Service_WindowsAzure_CommandLine
    29  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    39  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    40  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * 
    41  *
    32  * @command-handler certificate
    42  * @command-handler certificate
    33  * @command-handler-description Windows Azure Certificate commands
    43  * @command-handler-description Windows Azure Certificate commands
    34  * @command-handler-header Windows Azure SDK for PHP
    44  * @command-handler-header Windows Azure SDK for PHP
    35  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
    45  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
    36  * @command-handler-footer Note: Parameters that are common across all commands can be stored 
    46  * @command-handler-footer Note: Parameters that are common across all commands can be stored
    37  * @command-handler-footer in two dedicated environment variables.
    47  * @command-handler-footer in two dedicated environment variables.
    38  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
    48  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
    39  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
    49  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
    40  * @command-handler-footer 
    50  * @command-handler-footer
    41  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
    51  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
    42  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
    52  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
    43  * @command-handler-footer value per line. It accepts the same parameters as one can
    53  * @command-handler-footer value per line. It accepts the same parameters as one can
    44  * @command-handler-footer use from the command line command.
    54  * @command-handler-footer use from the command line command.
    45  */
    55  */
    46 class Zend_Service_WindowsAzure_CommandLine_Certificate
    56 class Zend_Service_WindowsAzure_CommandLine_Certificate
    47 	extends Zend_Service_Console_Command
    57 	extends Zend_Service_Console_Command
    48 {	
    58 {
    49 	/**
    59 	/**
    50 	 * List certificates for a specified hosted service in a specified subscription.
    60 	 * List certificates for a specified hosted service in a specified subscription.
    51 	 * 
    61 	 *
    52 	 * @command-name List
    62 	 * @command-name List
    53 	 * @command-description List certificates for a specified hosted service in a specified subscription.
    63 	 * @command-description List certificates for a specified hosted service in a specified subscription.
    54 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
    64 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
    55 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
    65 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
    56 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
    66 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
    68 		}
    78 		}
    69 		foreach ($result as $object) {
    79 		foreach ($result as $object) {
    70 			$this->_displayObjectInformation($object, array('Thumbprint', 'CertificateUrl', 'ThumbprintAlgorithm'));
    80 			$this->_displayObjectInformation($object, array('Thumbprint', 'CertificateUrl', 'ThumbprintAlgorithm'));
    71 		}
    81 		}
    72 	}
    82 	}
    73 	
    83 
    74 	/**
    84 	/**
    75 	 * Add a certificate for a specified hosted service in a specified subscription.
    85 	 * Add a certificate for a specified hosted service in a specified subscription.
    76 	 * 
    86 	 *
    77 	 * @command-name Add
    87 	 * @command-name Add
    78 	 * @command-description Add a certificate for a specified hosted service in a specified subscription.
    88 	 * @command-description Add a certificate for a specified hosted service in a specified subscription.
    79 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
    89 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
    80 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
    90 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
    81 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
    91 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
    93 		if ($waitForOperation) {
   103 		if ($waitForOperation) {
    94 			$client->waitForOperation();
   104 			$client->waitForOperation();
    95 		}
   105 		}
    96 		echo $client->getLastRequestId();
   106 		echo $client->getLastRequestId();
    97 	}
   107 	}
    98 	
   108 
    99 	/**
   109 	/**
   100 	 * Gets a certificate from a specified hosted service in a specified subscription.
   110 	 * Gets a certificate from a specified hosted service in a specified subscription.
   101 	 * 
   111 	 *
   102 	 * @command-name Get
   112 	 * @command-name Get
   103 	 * @command-description Gets a certificate from a specified hosted service in a specified subscription.
   113 	 * @command-description Gets a certificate from a specified hosted service in a specified subscription.
   104 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
   114 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
   105 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
   115 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
   106 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
   116 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
   115 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
   125 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
   116 		$result = $client->getCertificate($serviceName, $algorithm, $thumbprint);
   126 		$result = $client->getCertificate($serviceName, $algorithm, $thumbprint);
   117 
   127 
   118 		$this->_displayObjectInformation($result, array('Thumbprint', 'CertificateUrl', 'ThumbprintAlgorithm'));
   128 		$this->_displayObjectInformation($result, array('Thumbprint', 'CertificateUrl', 'ThumbprintAlgorithm'));
   119 	}
   129 	}
   120 	
   130 
   121 	/**
   131 	/**
   122 	 * Gets a certificate property from a specified hosted service in a specified subscription.
   132 	 * Gets a certificate property from a specified hosted service in a specified subscription.
   123 	 * 
   133 	 *
   124 	 * @command-name GetProperty
   134 	 * @command-name GetProperty
   125 	 * @command-description Gets a certificate property from a specified hosted service in a specified subscription.
   135 	 * @command-description Gets a certificate property from a specified hosted service in a specified subscription.
   126 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
   136 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
   127 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
   137 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
   128 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
   138 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
   138 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
   148 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
   139 		$result = $client->getCertificate($serviceName, $algorithm, $thumbprint);
   149 		$result = $client->getCertificate($serviceName, $algorithm, $thumbprint);
   140 
   150 
   141 		printf("%s\r\n", $result->$property);
   151 		printf("%s\r\n", $result->$property);
   142 	}
   152 	}
   143 	
   153 
   144 	/**
   154 	/**
   145 	 * Deletes a certificate from a specified hosted service in a specified subscription.
   155 	 * Deletes a certificate from a specified hosted service in a specified subscription.
   146 	 * 
   156 	 *
   147 	 * @command-name Delete
   157 	 * @command-name Delete
   148 	 * @command-description Deletes a certificate from a specified hosted service in a specified subscription.
   158 	 * @command-description Deletes a certificate from a specified hosted service in a specified subscription.
   149 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
   159 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
   150 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
   160 	 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
   151 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
   161 	 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.