diff options
| -rw-r--r-- | Sluift/client.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp index f1fc2c7..813c180 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2013-2014 Isode Limited. | 2 | * Copyright (c) 2013-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <boost/lambda/lambda.hpp> | 7 | #include <boost/lambda/lambda.hpp> |
| @@ -26,10 +26,11 @@ | |||
| 26 | #include <Swiften/Roster/SetRosterRequest.h> | 26 | #include <Swiften/Roster/SetRosterRequest.h> |
| 27 | #include <Swiften/Presence/SubscriptionManager.h> | 27 | #include <Swiften/Presence/SubscriptionManager.h> |
| 28 | #include <Swiften/Roster/XMPPRosterItem.h> | 28 | #include <Swiften/Roster/XMPPRosterItem.h> |
| 29 | #include <Swiften/Queries/IQRouter.h> | 29 | #include <Swiften/Queries/IQRouter.h> |
| 30 | #include <Swiften/Queries/Requests/GetSoftwareVersionRequest.h> | 30 | #include <Swiften/Queries/Requests/GetSoftwareVersionRequest.h> |
| 31 | #include <Swiften/TLS/PKCS12Certificate.h> | ||
| 31 | #include <Sluift/Lua/FunctionRegistration.h> | 32 | #include <Sluift/Lua/FunctionRegistration.h> |
| 32 | #include <Swiften/Base/foreach.h> | 33 | #include <Swiften/Base/foreach.h> |
| 33 | #include <Swiften/Base/IDGenerator.h> | 34 | #include <Swiften/Base/IDGenerator.h> |
| 34 | #include <Sluift/Lua/Check.h> | 35 | #include <Sluift/Lua/Check.h> |
| 35 | #include <Sluift/Lua/Value.h> | 36 | #include <Sluift/Lua/Value.h> |
| @@ -730,10 +731,33 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( | |||
| 730 | client->getClient()->getDiscoManager()->setCapsNode(Lua::checkString(L, 2)); | 731 | client->getClient()->getDiscoManager()->setCapsNode(Lua::checkString(L, 2)); |
| 731 | return 0; | 732 | return 0; |
| 732 | } | 733 | } |
| 733 | 734 | ||
| 734 | SLUIFT_LUA_FUNCTION_WITH_HELP( | 735 | SLUIFT_LUA_FUNCTION_WITH_HELP( |
| 736 | Client, set_certificate, | ||
| 737 | "Sets a client certificate to use for strong authentication with the server.", | ||
| 738 | "self\n" | ||
| 739 | "file PKCS #12 file\n" | ||
| 740 | "pwd passphrase for the certificate private key\n", | ||
| 741 | "" | ||
| 742 | ) { | ||
| 743 | std::string file; | ||
| 744 | std::string pwd; | ||
| 745 | int index = 2; | ||
| 746 | if (!lua_isnoneornil(L, index)) { | ||
| 747 | file = Lua::checkString(L, index); | ||
| 748 | ++index; | ||
| 749 | if (!lua_isnoneornil(L, index)) { | ||
| 750 | pwd = Lua::checkString(L, index); | ||
| 751 | ++index; | ||
| 752 | } | ||
| 753 | } | ||
| 754 | getClient(L)->getClient()->setCertificate(boost::make_shared<PKCS12Certificate>(file, createSafeByteArray(pwd))); | ||
| 755 | return 0; | ||
| 756 | } | ||
| 757 | |||
| 758 | SLUIFT_LUA_FUNCTION_WITH_HELP( | ||
| 735 | Client, jid, | 759 | Client, jid, |
| 736 | "Returns the JID of this client", | 760 | "Returns the JID of this client", |
| 737 | "self\n", | 761 | "self\n", |
| 738 | "" | 762 | "" |
| 739 | ) { | 763 | ) { |
Swift