1 | /******************************************************************** |
2 | * Copyright (c) 2013 - 2014, Pivotal Inc. |
3 | * All rights reserved. |
4 | * |
5 | * Author: Zhanwei Wang |
6 | ********************************************************************/ |
7 | /******************************************************************** |
8 | * 2014 - |
9 | * open source under Apache License Version 2.0 |
10 | ********************************************************************/ |
11 | /** |
12 | * Licensed to the Apache Software Foundation (ASF) under one |
13 | * or more contributor license agreements. See the NOTICE file |
14 | * distributed with this work for additional information |
15 | * regarding copyright ownership. The ASF licenses this file |
16 | * to you under the Apache License, Version 2.0 (the |
17 | * "License"); you may not use this file except in compliance |
18 | * with the License. You may obtain a copy of the License at |
19 | * |
20 | * http://www.apache.org/licenses/LICENSE-2.0 |
21 | * |
22 | * Unless required by applicable law or agreed to in writing, software |
23 | * distributed under the License is distributed on an "AS IS" BASIS, |
24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
25 | * See the License for the specific language governing permissions and |
26 | * limitations under the License. |
27 | */ |
28 | #ifndef _HDFS_LIBHDFS3_RPC_SASLCLIENT_H_ |
29 | #define _HDFS_LIBHDFS3_RPC_SASLCLIENT_H_ |
30 | |
31 | #include <gsasl.h> |
32 | |
33 | #include "client/Token.h" |
34 | #include "network/Socket.h" |
35 | #include "RpcAuth.h" |
36 | #include "RpcHeader.pb.h" |
37 | |
38 | namespace Hdfs { |
39 | namespace Internal { |
40 | |
41 | #define SWITCH_TO_SIMPLE_AUTH -88 |
42 | |
43 | class SaslClient { |
44 | public: |
45 | SaslClient(const RpcSaslProto_SaslAuth & auth, const Token & token, |
46 | const std::string & principal); |
47 | |
48 | ~SaslClient(); |
49 | |
50 | std::string evaluateChallenge(const std::string & chanllege); |
51 | |
52 | bool isComplete(); |
53 | |
54 | private: |
55 | void initKerberos(const RpcSaslProto_SaslAuth & auth, |
56 | const std::string & principal); |
57 | void initDigestMd5(const RpcSaslProto_SaslAuth & auth, const Token & token); |
58 | |
59 | private: |
60 | Gsasl * ctx; |
61 | Gsasl_session * session; |
62 | bool complete; |
63 | }; |
64 | |
65 | } |
66 | } |
67 | |
68 | #endif /* _HDFS_LIBHDFS3_RPC_SASLCLIENT_H_ */ |
69 | |