gssapi_client.hpp 2.19 KB
Newer Older
1
/*
2
    Copyright (c) 2007-2014 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_CLIENT_HPP_INCLUDED__
#define __ZMQ_GSSAPI_CLIENT_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

namespace zmq
{

    class msg_t;

32
    class gssapi_client_t :
33
        public gssapi_mechanism_base_t
34 35 36
    {
    public:

37 38
        gssapi_client_t (const options_t &options_);
        virtual ~gssapi_client_t ();
39 40 41 42

        // mechanism implementation
        virtual int next_handshake_command (msg_t *msg_);
        virtual int process_handshake_command (msg_t *msg_);
43 44
        virtual int encode (msg_t *msg_);
        virtual int decode (msg_t *msg_);
Martin Hurton's avatar
Martin Hurton committed
45
        virtual status_t status () const;
46 47

    private:
Chris Laws's avatar
Chris Laws committed
48

49
        enum state_t {
50
            call_next_init,
51 52
            send_next_token,
            recv_next_token,
53 54
            send_ready,
            recv_ready,
55
            connected
56 57
        };

Chris Busbey's avatar
Chris Busbey committed
58
        //  Human-readable principal name of the service we are connecting to
59 60
        char * service_name;

61
        //  Current FSM state
62
        state_t state;
63 64 65

        //  Points to either send_tok or recv_tok
        //  during context initialization
66
        gss_buffer_desc *token_ptr;
67 68

        //  The desired underlying mechanism
69
        gss_OID_set_desc mechs;
70 71

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

74
        int initialize_context ();
75 76
        int produce_next_token (msg_t *msg_);
        int process_next_token (msg_t *msg_);
77 78 79 80 81
    };

}

#endif
Chris Laws's avatar
Chris Laws committed
82 83

#endif