MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / LicenseCheckout

Method LicenseCheckout

enterprise.cpp:235–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233
234
235BinaryNinja::Enterprise::LicenseCheckout::LicenseCheckout(int64_t duration): m_acquiredLicense(false)
236{
237 // This is a port of python's binaryninja.enterprise.LicenseCheckout
238
239 // UI builds have their own license manager
240 if (BNIsUIEnabled())
241 return;
242
243 if (!IsInitialized())
244 {
245 if (!Initialize())
246 {
247 // Named/computer licenses don't need this flow at all
248 if (!IsFloatingLicense())
249 {
250 return;
251 }
252
253 // Floating licenses though, this is an error. Probably the error
254 // for needing to set enterprise.server.url in settings.json
255 throw EnterpriseException(
256 "Could not initialize Binary Ninja Enterprise: " + GetLastError()
257 );
258 }
259 }
260
261 if (!IsFloatingLicense())
262 {
263 return;
264 }
265 if (!IsConnected())
266 {
267 Connect();
268 }
269 if (!IsAuthenticated())
270 {
271 // Try keychain
272 bool gotAuth = AuthenticateWithMethod("Keychain", false);
273 if (!gotAuth)
274 {
275 char* username = getenv("BN_ENTERPRISE_USERNAME");
276 char* password = getenv("BN_ENTERPRISE_PASSWORD");
277 if (username && password)
278 {
279 gotAuth = AuthenticateWithCredentials(username, password, true);
280 }
281 }
282 if (!gotAuth)
283 {
284 throw EnterpriseException(
285 "Could not checkout a license: Not authenticated. Try one of the following: \n"
286 " - Log in and check out a license for an extended time\n"
287 " - Set BN_ENTERPRISE_USERNAME and BN_ENTERPRISE_PASSWORD environment variables\n"
288 " - Use BinaryNinja::Enterprise::AuthenticateWithCredentials or AuthenticateWithMethod in your code"
289 );
290 }
291 }
292

Callers 5

_init_pluginsFunction · 0.80
mainFunction · 0.80
multitool.pyFile · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 1

EnterpriseExceptionClass · 0.85

Tested by 1

mainFunction · 0.64