OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ | 5 #ifndef NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ |
6 #define NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ | 6 #define NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/http/http_auth.h" | 17 #include "net/http/http_auth.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class HttpAuthChallengeTokenizer; | 21 class HttpAuthChallengeTokenizer; |
22 class HttpAuthPreferences; | |
22 | 23 |
23 namespace android { | 24 namespace android { |
24 | 25 |
25 // This class provides a threadsafe wrapper for SetResult, which is called from | 26 // This class provides a threadsafe wrapper for SetResult, which is called from |
26 // Java. A new instance of this class is needed for each call, and the instance | 27 // Java. A new instance of this class is needed for each call, and the instance |
27 // destroys itself when the callback is received. It is written to allow | 28 // destroys itself when the callback is received. It is written to allow |
28 // setResult to be called on any thread, but in practice they will be called | 29 // setResult to be called on any thread, but in practice they will be called |
29 // on the application's main thread. | 30 // on the application's main thread. |
30 // | 31 // |
31 // We cannot use a Callback object here, because there is no way of invoking the | 32 // We cannot use a Callback object here, because there is no way of invoking the |
(...skipping 16 matching lines...) Expand all Loading... | |
48 }; | 49 }; |
49 | 50 |
50 // Class providing Negotiate (SPNEGO/Kerberos) authentication support on | 51 // Class providing Negotiate (SPNEGO/Kerberos) authentication support on |
51 // Android. The actual authentication is done through an Android authenticator | 52 // Android. The actual authentication is done through an Android authenticator |
52 // provided by third parties who want Kerberos support. This class simply | 53 // provided by third parties who want Kerberos support. This class simply |
53 // provides a bridge to the Java code, and hence to the service. See | 54 // provides a bridge to the Java code, and hence to the service. See |
54 // https://drive.google.com/open?id=1G7WAaYEKMzj16PTHT_cIYuKXJG6bBcrQ7QQBQ6ihOcQ &authuser=1 | 55 // https://drive.google.com/open?id=1G7WAaYEKMzj16PTHT_cIYuKXJG6bBcrQ7QQBQ6ihOcQ &authuser=1 |
55 // for the full details. | 56 // for the full details. |
56 class NET_EXPORT_PRIVATE HttpAuthNegotiateAndroid { | 57 class NET_EXPORT_PRIVATE HttpAuthNegotiateAndroid { |
57 public: | 58 public: |
58 // Creates an object for one negotiation session. |account_type| is the | 59 // Creates an object for one negotiation session. |prefs| are the |
59 // Android account type, used by Android to find the correct authenticator. | 60 // authentication preferences. In particular they include the Android account |
60 explicit HttpAuthNegotiateAndroid(const std::string& account_type); | 61 // type, which is used to connect to the correct Android Authenticator. |
62 explicit HttpAuthNegotiateAndroid(HttpAuthPreferences* prefs); | |
asanka
2015/11/25 19:00:09
Let's pass in const references for the auth handle
aberent
2015/11/26 15:58:00
Sadly we can't, because most of the auth handlers
| |
61 ~HttpAuthNegotiateAndroid(); | 63 ~HttpAuthNegotiateAndroid(); |
62 | 64 |
63 // Register the JNI for this class. | 65 // Register the JNI for this class. |
64 static bool Register(JNIEnv* env); | 66 static bool Register(JNIEnv* env); |
65 | 67 |
66 // Does nothing, but needed for compatibility with the Negotiate | 68 // Does nothing, but needed for compatibility with the Negotiate |
67 // authenticators for other O.S.. Always returns true. | 69 // authenticators for other O.S.. Always returns true. |
68 bool Init(); | 70 bool Init(); |
69 | 71 |
70 // True if authentication needs the identity of the user from Chrome. | 72 // True if authentication needs the identity of the user from Chrome. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 const net::CompletionCallback& callback); | 108 const net::CompletionCallback& callback); |
107 | 109 |
108 // Delegation is allowed on the Kerberos ticket. This allows certain servers | 110 // Delegation is allowed on the Kerberos ticket. This allows certain servers |
109 // to act as the user, such as an IIS server retrieving data from a | 111 // to act as the user, such as an IIS server retrieving data from a |
110 // Kerberized MSSQL server. | 112 // Kerberized MSSQL server. |
111 void Delegate(); | 113 void Delegate(); |
112 | 114 |
113 private: | 115 private: |
114 void SetResultInternal(int result, const std::string& token); | 116 void SetResultInternal(int result, const std::string& token); |
115 | 117 |
116 std::string account_type_; | 118 HttpAuthPreferences* prefs_; |
117 bool can_delegate_; | 119 bool can_delegate_; |
118 bool first_challenge_; | 120 bool first_challenge_; |
119 std::string server_auth_token_; | 121 std::string server_auth_token_; |
120 std::string* auth_token_; | 122 std::string* auth_token_; |
121 base::android::ScopedJavaGlobalRef<jobject> java_authenticator_; | 123 base::android::ScopedJavaGlobalRef<jobject> java_authenticator_; |
122 net::CompletionCallback completion_callback_; | 124 net::CompletionCallback completion_callback_; |
123 | 125 |
124 base::WeakPtrFactory<HttpAuthNegotiateAndroid> weak_factory_; | 126 base::WeakPtrFactory<HttpAuthNegotiateAndroid> weak_factory_; |
125 | 127 |
126 DISALLOW_COPY_AND_ASSIGN(HttpAuthNegotiateAndroid); | 128 DISALLOW_COPY_AND_ASSIGN(HttpAuthNegotiateAndroid); |
127 }; | 129 }; |
128 | 130 |
129 } // namespace android | 131 } // namespace android |
130 } // namespace net | 132 } // namespace net |
131 | 133 |
132 #endif // NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ | 134 #endif // NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ |
OLD | NEW |