OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_ANDROID_HTTP_DUMMY_SPNEGO_AUTHENTICATOR_H_ | |
6 #define NET_ANDROID_HTTP_DUMMY_SPNEGO_AUTHENTICATOR_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <cstdint> | |
10 #include <string> | |
11 | |
12 // Much of the code in this file is only here to duplicate the interfaces of | |
13 // the Mock GSSAPI library, so that we can run the same tests on Android. | |
Ryan Sleevi
2015/06/29 13:56:44
https://groups.google.com/a/chromium.org/forum/#!t
aberent
2015/07/02 21:13:34
Done.
| |
14 | |
15 namespace net { | |
16 | |
17 // These constant values are arbitrary, and different from the real GSSAPI | |
18 // values, but must match those used in DummySpnegoAuthenticator.java | |
19 #define GSS_S_COMPLETE 0 | |
20 #define GSS_S_CONTINUE_NEEDED 1 | |
21 #define GSS_S_FAILURE 2 | |
22 | |
23 class gss_buffer_desc; | |
24 | |
25 typedef struct gss_OID_desc_struct { | |
26 uint32_t length; | |
27 void* elements; | |
28 } gss_OID_desc, *gss_OID; | |
29 | |
30 extern gss_OID CHROME_GSS_SPNEGO_MECH_OID_DESC; | |
31 | |
32 namespace test { | |
33 | |
34 // Copy of class in Mock GSSAPI library. | |
35 class GssContextMockImpl { | |
36 public: | |
37 GssContextMockImpl(); | |
38 GssContextMockImpl(const GssContextMockImpl& other); | |
39 GssContextMockImpl(const char* src_name, | |
40 const char* targ_name, | |
41 uint32_t lifetime_rec, | |
42 const gss_OID_desc& mech_type, | |
43 uint32_t ctx_flags, | |
44 int locally_initiated, | |
45 int open); | |
46 ~GssContextMockImpl(); | |
47 | |
48 void Assign(const GssContextMockImpl& other); | |
49 | |
50 std::string src_name; | |
51 std::string targ_name; | |
52 int32_t lifetime_rec; | |
53 gss_OID_desc mech_type; | |
54 int32_t ctx_flags; | |
55 int locally_initiated; | |
56 int open; | |
57 }; | |
58 | |
59 } // namespace test | |
60 | |
61 namespace android { | |
62 | |
63 // Interface to Java DummySpnegoAuthenticator. | |
64 class DummySpnegoAuthenticator { | |
65 public: | |
66 struct SecurityContextQuery { | |
67 SecurityContextQuery(const std::string& expected_package, | |
68 uint32_t response_code, | |
69 uint32_t minor_response_code, | |
70 const test::GssContextMockImpl& context_info, | |
71 const char* expected_input_token, | |
72 const char* output_token); | |
73 ~SecurityContextQuery(); | |
74 | |
75 std::string expected_package; | |
76 uint32_t response_code; | |
77 uint32_t minor_response_code; | |
78 test::GssContextMockImpl context_info; | |
79 std::string expected_input_token; | |
80 std::string output_token; | |
81 }; | |
82 | |
83 static void EnsureTestAccountExists(); | |
84 static void RemoveTestAccounts(); | |
85 | |
86 void ExpectSecurityContext(const std::string& expected_package, | |
87 uint32_t response_code, | |
88 uint32_t minor_response_code, | |
89 const test::GssContextMockImpl& context_info, | |
90 std::string& expected_input_token, | |
91 std::string& output_token); | |
92 | |
93 static void SetNextResult(int result, const std::string& token); | |
94 | |
95 static bool RegisterJni(JNIEnv* env); | |
96 }; | |
97 | |
98 } // namespace android | |
99 } // namespace net | |
100 | |
101 #endif // NET_ANDROID_HTTP_DUMMY_SPNEGO_AUTHENTICATOR_DRIVER_H | |
OLD | NEW |