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

Side by Side Diff: remoting/host/pam_authorization_factory_posix.cc

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: Add the missing new files Created 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/pam_authorization_factory_posix.h" 5 #include "remoting/host/pam_authorization_factory_posix.h"
6 6
7 #include <security/pam_appl.h> 7 #include <security/pam_appl.h>
8 8
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "remoting/protocol/channel_authenticator.h" 11 #include "remoting/protocol/channel_authenticator.h"
12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 namespace { 16 namespace {
17 class PamAuthorizer : public protocol::Authenticator { 17 class PamAuthorizer : public protocol::Authenticator {
18 public: 18 public:
19 PamAuthorizer(scoped_ptr<protocol::Authenticator> underlying); 19 PamAuthorizer(scoped_ptr<protocol::Authenticator> underlying);
20 virtual ~PamAuthorizer(); 20 virtual ~PamAuthorizer();
21 21
22 // protocol::Authenticator interface. 22 // protocol::Authenticator interface.
23 virtual State state() const OVERRIDE; 23 virtual State state() const OVERRIDE;
24 virtual RejectionReason rejection_reason() const OVERRIDE; 24 virtual RejectionReason rejection_reason() const OVERRIDE;
25 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; 25 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE;
26 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; 26 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE;
27 virtual scoped_ptr<protocol::ChannelAuthenticator> 27 virtual scoped_ptr<protocol::ChannelAuthenticator>
28 CreateChannelAuthenticator() const OVERRIDE; 28 CreateChannelAuthenticator() const OVERRIDE;
29 virtual void PerformExternalAction(
30 const base::Closure& resume_callback) OVERRIDE;
29 31
30 private: 32 private:
31 void MaybeCheckLocalLogin(); 33 void MaybeCheckLocalLogin();
32 bool IsLocalLoginAllowed(); 34 bool IsLocalLoginAllowed();
33 35
34 static int PamConversation(int num_messages, 36 static int PamConversation(int num_messages,
35 const struct pam_message** messages, 37 const struct pam_message** messages,
36 struct pam_response** responses, 38 struct pam_response** responses,
37 void* context); 39 void* context);
38 40
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 scoped_ptr<buzz::XmlElement> result (underlying_->GetNextMessage()); 77 scoped_ptr<buzz::XmlElement> result (underlying_->GetNextMessage());
76 MaybeCheckLocalLogin(); 78 MaybeCheckLocalLogin();
77 return result.Pass(); 79 return result.Pass();
78 } 80 }
79 81
80 scoped_ptr<protocol::ChannelAuthenticator> 82 scoped_ptr<protocol::ChannelAuthenticator>
81 PamAuthorizer::CreateChannelAuthenticator() const { 83 PamAuthorizer::CreateChannelAuthenticator() const {
82 return underlying_->CreateChannelAuthenticator(); 84 return underlying_->CreateChannelAuthenticator();
83 } 85 }
84 86
87 void PamAuthorizer::PerformExternalAction(
88 const base::Closure& resume_callback) {
89 underlying_->PerformExternalAction(resume_callback);
90 }
91
92
85 void PamAuthorizer::MaybeCheckLocalLogin() { 93 void PamAuthorizer::MaybeCheckLocalLogin() {
86 if (local_login_status_ == NOT_CHECKED && state() == ACCEPTED) { 94 if (local_login_status_ == NOT_CHECKED && state() == ACCEPTED) {
87 local_login_status_ = IsLocalLoginAllowed() ? ALLOWED : DISALLOWED; 95 local_login_status_ = IsLocalLoginAllowed() ? ALLOWED : DISALLOWED;
88 } 96 }
89 } 97 }
90 98
91 bool PamAuthorizer::IsLocalLoginAllowed() { 99 bool PamAuthorizer::IsLocalLoginAllowed() {
92 std::string username; 100 std::string username;
93 if (!base::Environment::Create()->GetVar("USER", &username)) { 101 if (!base::Environment::Create()->GetVar("USER", &username)) {
94 return false; 102 return false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const std::string& remote_jid, 161 const std::string& remote_jid,
154 const buzz::XmlElement* first_message) { 162 const buzz::XmlElement* first_message) {
155 scoped_ptr<protocol::Authenticator> authenticator( 163 scoped_ptr<protocol::Authenticator> authenticator(
156 underlying_->CreateAuthenticator(local_jid, remote_jid, first_message)); 164 underlying_->CreateAuthenticator(local_jid, remote_jid, first_message));
157 return scoped_ptr<protocol::Authenticator>( 165 return scoped_ptr<protocol::Authenticator>(
158 new PamAuthorizer(authenticator.Pass())); 166 new PamAuthorizer(authenticator.Pass()));
159 } 167 }
160 168
161 169
162 } // namespace remoting 170 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698