(self, iprot, oprot)
| 8 | self.authenticated = {} |
| 9 | |
| 10 | def process(self, iprot, oprot): |
| 11 | trans = oprot.trans |
| 12 | if trans not in self.authenticated: |
| 13 | self.authenticated[trans] = False |
| 14 | oldclose = trans.close |
| 15 | |
| 16 | def wrap(): |
| 17 | if self in self.authenticated: |
| 18 | del self.authenticated[trans] |
| 19 | oldclose() |
| 20 | |
| 21 | trans.close = wrap |
| 22 | authenticated = self.authenticated[trans] |
| 23 | (name, type, seqid) = iprot.readMessageBegin() |
| 24 | |
| 25 | # unknown method |
| 26 | if name not in self._processMap: |
| 27 | iprot.skip(Pyload.TType.STRUCT) |
| 28 | iprot.readMessageEnd() |
| 29 | x = Pyload.TApplicationException(Pyload.TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % name) |
| 30 | oprot.writeMessageBegin(name, Pyload.TMessageType.EXCEPTION, seqid) |
| 31 | x.write(oprot) |
| 32 | oprot.writeMessageEnd() |
| 33 | oprot.trans.flush() |
| 34 | return |
| 35 | |
| 36 | # not logged in |
| 37 | elif not authenticated and not name == "login": |
| 38 | iprot.skip(Pyload.TType.STRUCT) |
| 39 | iprot.readMessageEnd() |
| 40 | # 20 - Not logged in (in situ declared error code) |
| 41 | x = Pyload.TApplicationException(20, 'Not logged in') |
| 42 | oprot.writeMessageBegin(name, Pyload.TMessageType.EXCEPTION, seqid) |
| 43 | x.write(oprot) |
| 44 | oprot.writeMessageEnd() |
| 45 | oprot.trans.flush() |
| 46 | return |
| 47 | |
| 48 | elif not authenticated and name == "login": |
| 49 | args = Pyload.login_args() |
| 50 | args.read(iprot) |
| 51 | iprot.readMessageEnd() |
| 52 | result = Pyload.login_result() |
| 53 | # api login |
| 54 | self.authenticated[trans] = self._handler.checkAuth(args.username, args.password, trans.remoteaddr[0]) |
| 55 | |
| 56 | result.success = True if self.authenticated[trans] else False |
| 57 | oprot.writeMessageBegin("login", Pyload.TMessageType.REPLY, seqid) |
| 58 | result.write(oprot) |
| 59 | oprot.writeMessageEnd() |
| 60 | oprot.trans.flush() |
| 61 | |
| 62 | elif self._handler.isAuthorized(name, authenticated): |
| 63 | self._processMap[name](self, seqid, iprot, oprot) |
| 64 | |
| 65 | else: |
| 66 | #no permission |
| 67 | iprot.skip(Pyload.TType.STRUCT) |
nothing calls this directly
no test coverage detected