mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-07-02 23:23:21 +00:00
32 lines
818 B
Python
32 lines
818 B
Python
from .base.device import Device
|
|
from enum import Enum
|
|
|
|
from common.sdk.gm import piico, ccupm, sctu
|
|
|
|
|
|
class CryptoVendor(Enum):
|
|
PIICO = "piico"
|
|
CCUPM = "ccupm"
|
|
SCTU = "sctu"
|
|
|
|
@classmethod
|
|
def from_str(cls, name: str):
|
|
try:
|
|
return cls[name.upper()]
|
|
except KeyError:
|
|
for vendor in cls:
|
|
if vendor.value.lower() == name.lower():
|
|
return vendor
|
|
raise ValueError(f"Unknown GM Vendor: {name}")
|
|
|
|
|
|
def open_gm_device(vendor: CryptoVendor) -> Device:
|
|
if vendor is CryptoVendor.PIICO:
|
|
return piico.PiicoDevice()
|
|
elif vendor is CryptoVendor.CCUPM:
|
|
return ccupm.CCUPMDevice()
|
|
elif vendor is CryptoVendor.SCTU:
|
|
return sctu.SCTUDevice()
|
|
else:
|
|
raise Exception("UnSupported HSM")
|