gssapi_server.hpp 2.28 KB
Newer Older
1
/*
2
    Copyright (c) 2007-2015 Contributors as noted in the AUTHORS file
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

    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/>.
*/

20 21
#ifndef __ZMQ_GSSAPI_SERVER_HPP_INCLUDED__
#define __ZMQ_GSSAPI_SERVER_HPP_INCLUDED__
22

Chris Laws's avatar
Chris Laws committed
23 24
#ifdef HAVE_LIBGSSAPI_KRB5

25
#include "gssapi_mechanism_base.hpp"
26 27 28 29 30 31 32

namespace zmq
{

    class msg_t;
    class session_base_t;

33
    class gssapi_server_t :
34
        public gssapi_mechanism_base_t
35 36 37
    {
    public:

38
        gssapi_server_t (session_base_t *session_,
39 40
                            const std::string &peer_address,
                            const options_t &options_);
41
        virtual ~gssapi_server_t ();
42 43 44 45

        // mechanism implementation
        virtual int next_handshake_command (msg_t *msg_);
        virtual int process_handshake_command (msg_t *msg_);
46 47
        virtual int encode (msg_t *msg_);
        virtual int decode (msg_t *msg_);
48
        virtual int zap_msg_available ();
Martin Hurton's avatar
Martin Hurton committed
49
        virtual status_t status () const;
50 51 52 53

    private:

        enum state_t {
54 55
            send_next_token,
            recv_next_token,
56
            expect_zap_reply,
57 58
            send_ready,
            recv_ready,
59
            connected
60 61 62
        };

        session_base_t * const session;
Chris Laws's avatar
Chris Laws committed
63

64
        const std::string peer_address;
Chris Laws's avatar
Chris Laws committed
65

66
        //  Current FSM state
67
        state_t state;
68 69

        //  True iff server considers the client authenticated
70
        bool security_context_established;
71 72

        //  The underlying mechanism type (ignored)
73
        gss_OID doid;
74

75 76 77
        void accept_context ();
        int produce_next_token (msg_t *msg_);
        int process_next_token (msg_t *msg_);
78 79
	void send_zap_request ();
	int receive_and_process_zap_reply();
80 81 82 83 84
    };

}

#endif
Chris Laws's avatar
Chris Laws committed
85 86

#endif