Exemplo n.º 1
0
	def is_token_valid(token_data):
		ret = True
		#check enable flag
		if( token_data['initialized']!=True or token_data['isValid']!=True):
			ret = False

		#check issue time and expire time
		now_stamp = DatetimeUtil.datetime_timestamp(datetime.datetime.now())
		if( (token_data['issuedate'] > now_stamp) or (now_stamp > token_data['expireddate']) ):
			ret = False
		return ret
Exemplo n.º 2
0
        "--------------------------------------------------------------------")

    # list Access control
    '''json_data=TypesUtil.string_to_json(token_data[-1])
	print("resource: %s" %(json_data['resource']))
	print("action: %s" %(json_data['action']))
	print("conditions: %s" %(json_data['conditions']))'''

    # ----------------------------------- Send transact --------------------------
    #========== set master of domain ========
    #myCapACtoken.assignVZoneMaster(node_address);
    #myCapACtoken.revokeVZoneMaster()

    # ========= set capability flag ========
    #myCapACtoken.initCapToken(node_address);
    #myCapACtoken.setCapToken_isValid(node_address, True)

    # ============= set issue date and expired date ==========
    nowtime = datetime.datetime.now()
    #calculate issue_time and expire_time
    issue_time = DatetimeUtil.datetime_timestamp(nowtime)
    duration = DatetimeUtil.datetime_duration(0, 1, 0, 0)
    expire_time = DatetimeUtil.datetime_timestamp(nowtime + duration)
    #myCapACtoken.setCapToken_expireddate(node_address, issue_time, expire_time)

    #set access right
    #access_right='{"resource":"/BlendCAC/api/v1.0/getCapToken", "action":"GET", "conditions":{"value": {"start": "10:08:32", "end": "23:32:32"},"type": "Timespan"}}';
    #myCapACtoken.setCapToken_authorization(node_address, access_right)

    pass