self.debug = False
self.locked = False # switch to mark registration as locked so others cannot overwrite
self.serverAddress = FIND_URI # uri of the SMARTAPI registration service
+ self.serverKeyAddress = FIND_KEY_URI # uri from where the public key can be fecthed from
+ def setServerKeyAddress(self, registrationServerKeyUri):
+ self.serverKeyAddress = registrationServerKeyUri
+
def registrateAndLock(self):
self.locked = True
resp = self.registrate()
# decrypt and return
activity = activity.decrypt(self.aesKey)
- if self.debug:
+ if self.debug and activity is not None:
print"\nRegistration activity:"
activity.turtlePrint()
keyString = ""
key = None
try:
- keyString = HttpClient().sendGet(FIND_KEY_URI)
+ keyString = HttpClient().sendGet(self.serverKeyAddress)
key = SmartAPICrypto().extractPemFormatPublicKey(keyString, "RSA");
except:
print "Failed to get a key from the registration server."
myIdentity = "http://adapt.asema.com/demos/python/datasource/"
adaptServiceIdentity = "http://adapt.asema.com"
-registrationServerUri = "http://find.smart-api.io/smart/v1.0e1.0/access"
+#registrationServerUri = "http://find.smart-api.io/smart/v1.0e1.0/access"
+registrationServerUri = "http://192.168.2.96:8080/smartapifind-core/smart/v1.0e1.0/access"
+registrationServerKeyUri = "http://192.168.2.96:8080/smartapifind-core/smart/v1.0e1.0/key"
PORT = 8111
def run(self):
agent = RegistrationAgent(myIdentity)
agent.setServerAddress(registrationServerUri)
+ agent.setServerKeyAddress(registrationServerKeyUri)
agent.setDebugMode(True)
# registrate