summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Taylor <alex@vector35.com>2023-03-10 01:59:21 -0500
committerAlexander Taylor <alex@vector35.com>2023-03-10 01:59:21 -0500
commit688a36a98c65c71baafbde9a20926f34ce9b3a5f (patch)
treeb6845ec45b00414a5bfeb4d7fcf632bb75377ca2
parent98f82f57bfc4283d3c00e1da5ac68d2e737c7640 (diff)
Make Enterprise C++ API more clear.
-rw-r--r--enterprise.cpp58
-rw-r--r--enterprise.h10
-rw-r--r--examples/enterprise_test/src/enterprise_test.cpp2
3 files changed, 35 insertions, 35 deletions
diff --git a/enterprise.cpp b/enterprise.cpp
index 3a25162c..52a120ae 100644
--- a/enterprise.cpp
+++ b/enterprise.cpp
@@ -21,21 +21,21 @@
#include "enterprise.h"
#include <time.h>
-using namespace BinaryNinja::EnterpriseServer;
+using namespace BinaryNinja::Enterprise;
-bool BinaryNinja::EnterpriseServer::AuthenticateWithCredentials(const std::string& username, const std::string& password, bool remember)
+bool BinaryNinja::Enterprise::AuthenticateWithCredentials(const std::string& username, const std::string& password, bool remember)
{
return BNAuthenticateEnterpriseServerWithCredentials(username.c_str(), password.c_str(), remember);
}
-bool BinaryNinja::EnterpriseServer::AuthenticateWithMethod(const std::string& method, bool remember)
+bool BinaryNinja::Enterprise::AuthenticateWithMethod(const std::string& method, bool remember)
{
return BNAuthenticateEnterpriseServerWithMethod(method.c_str(), remember);
}
-std::vector<std::pair<std::string, std::string>> BinaryNinja::EnterpriseServer::GetAuthenticationMethods()
+std::vector<std::pair<std::string, std::string>> BinaryNinja::Enterprise::GetAuthenticationMethods()
{
char** methods;
char** names;
@@ -54,49 +54,49 @@ std::vector<std::pair<std::string, std::string>> BinaryNinja::EnterpriseServer::
}
-bool BinaryNinja::EnterpriseServer::Deauthenticate()
+bool BinaryNinja::Enterprise::Deauthenticate()
{
return BNDeauthenticateEnterpriseServer();
}
-void BinaryNinja::EnterpriseServer::CancelAuthentication()
+void BinaryNinja::Enterprise::CancelAuthentication()
{
return BNCancelEnterpriseServerAuthentication();
}
-bool BinaryNinja::EnterpriseServer::Connect()
+bool BinaryNinja::Enterprise::Connect()
{
return BNConnectEnterpriseServer();
}
-bool BinaryNinja::EnterpriseServer::AcquireLicense(uint64_t timeout)
+bool BinaryNinja::Enterprise::UpdateLicense(uint64_t timeout)
{
return BNAcquireEnterpriseServerLicense(timeout);
}
-bool BinaryNinja::EnterpriseServer::ReleaseLicense()
+bool BinaryNinja::Enterprise::ReleaseLicense()
{
return BNReleaseEnterpriseServerLicense();
}
-bool BinaryNinja::EnterpriseServer::IsConnected()
+bool BinaryNinja::Enterprise::IsConnected()
{
return BNIsEnterpriseServerConnected();
}
-bool BinaryNinja::EnterpriseServer::IsAuthenticated()
+bool BinaryNinja::Enterprise::IsAuthenticated()
{
return BNIsEnterpriseServerAuthenticated();
}
-std::string BinaryNinja::EnterpriseServer::GetUsername()
+std::string BinaryNinja::Enterprise::GetUsername()
{
char* value = BNGetEnterpriseServerUsername();
std::string result = value;
@@ -105,7 +105,7 @@ std::string BinaryNinja::EnterpriseServer::GetUsername()
}
-std::string BinaryNinja::EnterpriseServer::GetToken()
+std::string BinaryNinja::Enterprise::GetToken()
{
char* value = BNGetEnterpriseServerToken();
std::string result = value;
@@ -114,7 +114,7 @@ std::string BinaryNinja::EnterpriseServer::GetToken()
}
-std::string BinaryNinja::EnterpriseServer::GetServerName()
+std::string BinaryNinja::Enterprise::GetServerName()
{
char* value = BNGetEnterpriseServerName();
std::string result = value;
@@ -123,7 +123,7 @@ std::string BinaryNinja::EnterpriseServer::GetServerName()
}
-std::string BinaryNinja::EnterpriseServer::GetServerId()
+std::string BinaryNinja::Enterprise::GetServerId()
{
char* value = BNGetEnterpriseServerId();
std::string result = value;
@@ -132,13 +132,13 @@ std::string BinaryNinja::EnterpriseServer::GetServerId()
}
-uint64_t BinaryNinja::EnterpriseServer::GetServerVersion()
+uint64_t BinaryNinja::Enterprise::GetServerVersion()
{
return BNGetEnterpriseServerVersion();
}
-std::string BinaryNinja::EnterpriseServer::GetServerBuildId()
+std::string BinaryNinja::Enterprise::GetServerBuildId()
{
char* value = BNGetEnterpriseServerBuildId();
std::string result = value;
@@ -147,37 +147,37 @@ std::string BinaryNinja::EnterpriseServer::GetServerBuildId()
}
-uint64_t BinaryNinja::EnterpriseServer::GetLicenseExpirationTime()
+uint64_t BinaryNinja::Enterprise::GetLicenseExpirationTime()
{
return BNGetEnterpriseServerLicenseExpirationTime();
}
-uint64_t BinaryNinja::EnterpriseServer::GetLicenseDuration()
+uint64_t BinaryNinja::Enterprise::GetLicenseDuration()
{
return BNGetEnterpriseServerLicenseDuration();
}
-bool BinaryNinja::EnterpriseServer::IsFloatingLicense()
+bool BinaryNinja::Enterprise::IsFloatingLicense()
{
return BNIsEnterpriseServerFloatingLicense();
}
-uint64_t BinaryNinja::EnterpriseServer::GetReservationTimeLimit()
+uint64_t BinaryNinja::Enterprise::GetReservationTimeLimit()
{
return BNGetEnterpriseServerReservationTimeLimit();
}
-bool BinaryNinja::EnterpriseServer::IsLicenseStillActivated()
+bool BinaryNinja::Enterprise::IsLicenseStillActivated()
{
return BNIsEnterpriseServerLicenseStillActivated();
}
-std::string BinaryNinja::EnterpriseServer::GetLastError()
+std::string BinaryNinja::Enterprise::GetLastError()
{
return BNGetEnterpriseServerLastError();
char* str = BNGetEnterpriseServerLastError();
@@ -187,19 +187,19 @@ std::string BinaryNinja::EnterpriseServer::GetLastError()
}
-void BinaryNinja::EnterpriseServer::RegisterNotification(BNEnterpriseServerCallbacks* notify)
+void BinaryNinja::Enterprise::RegisterNotification(BNEnterpriseServerCallbacks* notify)
{
BNRegisterEnterpriseServerNotification(notify);
}
-void BinaryNinja::EnterpriseServer::UnregisterNotification(BNEnterpriseServerCallbacks* notify)
+void BinaryNinja::Enterprise::UnregisterNotification(BNEnterpriseServerCallbacks* notify)
{
BNUnregisterEnterpriseServerNotification(notify);
}
-BinaryNinja::EnterpriseServer::LicenseCheckout::LicenseCheckout(int64_t duration)
+BinaryNinja::Enterprise::LicenseCheckout::LicenseCheckout(int64_t duration)
{
// This is a port of python's binaryninja.enterprise.LicenseCheckout
@@ -239,7 +239,7 @@ BinaryNinja::EnterpriseServer::LicenseCheckout::LicenseCheckout(int64_t duration
// If we have an expired named license, try to get a fresh floating one
if (!IsLicenseStillActivated() || (!IsFloatingLicense() && (time_t)BNGetLicenseExpirationTime() < time(nullptr)))
{
- if (!EnterpriseServer::AcquireLicense(duration))
+ if (!Enterprise::UpdateLicense(duration))
{
throw EnterpriseException("Could not checkout a license: " + GetLastError());
}
@@ -248,7 +248,7 @@ BinaryNinja::EnterpriseServer::LicenseCheckout::LicenseCheckout(int64_t duration
}
-BinaryNinja::EnterpriseServer::LicenseCheckout::~LicenseCheckout()
+BinaryNinja::Enterprise::LicenseCheckout::~LicenseCheckout()
{
// UI builds have their own license manager
if (BNIsUIEnabled())
@@ -257,6 +257,6 @@ BinaryNinja::EnterpriseServer::LicenseCheckout::~LicenseCheckout()
// Don't release if we got one from keychain
if (m_acquiredLicense)
{
- EnterpriseServer::ReleaseLicense();
+ Enterprise::ReleaseLicense();
}
}
diff --git a/enterprise.h b/enterprise.h
index abf010e9..f6f77de8 100644
--- a/enterprise.h
+++ b/enterprise.h
@@ -31,7 +31,7 @@ namespace BinaryNinja
API for interacting with an Enterprise Server.
These methods will only do anything on Enterprise editions of Binary Ninja.
*/
- namespace EnterpriseServer
+ namespace Enterprise
{
/*!
Custom exception class for all Enterprise functions that can throw exceptions
@@ -85,7 +85,7 @@ namespace BinaryNinja
\param timeout Time (in minutes)
\return True if successful
*/
- bool AcquireLicense(uint64_t timeout);
+ bool UpdateLicense(uint64_t timeout);
/*!
Release the current hold on a license
@@ -197,10 +197,10 @@ namespace BinaryNinja
\code{.cpp}
using namespace BinaryNinja;
- assert(EnterpriseServer::Connect());
- assert(EnterpriseServer::AuthenticateWithCredentials("username", "password", true));
+ assert(Enterprise::Connect());
+ assert(Enterprise::AuthenticateWithCredentials("username", "password", true));
{
- EnterpriseServer::LicenseCheckout _{};
+ Enterprise::LicenseCheckout _{};
Ref<BinaryView> bv = OpenView("/bin/ls", true, {}, options);
printf("%llx\n", bv->GetStart());
// License is released at end of scope
diff --git a/examples/enterprise_test/src/enterprise_test.cpp b/examples/enterprise_test/src/enterprise_test.cpp
index bc2444f5..2a6b42c0 100644
--- a/examples/enterprise_test/src/enterprise_test.cpp
+++ b/examples/enterprise_test/src/enterprise_test.cpp
@@ -36,7 +36,7 @@ int main(int argc, char* argv[])
exit(-1);
}
- EnterpriseServer::LicenseCheckout _{};
+ Enterprise::LicenseCheckout _{};
/* In order to initiate the bundled plugins properly, the location
* of where bundled plugins directory is must be set. */