public ExperimentRecord[] RetrieveExperimentRecords(long experimentID, Criterion[] carray) { ExperimentRecord[] records = null; BrokerDB brokerDB = new BrokerDB(); int roles = 0; int userID = 0; int groupID = 0; //long[] expIDs = null; Ticket expTicket = brokerDB.RetrieveTicket(opHeader.coupon, TicketTypes.REDEEM_SESSION); if (expTicket != null && !expTicket.IsExpired()) { //Parse payload, only get what is needed XmlQueryDoc expDoc = new XmlQueryDoc(expTicket.payload); //long expID = -1; string userStr = expDoc.Query("RedeemSessionPayload/userID"); if ((userStr != null) && (userStr.Length > 0)) userID = Convert.ToInt32(userStr); string groupStr = expDoc.Query("RedeemSessionPayload/groupID"); if ((groupStr != null) && (groupStr.Length > 0)) groupID = Convert.ToInt32(groupStr); if (userID > 0) { AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass(); roles = wrapper.GetExperimentAuthorizationWrapper(experimentID, userID, groupID); } if ((roles | ExperimentAccess.READ) == ExperimentAccess.READ) { records = brokerDB.RetrieveExperimentRecords(experimentID, carray); } else { throw new AccessDeniedException("You do not have the required permission to access the experiment"); } } return records; }
public StorageStatus ClientCloseExperiment(long experimentId) { BrokerDB ticketIssuer = new BrokerDB(); StorageStatus status = null; bool experimentClosed = false; //Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId, // opHeader.coupon.passkey); if (ticketIssuer.AuthenticateIssuedCoupon(opHeader.coupon)) { Ticket expTicket = ticketIssuer.RetrieveTicket(opHeader.coupon, TicketTypes.EXECUTE_EXPERIMENT); if (expTicket != null) { // Check for ESS use Ticket essTicket = ticketIssuer.RetrieveTicket(opHeader.coupon, TicketTypes.ADMINISTER_EXPERIMENT); if (essTicket != null) { ProcessAgentInfo ess = ticketIssuer.GetProcessAgentInfo(essTicket.redeemerGuid); if (ess != null) { if (ess.retired) { throw new Exception("The ProcessAgent is retired"); } ExperimentStorageProxy essProxy = new ExperimentStorageProxy(); essProxy.AgentAuthHeaderValue = new AgentAuthHeader(); essProxy.AgentAuthHeaderValue.coupon = ess.identOut; essProxy.Url = ess.webServiceUrl; status = essProxy.CloseExperiment(experimentId); DataStorageAPI.UpdateExperimentStatus(status); } ticketIssuer.CancelIssuedTicket(opHeader.coupon, essTicket); } else { // Close the local Experiment records // Note: store and retrieve tickets are not cancelled. experimentClosed = DataStorageAPI.CloseExperiment(experimentId, StorageStatus.CLOSED_USER); status = DataStorageAPI.RetrieveExperimentStatus(experimentId); } } } return status; }
public Experiment RetrieveExperiment(long experimentID) { Experiment experiment = null; BrokerDB brokerDB = new BrokerDB(); int roles = 0; int userID = 0; int groupID = 0; //long[] expIDs = null; Ticket expTicket = brokerDB.RetrieveTicket(opHeader.coupon, TicketTypes.REDEEM_SESSION); if (expTicket != null && !expTicket.IsExpired()) { //Parse payload, only get what is needed XmlQueryDoc expDoc = new XmlQueryDoc(expTicket.payload); //long expID = -1; string userStr = expDoc.Query("RedeemSessionPayload/userID"); if ((userStr != null) && (userStr.Length > 0)) userID = Convert.ToInt32(userStr); string groupStr = expDoc.Query("RedeemSessionPayload/groupID"); if ((groupStr != null) && (groupStr.Length > 0)) groupID = Convert.ToInt32(groupStr); if (userID > 0) { AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass(); roles = wrapper.GetExperimentAuthorizationWrapper(experimentID, userID, groupID); } if ((roles | ExperimentAccess.READ) == ExperimentAccess.READ) { experiment = new Experiment(); experiment.experimentId = experimentID; experiment.issuerGuid = ProcessAgentDB.ServiceGuid; ProcessAgentInfo ess = brokerDB.GetExperimentESS(experimentID); if (ess != null) { ExperimentStorageProxy essProxy = new ExperimentStorageProxy(); Coupon opCoupon = brokerDB.GetEssOpCoupon(experimentID, TicketTypes.RETRIEVE_RECORDS, 60, ess.agentGuid); if (opCoupon == null) { string payload = TicketLoadFactory.Instance().RetrieveRecordsPayload(experimentID, ess.webServiceUrl); opCoupon = brokerDB.CreateTicket(TicketTypes.RETRIEVE_RECORDS, ess.agentGuid, ProcessAgentDB.ServiceGuid, 60, payload); } essProxy.OperationAuthHeaderValue = new OperationAuthHeader(); essProxy.OperationAuthHeaderValue.coupon = opCoupon; essProxy.Url = ess.webServiceUrl; essProxy.GetRecords(experimentID, null); } } else { throw new AccessDeniedException("You do not have permission to read this experiment"); } } return experiment; }
protected long[] getExperimentIDs(Coupon opCoupon, Criterion[] carray) { BrokerDB brokerDB = new BrokerDB(); int userID = 0; int groupID = 0; long[] expIDs = null; Ticket expTicket = brokerDB.RetrieveTicket(opCoupon, TicketTypes.REDEEM_SESSION); if (expTicket != null && !expTicket.IsExpired()) { //Parse payload, only get what is needed XmlQueryDoc expDoc = new XmlQueryDoc(expTicket.payload); //long expID = -1; string userStr = expDoc.Query("RedeemSessionPayload/userID"); if ((userStr != null) && (userStr.Length > 0)) userID = Convert.ToInt32(userStr); string groupStr = expDoc.Query("RedeemSessionPayload/groupID"); if ((groupStr != null) && (groupStr.Length > 0)) groupID = Convert.ToInt32(groupStr); if (userID > 0) { expIDs = DataStorageAPI.RetrieveAuthorizedExpIDs(userID, groupID, carray); } } return expIDs; }