summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjacore.h9
-rw-r--r--python/__init__.py7
-rw-r--r--python/enterprise.py11
3 files changed, 22 insertions, 5 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h
index cf1f09f1..d8f4f9ab 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -2696,10 +2696,11 @@ extern "C"
BINARYNINJACOREAPI bool BNIsEnterpriseServerConnected(void);
BINARYNINJACOREAPI bool BNIsEnterpriseServerAuthenticated(void);
BINARYNINJACOREAPI char* BNGetEnterpriseServerUsername(void);
- BINARYNINJACOREAPI char* BNGetEnterpriseServerName();
- BINARYNINJACOREAPI char* BNGetEnterpriseServerId();
- BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerVersion();
- BINARYNINJACOREAPI char* BNGetEnterpriseServerBuildId();
+ BINARYNINJACOREAPI char* BNGetEnterpriseServerToken(void);
+ BINARYNINJACOREAPI char* BNGetEnterpriseServerName(void);
+ BINARYNINJACOREAPI char* BNGetEnterpriseServerId(void);
+ BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerVersion(void);
+ BINARYNINJACOREAPI char* BNGetEnterpriseServerBuildId(void);
BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerLicenseExpirationTime(void);
BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerLicenseDuration(void);
BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerReservationTimeLimit(void);
diff --git a/python/__init__.py b/python/__init__.py
index 12cb7033..c1af70d4 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -129,7 +129,12 @@ def _init_plugins():
if not core_ui_enabled() and core.BNGetProduct() == "Binary Ninja Enterprise Client":
# Enterprise client needs to checkout a license reservation or else BNInitPlugins will fail
- if not enterprise.authenticate_with_method("Keychain") and (not core.BNIsLicenseValidated() or not enterprise.is_license_still_activated()):
+ if not enterprise.is_license_still_activated():
+ try:
+ enterprise.authenticate_with_method("Keychain")
+ except RuntimeError:
+ pass
+ if not core.BNIsLicenseValidated() or not enterprise.is_license_still_activated():
raise RuntimeError(
"To use Binary Ninja Enterprise from a headless python script, you must check out a license first.\n"
"You can either check out a license for an extended time with the UI, or use the binaryninja.enterprise module.")
diff --git a/python/enterprise.py b/python/enterprise.py
index b94fd7ca..1d9743a1 100644
--- a/python/enterprise.py
+++ b/python/enterprise.py
@@ -99,6 +99,17 @@ def username() -> Optional[str]:
return value
+def token() -> Optional[str]:
+ """
+ Get the token of the currently authenticated user to the Enterprise Server.
+ :return: Token, if authenticated. None, otherwise.
+ """
+ value = core.BNGetEnterpriseServerToken()
+ if value == "":
+ return None
+ return value
+
+
def server_name() -> Optional[str]:
"""
Get the display name of the currently connected server