summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2015-05-05 15:52:01 -0230
committerDwayne Boone <dwayne@zeroc.com>2015-05-05 15:52:01 -0230
commitb61582b1c6b16be4339aa0bded3ad8f542a01df9 (patch)
tree2040386a942217e2412e48c1e56465817ecac3d5 /ruby
parentMissing export declarations (diff)
downloadice-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 'ruby')
-rw-r--r--ruby/src/IceRuby/Connection.cpp62
-rw-r--r--ruby/src/IceRuby/Endpoint.cpp40
-rw-r--r--ruby/test/Ice/info/AllTests.rb9
3 files changed, 105 insertions, 6 deletions
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp
index df2caa1000b..2bad860a09a 100644
--- a/ruby/src/IceRuby/Connection.cpp
+++ b/ruby/src/IceRuby/Connection.cpp
@@ -12,6 +12,7 @@
#include <Types.h>
#include <Util.h>
#include <Ice/Object.h>
+#include <IceSSL/ConnectionInfo.h>
using namespace std;
using namespace IceRuby;
@@ -23,6 +24,8 @@ static VALUE _ipConnectionInfoClass;
static VALUE _tcpConnectionInfoClass;
static VALUE _udpConnectionInfoClass;
static VALUE _wsConnectionInfoClass;
+static VALUE _sslConnectionInfoClass;
+static VALUE _wssConnectionInfoClass;
// **********************************************************************
// Connection
@@ -332,6 +335,41 @@ IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p)
rb_ivar_set(info, rb_intern("@mcastAddress"), createString(udp->mcastAddress));
rb_ivar_set(info, rb_intern("@mcastPort"), INT2FIX(udp->mcastPort));
}
+ else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p))
+ {
+ info = Data_Wrap_Struct(_wssConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
+
+ IceSSL::WSSConnectionInfoPtr wss = IceSSL::WSSConnectionInfoPtr::dynamicCast(p);
+ rb_ivar_set(info, rb_intern("@localAddress"), createString(wss->localAddress));
+ rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(wss->localPort));
+ rb_ivar_set(info, rb_intern("@remoteAddress"), createString(wss->remoteAddress));
+ rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(wss->remotePort));
+ rb_ivar_set(info, rb_intern("@cipher"), createString(wss->cipher));
+ rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(wss->certs));
+ rb_ivar_set(info, rb_intern("@verified"), wss->verified ? Qtrue : Qfalse);
+
+ volatile VALUE result = callRuby(rb_hash_new);
+ for(Ice::HeaderDict::const_iterator q = wss->headers.begin(); q != wss->headers.end(); ++q)
+ {
+ volatile VALUE key = createString(q->first);
+ volatile VALUE value = createString(q->second);
+ callRuby(rb_hash_aset, result, key, value);
+ }
+ rb_ivar_set(info, rb_intern("@headers"), result);
+ }
+ else if(IceSSL::ConnectionInfoPtr::dynamicCast(p))
+ {
+ info = Data_Wrap_Struct(_sslConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
+
+ IceSSL::ConnectionInfoPtr ssl = IceSSL::ConnectionInfoPtr::dynamicCast(p);
+ rb_ivar_set(info, rb_intern("@localAddress"), createString(ssl->localAddress));
+ rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ssl->localPort));
+ rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ssl->remoteAddress));
+ rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ssl->remotePort));
+ rb_ivar_set(info, rb_intern("@cipher"), createString(ssl->cipher));
+ rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(ssl->certs));
+ rb_ivar_set(info, rb_intern("@verified"), ssl->verified ? Qtrue : Qfalse);
+ }
else if(Ice::IPConnectionInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_ipConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
@@ -429,5 +467,27 @@ IceRuby::initConnection(VALUE iceModule)
//
// Instance members.
//
- //rb_define_attr(_wsConnectionInfoClass, "headers", 1, 0);
+ rb_define_attr(_wsConnectionInfoClass, "headers", 1, 0);
+
+ //
+ // SSLConnectionInfo
+ //
+ _sslConnectionInfoClass = rb_define_class_under(iceModule, "SSLConnectionInfo", _ipConnectionInfoClass);
+
+ //
+ // Instance members.
+ //
+ rb_define_attr(_wsConnectionInfoClass, "cipher", 1, 0);
+ rb_define_attr(_wsConnectionInfoClass, "certs", 1, 0);
+ rb_define_attr(_wsConnectionInfoClass, "verified", 1, 0);
+
+ //
+ // WSSConnectionInfo
+ //
+ _wssConnectionInfoClass = rb_define_class_under(iceModule, "WSSConnectionInfo", _sslConnectionInfoClass);
+
+ //
+ // Instance members.
+ //
+ rb_define_attr(_wssConnectionInfoClass, "headers", 1, 0);
}
diff --git a/ruby/src/IceRuby/Endpoint.cpp b/ruby/src/IceRuby/Endpoint.cpp
index c6f8d8565e3..cad2ba3ba44 100644
--- a/ruby/src/IceRuby/Endpoint.cpp
+++ b/ruby/src/IceRuby/Endpoint.cpp
@@ -10,6 +10,7 @@
#include <Endpoint.h>
#include <Util.h>
#include <Ice/Object.h>
+#include <IceSSL/EndpointInfo.h>
using namespace std;
using namespace IceRuby;
@@ -22,6 +23,8 @@ static VALUE _tcpEndpointInfoClass;
static VALUE _udpEndpointInfoClass;
static VALUE _wsEndpointInfoClass;
static VALUE _opaqueEndpointInfoClass;
+static VALUE _sslEndpointInfoClass;
+static VALUE _wssEndpointInfoClass;
// **********************************************************************
// Endpoint
@@ -170,6 +173,25 @@ IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p)
rb_ivar_set(info, rb_intern("@rawBytes"), v);
rb_ivar_set(info, rb_intern("@rawEncoding"), createEncodingVersion(opaque->rawEncoding));
}
+ else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p))
+ {
+ info = Data_Wrap_Struct(_wssEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
+
+ IceSSL::WSSEndpointInfoPtr wss = IceSSL::WSSEndpointInfoPtr::dynamicCast(p);
+ rb_ivar_set(info, rb_intern("@host"), createString(wss->host));
+ rb_ivar_set(info, rb_intern("@port"), INT2FIX(wss->port));
+ rb_ivar_set(info, rb_intern("@sourceAddress"), createString(wss->sourceAddress));
+ rb_ivar_set(info, rb_intern("@resource"), createString(wss->resource));
+ }
+ else if(IceSSL::EndpointInfoPtr::dynamicCast(p))
+ {
+ info = Data_Wrap_Struct(_sslEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
+
+ IceSSL::EndpointInfoPtr ssl = IceSSL::EndpointInfoPtr::dynamicCast(p);
+ rb_ivar_set(info, rb_intern("@host"), createString(ssl->host));
+ rb_ivar_set(info, rb_intern("@port"), INT2FIX(ssl->port));
+ rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ssl->sourceAddress));
+ }
else if(Ice::IPEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_ipEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
@@ -183,6 +205,7 @@ IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p)
{
info = Data_Wrap_Struct(_endpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
}
+
rb_ivar_set(info, rb_intern("@timeout"), INT2FIX(p->timeout));
rb_ivar_set(info, rb_intern("@compress"), p->compress ? Qtrue : Qfalse);
return info;
@@ -306,7 +329,7 @@ IceRuby::initEndpoint(VALUE iceModule)
//
// WSEndpointInfo
//
- _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _ipEndpointInfoClass);
+ _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _tcpEndpointInfoClass);
//
// Instance members.
@@ -323,6 +346,21 @@ IceRuby::initEndpoint(VALUE iceModule)
//
rb_define_attr(_opaqueEndpointInfoClass, "rawBytes", 1, 0);
rb_define_attr(_opaqueEndpointInfoClass, "rawEncoding", 1, 0);
+
+ //
+ // SSLEndpointInfo
+ //
+ _sslEndpointInfoClass = rb_define_class_under(iceModule, "SSLEndpointInfo", _ipEndpointInfoClass);
+
+ //
+ // WSSEndpointInfo
+ //
+ _wssEndpointInfoClass = rb_define_class_under(iceModule, "WSSEndpointInfo", _sslEndpointInfoClass);
+
+ //
+ // Instance members.
+ //
+ rb_define_attr(_wssEndpointInfoClass, "resource", 1, 0);
}
bool
diff --git a/ruby/test/Ice/info/AllTests.rb b/ruby/test/Ice/info/AllTests.rb
index a2ca97ba20f..8f66870a57d 100644
--- a/ruby/test/Ice/info/AllTests.rb
+++ b/ruby/test/Ice/info/AllTests.rb
@@ -30,9 +30,9 @@ def allTests(communicator)
(ipEndpoint.type() == Ice::WSEndpointType && !ipEndpoint.secure()) ||
(ipEndpoint.type() == Ice::WSSEndpointType && ipEndpoint.secure()))
test((ipEndpoint.type() == Ice::TCPEndpointType && ipEndpoint.is_a?(Ice::TCPEndpointInfo)) ||
- (ipEndpoint.type() == Ice::SSLEndpointType) ||
+ (ipEndpoint.type() == Ice::SSLEndpointType && ipEndpoint.is_a?(Ice::SSLEndpointInfo)) ||
(ipEndpoint.type() == Ice::WSEndpointType && ipEndpoint.is_a?(Ice::WSEndpointInfo)) ||
- (ipEndpoint.type() == Ice::WSSEndpointType))
+ (ipEndpoint.type() == Ice::WSSEndpointType && ipEndpoint.is_a?(Ice::WSSEndpointInfo)))
udpEndpoint = endps[1].getInfo()
test(udpEndpoint.is_a?(Ice::UDPEndpointInfo));
@@ -102,8 +102,9 @@ def allTests(communicator)
test(ctx["remotePort"] == info.localPort.to_s())
test(ctx["localPort"] == info.remotePort.to_s())
- if base.ice_getConnection().type() == "ws"
- test(info.is_a?(Ice::WSConnectionInfo))
+ if base.ice_getConnection().type() == "ws" || base.ice_getConnection().type() == "wss"
+ test((base.ice_getConnection().type() == "ws" && info.is_a?(Ice::WSConnectionInfo)) ||
+ (base.ice_getConnection().type() == "wss" && info.is_a?(Ice::WSSConnectionInfo)))
test(info.headers["Upgrade"] == "websocket")
test(info.headers["Connection"] == "Upgrade")