diff --git a/mitel_ommclient2/client.py b/mitel_ommclient2/client.py index 2e6f784..6eccfcb 100644 --- a/mitel_ommclient2/client.py +++ b/mitel_ommclient2/client.py @@ -105,6 +105,15 @@ class OMMClient2: # Determine next possible ppn next_ppn = int(pp.ppn) + 1 + def get_publickey(self): + """ + Get public key for encrypted values + """ + m = messages.GetPublicKey() + r = self.connection.request(m) + r.raise_on_error() + return int(r.modulus, 16), int(r.exponent, 16) + def get_user(self, uid): """ Get PP user @@ -185,7 +194,26 @@ class OMMClient2: m = messages.SetPPUser() m.childs.user = [t] r = self.connection.request(m) - + r.raise_on_error() + if r.childs.user is None: + return None + return r.childs.user[0] + + def set_user_sipauth(self, uid, sipAuthId, sipPw): + """ + Set PP user sip credentials + + :param uid: User id + :param sipAuthId: SIP user name + :param sipPw: Encrypted sip password + """ + t = types.PPUserType() + t.uid = uid + t.sipAuthId = sipAuthId + t.sipPw = sipPw + m = messages.SetPPUser() + m.childs.user = [t] + r = self.connection.request(m) r.raise_on_error() if r.childs.user is None: return None diff --git a/mitel_ommclient2/messages/__init__.py b/mitel_ommclient2/messages/__init__.py index 36ebf85..f376b82 100644 --- a/mitel_ommclient2/messages/__init__.py +++ b/mitel_ommclient2/messages/__init__.py @@ -137,6 +137,7 @@ def response_type(c): from .getaccount import GetAccount, GetAccountResp from .getppdev import GetPPDev, GetPPDevResp from .getppuser import GetPPUser, GetPPUserResp +from .getpublickey import GetPublicKey, GetPublicKeyResp from .open import Open, OpenResp from .ping import Ping, PingResp from .setppuser import SetPPUser, SetPPUserResp diff --git a/mitel_ommclient2/messages/getpublickey.py b/mitel_ommclient2/messages/getpublickey.py new file mode 100644 index 0000000..3e36e85 --- /dev/null +++ b/mitel_ommclient2/messages/getpublickey.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +from . import Request, Response, request_type, response_type + + +@request_type +class GetPublicKey(Request): + pass + + +@response_type +class GetPublicKeyResp(Response): + FIELDS = { + "modulus": str, + "exponent": str, + }