Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
a4a0dc66
Commit
a4a0dc66
authored
Sep 30, 2013
by
Mike Gatny
Committed by
Chris Busbey
Apr 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split up gssapi mechanism into client and server.
parent
abcb2243
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
350 additions
and
142 deletions
+350
-142
Makefile.am
src/Makefile.am
+4
-2
gssapi_client.cpp
src/gssapi_client.cpp
+245
-0
gssapi_client.hpp
src/gssapi_client.hpp
+72
-0
gssapi_server.cpp
src/gssapi_server.cpp
+17
-124
gssapi_server.hpp
src/gssapi_server.hpp
+5
-13
stream_engine.cpp
src/stream_engine.cpp
+7
-3
No files found.
src/Makefile.am
View file @
a4a0dc66
...
...
@@ -25,7 +25,8 @@ libzmq_la_SOURCES = \
err.hpp
\
fd.hpp
\
fq.hpp
\
gssapi_mechanism.hpp
\
gssapi_client.hpp
\
gssapi_server.hpp
\
i_encoder.hpp
\
i_decoder.hpp
\
i_engine.hpp
\
...
...
@@ -102,7 +103,8 @@ libzmq_la_SOURCES = \
epoll.cpp
\
err.cpp
\
fq.cpp
\
gssapi_mechanism.cpp
\
gssapi_client.cpp
\
gssapi_server.cpp
\
io_object.cpp
\
io_thread.cpp
\
ip.cpp
\
...
...
src/gssapi_client.cpp
0 → 100644
View file @
a4a0dc66
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "platform.hpp"
#ifdef ZMQ_HAVE_WINDOWS
#include "windows.hpp"
#endif
#include <string.h>
#include <string>
#include "msg.hpp"
#include "session_base.hpp"
#include "err.hpp"
#include "gssapi_client.hpp"
#include "wire.hpp"
zmq
::
gssapi_client_t
::
gssapi_client_t
(
const
options_t
&
options_
)
:
mechanism_t
(
options_
),
expecting_another_token
(
true
),
state
(
sending_hello
)
{
}
zmq
::
gssapi_client_t
::~
gssapi_client_t
()
{
}
int
zmq
::
gssapi_client_t
::
next_handshake_command
(
msg_t
*
msg_
)
{
int
rc
=
0
;
switch
(
state
)
{
case
sending_hello
:
rc
=
produce_hello
(
msg_
);
if
(
rc
==
0
)
state
=
waiting_for_welcome
;
break
;
case
sending_initiate
:
rc
=
produce_initiate
(
msg_
);
if
(
rc
==
0
)
state
=
waiting_for_token
;
break
;
case
sending_token
:
rc
=
produce_token
(
msg_
);
if
(
rc
==
0
)
state
=
waiting_for_ready
;
//state = expecting_another_token? waiting_for_token: waiting_for_ready;
break
;
default
:
errno
=
EAGAIN
;
rc
=
-
1
;
}
return
rc
;
}
int
zmq
::
gssapi_client_t
::
process_handshake_command
(
msg_t
*
msg_
)
{
int
rc
=
0
;
switch
(
state
)
{
case
waiting_for_welcome
:
rc
=
process_welcome
(
msg_
);
if
(
rc
==
0
)
state
=
sending_initiate
;
break
;
case
waiting_for_token
:
rc
=
process_token
(
msg_
);
if
(
rc
==
0
)
state
=
sending_token
;
// state = expecting_another_token? sending_token: sending_ready;
break
;
case
waiting_for_ready
:
rc
=
process_ready
(
msg_
);
if
(
rc
==
0
)
state
=
ready
;
break
;
default
:
errno
=
EPROTO
;
rc
=
-
1
;
break
;
}
if
(
rc
==
0
)
{
rc
=
msg_
->
close
();
errno_assert
(
rc
==
0
);
rc
=
msg_
->
init
();
errno_assert
(
rc
==
0
);
}
return
rc
;
}
bool
zmq
::
gssapi_client_t
::
is_handshake_complete
()
const
{
return
state
==
ready
;
}
int
zmq
::
gssapi_client_t
::
produce_hello
(
msg_t
*
msg_
)
const
{
const
std
::
string
username
=
"admin"
;
zmq_assert
(
username
.
length
()
<
256
);
const
std
::
string
password
=
"secret"
;
zmq_assert
(
password
.
length
()
<
256
);
const
size_t
command_size
=
6
+
1
+
username
.
length
()
+
1
+
password
.
length
();
const
int
rc
=
msg_
->
init_size
(
command_size
);
errno_assert
(
rc
==
0
);
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
memcpy
(
ptr
,
"
\x05
HELLO"
,
6
);
ptr
+=
6
;
*
ptr
++
=
static_cast
<
unsigned
char
>
(
username
.
length
());
memcpy
(
ptr
,
username
.
c_str
(),
username
.
length
());
ptr
+=
username
.
length
();
*
ptr
++
=
static_cast
<
unsigned
char
>
(
password
.
length
());
memcpy
(
ptr
,
password
.
c_str
(),
password
.
length
());
ptr
+=
password
.
length
();
return
0
;
}
int
zmq
::
gssapi_client_t
::
process_welcome
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
if
(
bytes_left
!=
8
||
memcmp
(
ptr
,
"
\x07
WELCOME"
,
8
))
{
errno
=
EPROTO
;
return
-
1
;
}
return
0
;
}
int
zmq
::
gssapi_client_t
::
produce_initiate
(
msg_t
*
msg_
)
const
{
unsigned
char
*
const
command_buffer
=
(
unsigned
char
*
)
malloc
(
512
);
alloc_assert
(
command_buffer
);
unsigned
char
*
ptr
=
command_buffer
;
// Add mechanism string
memcpy
(
ptr
,
"
\x08
INITIATE"
,
9
);
ptr
+=
9
;
// Add socket type property
const
char
*
socket_type
=
socket_type_string
(
options
.
type
);
ptr
+=
add_property
(
ptr
,
"Socket-Type"
,
socket_type
,
strlen
(
socket_type
));
// Add identity property
if
(
options
.
type
==
ZMQ_REQ
||
options
.
type
==
ZMQ_DEALER
||
options
.
type
==
ZMQ_ROUTER
)
{
ptr
+=
add_property
(
ptr
,
"Identity"
,
options
.
identity
,
options
.
identity_size
);
}
const
size_t
command_size
=
ptr
-
command_buffer
;
const
int
rc
=
msg_
->
init_size
(
command_size
);
errno_assert
(
rc
==
0
);
memcpy
(
msg_
->
data
(),
command_buffer
,
command_size
);
free
(
command_buffer
);
return
0
;
}
int
zmq
::
gssapi_client_t
::
produce_token
(
msg_t
*
msg_
)
const
{
unsigned
char
*
const
command_buffer
=
(
unsigned
char
*
)
malloc
(
512
);
alloc_assert
(
command_buffer
);
unsigned
char
*
ptr
=
command_buffer
;
// Add command name
memcpy
(
ptr
,
"
\x05
TOKEN"
,
6
);
ptr
+=
6
;
// Add socket type property
const
char
*
socket_type
=
socket_type_string
(
options
.
type
);
ptr
+=
add_property
(
ptr
,
"Socket-Type"
,
socket_type
,
strlen
(
socket_type
));
// Add identity property
if
(
options
.
type
==
ZMQ_REQ
||
options
.
type
==
ZMQ_DEALER
||
options
.
type
==
ZMQ_ROUTER
)
{
ptr
+=
add_property
(
ptr
,
"Identity"
,
options
.
identity
,
options
.
identity_size
);
}
const
size_t
command_size
=
ptr
-
command_buffer
;
const
int
rc
=
msg_
->
init_size
(
command_size
);
errno_assert
(
rc
==
0
);
memcpy
(
msg_
->
data
(),
command_buffer
,
command_size
);
free
(
command_buffer
);
return
0
;
}
int
zmq
::
gssapi_client_t
::
process_token
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
if
(
bytes_left
<
6
||
memcmp
(
ptr
,
"
\x05
TOKEN"
,
6
))
{
errno
=
EPROTO
;
return
-
1
;
}
ptr
+=
6
;
bytes_left
-=
6
;
expecting_another_token
=
false
;
return
parse_metadata
(
ptr
,
bytes_left
);
}
int
zmq
::
gssapi_client_t
::
process_ready
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
if
(
bytes_left
<
6
||
memcmp
(
ptr
,
"
\x05
READY"
,
6
))
{
errno
=
EPROTO
;
return
-
1
;
}
ptr
+=
6
;
bytes_left
-=
6
;
return
parse_metadata
(
ptr
,
bytes_left
);
}
src/gssapi_client.hpp
0 → 100644
View file @
a4a0dc66
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_GSSAPI_CLIENT_HPP_INCLUDED__
#define __ZMQ_GSSAPI_CLIENT_HPP_INCLUDED__
#include "mechanism.hpp"
#include "options.hpp"
namespace
zmq
{
class
msg_t
;
class
session_base_t
;
class
gssapi_client_t
:
public
mechanism_t
{
public
:
gssapi_client_t
(
const
options_t
&
options_
);
virtual
~
gssapi_client_t
();
// mechanism implementation
virtual
int
next_handshake_command
(
msg_t
*
msg_
);
virtual
int
process_handshake_command
(
msg_t
*
msg_
);
virtual
bool
is_handshake_complete
()
const
;
private
:
enum
state_t
{
sending_hello
,
waiting_for_welcome
,
sending_initiate
,
sending_token
,
waiting_for_token
,
waiting_for_ready
,
ready
};
// True iff we are awaiting another GSS token.
bool
expecting_another_token
;
state_t
state
;
int
produce_hello
(
msg_t
*
msg_
)
const
;
int
produce_initiate
(
msg_t
*
msg_
)
const
;
int
produce_token
(
msg_t
*
msg_
)
const
;
int
process_welcome
(
msg_t
*
msg
);
int
process_token
(
msg_t
*
msg_
);
int
process_ready
(
msg_t
*
msg_
);
};
}
#endif
src/gssapi_
mechanism
.cpp
→
src/gssapi_
server
.cpp
View file @
a4a0dc66
...
...
@@ -28,10 +28,10 @@
#include "msg.hpp"
#include "session_base.hpp"
#include "err.hpp"
#include "gssapi_
mechanism
.hpp"
#include "gssapi_
server
.hpp"
#include "wire.hpp"
zmq
::
gssapi_
mechanism_t
::
gssapi_mechanism
_t
(
session_base_t
*
session_
,
zmq
::
gssapi_
server_t
::
gssapi_server
_t
(
session_base_t
*
session_
,
const
std
::
string
&
peer_address_
,
const
options_t
&
options_
)
:
mechanism_t
(
options_
),
...
...
@@ -39,38 +39,28 @@ zmq::gssapi_mechanism_t::gssapi_mechanism_t (session_base_t *session_,
peer_address
(
peer_address_
),
expecting_zap_reply
(
false
),
expecting_another_token
(
true
),
state
(
options
.
as_server
?
waiting_for_hello
:
sending
_hello
)
state
(
waiting_for
_hello
)
{
}
zmq
::
gssapi_
mechanism_t
::~
gssapi_mechanism
_t
()
zmq
::
gssapi_
server_t
::~
gssapi_server
_t
()
{
}
int
zmq
::
gssapi_
mechanism
_t
::
next_handshake_command
(
msg_t
*
msg_
)
int
zmq
::
gssapi_
server
_t
::
next_handshake_command
(
msg_t
*
msg_
)
{
int
rc
=
0
;
switch
(
state
)
{
case
sending_hello
:
rc
=
produce_hello
(
msg_
);
if
(
rc
==
0
)
state
=
waiting_for_welcome
;
break
;
case
sending_welcome
:
rc
=
produce_welcome
(
msg_
);
if
(
rc
==
0
)
state
=
waiting_for_initiate
;
break
;
case
sending_initiate
:
rc
=
produce_initiate
(
msg_
);
if
(
rc
==
0
)
state
=
waiting_for_token
;
break
;
case
sending_token
:
rc
=
produce_token
(
msg_
);
if
(
rc
==
0
)
state
=
waiting_for_
ready
;
//state = expecting_another_token? waiting_for_token: waiting_for_ready;
state
=
waiting_for_
token
;
//state = expecting_another_token? waiting_for_token: waiting_for_ready;
break
;
case
sending_ready
:
rc
=
produce_ready
(
msg_
);
...
...
@@ -84,7 +74,7 @@ int zmq::gssapi_mechanism_t::next_handshake_command (msg_t *msg_)
return
rc
;
}
int
zmq
::
gssapi_
mechanism
_t
::
process_handshake_command
(
msg_t
*
msg_
)
int
zmq
::
gssapi_
server
_t
::
process_handshake_command
(
msg_t
*
msg_
)
{
int
rc
=
0
;
...
...
@@ -94,11 +84,6 @@ int zmq::gssapi_mechanism_t::process_handshake_command (msg_t *msg_)
if
(
rc
==
0
)
state
=
expecting_zap_reply
?
waiting_for_zap_reply
:
sending_welcome
;
break
;
case
waiting_for_welcome
:
rc
=
process_welcome
(
msg_
);
if
(
rc
==
0
)
state
=
sending_initiate
;
break
;
case
waiting_for_initiate
:
rc
=
process_initiate
(
msg_
);
if
(
rc
==
0
)
...
...
@@ -109,11 +94,6 @@ int zmq::gssapi_mechanism_t::process_handshake_command (msg_t *msg_)
if
(
rc
==
0
)
state
=
sending_ready
;
// state = expecting_another_token? sending_token: sending_ready;
break
;
case
waiting_for_ready
:
rc
=
process_ready
(
msg_
);
if
(
rc
==
0
)
state
=
ready
;
break
;
default
:
errno
=
EPROTO
;
rc
=
-
1
;
...
...
@@ -128,12 +108,12 @@ int zmq::gssapi_mechanism_t::process_handshake_command (msg_t *msg_)
return
rc
;
}
bool
zmq
::
gssapi_
mechanism
_t
::
is_handshake_complete
()
const
bool
zmq
::
gssapi_
server
_t
::
is_handshake_complete
()
const
{
return
state
==
ready
;
}
int
zmq
::
gssapi_
mechanism
_t
::
zap_msg_available
()
int
zmq
::
gssapi_
server
_t
::
zap_msg_available
()
{
if
(
state
!=
waiting_for_zap_reply
)
{
errno
=
EFSM
;
...
...
@@ -145,36 +125,7 @@ int zmq::gssapi_mechanism_t::zap_msg_available ()
return
rc
;
}
int
zmq
::
gssapi_mechanism_t
::
produce_hello
(
msg_t
*
msg_
)
const
{
const
std
::
string
username
=
"admin"
;
zmq_assert
(
username
.
length
()
<
256
);
const
std
::
string
password
=
"secret"
;
zmq_assert
(
password
.
length
()
<
256
);
const
size_t
command_size
=
6
+
1
+
username
.
length
()
+
1
+
password
.
length
();
const
int
rc
=
msg_
->
init_size
(
command_size
);
errno_assert
(
rc
==
0
);
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
memcpy
(
ptr
,
"
\x05
HELLO"
,
6
);
ptr
+=
6
;
*
ptr
++
=
static_cast
<
unsigned
char
>
(
username
.
length
());
memcpy
(
ptr
,
username
.
c_str
(),
username
.
length
());
ptr
+=
username
.
length
();
*
ptr
++
=
static_cast
<
unsigned
char
>
(
password
.
length
());
memcpy
(
ptr
,
password
.
c_str
(),
password
.
length
());
ptr
+=
password
.
length
();
return
0
;
}
int
zmq
::
gssapi_mechanism_t
::
process_hello
(
msg_t
*
msg_
)
int
zmq
::
gssapi_server_t
::
process_hello
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
...
...
@@ -236,7 +187,7 @@ int zmq::gssapi_mechanism_t::process_hello (msg_t *msg_)
return
0
;
}
int
zmq
::
gssapi_
mechanism
_t
::
produce_welcome
(
msg_t
*
msg_
)
const
int
zmq
::
gssapi_
server
_t
::
produce_welcome
(
msg_t
*
msg_
)
const
{
const
int
rc
=
msg_
->
init_size
(
8
);
errno_assert
(
rc
==
0
);
...
...
@@ -244,51 +195,7 @@ int zmq::gssapi_mechanism_t::produce_welcome (msg_t *msg_) const
return
0
;
}
int
zmq
::
gssapi_mechanism_t
::
process_welcome
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
if
(
bytes_left
!=
8
||
memcmp
(
ptr
,
"
\x07
WELCOME"
,
8
))
{
errno
=
EPROTO
;
return
-
1
;
}
return
0
;
}
int
zmq
::
gssapi_mechanism_t
::
produce_initiate
(
msg_t
*
msg_
)
const
{
unsigned
char
*
const
command_buffer
=
(
unsigned
char
*
)
malloc
(
512
);
alloc_assert
(
command_buffer
);
unsigned
char
*
ptr
=
command_buffer
;
// Add mechanism string
memcpy
(
ptr
,
"
\x08
INITIATE"
,
9
);
ptr
+=
9
;
// Add socket type property
const
char
*
socket_type
=
socket_type_string
(
options
.
type
);
ptr
+=
add_property
(
ptr
,
"Socket-Type"
,
socket_type
,
strlen
(
socket_type
));
// Add identity property
if
(
options
.
type
==
ZMQ_REQ
||
options
.
type
==
ZMQ_DEALER
||
options
.
type
==
ZMQ_ROUTER
)
{
ptr
+=
add_property
(
ptr
,
"Identity"
,
options
.
identity
,
options
.
identity_size
);
}
const
size_t
command_size
=
ptr
-
command_buffer
;
const
int
rc
=
msg_
->
init_size
(
command_size
);
errno_assert
(
rc
==
0
);
memcpy
(
msg_
->
data
(),
command_buffer
,
command_size
);
free
(
command_buffer
);
return
0
;
}
int
zmq
::
gssapi_mechanism_t
::
process_initiate
(
msg_t
*
msg_
)
int
zmq
::
gssapi_server_t
::
process_initiate
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
...
...
@@ -302,7 +209,7 @@ int zmq::gssapi_mechanism_t::process_initiate (msg_t *msg_)
return
parse_metadata
(
ptr
,
bytes_left
);
}
int
zmq
::
gssapi_
mechanism
_t
::
produce_token
(
msg_t
*
msg_
)
const
int
zmq
::
gssapi_
server
_t
::
produce_token
(
msg_t
*
msg_
)
const
{
unsigned
char
*
const
command_buffer
=
(
unsigned
char
*
)
malloc
(
512
);
alloc_assert
(
command_buffer
);
...
...
@@ -334,7 +241,7 @@ int zmq::gssapi_mechanism_t::produce_token (msg_t *msg_) const
return
0
;
}
int
zmq
::
gssapi_
mechanism
_t
::
process_token
(
msg_t
*
msg_
)
int
zmq
::
gssapi_
server
_t
::
process_token
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
...
...
@@ -351,7 +258,7 @@ int zmq::gssapi_mechanism_t::process_token (msg_t *msg_)
return
parse_metadata
(
ptr
,
bytes_left
);
}
int
zmq
::
gssapi_
mechanism
_t
::
produce_ready
(
msg_t
*
msg_
)
const
int
zmq
::
gssapi_
server
_t
::
produce_ready
(
msg_t
*
msg_
)
const
{
unsigned
char
*
const
command_buffer
=
(
unsigned
char
*
)
malloc
(
512
);
alloc_assert
(
command_buffer
);
...
...
@@ -383,21 +290,7 @@ int zmq::gssapi_mechanism_t::produce_ready (msg_t *msg_) const
return
0
;
}
int
zmq
::
gssapi_mechanism_t
::
process_ready
(
msg_t
*
msg_
)
{
const
unsigned
char
*
ptr
=
static_cast
<
unsigned
char
*>
(
msg_
->
data
());
size_t
bytes_left
=
msg_
->
size
();
if
(
bytes_left
<
6
||
memcmp
(
ptr
,
"
\x05
READY"
,
6
))
{
errno
=
EPROTO
;
return
-
1
;
}
ptr
+=
6
;
bytes_left
-=
6
;
return
parse_metadata
(
ptr
,
bytes_left
);
}
void
zmq
::
gssapi_mechanism_t
::
send_zap_request
(
const
std
::
string
&
username
,
void
zmq
::
gssapi_server_t
::
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
)
{
int
rc
;
...
...
@@ -474,7 +367,7 @@ void zmq::gssapi_mechanism_t::send_zap_request (const std::string &username,
errno_assert
(
rc
==
0
);
}
int
zmq
::
gssapi_
mechanism
_t
::
receive_and_process_zap_reply
()
int
zmq
::
gssapi_
server
_t
::
receive_and_process_zap_reply
()
{
int
rc
=
0
;
msg_t
msg
[
7
];
// ZAP reply consists of 7 frames
...
...
src/gssapi_
mechanism
.hpp
→
src/gssapi_
server
.hpp
View file @
a4a0dc66
...
...
@@ -17,8 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_GSSAPI_
MECHANISM
_HPP_INCLUDED__
#define __ZMQ_GSSAPI_
MECHANISM
_HPP_INCLUDED__
#ifndef __ZMQ_GSSAPI_
SERVER
_HPP_INCLUDED__
#define __ZMQ_GSSAPI_
SERVER
_HPP_INCLUDED__
#include "mechanism.hpp"
#include "options.hpp"
...
...
@@ -29,14 +29,14 @@ namespace zmq
class
msg_t
;
class
session_base_t
;
class
gssapi_
mechanism
_t
:
public
mechanism_t
class
gssapi_
server
_t
:
public
mechanism_t
{
public
:
gssapi_
mechanism
_t
(
session_base_t
*
session_
,
gssapi_
server
_t
(
session_base_t
*
session_
,
const
std
::
string
&
peer_address
,
const
options_t
&
options_
);
virtual
~
gssapi_
mechanism
_t
();
virtual
~
gssapi_
server
_t
();
// mechanism implementation
virtual
int
next_handshake_command
(
msg_t
*
msg_
);
...
...
@@ -47,16 +47,12 @@ namespace zmq
private
:
enum
state_t
{
sending_hello
,
waiting_for_hello
,
sending_welcome
,
waiting_for_welcome
,
sending_initiate
,
waiting_for_initiate
,
sending_token
,
waiting_for_token
,
sending_ready
,
waiting_for_ready
,
waiting_for_zap_reply
,
ready
};
...
...
@@ -72,17 +68,13 @@ namespace zmq
state_t
state
;
int
produce_hello
(
msg_t
*
msg_
)
const
;
int
produce_welcome
(
msg_t
*
msg_
)
const
;
int
produce_initiate
(
msg_t
*
msg_
)
const
;
int
produce_token
(
msg_t
*
msg_
)
const
;
int
produce_ready
(
msg_t
*
msg_
)
const
;
int
process_hello
(
msg_t
*
msg_
);
int
process_welcome
(
msg_t
*
msg
);
int
process_initiate
(
msg_t
*
msg_
);
int
process_token
(
msg_t
*
msg_
);
int
process_ready
(
msg_t
*
msg_
);
void
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
);
...
...
src/stream_engine.cpp
View file @
a4a0dc66
...
...
@@ -43,7 +43,8 @@
#include "v2_decoder.hpp"
#include "null_mechanism.hpp"
#include "plain_mechanism.hpp"
#include "gssapi_mechanism.hpp"
#include "gssapi_client.hpp"
#include "gssapi_server.hpp"
#include "curve_client.hpp"
#include "curve_server.hpp"
#include "raw_decoder.hpp"
...
...
@@ -596,8 +597,11 @@ bool zmq::stream_engine_t::handshake ()
#endif
else
if
(
memcmp
(
greeting_recv
+
12
,
"GSSAPI
\0\0\0\0\0\0\0\0\0\0\0\0\0\0
"
,
20
)
==
0
)
{
mechanism
=
new
(
std
::
nothrow
)
gssapi_mechanism_t
(
session
,
peer_address
,
options
);
if
(
options
.
as_server
)
mechanism
=
new
(
std
::
nothrow
)
gssapi_server_t
(
session
,
peer_address
,
options
);
else
mechanism
=
new
(
std
::
nothrow
)
gssapi_client_t
(
options
);
alloc_assert
(
mechanism
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment