/// <summary> /// Submits the challenge for the ACME server to validate. /// </summary> /// <param name="authChallenge">The authentication challenge.</param> /// <returns>The challenge updated.</returns> /// <exception cref="InvalidOperationException">If the account key is missing.</exception> public async Task <AcmeResult <ChallengeEntity> > CompleteChallenge(ChallengeEntity authChallenge) { if (this.key == null) { throw new InvalidOperationException(); } var challenge = new ChallengeEntity { KeyAuthorization = ComputeKeyAuthorization(authChallenge), Type = authChallenge.Type }; var result = await this.handler.Post(authChallenge.Uri, challenge, key); ThrowIfError(result); return(new AcmeResult <ChallengeEntity> { Data = result.Data, Json = result.Json, Raw = result.Raw, Links = result.Links, Location = result.Location, ContentType = result.ContentType }); }
/// <summary> /// Computes the DNS value for the <paramref name="challenge"/>. /// </summary> /// <param name="challenge">The challenge.</param> /// <returns>The value for the text DNS record.</returns> /// <exception cref="System.InvalidOperationException">If the provided challenge is not a DNS challenge.</exception> public string ComputeDnsValue(ChallengeEntity challenge) { if (challenge?.Type != ChallengeTypes.Dns01) { throw new InvalidOperationException("The provided challenge is not a DNS challenge."); } return(challenge.ComputeDnsValue(this.key)); }
private async Task StartChallenge() { var authz = await _acmeClient.NewAuthorization(new AuthorizationIdentifier { Type = AuthorizationIdentifierTypes.Dns, Value = Hostname }); _challenge = authz.Data.Challenges.First(c => c.Type == ChallengeTypes.Http01); KeyAuthorisation = _acmeClient.ComputeKeyAuthorization(_challenge); }
public static void UpdateChallenge(Guid desafioId, Guid temporadaId, string name, DateTime startDate, DateTime endDate, int parameter, int goal, int prize, string description) { var challengeUpdate = new ChallengeEntity() { DesafioId = desafioId, TemporadaId = temporadaId, Name = name, StartDate = startDate, EndDate = endDate, Parameter = parameter, Goal = goal, Prize = prize, Description = description }; ChallengesRepository.Get().UpdateChallenge(challengeUpdate); }
public static void InsertNewChallenge(Guid temporadaId, string name, DateTime startDate, DateTime endDate, int parameter, int goal, int prize, string description) { var newChallenge = new ChallengeEntity() { DesafioId = Guid.NewGuid(), TemporadaId = temporadaId, Name = name, StartDate = startDate, EndDate = endDate, Parameter = parameter, Goal = goal, Prize = prize, Description = description }; ChallengesRepository.Get().InsertNewChallenge(newChallenge); }
/// <summary> /// Computes the key authorization string for <paramref name="challenge"/>. /// </summary> /// <param name="challenge">The challenge.</param> /// <returns>The key authorization string.</returns> public string ComputeKeyAuthorization(ChallengeEntity challenge) { return(challenge.ComputeKeyAuthorization(this.key)); }
private ChallengeEntity ComputeCoverageChanges(BuildEntity buildEntity, ReportingContext context, double currentRatio) { if (buildEntity.Status != "succeeded") { return(null); } var previousBuild = context.Builds .OrderByDescending(i => i.Date) .FirstOrDefault(i => i.Definition == buildEntity.Definition && i.Status == "succeeded" && i.CoverageCollection.Any()); if (previousBuild == null) { return(null); } var challenge = new ChallengeEntity { User = buildEntity.User, Build = buildEntity, ModuleCoverages = new List <ModuleChallengeCoverage>() }; var allModules = previousBuild.CoverageCollection.Select(i => i.Name).Union(buildEntity.CoverageCollection.Select(i => i.Name)); foreach (var moduleName in allModules) { var currentModuleName = moduleName; var previousModule = previousBuild.CoverageCollection.FirstOrDefault(i => i.Name == currentModuleName); var currentModule = buildEntity.CoverageCollection.FirstOrDefault(i => i.Name == currentModuleName); if (currentModule != null && previousModule != null && (previousModule.BlocksCovered == currentModule.BlocksCovered && previousModule.BlocksNotCovered == currentModule.BlocksNotCovered)) { continue; // Ignore if no change in the module. } if (currentModule == null) { continue; } var previousModuleCoverage = ComputeBuildCoverage(previousModule); var currentModuleCoverage = ComputeBuildCoverage(currentModule); var deltaCoverage = currentModuleCoverage - previousModuleCoverage; var allBlocks = currentModule.BlocksCovered + currentModule.BlocksNotCovered; challenge.ModuleCoverages.Add(new ModuleChallengeCoverage { Module = currentModuleName, DeltaCoverage = deltaCoverage, Blocks = allBlocks }); } var previousProjectCoverage = ComputeBuildCoverage(previousBuild); var currentProjectCoverage = ComputeBuildCoverage(buildEntity); challenge.Points = (currentProjectCoverage - previousProjectCoverage) * 100 * currentRatio; if (double.IsNaN(challenge.Points)) { challenge.Points = 0; } return(challenge); }
public JsonResult AddChallenge(ChallengeEntity challenge) { var result = ObjectService.AddEntity <ChallengeEntity>(challenge); return(Json(result, JsonRequestBehavior.AllowGet)); }