Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: remoting/host/user_authenticator_mac.cc

Issue 6605001: Local Login on Mac, using OS X Security framework (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Convert string literal to static const char[]. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/user_authenticator_mac.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/user_authenticator_mac.cc
diff --git a/remoting/host/user_authenticator_mac.cc b/remoting/host/user_authenticator_mac.cc
index 956484adfd1508013f77d7996112b165be7d8f3b..dd44b06604f1d86d4a1b9aacba2aad8e8ee93f4e 100644
--- a/remoting/host/user_authenticator_mac.cc
+++ b/remoting/host/user_authenticator_mac.cc
@@ -2,13 +2,73 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/user_authenticator_fake.h"
+#include "remoting/host/user_authenticator_mac.h"
+
+#include <Security/Security.h>
+
+#include <string>
+
+#include "base/logging.h"
namespace remoting {
+static const char kAuthorizationRightName[] = "system.login.tty";
+
+UserAuthenticatorMac::UserAuthenticatorMac() {
+}
+
+UserAuthenticatorMac::~UserAuthenticatorMac() {
+}
+
+bool UserAuthenticatorMac::Authenticate(const std::string& username,
+ const std::string& password) {
+ // The authorization right being requested. This particular right allows
+ // testing of a username/password, as if the user were logging on to the
+ // system locally.
+ AuthorizationItem right;
+ right.name = kAuthorizationRightName;
+ right.valueLength = 0;
+ right.value = NULL;
+ right.flags = 0;
+ AuthorizationRights rights;
+ rights.count = 1;
+ rights.items = &right;
+ // Passing the username/password as an "environment" parameter causes these
+ // to be submitted to the Security Framework, instead of the interactive
+ // password prompt appearing on the host system. Valid on OS X 10.4 and
+ // later versions.
+ AuthorizationItem environment_items[2];
+ environment_items[0].name = kAuthorizationEnvironmentUsername;
+ environment_items[0].valueLength = username.size();
+ environment_items[0].value = const_cast<char*>(username.data());
+ environment_items[0].flags = 0;
+ environment_items[1].name = kAuthorizationEnvironmentPassword;
+ environment_items[1].valueLength = password.size();
+ environment_items[1].value = const_cast<char*>(password.data());
+ environment_items[1].flags = 0;
+ AuthorizationEnvironment environment;
+ environment.count = 2;
+ environment.items = environment_items;
+
+ OSStatus status = AuthorizationCreate(&rights, &environment,
+ kAuthorizationFlagExtendRights,
+ NULL);
+ switch (status) {
+ case errAuthorizationSuccess:
+ return true;
+
+ case errAuthorizationDenied:
+ return false;
+
+ default:
+ LOG(ERROR) << "AuthorizationCreate returned " << status;
+ return false;
+ }
+}
+
// static
UserAuthenticator* UserAuthenticator::Create() {
- return new UserAuthenticatorFake();
+ return new UserAuthenticatorMac();
}
} // namespace remoting
« no previous file with comments | « remoting/host/user_authenticator_mac.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698