def sslinfo(): if (nrm_config["debug"] > 0): utils.nprint("SVC: SSLINFO_DN:", request.environ.get('HTTP_X_SSL_CLIENT_S_DN')) #utils.nprint("SSL_0: ", request.__dict__) #utils.nprint("SSL_1: ", request.headers) #utils.nprint("SSL_2: ", request.environ) udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') vuser = "******" with mydb_session() as s: results = sensenrm_db.validate_user(s, udn) if results: vuser = "******" return """ MRM-info: {} Version-info: {} NRMHost: {} SSL-Verified: {} SSL-DN: {} IP: {} AUTHZ-USER: {} """.format(title_info, version_info, request.environ.get('HTTP_X_MYHOST'), request.environ.get('HTTP_X_SSL_CLIENT_VERIFY'), request.environ.get('HTTP_X_SSL_CLIENT_S_DN'), request.environ.get('HTTP_X_REAL_IP'), vuser)
def put(self, deltaid): if (nrm_config["debug"] > 3): utils.nprint("SVC: CANCEL PUT ID=", deltaid) utils.nprint("SVC: CANCEL_SSL_DN:", request.environ.get('HTTP_X_SSL_CLIENT_S_DN')) udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') with mydb_session() as s: results = sensenrm_db.validate_user(s, udn) if results: status, resp = nrmcancel.cancel(deltaid, udn, "") if status == 200: if (nrm_config["debug"] > 3): utils.nprint("SVC: CANCEL_OK:", status) return {'result': "CANCELED"}, status elif status == 400: if (nrm_config["debug"] > 3): utils.nprint("SVC: CANCELLED_with_400:", status) return {'result': "CANCELED"}, 200 else: if (nrm_config["debug"] > 3): utils.nprint("SVC: CANCEL_FAILED:", status) return {'result': "FAILED", 'mesg': str(resp)}, status else: return { 'result': str("FAILED"), 'mesg': str("UNAUTHORIZED_USER") }, 403 return {'result': True}, 200
def get(self): if (nrm_config["debug"] > 3): utils.nprint("SVC: ALL_DELTAS GET: ", request.environ.get('HTTP_X_SSL_CLIENT_S_DN')) udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') with mydb_session() as s: isauthz = sensenrm_db.validate_user(s, udn) if isauthz: alldeltas = sensenrm_db.get_all_active_deltas(s, udn) rstatus = 200 return {'deltas': str(alldeltas)}, rstatus else: return {'deltas': str("UNAUTHORIZED_USER")}, 403
def get(self, deltaid): if (nrm_config["debug"] > 3): utils.nprint("SVC: DELTA GET_ID=", deltaid) utils.nprint("SVC: DELTA_SSL_DN:", request.environ.get('HTTP_X_SSL_CLIENT_S_DN')) udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') with mydb_session() as s: results = sensenrm_db.validate_user(s, udn) if results: status, phase = nrmdeltas.getDelta(deltaid, udn) # Status if (nrm_config["debug"] > 3): utils.nprint("SVC: DELTA SUMMARY=", status) return {'state': str(phase), 'deltaid': str(deltaid)}, status else: return { 'state': str("UNAUTHORIZED_USER"), 'deltaid': str(deltaid) }, 403
def put(self): if (nrm_config["debug"] > 3): utils.nprint("SVC: ALL_CANCEL PUT: ", request.environ.get('HTTP_X_SSL_CLIENT_S_DN')) udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') with mydb_session() as s: results = sensenrm_db.validate_user(s, udn) if results: status, allids = nrmcancel.cancelall(udn) if (nrm_config["debug"] > 3): utils.nprint("SVC: ALL_CANCEL:", status) return {'result': str(status), 'deltas': str(allids)}, 200 else: return { 'result': str("FAILED"), 'mesg': str("UNAUTHORIZED_USER") }, 403 return {'result': False}, 201
def post(self): args = self.reqparse.parse_args() if (nrm_config["debug"] > 3): utils.nprint("SVC: DELTAS POST ID: ", args['id']) utils.nprint("SVC: DELTAS_SSL_DN:", request.environ.get('HTTP_X_SSL_CLIENT_S_DN')) udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') with mydb_session() as s: results = sensenrm_db.validate_user(s, udn) if results: deltas, mystatus = nrmdeltas.processDelta(args, udn) if (nrm_config["debug"] > 7): utils.nprint("SVC: DELTA_POST=", mystatus) rstatus = 201 if int(mystatus) != 200: if (nrm_config["debug"] > 3): utils.nprint("SVC: DELTA_POST_ERROR=", mystatus) rstatus = mystatus return {'deltas': marshal(deltas, delta_fields)}, rstatus else: return {'deltas': str("UNAUTHORIZED_USER")}, 403
def put(self, deltaid): if (nrm_config["debug"] > 3): utils.nprint("SVC: COMMIT PUT ID=", deltaid) utils.nprint("SVC: COMMIT_SSL_DN:", request.environ.get('HTTP_X_SSL_CLIENT_S_DN')) udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') with mydb_session() as s: results = sensenrm_db.validate_user(s, udn) if results: status = nrmcommits.commit(deltaid, udn) if status: if (nrm_config["debug"] > 3): utils.nprint("SVC: COMMIT_OK") return {'result': "COMMITTED"}, 200 else: if (nrm_config["debug"] > 3): utils.nprint("SVC: COMMIT_FAILED") return {'result': "FAILED"}, 404 else: return {'result': str("FAILED:UNAUTHORIZED_USER")}, 403 return {'result': True}, 200
def get(self): if (nrm_config["debug"] > 3): utils.nprint("SVC: MODELS GET") udn = request.environ.get('HTTP_X_SSL_CLIENT_S_DN') with mydb_session() as s: results = sensenrm_db.validate_user(s, udn) if results: mymodels, status = nrmmodels.getModel() #mymodels,last_modtime,status = nrmmodels.getModel() if (nrm_config["debug"] > 3): utils.nprint("SVC: MODELS INIT DONE") if status: if (nrm_config["debug"] > 3): utils.nprint("SVC: MODELS RETURNED") #if (nrm_config["debug"]>9): utils.nprint(mymodels) return marshal(mymodels, model_fields) #mycontent = marshal(mymodels, model_fields) #myresp = make_response(jsonify(mycontent)) #myresp.status_code = 200 #return myresp else: if (nrm_config["debug"] > 3): utils.nprint("SVC: MODELS NO_CHANGES HERE") return marshal(mymodels, model_fields) #return {'model': str("NO_CHANGES")}, 304 #my_lasttime = time_rfc1123_from_datetime(last_modtime) #mymodels = [{"id":str(""),"href":str(""),"creationTime":str(time_rfc1123()),"model":str("")}] #mycontent = marshal(mymodels, model_fields) #myresp = make_response(jsonify(mycontent)) #myresp.headers["Last-Modified"] = str(my_lasttime) #myresp.headers["content-type"] = "application/json" #myresp.status_code = 200 ##myresp.status_code = 304 #return myresp else: mymodels = "UNAUTHORIZED_USER" if (nrm_config["debug"] > 3): utils.nprint("SVC: MODELS 403 INVALID_USER") return {'model': str("UNAUTHORIZED_USER")}, 403