diff options
Diffstat (limited to 'enterprise.cpp')
| -rw-r--r-- | enterprise.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/enterprise.cpp b/enterprise.cpp index d2f9ccad..ba3b5db7 100644 --- a/enterprise.cpp +++ b/enterprise.cpp @@ -36,6 +36,12 @@ bool BinaryNinja::Enterprise::Initialize() } +bool BinaryNinja::Enterprise::AuthenticateWithToken(const std::string& token, bool remember) +{ + return BNAuthenticateEnterpriseServerWithToken(token.c_str(), remember); +} + + bool BinaryNinja::Enterprise::AuthenticateWithCredentials(const std::string& username, const std::string& password, bool remember) { return BNAuthenticateEnterpriseServerWithCredentials(username.c_str(), password.c_str(), remember); @@ -282,10 +288,19 @@ BinaryNinja::Enterprise::LicenseCheckout::LicenseCheckout(int64_t duration): m_a } if (!gotAuth) { + char* token = getenv("BN_ENTERPRISE_TOKEN"); + if (token) + { + gotAuth = AuthenticateWithToken(token, true); + } + } + if (!gotAuth) + { throw EnterpriseException( "Could not checkout a license: Not authenticated. Try one of the following: \n" " - Log in and check out a license for an extended time\n" " - Set BN_ENTERPRISE_USERNAME and BN_ENTERPRISE_PASSWORD environment variables\n" + " - Set BN_ENTERPRISE_TOKEN environment variable\n" " - Use BinaryNinja::Enterprise::AuthenticateWithCredentials or AuthenticateWithMethod in your code" ); } |
