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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/user_authenticator_mac.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "remoting/host/user_authenticator_fake.h" 5 #include "remoting/host/user_authenticator_mac.h"
6
7 #include <Security/Security.h>
8
9 #include <string>
10
11 #include "base/logging.h"
6 12
7 namespace remoting { 13 namespace remoting {
8 14
15 static const char kAuthorizationRightName[] = "system.login.tty";
16
17 UserAuthenticatorMac::UserAuthenticatorMac() {
18 }
19
20 UserAuthenticatorMac::~UserAuthenticatorMac() {
21 }
22
23 bool UserAuthenticatorMac::Authenticate(const std::string& username,
24 const std::string& password) {
25 // The authorization right being requested. This particular right allows
26 // testing of a username/password, as if the user were logging on to the
27 // system locally.
28 AuthorizationItem right;
29 right.name = kAuthorizationRightName;
30 right.valueLength = 0;
31 right.value = NULL;
32 right.flags = 0;
33 AuthorizationRights rights;
34 rights.count = 1;
35 rights.items = &right;
36 // Passing the username/password as an "environment" parameter causes these
37 // to be submitted to the Security Framework, instead of the interactive
38 // password prompt appearing on the host system. Valid on OS X 10.4 and
39 // later versions.
40 AuthorizationItem environment_items[2];
41 environment_items[0].name = kAuthorizationEnvironmentUsername;
42 environment_items[0].valueLength = username.size();
43 environment_items[0].value = const_cast<char*>(username.data());
44 environment_items[0].flags = 0;
45 environment_items[1].name = kAuthorizationEnvironmentPassword;
46 environment_items[1].valueLength = password.size();
47 environment_items[1].value = const_cast<char*>(password.data());
48 environment_items[1].flags = 0;
49 AuthorizationEnvironment environment;
50 environment.count = 2;
51 environment.items = environment_items;
52
53 OSStatus status = AuthorizationCreate(&rights, &environment,
54 kAuthorizationFlagExtendRights,
55 NULL);
56 switch (status) {
57 case errAuthorizationSuccess:
58 return true;
59
60 case errAuthorizationDenied:
61 return false;
62
63 default:
64 LOG(ERROR) << "AuthorizationCreate returned " << status;
65 return false;
66 }
67 }
68
9 // static 69 // static
10 UserAuthenticator* UserAuthenticator::Create() { 70 UserAuthenticator* UserAuthenticator::Create() {
11 return new UserAuthenticatorFake(); 71 return new UserAuthenticatorMac();
12 } 72 }
13 73
14 } // namespace remoting 74 } // namespace remoting
OLDNEW
« 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