Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_HTTP_HTTP_ANDROID_AUTH_NEGOTIATE_H_ | |
| 6 #define NET_HTTP_HTTP_ANDROID_AUTH_NEGOTIATE_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/android/jni_android.h" | |
| 12 #include "base/callback.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/task_runner.h" | |
| 17 #include "net/base/completion_callback.h" | |
| 18 #include "net/http/http_auth.h" | |
| 19 | |
| 20 namespace net { | |
| 21 | |
| 22 class HttpAuthChallengeTokenizer; | |
| 23 | |
| 24 namespace android { | |
| 25 | |
| 26 class NET_EXPORT_PRIVATE AndroidAuthNegotiate { | |
|
cbentzel
2015/06/11 20:51:43
This should probably be named HttpAuthAndroidNegot
aberent
2015/06/15 15:52:19
Actually we almost seem to always put the "Android
| |
| 27 public: | |
| 28 AndroidAuthNegotiate(const std::string& account_type, | |
| 29 const std::string& scheme); | |
|
cbentzel
2015/06/11 20:51:43
scheme isn't needed here because this is only bein
aberent
2015/06/15 15:52:19
Done.
| |
| 30 ~AndroidAuthNegotiate(); | |
| 31 bool Init(); | |
| 32 | |
| 33 bool NeedsIdentity() const; | |
| 34 | |
| 35 bool AllowsExplicitCredentials() const; | |
| 36 | |
| 37 HttpAuth::AuthorizationResult ParseChallenge( | |
| 38 net::HttpAuthChallengeTokenizer* tok); | |
| 39 | |
| 40 // Generates an authentication token. | |
| 41 // | |
| 42 // The return value is an error code. The authentication token will be | |
| 43 // returned in |*auth_token|. If the result code not |OK|, the value of | |
| 44 // |*auth_token| is unspecified. | |
| 45 // | |
| 46 // If the operation cannot be completed synchronously, |ERR_IO_PENDING| will | |
| 47 // be returned and the real result code will be passed to the completion | |
| 48 // callback. Otherwise the result code is returned immediately from this | |
| 49 // call. | |
| 50 // | |
| 51 // If the AndroidAuthNegotiate object is deleted before completion then the | |
| 52 // callback will not be called. | |
| 53 // | |
| 54 // If no immediate result is returned then |auth_token| must remain valid | |
| 55 // until the callback has been called. | |
| 56 // | |
| 57 // |spn| is the Service Principal Name of the server that the token is | |
| 58 // being generated for. | |
| 59 // | |
| 60 // If this is the first round of a multiple round scheme, credentials are | |
| 61 // obtained using |*credentials|. If |credentials| is NULL, the default | |
| 62 // credentials are used instead. | |
| 63 int GenerateAuthToken(const AuthCredentials* credentials, | |
| 64 const std::string& spn, | |
| 65 std::string* auth_token, | |
| 66 const net::CompletionCallback& callback); | |
| 67 | |
| 68 // Delegation is allowed on the Kerberos ticket. This allows certain servers | |
| 69 // to act as the user, such as an IIS server retrieving data from a | |
| 70 // Kerberized MSSQL server. | |
| 71 void Delegate(); | |
| 72 void SetResult(JNIEnv* env, jobject obj, bool result, jstring token); | |
| 73 static bool Register(JNIEnv* env); | |
| 74 | |
| 75 private: | |
| 76 void SetResultInternal(bool result, std::string token); | |
|
cbentzel
2015/06/11 20:51:43
const std::string&
aberent
2015/06/15 15:52:19
Done.
| |
| 77 | |
| 78 std::string account_type_; | |
| 79 std::string scheme_; | |
| 80 bool can_delegate_; | |
| 81 bool first_challenge_; | |
| 82 std::string server_auth_token_; | |
| 83 std::string* auth_token_; | |
| 84 base::android::ScopedJavaGlobalRef<jobject> java_authenticator_; | |
| 85 net::CompletionCallback completion_callback_; | |
| 86 scoped_refptr<base::TaskRunner> callback_task_runner_; | |
| 87 base::Callback<void(bool, std::string)> thread_safe_callback_; | |
| 88 | |
| 89 base::WeakPtrFactory<AndroidAuthNegotiate> weak_factory_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(AndroidAuthNegotiate); | |
| 92 }; | |
| 93 | |
| 94 } // namespace android | |
| 95 } // namespace net | |
| 96 | |
| 97 #endif // NET_HTTP_HTTP_ANDROID_AUTH_NEGOTIATE_H_ | |
| OLD | NEW |