Browse code
wiring
Greg Wiley authored on 26/04/2017 18:50:25
Showing 11 changed files
Showing 11 changed files
- conversation.cc
- conversation.h
- dual_control_integrate.cc
- pam.cc
- pam.h
- sys_pwd.cc
- sys_pwd.h
- sys_unistd.cc
- sys_unistd.h
- validator.cc
- validator.h
... | ... |
@@ -45,6 +45,7 @@ public: |
45 | 45 |
{ |
46 | 46 |
return delegate_->initiate (request); |
47 | 47 |
} |
48 |
+ static conversation create (pam &pam); |
|
48 | 49 |
}; |
49 | 50 |
|
50 | 51 |
inline conversation wrap (conversation_ifc *delegate) |
... | ... |
@@ -52,7 +53,6 @@ inline conversation wrap (conversation_ifc *delegate) |
52 | 53 |
return conversation (std::shared_ptr<conversation_ifc> (delegate)); |
53 | 54 |
}; |
54 | 55 |
|
55 |
-conversation create_conversation (pam &pam); |
|
56 | 56 |
|
57 | 57 |
#endif |
58 | 58 |
|
... | ... |
@@ -19,11 +19,33 @@ |
19 | 19 |
|
20 | 20 |
#include "request.h" |
21 | 21 |
#include "dual_control.h" |
22 |
+#include "validator.h" |
|
23 |
+#include "logger.h" |
|
24 |
+#include "conversation.h" |
|
25 |
+#include "user.h" |
|
26 |
+#include "token.h" |
|
27 |
+#include "sys_pwd.h" |
|
28 |
+#include "sys_unistd.h" |
|
29 |
+#include "sys_fstream.h" |
|
30 |
+#include "pam.h" |
|
31 |
+#include "sys_syslog.h" |
|
22 | 32 |
|
23 | 33 |
namespace { |
24 | 34 |
dual_control initialize() { |
25 | 35 |
dual_control_configuration configuration; |
26 |
- // .... |
|
36 |
+ pwd pwd(pwd::create()); |
|
37 |
+ unistd unistd(unistd::create()); |
|
38 |
+ directory directory(directory::create(unistd, pwd)); |
|
39 |
+ fstreams fstreams(fstreams::create()); |
|
40 |
+ user_token_supplier user_token_supplier (user_token_supplier::create(fstreams)); |
|
41 |
+ validator validator(validator::create(directory, user_token_supplier)); |
|
42 |
+ pam pam(pam::create()); |
|
43 |
+ conversation conversation(conversation::create(pam)); |
|
44 |
+ sys_syslog sys_syslog(sys_syslog::create()); |
|
45 |
+ logger logger(logger::create(sys_syslog)); |
|
46 |
+ configuration.validator = validator; |
|
47 |
+ configuration.logger = logger; |
|
48 |
+ configuration.conversation = conversation; |
|
27 | 49 |
return dual_control::create(configuration); |
28 | 50 |
} |
29 | 51 |
dual_control dc = initialize(); |
... | ... |
@@ -9,21 +9,25 @@ |
9 | 9 |
* at https://github.com/cjdev/dual-control. |
10 | 10 |
*/ |
11 | 11 |
|
12 |
+#include <memory> |
|
12 | 13 |
#include <vector> |
13 | 14 |
#include <security/pam_modules.h> |
14 | 15 |
#include <security/pam_appl.h> |
15 | 16 |
|
16 | 17 |
#include "pam.h" |
17 | 18 |
|
18 |
-class syspam : public pam_ifc |
|
19 |
+namespace { |
|
20 |
+class impl : public pam_ifc |
|
19 | 21 |
{ |
20 | 22 |
public: |
21 |
- int get_conv (pam_handle *handle, const pam_conv **pout); |
|
23 |
+ int get_conv (pam_handle *handle, const pam_conv **out) { |
|
24 |
+ return ::pam_get_item(handle, PAM_CONV, (const void **)out); |
|
25 |
+ } |
|
22 | 26 |
}; |
23 |
- |
|
24 |
-int syspam::get_conv (pam_handle *handle, |
|
25 |
- std::shared_ptr<pam_conv_ifc> &out) |
|
26 |
-{ |
|
27 |
- return pam_get_item (handle, PAM_CONV, (const void **)pout); |
|
28 | 27 |
} |
29 | 28 |
|
29 |
+ |
|
30 |
+pam pam::create() { |
|
31 |
+ static pam singleton(std::shared_ptr<pam_ifc>(new impl)); |
|
32 |
+ return singleton; |
|
33 |
+} |
... | ... |
@@ -41,7 +41,7 @@ public: |
41 | 41 |
}; |
42 | 42 |
} |
43 | 43 |
|
44 |
-validator create_validator (const directory &directory, |
|
44 |
+validator validator::create (const directory &directory, |
|
45 | 45 |
const user_token_supplier &user_token_supplier) |
46 | 46 |
{ |
47 | 47 |
std::shared_ptr<validator_ifc> delegate (new impl (directory, |
... | ... |
@@ -42,10 +42,8 @@ public: |
42 | 42 |
{ |
43 | 43 |
return delegate_->validate (user_name, token); |
44 | 44 |
} |
45 |
+ static validator create(const directory &directory, const user_token_supplier &token_supplier); |
|
45 | 46 |
}; |
46 | 47 |
|
47 |
-validator create_validator (const directory &directory, |
|
48 |
- const user_token_supplier &token_supplier); |
|
49 |
- |
|
50 | 48 |
#endif |
51 | 49 |
|