/// <inheritdoc/> public override Task <BoolResponse> Delete(KeyRequest request, ServerCallContext context) { var tcs = new TaskCompletionSource <BoolResponse>(); this.service.Write( NodeOperation.OperationKind.Delete, request.Key, default(ArraySegment <byte>), OnCommit, OnFailure); return(tcs.Task); void OnCommit() { tcs.TrySetResult(new BoolResponse { Succeeded = true, }); } void OnFailure() { tcs.TrySetResult(new BoolResponse { Succeeded = false, }); } }
public async Task <IActionResult> AdminApprove(int?id) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (userId == null) { return(NotFound()); } if (id == null) { return(NotFound()); } var keyRequest = await _context.KeyRequest.FindAsync(id); if (keyRequest == null) { return(NotFound()); } KeyRequest key = new KeyRequest(); var data = _context.KeyRequest.Where(i => i.Id == id).SingleOrDefault(); key.ProductKey = data.ProductKey; key.Duration = data.Duration; key.LicenseKey = Generate(data.ProductKey, data.Duration); return(View(key)); }
public void Send_KeyRequest() { // A connecting to B // if A doesnt know B's key, the connection starts with a key request // if B doesnt know A's key, once request received from A, B sends a key req KeyRequest keyRequest = new KeyRequest(); if (RequestReceived) { // generate inbound key Debug.Assert(InboundEnc == null); InboundEnc = new RijndaelManaged(); InboundEnc.GenerateKey(); InboundEnc.GenerateIV(); // make packet keyRequest.Encryption = Utilities.CryptType(InboundEnc); keyRequest.Key = InboundEnc.Key; keyRequest.IV = InboundEnc.IV; } Log("Key Request Sent"); SendPacket(keyRequest); }
public void TestPairingKeyResponse() { // We don't have secrets to start with. Secrets secrets = null; // We've just received a message from the server var incomingMessageJsonStr = incomingKeyRequestJson(); // Let's parse it var incomingMessage = Message.FromJson(incomingMessageJsonStr, secrets); Assert.Equal("key_request", incomingMessage.EventName); // Incoming Message is a key_request. var keyRequest = new KeyRequest(incomingMessage); // Let's generate the Secrets and the KeyResponse var result = PairingHelper.GenerateSecretsAndKeyResponse(keyRequest); secrets = result.Secrets; // Save These. They are precious! // Let's Assert KeyResponse values var keyResponse = result.KeyResponse; Assert.NotEmpty(keyResponse.Benc); Assert.NotEmpty(keyResponse.Bhmac); Assert.Equal("62", keyResponse.RequestId); // Let's now prepare to send the key_response back to the server. var msgToSend = keyResponse.ToMessage(); Assert.Equal("62", msgToSend.Id); Assert.NotEmpty((string)msgToSend.Data["enc"]["B"]); Assert.NotEmpty((string)msgToSend.Data["hmac"]["B"]); }
/// <inheritdoc /> public override Task <BoolResponse> Echo(KeyRequest request, ServerCallContext context) { var result = new BoolResponse { Succeeded = !string.IsNullOrEmpty(request.Key), }; return(Task.FromResult(result)); }
public async Task <IActionResult> Key([FromBody] KeyRequest request) { var key = await m_ChainManager.GetKeyAsync(request); if (key == null) { return(NotFound("key not found")); } return(Json(key)); }
public override async Task <UrlAssociationReply> GetUrlByKey(KeyRequest request, ServerCallContext context) { var id = _keyConverter.Decode(request.Key); var address = await _context.Addresses.SingleAsync(a => a.Id == id); return(new UrlAssociationReply { Key = request.Key, Address = address.Url }); }
/// <inheritdoc/> public override async Task <BoolResponse> Delete(KeyRequest request, ServerCallContext context) { var succeeded = await this.service.Write( NodeOperation.OperationKind.Delete, request.Key, default(ArraySegment <byte>)); return(new BoolResponse { Succeeded = succeeded, }); }
public async Task <GetKeyAccountsResponse> GetKeyAsync(KeyRequest request) { try { var keyAccounts = await m_EosApi.GetKeyAccounts(new GetKeyAccountsRequest { public_key = request.PublicKey }); return(keyAccounts); } catch { return(null); } }
public async Task <ActionResult> ProcessKeyRequests(IFormCollection form) { var userManager = serviceProvider.GetService <UserManager <ApplicationUser> >(); var user = await userManager.GetUserAsync(HttpContext.User); string[] campus = form["campus"]; string[] roomNumber = form["roomNumber"]; string[] reasonForAccess = form["reasonForAccess"]; var keyRequest = new KeyRequest { Creation_Date = DateTime.Now, Requestor = user.BannerID, UserId = user.Id, ApplicationUser = user }; applicationDbContext.KeyRequest.Add(keyRequest); applicationDbContext.SaveChanges(); try { for (int i = 0; i < campus.Length; i++) { roomNumber[i] = roomNumber[i].Trim(); var keyRequestLine = new KeyRequestLines { KeyRequestId = applicationDbContext.KeyRequest .Where(k => k.Requestor == user.BannerID) .Where(c => c.Creation_Date == keyRequest.Creation_Date) .FirstOrDefault() .Id, RoomID = roomNumber[i], status = "Waiting for approval.", ReasonForAccess = reasonForAccess[i], Campus = campus[i], ApprovalDate = null, CompletedDate = null }; applicationDbContext.KeyRequestLines.Add(keyRequestLine); await applicationDbContext.SaveChangesAsync(); } return(RedirectToAction("Status", "Status")); } catch (Exception e) { ViewBag.RequestKey = "One of your values entered were incorrect, please try again."; } return(View("RequestKey")); }
private async Task <bool> GetKeyRequest() { var req = new KeyRequest(); var response = await req.Request(new KeyRequestModel { programHash = this.programHash, sessionKey = this.sessionKey }); if (response.result) { return(true); } else { return(false); } }
public async Task <IActionResult> AdminApprove(KeyRequest key) { ModelState.Clear(); var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (userId == null) { return(NotFound()); } var keyRequest = await _context.KeyRequest.FindAsync(key.Id); if (keyRequest == null) { return(NotFound()); } key.LicenseKey = Generate(key.ProductKey, key.Duration); if (ModelState.IsValid) { try { keyRequest.Status = "Approved"; keyRequest.ApprovedDate = DateTime.Now; keyRequest.LicenseKey = key.LicenseKey; keyRequest.Duration = key.Duration; _context.Update(keyRequest); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KeyRequestExists(keyRequest.Id)) { return(NotFound()); } else { throw; } } } return(View(key)); }
public async Task <IActionResult> Create([Bind("Id,ProductKey,LicenseKey,Duration,ShopName,ShopContactNo")] KeyRequest keyRequest) { if (ModelState.IsValid) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); keyRequest.RequestedBy = userId; keyRequest.RequestedDate = DateTime.Now; keyRequest.Status = "Pending"; _context.Add(keyRequest); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(keyRequest)); }
public void Receive_KeyRequest(G2ReceivedPacket embeddedPacket) { KeyRequest request = KeyRequest.Decode(embeddedPacket); if (request.Key != null) { OutboundEnc = new RijndaelManaged(); OutboundEnc.Key = request.Key; OutboundEnc.IV = request.IV; StartEncryption(); } Send_KeyAck(); }
/// <inheritdoc/> public override Task <NodeResponse> Read(KeyRequest request, ServerCallContext context) { var getResult = this.service.Read(request.Key); var value = getResult.Item2 == null ? ByteString.Empty : ByteString.CopyFrom(getResult.Item2); var response = new NodeResponse { Node = new Node { Key = request.Key, Value = value, }, Succeeded = getResult.Item1, }; return(Task.FromResult(response)); }
public async Task <ContentResult <KeyRequest> > GetRequestInfo(string channelID, string key) { KeyRequest requestInfo = null; try { if (channelID == null || key == null) { throw new BaseException(ResultCode.FIELDS_MISSING); } if (!(await _chennelRepo.VerifyChannel(channelID))) { throw new BaseException(ResultCode.INVALID_CHANNEL_ID); } requestInfo = await _requestsRepo.GetRequestInfo(channelID, key); return(new ContentResult <KeyRequest>( requestInfo, true, ResultCode.SUCCESS )); } catch (BaseException e) { return(new ContentResult <KeyRequest>(e)); } catch (Exception e) { _logger.Error(e); return(new ContentResult <KeyRequest>(null, false, ResultCode.UNKNOWN_ERROR, e.Message)); } finally { await Task.Run(() => _logger.Info( $"CheckingRequestInfo: Success={(requestInfo != null)}, " + $"ChannelID=\"{channelID}\", " + $"RecordID={(requestInfo == null ? -1 : requestInfo.ID)}, " + $"IPAddress=\"{Request.HttpContext.Connection.RemoteIpAddress.ToString()}\", " + $"UserAgent=\"{Request.Headers["User-Agent"]}\"" )); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProductKey,LicenseKey,Duration,ShopName,ShopContactNo")] KeyRequest keyRequest) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (userId == null) { return(NotFound()); } if (id != keyRequest.Id) { return(NotFound()); } if (ModelState.IsValid) { try { keyRequest.RequestedBy = userId; keyRequest.RequestedDate = DateTime.Now; keyRequest.Status = "Pending"; _context.Update(keyRequest); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KeyRequestExists(keyRequest.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(keyRequest)); }
/// <summary> /// Get an Artifact upload link. Create a new artifact. /// </summary> /// <exception cref="PollinationSDK.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="owner"></param> /// <param name="name"></param> /// <param name="keyRequest"></param> /// <returns>Task of ApiResponse (S3UploadRequest)</returns> public async System.Threading.Tasks.Task <ApiResponse <S3UploadRequest> > CreateArtifactAsyncWithHttpInfo(string owner, string name, KeyRequest keyRequest) { // verify the required parameter 'owner' is set if (owner == null) { throw new ApiException(400, "Missing required parameter 'owner' when calling ArtifactsApi->CreateArtifact"); } // verify the required parameter 'name' is set if (name == null) { throw new ApiException(400, "Missing required parameter 'name' when calling ArtifactsApi->CreateArtifact"); } // verify the required parameter 'keyRequest' is set if (keyRequest == null) { throw new ApiException(400, "Missing required parameter 'keyRequest' when calling ArtifactsApi->CreateArtifact"); } var localVarPath = "/projects/{owner}/{name}/artifacts"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (owner != null) { localVarPathParams.Add("owner", this.Configuration.ApiClient.ParameterToString(owner)); // path parameter } if (name != null) { localVarPathParams.Add("name", this.Configuration.ApiClient.ParameterToString(name)); // path parameter } if (keyRequest != null && keyRequest.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(keyRequest); // http body (model) parameter } else { localVarPostBody = keyRequest; // byte array } // authentication (Compulsory Auth) required // http basic authentication required if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password)) { localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password); } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateArtifact", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <S3UploadRequest>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), (S3UploadRequest)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(S3UploadRequest)))); }
public static ApduRequest EncodeAuthenticateRequest(KeyRequest<KeySignRequest> request) { var requestBytes = RawMessageCodec.EncodeKeySignRequest(request.Request); return new ApduRequest(AuthenticateCommand, (byte)request.Flags, 0x00, requestBytes.Segment()); }
public static ApduRequest EncodeRegisterRequest(KeyRequest<KeyRegisterRequest> request) { var requestBytes = RawMessageCodec.EncodeKeyRegisterRequest(request.Request); return new ApduRequest(RegisterCommand, (byte)request.Flags, 0x00, requestBytes.Segment()); }
/// <inheritdoc/> public ClientResponse <KeyResponse> ImportKey(Guid?keyId, KeyRequest request) { return(client.ImportKeyAsync(keyId, request).GetAwaiter().GetResult()); }
/// <summary> /// Get an Artifact upload link. Create a new artifact. /// </summary> /// <exception cref="PollinationSDK.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="owner"></param> /// <param name="name"></param> /// <param name="keyRequest"></param> /// <returns>Task of S3UploadRequest</returns> public async System.Threading.Tasks.Task <S3UploadRequest> CreateArtifactAsync(string owner, string name, KeyRequest keyRequest) { ApiResponse <S3UploadRequest> localVarResponse = await CreateArtifactAsyncWithHttpInfo(owner, name, keyRequest); return(localVarResponse.Data); }
public static ApduRequest EncodeAuthenticateRequest(KeyRequest <KeySignRequest> request) { var requestBytes = RawMessageCodec.EncodeKeySignRequest(request.Request); return(new ApduRequest(AuthenticateCommand, (byte)request.Flags, 0x00, requestBytes.Segment())); }
public static ApduRequest EncodeRegisterRequest(KeyRequest <KeyRegisterRequest> request) { var requestBytes = RawMessageCodec.EncodeKeyRegisterRequest(request.Request); return(new ApduRequest(RegisterCommand, (byte)request.Flags, 0x00, requestBytes.Segment())); }
/// <summary> /// Get an Artifact upload link. Create a new artifact. /// </summary> /// <exception cref="PollinationSDK.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="owner"></param> /// <param name="name"></param> /// <param name="keyRequest"></param> /// <returns>S3UploadRequest</returns> public S3UploadRequest CreateArtifact(string owner, string name, KeyRequest keyRequest) { ApiResponse <S3UploadRequest> localVarResponse = CreateArtifactWithHttpInfo(owner, name, keyRequest); return(localVarResponse.Data); }