Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_interfaces.py 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. ###############################################################################
  2. #
  3. # The MIT License (MIT)
  4. #
  5. # Copyright (c) typedef int GmbH
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. # THE SOFTWARE.
  24. #
  25. ###############################################################################
  26. import abc
  27. class IMarketMaker(abc.ABC):
  28. """
  29. XBR Market Maker interface.
  30. """
  31. @abc.abstractmethod
  32. def status(self, details):
  33. """
  34. :param details:
  35. :return:
  36. """
  37. @abc.abstractmethod
  38. def offer(self, key_id, price, details):
  39. """
  40. :param key_id:
  41. :param price:
  42. :param details:
  43. :return:
  44. """
  45. @abc.abstractmethod
  46. def revoke(self, key_id, details):
  47. """
  48. :param key_id:
  49. :param details:
  50. :return:
  51. """
  52. @abc.abstractmethod
  53. def quote(self, key_id, details):
  54. """
  55. :param key_id:
  56. :param details:
  57. :return:
  58. """
  59. @abc.abstractmethod
  60. def buy(self, channel_id, channel_seq, buyer_pubkey, datakey_id, amount, balance, signature, details):
  61. """
  62. :param channel_id:
  63. :param channel_seq:
  64. :param buyer_pubkey:
  65. :param datakey_id:
  66. :param amount:
  67. :param balance:
  68. :param signature:
  69. :param details:
  70. :return:
  71. """
  72. @abc.abstractmethod
  73. def get_payment_channels(self, address, details):
  74. """
  75. :param address:
  76. :param details:
  77. :return:
  78. """
  79. @abc.abstractmethod
  80. def get_payment_channel(self, channel_id, details):
  81. """
  82. :param channel_id:
  83. :param details:
  84. :return:
  85. """
  86. class IProvider(abc.ABC):
  87. """
  88. XBR Provider interface.
  89. """
  90. @abc.abstractmethod
  91. def sell(self, key_id, buyer_pubkey, amount_paid, post_balance, signature, details):
  92. """
  93. :param key_id:
  94. :param buyer_pubkey:
  95. :param amount_paid:
  96. :param post_balance:
  97. :param signature:
  98. :param details:
  99. :return:
  100. """
  101. class IConsumer(abc.ABC):
  102. """
  103. XBR Consumer interface.
  104. """
  105. class ISeller(abc.ABC):
  106. """
  107. XBR Seller interface.
  108. """
  109. @abc.abstractmethod
  110. async def start(self, session):
  111. """
  112. :param session:
  113. :return:
  114. """
  115. @abc.abstractmethod
  116. async def wrap(self, uri, payload):
  117. """
  118. :param uri:
  119. :param payload:
  120. :return:
  121. """
  122. class IBuyer(abc.ABC):
  123. """
  124. XBR Buyer interface.
  125. """
  126. @abc.abstractmethod
  127. async def start(self, session):
  128. """
  129. Start buying keys over the provided session.
  130. :param session: WAMP session that allows to talk to the XBR Market Maker.
  131. """
  132. @abc.abstractmethod
  133. async def unwrap(self, key_id, enc_ser, ciphertext):
  134. """
  135. Decrypt and deserialize received XBR payload.
  136. :param key_id: The ID of the datakey the payload is encrypted with.
  137. :type key_id: bytes
  138. :param enc_ser: The serializer that was used for serializing the payload. One of ``cbor``, ``json``, ``msgpack``, ``ubjson``.
  139. :type enc_ser: str
  140. :param ciphertext: The encrypted payload to unwrap.
  141. :type ciphertext: bytes
  142. :returns: The unwrapped application payload.
  143. :rtype: object
  144. """
  145. class IDelegate(ISeller, IBuyer):
  146. """
  147. XBR Delegate interface.
  148. """