diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2015-05-05 15:52:01 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2015-05-05 15:52:01 -0230 |
commit | b61582b1c6b16be4339aa0bded3ad8f542a01df9 (patch) | |
tree | 2040386a942217e2412e48c1e56465817ecac3d5 /php/src | |
parent | Missing export declarations (diff) | |
download | ice-b61582b1c6b16be4339aa0bded3ad8f542a01df9.tar.bz2 ice-b61582b1c6b16be4339aa0bded3ad8f542a01df9.tar.xz ice-b61582b1c6b16be4339aa0bded3ad8f542a01df9.zip |
ICE-6471 Add support for IceSSL endpoint/connection info to Python/Ruby/PHP
Diffstat (limited to 'php/src')
-rw-r--r-- | php/src/IcePHP/Connection.cpp | 75 | ||||
-rw-r--r-- | php/src/IcePHP/Endpoint.cpp | 41 |
2 files changed, 115 insertions, 1 deletions
diff --git a/php/src/IcePHP/Connection.cpp b/php/src/IcePHP/Connection.cpp index b664cd9fac5..cdb739c8693 100644 --- a/php/src/IcePHP/Connection.cpp +++ b/php/src/IcePHP/Connection.cpp @@ -11,6 +11,7 @@ #include <Endpoint.h> #include <Types.h> #include <Util.h> +#include <IceSSL/ConnectionInfo.h> using namespace std; using namespace IcePHP; @@ -27,6 +28,8 @@ static zend_class_entry* ipConnectionInfoClassEntry = 0; static zend_class_entry* tcpConnectionInfoClassEntry = 0; static zend_class_entry* udpConnectionInfoClassEntry = 0; static zend_class_entry* wsConnectionInfoClassEntry = 0; +static zend_class_entry* sslConnectionInfoClassEntry = 0; +static zend_class_entry* wssConnectionInfoClassEntry = 0; // // Ice::Connection support. @@ -572,6 +575,37 @@ IcePHP::connectionInit(TSRMLS_D) zend_declare_property_string(wsConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1, STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + // + // Register the SSLConnectionInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "SSLConnectionInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_SSLConnectionInfo", NULL); +#endif + ce.create_object = handleConnectionInfoAlloc; + sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC); + zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("cipher"), sizeof("cipher") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("certs"), sizeof("certs") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_bool(sslConnectionInfoClassEntry, STRCAST("verified"), sizeof("verified") - 1, 0, + ZEND_ACC_PUBLIC TSRMLS_CC); + + // + // Register the WSConnectionInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSConnectionInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_WSSConnectionInfo", NULL); +#endif + ce.create_object = handleConnectionInfoAlloc; + wssConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, sslConnectionInfoClassEntry, NULL TSRMLS_CC); + zend_declare_property_string(wssConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + + return true; } @@ -651,6 +685,28 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC add_property_long(zv, STRCAST("mcastPort"), static_cast<long>(info->mcastPort)); } } + else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p)) + { + IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(p); + if((status = object_init_ex(zv, wssConnectionInfoClassEntry)) == SUCCESS) + { + zval* zmap; + MAKE_STD_ZVAL(zmap); + AutoDestroy mapDestroyer(zmap); + if(createStringMap(zmap, info->headers TSRMLS_CC)) + { + add_property_zval(zv, STRCAST("headers"), zmap); + } + else + { + return false; + } + } + } + else if(IceSSL::ConnectionInfoPtr::dynamicCast(p)) + { + status = object_init_ex(zv, sslConnectionInfoClassEntry); + } else if(Ice::IPConnectionInfoPtr::dynamicCast(p)) { status = object_init_ex(zv, ipConnectionInfoClassEntry); @@ -666,6 +722,25 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC return false; } + if(IceSSL::ConnectionInfoPtr::dynamicCast(p)) + { + IceSSL::ConnectionInfoPtr info = IceSSL::ConnectionInfoPtr::dynamicCast(p); + add_property_string(zv, STRCAST("cipher"), const_cast<char*>(info->cipher.c_str()), 1); + add_property_bool(zv, STRCAST("verified"), info->verified ? 1 : 0); + + zval* zarr; + MAKE_STD_ZVAL(zarr); + AutoDestroy listDestroyer(zarr); + if(createStringArray(zarr, info->certs TSRMLS_CC)) + { + add_property_zval(zv, STRCAST("certs"), zarr); + } + else + { + return false; + } + } + if(Ice::IPConnectionInfoPtr::dynamicCast(p)) { Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(p); diff --git a/php/src/IcePHP/Endpoint.cpp b/php/src/IcePHP/Endpoint.cpp index 317dcb6c3d8..4ca32bbf600 100644 --- a/php/src/IcePHP/Endpoint.cpp +++ b/php/src/IcePHP/Endpoint.cpp @@ -9,6 +9,7 @@ #include <Endpoint.h> #include <Util.h> +#include <IceSSL/EndpointInfo.h> using namespace std; using namespace IcePHP; @@ -26,6 +27,8 @@ static zend_class_entry* tcpEndpointInfoClassEntry = 0; static zend_class_entry* udpEndpointInfoClassEntry = 0; static zend_class_entry* wsEndpointInfoClassEntry = 0; static zend_class_entry* opaqueEndpointInfoClassEntry = 0; +static zend_class_entry* sslEndpointInfoClassEntry = 0; +static zend_class_entry* wssEndpointInfoClassEntry = 0; // // Ice::Endpoint support. @@ -362,7 +365,7 @@ IcePHP::endpointInit(TSRMLS_D) #endif ce.create_object = handleEndpointInfoAlloc; wsEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry, NULL TSRMLS_CC); - zend_declare_property_string(udpEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1, + zend_declare_property_string(wsEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1, STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); // @@ -380,6 +383,30 @@ IcePHP::endpointInit(TSRMLS_D) zend_declare_property_null(opaqueEndpointInfoClassEntry, STRCAST("rawBytes"), sizeof("rawBytes") - 1, ZEND_ACC_PUBLIC TSRMLS_CC); + // + // Define the SSLEndpointInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "SSLEndpointInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_SSLEndpointInfo", NULL); +#endif + ce.create_object = handleEndpointInfoAlloc; + sslEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry, NULL TSRMLS_CC); + + // + // Define the WSSEndpointInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSEndpointInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_WSSEndpointInfo", NULL); +#endif + ce.create_object = handleEndpointInfoAlloc; + wssEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, sslEndpointInfoClassEntry, NULL TSRMLS_CC); + zend_declare_property_string(wssEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + return true; } @@ -471,6 +498,18 @@ IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p TSRMLS_DC) zval_ptr_dtor(&rawBytes); // add_property_zval increased the refcount of rawBytes } } + else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p)) + { + IceSSL::WSSEndpointInfoPtr info = IceSSL::WSSEndpointInfoPtr::dynamicCast(p); + if((status = object_init_ex(zv, wssEndpointInfoClassEntry)) == SUCCESS) + { + add_property_string(zv, STRCAST("resource"), const_cast<char*>(info->resource.c_str()), 1); + } + } + else if(IceSSL::EndpointInfoPtr::dynamicCast(p)) + { + status = object_init_ex(zv, sslEndpointInfoClassEntry); + } else if(Ice::IPEndpointInfoPtr::dynamicCast(p)) { status = object_init_ex(zv, ipEndpointInfoClassEntry); |