diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 15:52:00 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 15:52:00 +0000 |
commit | baaf80940b221830d51faee6a110e4ca28775d35 (patch) | |
tree | 59d3dbbe5714c2462cfcc23d78e7842825fe601d /remoting | |
parent | 9d9b7f892057087b4f3fa6c2b80bc32a380d8d11 (diff) | |
download | chromium_src-baaf80940b221830d51faee6a110e4ca28775d35.zip chromium_src-baaf80940b221830d51faee6a110e4ca28775d35.tar.gz chromium_src-baaf80940b221830d51faee6a110e4ca28775d35.tar.bz2 |
Use PAM auth on Linux, and stubs on other platforms.
BUG=None
TEST=Enter correct or incorrect user/password into Local Login prompt.
Review URL: http://codereview.chromium.org/6566006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/chromoting_host_unittest.cc | 4 | ||||
-rw-r--r-- | remoting/host/desktop_environment.cc | 21 | ||||
-rw-r--r-- | remoting/host/desktop_environment.h | 4 | ||||
-rw-r--r-- | remoting/host/desktop_environment_fake.cc | 31 | ||||
-rw-r--r-- | remoting/host/desktop_environment_fake.h | 29 | ||||
-rw-r--r-- | remoting/host/user_authenticator.h | 4 | ||||
-rw-r--r-- | remoting/host/user_authenticator_fake.cc | 19 | ||||
-rw-r--r-- | remoting/host/user_authenticator_fake.h | 33 | ||||
-rw-r--r-- | remoting/host/user_authenticator_linux.cc | 14 | ||||
-rw-r--r-- | remoting/host/user_authenticator_mac.cc | 14 | ||||
-rw-r--r-- | remoting/host/user_authenticator_win.cc | 14 | ||||
-rw-r--r-- | remoting/remoting.gyp | 9 |
12 files changed, 192 insertions, 4 deletions
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index f4a1da7..576aeae 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -6,7 +6,7 @@ #include "remoting/host/capturer_fake.h" #include "remoting/host/chromoting_host.h" #include "remoting/host/chromoting_host_context.h" -#include "remoting/host/desktop_environment.h" +#include "remoting/host/desktop_environment_fake.h" #include "remoting/host/host_mock_objects.h" #include "remoting/host/in_memory_host_config.h" #include "remoting/proto/video.pb.h" @@ -81,7 +81,7 @@ class ChromotingHostTest : public testing::Test { Capturer* capturer = new CapturerFake(context_.main_message_loop()); input_stub_ = new protocol::MockInputStub(); DesktopEnvironment* desktop = - new DesktopEnvironment(capturer, input_stub_); + new DesktopEnvironmentFake(capturer, input_stub_); host_ = ChromotingHost::Create(&context_, config_, desktop); connection_ = new protocol::MockConnectionToClient(); session_ = new protocol::MockSession(); diff --git a/remoting/host/desktop_environment.cc b/remoting/host/desktop_environment.cc index 22628a2..598a632 100644 --- a/remoting/host/desktop_environment.cc +++ b/remoting/host/desktop_environment.cc @@ -6,6 +6,7 @@ #include "remoting/host/capturer.h" #include "remoting/host/chromoting_host.h" +#include "remoting/host/user_authenticator.h" #include "remoting/proto/auth.pb.h" #include "remoting/protocol/client_stub.h" #include "remoting/protocol/input_stub.h" @@ -33,7 +34,25 @@ void DesktopEnvironment::SuggestResolution( void DesktopEnvironment::BeginSessionRequest( const protocol::LocalLoginCredentials* credentials, Task* done) { DCHECK(event_handler_); - event_handler_->LocalLoginSucceeded(); + + bool success = false; + scoped_ptr<UserAuthenticator> authenticator(UserAuthenticator::Create()); + switch (credentials->type()) { + case protocol::PASSWORD: + success = authenticator->Authenticate(credentials->username(), + credentials->credential()); + break; + + default: + LOG(ERROR) << "Invalid credentials type " << credentials->type(); + break; + } + + if (success) { + event_handler_->LocalLoginSucceeded(); + } else { + LOG(WARNING) << "Login failed for user " << credentials->username(); + } done->Run(); delete done; diff --git a/remoting/host/desktop_environment.h b/remoting/host/desktop_environment.h index 2694ef1..16404d7 100644 --- a/remoting/host/desktop_environment.h +++ b/remoting/host/desktop_environment.h @@ -45,9 +45,11 @@ class DesktopEnvironment : public protocol::HostStub { virtual void BeginSessionRequest( const protocol::LocalLoginCredentials* credentials, Task* done); - private: + protected: + // Allow access by DesktopEnvironmentFake for unittest. EventHandler* event_handler_; + private: // Capturer to be used by ScreenRecorder. Once the ScreenRecorder is // constructed this is set to NULL. scoped_ptr<Capturer> capturer_; diff --git a/remoting/host/desktop_environment_fake.cc b/remoting/host/desktop_environment_fake.cc new file mode 100644 index 0000000..36da27a7 --- /dev/null +++ b/remoting/host/desktop_environment_fake.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "remoting/host/desktop_environment_fake.h" + +#include "base/task.h" + +using remoting::protocol::InputStub; + +namespace remoting { + +DesktopEnvironmentFake::DesktopEnvironmentFake(Capturer* capturer, + InputStub* input_stub) + : DesktopEnvironment(capturer, input_stub) { +} + +DesktopEnvironmentFake::~DesktopEnvironmentFake() {} + +void DesktopEnvironmentFake::BeginSessionRequest( + const protocol::LocalLoginCredentials* credentials, Task* done) { + DCHECK(event_handler_); + + // For unit-test, don't require a valid Unix user/password for connection. + event_handler_->LocalLoginSucceeded(); + + done->Run(); + delete done; +} + +} // namespace remoting diff --git a/remoting/host/desktop_environment_fake.h b/remoting/host/desktop_environment_fake.h new file mode 100644 index 0000000..66ec320 --- /dev/null +++ b/remoting/host/desktop_environment_fake.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_FAKE_H_ +#define REMOTING_HOST_DESKTOP_ENVIRONMENT_FAKE_H_ + +#include "remoting/host/desktop_environment.h" + +namespace remoting { + +// A DesktopEnvironmentFake allows connection to proceed for unit-testing, +// without needing a valid user/password for the system. +class DesktopEnvironmentFake : public DesktopEnvironment { + public: + DesktopEnvironmentFake(Capturer* capturer, protocol::InputStub* input_stub); + virtual ~DesktopEnvironmentFake(); + + // Overridden to do no authentication. + virtual void BeginSessionRequest( + const protocol::LocalLoginCredentials* credentials, Task* done); + + private: + DISALLOW_COPY_AND_ASSIGN(DesktopEnvironmentFake); +}; + +} // namespace remoting + +#endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_FAKE_H_ diff --git a/remoting/host/user_authenticator.h b/remoting/host/user_authenticator.h index 10f6cfd..b6f6a7f 100644 --- a/remoting/host/user_authenticator.h +++ b/remoting/host/user_authenticator.h @@ -13,6 +13,7 @@ namespace remoting { // Implementation is platform-specific. // Implementations may assume each instance of this class handles only a // single Authenticate request. + // TODO(lambroslambrou): Decide whether this needs an asychronous interface // (for example AuthenticateStart()..AuthenticateEndCallback()), or whether the // multi-threading policy could be handled by the caller. @@ -20,6 +21,9 @@ class UserAuthenticator { public: virtual ~UserAuthenticator() {} + // Create platform-specific authenticator. + static UserAuthenticator* Create(); + // Authenticate a user, returning true if the username/password are valid. virtual bool Authenticate(const std::string& username, const std::string& password) = 0; diff --git a/remoting/host/user_authenticator_fake.cc b/remoting/host/user_authenticator_fake.cc new file mode 100644 index 0000000..ae8e013 --- /dev/null +++ b/remoting/host/user_authenticator_fake.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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 <string> + +namespace remoting { + +UserAuthenticatorFake::UserAuthenticatorFake() {} +UserAuthenticatorFake::~UserAuthenticatorFake() {} + +bool UserAuthenticatorFake::Authenticate(const std::string& username, + const std::string& password) { + return true; +} + +} // namespace remoting diff --git a/remoting/host/user_authenticator_fake.h b/remoting/host/user_authenticator_fake.h new file mode 100644 index 0000000..f351931 --- /dev/null +++ b/remoting/host/user_authenticator_fake.h @@ -0,0 +1,33 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef REMOTING_HOST_USER_AUTHENTICATOR_FAKE_H_ +#define REMOTING_HOST_USER_AUTHENTICATOR_FAKE_H_ + +#include <string> + +#include "base/basictypes.h" +#include "remoting/host/user_authenticator.h" + +namespace remoting { + +// Temporary stub for platforms where this hasn't been implemented yet. + +// TODO(lambroslambrou): Implement properly on those platforms, then +// delete this stub when it's no longer needed. +class UserAuthenticatorFake : public UserAuthenticator { + public: + UserAuthenticatorFake(); + virtual ~UserAuthenticatorFake(); + + virtual bool Authenticate(const std::string& username, + const std::string& password); + + private: + DISALLOW_COPY_AND_ASSIGN(UserAuthenticatorFake); +}; + +} // namespace remoting + +#endif // REMOTING_HOST_USER_AUTHENTICATOR_FAKE_H_ diff --git a/remoting/host/user_authenticator_linux.cc b/remoting/host/user_authenticator_linux.cc new file mode 100644 index 0000000..d3b837c --- /dev/null +++ b/remoting/host/user_authenticator_linux.cc @@ -0,0 +1,14 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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_pam.h" + +namespace remoting { + +// static +UserAuthenticator* UserAuthenticator::Create() { + return new UserAuthenticatorPam(); +} + +} // namespace remoting diff --git a/remoting/host/user_authenticator_mac.cc b/remoting/host/user_authenticator_mac.cc new file mode 100644 index 0000000..956484a --- /dev/null +++ b/remoting/host/user_authenticator_mac.cc @@ -0,0 +1,14 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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" + +namespace remoting { + +// static +UserAuthenticator* UserAuthenticator::Create() { + return new UserAuthenticatorFake(); +} + +} // namespace remoting diff --git a/remoting/host/user_authenticator_win.cc b/remoting/host/user_authenticator_win.cc new file mode 100644 index 0000000..956484a --- /dev/null +++ b/remoting/host/user_authenticator_win.cc @@ -0,0 +1,14 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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" + +namespace remoting { + +// static +UserAuthenticator* UserAuthenticator::Create() { + return new UserAuthenticatorFake(); +} + +} // namespace remoting diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 4b411f5..0bfec9c 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -221,6 +221,9 @@ 'host/capturer_gdi.h', 'host/event_executor_win.cc', 'host/event_executor_win.h', + 'host/user_authenticator_fake.cc', + 'host/user_authenticator_fake.h', + 'host/user_authenticator_win.cc', ], }], ['OS=="linux"', { @@ -231,6 +234,7 @@ 'host/event_executor_linux.h', 'host/user_authenticator_pam.cc', 'host/user_authenticator_pam.h', + 'host/user_authenticator_linux.cc' ], 'link_settings': { 'libraries': [ @@ -247,6 +251,9 @@ 'host/capturer_mac.h', 'host/event_executor_mac.cc', 'host/event_executor_mac.h', + 'host/user_authenticator_fake.cc', + 'host/user_authenticator_fake.h', + 'host/user_authenticator_mac.cc', ], 'link_settings': { 'libraries': [ @@ -511,6 +518,8 @@ 'host/access_verifier_unittest.cc', 'host/chromoting_host_context_unittest.cc', 'host/chromoting_host_unittest.cc', + 'host/desktop_environment_fake.cc', + 'host/desktop_environment_fake.h', 'host/differ_block_unittest.cc', 'host/differ_unittest.cc', 'host/heartbeat_sender_unittest.cc', |