def status(self): """ Demo/debug-oriented function, to display the information of all controlled resources """ pat = self.oidch.get_new_pat() resource_reg_endpoint = self.wkh.get( TYPE_UMA_V2, KEY_UMA_V2_RESOURCE_REGISTRATION_ENDPOINT) actual_resources = resource.list(pat, resource_reg_endpoint, self.verify) print("-----------STATUS-----------") print( str(len(self.registered_resources)) + " Locally cached resources, with IDS: " + str(self.registered_resources)) print( str(len(actual_resources)) + " Actual Resources registered in the AS, with IDS: " + str(actual_resources)) print("-----------LIVE INFORMATION FROM AS------") for r in actual_resources: info = resource.read(pat, resource_reg_endpoint, r, secure=self.verify) print(info) print("++++++++++++++++") print("-----------STATUS END-------")
def get_resource(self, resource_id: str): """ Returns the matching resource for resource_id or None if not found """ pat = self.oidch.get_new_pat() resource_reg_endpoint = self.wkh.get( TYPE_UMA_V2, KEY_UMA_V2_RESOURCE_REGISTRATION_ENDPOINT) data = resource.read(pat, resource_reg_endpoint, resource_id, self.verify) if "_id" in data and data["_id"] == resource_id: return data return None
def resource_exists(self, icon_uri: str): """ Checks if the resources managed already contain a resource with that URI. Returns the matching (resource_id, scopes) or None if not found """ pat = self.oidch.get_new_pat() resource_reg_endpoint = self.wkh.get( TYPE_UMA_V2, KEY_UMA_V2_RESOURCE_REGISTRATION_ENDPOINT) r = self.mongo.get_id_from_uri(icon_uri) if not r: return False data = resource.read(pat, resource_reg_endpoint, r, self.verify) if "icon_uri" in data and data["icon_uri"] == icon_uri: return True return False
def resource_exists(self, icon_uri: str) -> (str, str): """ Checks if the resources managed already contain a resource with that URI. Returns the matching (resource_id, scopes) or None if not found """ self.update_resources_from_as() pat = self.oidch.get_new_pat() resource_reg_endpoint = self.wkh.get( TYPE_UMA_V2, KEY_UMA_V2_RESOURCE_REGISTRATION_ENDPOINT) for r in self.registered_resources: data = resource.read(pat, resource_reg_endpoint, r, self.verify) #if "icon_uri" in data and data["icon_uri"] == icon_uri: if "icon_uri" in data: #Default behavior for demo purposes return data["_id"], data["resource_scopes"] return None, None