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 19 matching lines...) Expand all Loading... |
51 }; | 52 }; |
52 | 53 |
53 // Class providing Negotiate (SPNEGO/Kerberos) authentication support on | 54 // Class providing Negotiate (SPNEGO/Kerberos) authentication support on |
54 // Android. The actual authentication is done through an Android authenticator | 55 // Android. The actual authentication is done through an Android authenticator |
55 // provided by third parties who want Kerberos support. This class simply | 56 // provided by third parties who want Kerberos support. This class simply |
56 // provides a bridge to the Java code, and hence to the service. See | 57 // provides a bridge to the Java code, and hence to the service. See |
57 // https://drive.google.com/open?id=1G7WAaYEKMzj16PTHT_cIYuKXJG6bBcrQ7QQBQ6ihOcQ
&authuser=1 | 58 // https://drive.google.com/open?id=1G7WAaYEKMzj16PTHT_cIYuKXJG6bBcrQ7QQBQ6ihOcQ
&authuser=1 |
58 // for the full details. | 59 // for the full details. |
59 class NET_EXPORT_PRIVATE HttpAuthNegotiateAndroid { | 60 class NET_EXPORT_PRIVATE HttpAuthNegotiateAndroid { |
60 public: | 61 public: |
61 // Creates an object for one negotiation session. |account_type| is the | 62 // Creates an object for one negotiation session. |prefs| are the |
62 // Android account type, used by Android to find the correct authenticator. | 63 // authentication preferences. In particular they include the Android account |
63 explicit HttpAuthNegotiateAndroid(const std::string& account_type); | 64 // type, which is used to connect to the correct Android Authenticator. |
| 65 explicit HttpAuthNegotiateAndroid(const HttpAuthPreferences* prefs); |
64 ~HttpAuthNegotiateAndroid(); | 66 ~HttpAuthNegotiateAndroid(); |
65 | 67 |
66 // Register the JNI for this class. | 68 // Register the JNI for this class. |
67 static bool Register(JNIEnv* env); | 69 static bool Register(JNIEnv* env); |
68 | 70 |
69 // Does nothing, but needed for compatibility with the Negotiate | 71 // Does nothing, but needed for compatibility with the Negotiate |
70 // authenticators for other O.S.. Always returns true. | 72 // authenticators for other O.S.. Always returns true. |
71 bool Init(); | 73 bool Init(); |
72 | 74 |
73 // True if authentication needs the identity of the user from Chrome. | 75 // True if authentication needs the identity of the user from Chrome. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 const net::CompletionCallback& callback); | 111 const net::CompletionCallback& callback); |
110 | 112 |
111 // Delegation is allowed on the Kerberos ticket. This allows certain servers | 113 // Delegation is allowed on the Kerberos ticket. This allows certain servers |
112 // to act as the user, such as an IIS server retrieving data from a | 114 // to act as the user, such as an IIS server retrieving data from a |
113 // Kerberized MSSQL server. | 115 // Kerberized MSSQL server. |
114 void Delegate(); | 116 void Delegate(); |
115 | 117 |
116 private: | 118 private: |
117 void SetResultInternal(int result, const std::string& token); | 119 void SetResultInternal(int result, const std::string& token); |
118 | 120 |
119 std::string account_type_; | 121 const HttpAuthPreferences* prefs_; |
120 bool can_delegate_; | 122 bool can_delegate_; |
121 bool first_challenge_; | 123 bool first_challenge_; |
122 std::string server_auth_token_; | 124 std::string server_auth_token_; |
123 std::string* auth_token_; | 125 std::string* auth_token_; |
124 base::android::ScopedJavaGlobalRef<jobject> java_authenticator_; | 126 base::android::ScopedJavaGlobalRef<jobject> java_authenticator_; |
125 net::CompletionCallback completion_callback_; | 127 net::CompletionCallback completion_callback_; |
126 | 128 |
127 base::WeakPtrFactory<HttpAuthNegotiateAndroid> weak_factory_; | 129 base::WeakPtrFactory<HttpAuthNegotiateAndroid> weak_factory_; |
128 | 130 |
129 DISALLOW_COPY_AND_ASSIGN(HttpAuthNegotiateAndroid); | 131 DISALLOW_COPY_AND_ASSIGN(HttpAuthNegotiateAndroid); |
130 }; | 132 }; |
131 | 133 |
132 } // namespace android | 134 } // namespace android |
133 } // namespace net | 135 } // namespace net |
134 | 136 |
135 #endif // NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ | 137 #endif // NET_ANDROID_HTTP_AUTH_NEGOTIATE_ANDROID_H_ |
OLD | NEW |