Class: RubyCyrusSASL::Client
- Inherits:
-
Object
- Object
- RubyCyrusSASL::Client
- Defined in:
- lib/ruby-cyrus-sasl/Client.rb,
ext/rubysasl/rubysasl.c
Instance Method Summary collapse
- #complete? ⇒ Boolean
-
#initialize(callback) ⇒ Client
constructor
A new instance of Client.
- #mech ⇒ Object
- #sasl_client_start(mechlist) ⇒ Object
- #sasl_client_step(serverin) ⇒ Object
- #start(mech_list) ⇒ Object
- #step(challenge) ⇒ Object
Constructor Details
#initialize(callback) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/ruby-cyrus-sasl/Client.rb', line 6 def initialize callback @callback = callback @complete = false @mech = nil end |
Instance Method Details
#complete? ⇒ Boolean
25 26 27 |
# File 'lib/ruby-cyrus-sasl/Client.rb', line 25 def complete? @complete end |
#mech ⇒ Object
21 22 23 |
# File 'lib/ruby-cyrus-sasl/Client.rb', line 21 def mech @mech end |
#sasl_client_start(mechlist) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/rubysasl/rubysasl.c', line 96
static VALUE t_sasl_client_start(VALUE self, VALUE mechlist)
{
sasl_conn_t *c_conn;
const char *c_mechlist = (mechlist != Qnil) ? RSTRING_PTR(mechlist) : NULL;
sasl_interact_t *c_prompt_need = NULL;
const char *c_clientout;
unsigned c_clientoutlen = 0;
const char *c_mech;
int err;
VALUE result;
Data_Get_Struct(self, sasl_conn_t, c_conn);
do {
err = sasl_client_start(c_conn, c_mechlist, &c_prompt_need, &c_clientout, &c_clientoutlen, &c_mech);
if (err == SASL_INTERACT) {
VALUE callbackFunc = rb_iv_get(self, "@callback");
handle_callbacks(callbackFunc, c_prompt_need);
}
} while (err == SASL_INTERACT);
if (err != SASL_OK && err != SASL_CONTINUE) {
rb_raise(rb_eException, "starting SASL negotiation details: %s", sasl_errdetail(c_conn));
return Qnil;
}
rb_iv_set(self, "@mech", rb_str_new2(c_mech));
result = rb_str_new(c_clientout, c_clientoutlen);
return result;
}
|
#sasl_client_step(serverin) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'ext/rubysasl/rubysasl.c', line 127
static VALUE t_sasl_client_step(VALUE self, VALUE serverin)
{
sasl_conn_t *c_conn;
const char *c_serverin;
unsigned c_serverinlen;
sasl_interact_t *c_prompt_need = NULL;
const char *c_clientout;
unsigned c_clientoutlen;
int err;
VALUE result;
Data_Get_Struct(self, sasl_conn_t, c_conn);
c_serverin = (serverin != Qnil) ? RSTRING_PTR(serverin) : NULL;
c_serverinlen = (serverin != Qnil) ? RSTRING_LEN(serverin) : 0;
do {
err = sasl_client_step(c_conn, c_serverin, c_serverinlen, &c_prompt_need, &c_clientout, &c_clientoutlen);
if (err == SASL_INTERACT) {
VALUE callbackFunc = rb_iv_get(self, "@callback");
handle_callbacks(callbackFunc, c_prompt_need);
}
} while (err == SASL_INTERACT);
if (err != SASL_OK && err != SASL_CONTINUE) {
rb_raise(rb_eException, "starting SASL negotiation details: %s", sasl_errdetail(c_conn));
return Qnil;
}
if (err == SASL_OK)
rb_iv_set(self, "@complete", Qtrue);
result = rb_str_new(c_clientout, c_clientoutlen);
return result;
}
|
#start(mech_list) ⇒ Object
12 13 14 15 |
# File 'lib/ruby-cyrus-sasl/Client.rb', line 12 def start mech_list puts mech_list sasl_client_start mech_list end |
#step(challenge) ⇒ Object
17 18 19 |
# File 'lib/ruby-cyrus-sasl/Client.rb', line 17 def step challenge sasl_client_step challenge end |