/// <summary> /// Merges API version information from the specified attributes with the current conventions. /// </summary> /// <param name="attributes">The <see cref="IEnumerable{T}">sequence</see> of attributes to merge.</param> protected virtual void MergeAttributesWithConventions(IEnumerable <object> attributes) { if (VersionNeutral |= attributes.OfType <IApiVersionNeutral>().Any()) { return; } const ApiVersionProviderOptions DeprecatedAdvertised = Deprecated | Advertised; var providers = attributes.OfType <IApiVersionProvider>(); foreach (var provider in providers) { switch (provider.Options) { case None: SupportedVersions.UnionWith(provider.Versions); break; case Deprecated: DeprecatedVersions.UnionWith(provider.Versions); break; case Advertised: AdvertisedVersions.UnionWith(provider.Versions); break; case DeprecatedAdvertised: DeprecatedAdvertisedVersions.UnionWith(provider.Versions); break; } } }
internal static MobileConnectStatus StartAuthentication(IAuthenticationService authentication, DiscoveryResponse discoveryResponse, string encryptedMSISDN, string state, string nonce, MobileConnectConfig config, MobileConnectRequestOptions options) { if (!IsUsableDiscoveryResponse(discoveryResponse)) { return(MobileConnectStatus.StartDiscovery()); } StartAuthenticationResponse response; try { string clientId = discoveryResponse.ResponseData.response.client_id ?? config.ClientId; string authorizationUrl = discoveryResponse.OperatorUrls.AuthorizationUrl; SupportedVersions supportedVersions = discoveryResponse.ProviderMetadata?.MobileConnectVersionSupported; AuthenticationOptions authOptions = options?.AuthenticationOptions ?? new AuthenticationOptions(); authOptions.ClientName = discoveryResponse.ApplicationShortName; response = authentication.StartAuthentication(clientId, authorizationUrl, config.RedirectUrl, state, nonce, encryptedMSISDN, supportedVersions, authOptions); } catch (MobileConnectInvalidArgumentException e) { Log.Error(() => $"An invalid argument was passed to StartAuthentication arg={e.Argument}"); return(MobileConnectStatus.Error(ErrorCodes.InvalidArgument, string.Format("An argument was found to be invalid during the process. The argument was {0}.", e.Argument), e)); } catch (Exception e) { Log.Error(() => $"A general error occurred in AttemptDiscoveryAfterOperatorSelection state={state} nonce={nonce} authUrl={discoveryResponse.OperatorUrls.AuthorizationUrl}"); return(MobileConnectStatus.Error(ErrorCodes.Unknown, "An unknown error occured while generating an authorization url", e)); } return(MobileConnectStatus.Authentication(response.Url, state, nonce)); }
public void GetSupportedVersionShouldReturnNullIfScopeNotRecognised() { var versions = new SupportedVersions(null); var actual = versions.GetSupportedVersion("testest"); Assert.IsNull(actual); }
/// <summary> /// Indicates that the specified API version is supported by the configured action. /// </summary> /// <param name="apiVersion">The supported <see cref="ApiVersion">API version</see> implemented by the action.</param> /// <returns>The original <see cref="ActionApiVersionConventionBuilder"/>.</returns> public virtual ActionApiVersionConventionBuilder HasApiVersion(ApiVersion apiVersion) { Arg.NotNull(apiVersion, nameof(apiVersion)); Contract.Ensures(Contract.Result <ActionApiVersionConventionBuilder>() != null); SupportedVersions.Add(apiVersion); return(this); }
public void IsVersionSupportedShouldReturnTrueIfMaxVersionSupported() { var versions = new SupportedVersions(null); string version = "mc_v1.1"; var actual = versions.IsVersionSupported(version); Assert.IsTrue(actual); }
public void GetSupportedVersionShouldReturnVersionFromDefaultVersionsIfOpenidScopeNotFound() { var versions = new SupportedVersions(null); var expected = "mc_v1.2"; var actual = versions.GetSupportedVersion("openid mc_authz"); Assert.AreEqual(expected, actual); }
public void IsVersionSupportedShouldReturnFalseIfVersionEmpty() { var versions = new SupportedVersions(null); string version = ""; var actual = versions.IsVersionSupported(version); Assert.IsFalse(actual); }
/// <summary> /// Retrieves path to the all compatible R installations from registry. /// </summary> private IEnumerable <IRInterpreterInfo> GetCompatibleEnginesFromRegistry() { var engines = GetInstalledEnginesFromRegistry().Where(e => SupportedVersions.IsCompatibleVersion(e.Version)); // Among duplicates by path take the highest version return (from e in engines group e by e.InstallPath.TrimTrailingSlash() into g select g.OrderByDescending(e => e.Version).First()); }
public void IsVersionSupportedShouldReturnTrueIfLowerThanMaxVersionSupported() { var versions = new SupportedVersions(new Dictionary <string, string> { ["openid"] = "mc_v1.2" }); string version = "mc_v1.1"; var actual = versions.IsVersionSupported(version); Assert.IsTrue(actual); }
public void GetSupportedVersionShouldReturnVersionForOpenidIfScopeNotFound() { var versions = new SupportedVersions(new Dictionary <string, string> { ["openid"] = "1.2", ["openid mc_authn"] = "2.0" }); var expected = "1.2"; var actual = versions.GetSupportedVersion("openid mc_authz"); Assert.AreEqual(expected, actual); }
private bool LoadConfig() { var configFile = new FileInfo(m_dirInf.FullName + "\\templateConfig.cfg"); if (!configFile.Exists) { Log.LogError(String.Format("Tried to load game template {0}, but there was no config file.", m_dirInf.Name)); return(false); } var reader = new StreamReader(configFile.OpenRead()); string sLine = null; while (reader.EndOfStream == false) { sLine = reader.ReadLine(); var splitLine = sLine.Split('='); if (splitLine[0] == ConfigValueNames.DescFilePath) { DescFilePath = splitLine[1]; } else if (splitLine[0] == ConfigValueNames.IconPath) { IconPath = splitLine[1]; } else if (splitLine[0] == ConfigValueNames.CompatibleVersions) { string sVersionsString = splitLine[1]; if (sVersionsString == "all") { continue; } var versions = sVersionsString.Split(';'); for (int i = 0; i < versions.Count(); i++) { var version = new CEVersion(); version.SetFromString(versions[i]); SupportedVersions.Add(version); } } else { Log.LogWarning("Found unknown value while reading game template '" + Name + "' config: '" + splitLine[0] + "'"); } } return(true); }
public override IEnumerable <IRInterpreterInfo> GetCompatibleEngines() { var rFrameworkPath = Path.Combine("/Library/Frameworks/R.framework/Versions"); foreach (var path in _fileSystem.GetDirectories(rFrameworkPath)) { var version = VersionFromPath(path, out var versionString, out var architecture); if (version != null && SupportedVersions.IsCompatibleVersion(version)) { yield return(new RMacInterpreterInfo("R " + versionString, versionString, architecture, version, _fileSystem)); } } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj is NuGetPackageInfo other) { return(string.Equals(other.AssemblyInfo, AssemblyInfo, StringComparison.Ordinal) && string.Equals(other.PackageId, PackageId, StringComparison.Ordinal) && SupportedVersions.SequenceEqual(other.SupportedVersions, new SupportedVersionsComparer())); } return(false); }
public virtual void ApplyTo(HttpActionDescriptor actionDescriptor) { if (actionDescriptor == null) { throw new ArgumentNullException(nameof(actionDescriptor)); } var attributes = new List <object>(); attributes.AddRange(actionDescriptor.GetCustomAttributes <IApiVersionNeutral>(inherit: true)); attributes.AddRange(actionDescriptor.GetCustomAttributes <IApiVersionProvider>(inherit: false)); MergeAttributesWithConventions(attributes); if (VersionNeutral) { actionDescriptor.SetProperty(ApiVersionModel.Neutral); return; } ApiVersionModel?versionModel; if (MappedVersions.Count == 0) { var declaredVersions = SupportedVersions.Union(DeprecatedVersions); versionModel = new ApiVersionModel( declaredVersions, SupportedVersions, DeprecatedVersions, AdvertisedVersions, DeprecatedAdvertisedVersions); } else { var emptyVersions = Empty <ApiVersion>(); versionModel = new ApiVersionModel( declaredVersions: MappedVersions, supportedVersions: emptyVersions, deprecatedVersions: emptyVersions, advertisedVersions: emptyVersions, deprecatedAdvertisedVersions: emptyVersions); } actionDescriptor.SetProperty(versionModel); }
private static Type GetImplementation(SupportedVersions version) { switch (version) { case SupportedVersions.SqlCe31: return(LoadSqlCe31()); case SupportedVersions.SqlCe35: return(LoadSqlCe35()); case SupportedVersions.SqlCe40: return(LoadSqlCe40()); default: throw new NotSupportedException(); } }
private IRInterpreterInfo TryFindRInProgramFiles() { // Force 64-bit PF var programFiles = Environment.GetEnvironmentVariable("ProgramW6432"); var baseRFolder = Path.Combine(programFiles, @"R"); var versions = new List <Version>(); try { if (_fileSystem.DirectoryExists(baseRFolder)) { var directories = _fileSystem .GetDirectoryInfo(baseRFolder) .EnumerateFileSystemInfos() .Where(x => (x.Attributes & FileAttributes.Directory) != 0); foreach (IFileSystemInfo fsi in directories) { string subFolderName = fsi.FullName.Substring(baseRFolder.Length + 1); var v = GetRVersionFromFolderName(subFolderName); if (SupportedVersions.IsCompatibleVersion(v)) { versions.Add(v); } } } } catch (IOException) { // Don't do anything if there is no RRO installed } if (versions.Count > 0) { versions.Sort(); var highest = versions[versions.Count - 1]; var name = string.Format(CultureInfo.InvariantCulture, "R-{0}.{1}.{2}", highest.Major, highest.Minor, highest.Build); var path = Path.Combine(baseRFolder, name); var ri = CreateInfo(name, path); if (ri.VerifyInstallation(SupportedVersions)) { return(ri); } } return(null); }
/// <summary> /// Applies the builder conventions to the specified controller action. /// </summary> /// <param name="actionModel">The <see cref="ActionModel">action model</see> to apply the conventions to.</param> #pragma warning disable CA1725 public virtual void ApplyTo(ActionModel actionModel) #pragma warning restore CA1725 { if (actionModel == null) { throw new ArgumentNullException(nameof(actionModel)); } MergeAttributesWithConventions(actionModel.Attributes); if (VersionNeutral) { actionModel.SetProperty(ApiVersionModel.Neutral); return; } ApiVersionModel versionModel; if (MappedVersions.Count == 0) { var declaredVersions = SupportedVersions.Union(DeprecatedVersions); versionModel = new ApiVersionModel( declaredVersions, SupportedVersions, DeprecatedVersions, AdvertisedVersions, DeprecatedAdvertisedVersions); } else { var emptyVersions = Empty <ApiVersion>(); versionModel = new ApiVersionModel( declaredVersions: MappedVersions, supportedVersions: emptyVersions, deprecatedVersions: emptyVersions, advertisedVersions: emptyVersions, deprecatedAdvertisedVersions: emptyVersions); } actionModel.SetProperty(versionModel); }
public static string GetAmbariConfigurationDocument(string clusterVersion) { if (String.IsNullOrEmpty(clusterVersion)) { throw new ArgumentException("clusterVersion"); } Version version = new Version(clusterVersion); string twoPartVersion = String.Format("{0}.{1}", version.Major, version.Minor); if (!SupportedVersions.ContainsKey(twoPartVersion)) { throw new NotSupportedException(String.Format("No documents available for the specified cluster version {0}", clusterVersion.ToString())); } string locationOfVersionedDocuments = SupportedVersions[twoPartVersion]; string documentName = String.Format("{0}.{1}", locationOfVersionedDocuments, ambariConfigurationDocumentName); return(ReadEmbeddedResource(documentName)); }
/// <summary> /// Returns a modified scope value based on the version required. Depending on the version the value mc_authn may be added or removed /// </summary> /// <param name="scopeRequested">Request scope value</param> /// <param name="versions">SupportedVersions from ProviderMetadata, used for finding the supported version for the requested auth type</param> /// <param name="shouldUseAuthorize">If mc_authz should be used over mc_authn</param> /// <param name="version">Supported version of the scope selected to use</param> /// <returns>Returns a modified scope value with mc_authn removed or added</returns> private string CoerceAuthenticationScope(string scopeRequested, SupportedVersions versions, bool shouldUseAuthorize, out string version) { var requiredScope = shouldUseAuthorize ? MobileConnectConstants.MOBILECONNECTAUTHORIZATION : MobileConnectConstants.MOBILECONNECTAUTHENTICATION; var disallowedScope = shouldUseAuthorize ? Constants.Scope.AUTHN : Constants.Scope.AUTHZ; versions = versions ?? new SupportedVersions(null); version = versions.GetSupportedVersion(requiredScope); var splitScope = scopeRequested.Split().ToList(); splitScope = Scope.CoerceOpenIdScope(splitScope, requiredScope); splitScope.RemoveAll(x => x.Equals(disallowedScope, StringComparison.OrdinalIgnoreCase)); if (!shouldUseAuthorize && version == Constants.DefaultOptions.VERSION_MOBILECONNECTAUTHN) { splitScope.RemoveAll(x => x.Equals(Constants.Scope.AUTHN, StringComparison.OrdinalIgnoreCase)); } return(Scope.CreateScope(splitScope)); }
public async ValueTask RegisterConnectionAsync(IHazelConnection connection, string name, int clientVersion, ISet <Mod>?mods) { if (!SupportedVersions.Contains(clientVersion)) { using var packet = MessageWriter.Get(MessageType.Reliable); Message01JoinGameS2C.SerializeError(packet, false, DisconnectReason.IncorrectVersion); await connection.SendAsync(packet); return; } if (name.Length > 10) { using var packet = MessageWriter.Get(MessageType.Reliable); Message01JoinGameS2C.SerializeError(packet, false, DisconnectReason.Custom, DisconnectMessages.UsernameLength); await connection.SendAsync(packet); return; } if (string.IsNullOrWhiteSpace(name) || !name.All(TextBox.IsCharAllowed)) { using var packet = MessageWriter.Get(MessageType.Reliable); Message01JoinGameS2C.SerializeError(packet, false, DisconnectReason.Custom, DisconnectMessages.UsernameIllegalCharacters); await connection.SendAsync(packet); return; } var client = _clientFactory.Create(connection, name, clientVersion, mods ?? new HashSet <Mod>(0)); var id = NextId(); client.Id = id; _logger.LogTrace("Client connected."); _clients.TryAdd(id, client); using var writer = MessageWriter.Get(MessageType.Reliable); ModdedHandshakeS2C.Serialize(writer, ServerBrand); await connection.SendAsync(writer); }
/// <summary> /// Applies the builder conventions to the specified controller action. /// </summary> /// <param name="actionModel">The <see cref="ActionModel">action model</see> to apply the conventions to.</param> public virtual void ApplyTo(ActionModel actionModel) { Arg.NotNull(actionModel, nameof(actionModel)); MergeAttributesWithConventions(actionModel.Attributes); if (VersionNeutral) { actionModel.SetProperty(ApiVersionModel.Neutral); return; } var versionModel = default(ApiVersionModel); if (MappedVersions.Count == 0) { var declaredVersions = SupportedVersions.Union(DeprecatedVersions); versionModel = new ApiVersionModel( declaredVersions, SupportedVersions, DeprecatedVersions, AdvertisedVersions, DeprecatedAdvertisedVersions); } else { var emptyVersions = Empty <ApiVersion>(); versionModel = new ApiVersionModel( declaredVersions: MappedVersions, supportedVersions: emptyVersions, deprecatedVersions: emptyVersions, advertisedVersions: emptyVersions, deprecatedAdvertisedVersions: emptyVersions); } actionModel.SetProperty(versionModel); }
public UniversalRecordRetrieveRsp UniversalRecordRetrieveRequest(string LocatorCode) { try { UniversalRecordRetrieveReq request = new UniversalRecordRetrieveReq(); UniversalRecordRetrieveRsp universalRecordRetrieveRsp = new UniversalRecordRetrieveRsp(); request.AuthorizedBy = "user"; request.TargetBranch = OFly.Utilities.CommonUtility.GetConfigValue(OFly.Utilities.ProjectConstants.G_TARGET_BRANCH); BillingPointOfSaleInfo billSaleInfo = new BillingPointOfSaleInfo(); billSaleInfo.OriginApplication = ConfigurationManager.AppSettings["OriginApplication"]; request.BillingPointOfSaleInfo = billSaleInfo; request.Item = LocatorCode; UniversalRecordRetrieveServicePortTypeClient client = new UniversalRecordRetrieveServicePortTypeClient("UniversalRecordRetrieveServicePort", OFly.Utilities.WsdlService.UNIVERSALRECORD_ENDPOINT); client.ClientCredentials.UserName.UserName = OFly.Utilities.Helper.RetrunUsername(); client.ClientCredentials.UserName.Password = OFly.Utilities.Helper.ReturnPassword(); var httpHeaders = OFly.Utilities.Helper.ReturnHttpHeader(); client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders)); SupportedVersions supportedVersions = new SupportedVersions(); supportedVersions.airVersion = "air_v31_0"; supportedVersions.urVersion = "universal_v31_0"; universalRecordRetrieveRsp = client.service(supportedVersions, request); return universalRecordRetrieveRsp; } catch (Exception ex) { throw ex; } }
private IEnumerable <IRInterpreterInfo> GetInstalledCranR(IEnumerable <InstalledPackageInfo> packagesInfo) { var selectedPackages = packagesInfo.Where(p => p.PackageName.EqualsIgnoreCase("r-base-core") && SupportedVersions.IsCompatibleVersion(p.GetVersion())); foreach (var package in selectedPackages) { yield return(RLinuxInterpreterInfo.CreateFromPackage(package, "CRAN R", _fileSystem)); } }
private IEnumerable <IRInterpreterInfo> GetInstalledMRO(IEnumerable <InstalledPackageInfo> packagesInfo) { var selectedPackages = packagesInfo.Where(p => p.PackageName.StartsWithIgnoreCase("microsoft-r-open-mro") && SupportedVersions.IsCompatibleVersion(p.GetVersion())); foreach (var package in selectedPackages) { yield return(RLinuxInterpreterInfo.CreateFromPackage(package, "Microsoft R Open", _fileSystem)); } }
/// <summary> /// Checks if the specified ETP version is supported. /// </summary> /// <param name="version">The ETP version to check.</param> /// <returns><c>true</c> if the ETP version is supported; <c>false</c> otherwise.</returns> public bool IsVersionSupported(EtpVersion version) { return(SupportedVersions.Any(v => v == version)); }
/// <inheritdoc/> public StartAuthenticationResponse StartAuthentication(string clientId, string authorizeUrl, string redirectUrl, string state, string nonce, string encryptedMsisdn, SupportedVersions versions, AuthenticationOptions options) { Validate.RejectNullOrEmpty(clientId, "clientId"); Validate.RejectNullOrEmpty(authorizeUrl, "authorizeUrl"); Validate.RejectNullOrEmpty(redirectUrl, "redirectUrl"); Validate.RejectNullOrEmpty(state, "state"); Validate.RejectNullOrEmpty(nonce, "nonce"); options = options ?? new AuthenticationOptions(); options.Scope = options.Scope ?? ""; bool shouldUseAuthorize = ShouldUseAuthorize(options); if (shouldUseAuthorize) { Validate.RejectNullOrEmpty(options.Context, "options.Context"); Validate.RejectNullOrEmpty(options.ClientName, "options.ClientName"); } options.State = state; options.Nonce = nonce; options.LoginHintToken = options.LoginHintToken; if (options.LoginHintToken == null) { options.LoginHint = options.LoginHint ?? LoginHint.GenerateForEncryptedMsisdn(encryptedMsisdn); } options.RedirectUrl = redirectUrl; options.ClientId = clientId; string version; string coercedScope = CoerceAuthenticationScope(options.Scope, versions, shouldUseAuthorize, out version); Log.Info(() => $"scope={options.Scope} => coercedScope={coercedScope}"); options.Scope = coercedScope; UriBuilder build = new UriBuilder(authorizeUrl); build.AddQueryParams(GetAuthenticationQueryParams(options, shouldUseAuthorize, version)); Log.Info(() => $"Authentication URI={build.Uri.AbsoluteUri}"); return(new StartAuthenticationResponse() { Url = build.Uri.AbsoluteUri }); }
internal static async Task <MobileConnectStatus> RequestHeadlessAuthentication(IAuthenticationService authentication, IJWKeysetService jwks, IIdentityService identity, DiscoveryResponse discoveryResponse, string encryptedMSISDN, string state, string nonce, MobileConnectConfig config, MobileConnectRequestOptions options, CancellationToken cancellationToken = default(CancellationToken)) { if (!IsUsableDiscoveryResponse(discoveryResponse)) { return(MobileConnectStatus.StartDiscovery()); } MobileConnectStatus status; try { string clientId = discoveryResponse.ResponseData.response.client_id ?? config.ClientId; string clientSecret = discoveryResponse.ResponseData.response.client_secret; string authorizationUrl = discoveryResponse.OperatorUrls.AuthorizationUrl; string tokenUrl = discoveryResponse.OperatorUrls.RequestTokenUrl; string issuer = discoveryResponse.ProviderMetadata.Issuer; SupportedVersions supportedVersions = discoveryResponse.ProviderMetadata.MobileConnectVersionSupported; AuthenticationOptions authOptions = options?.AuthenticationOptions ?? new AuthenticationOptions(); authOptions.ClientName = discoveryResponse.ApplicationShortName; var jwksTask = jwks.RetrieveJWKSAsync(discoveryResponse.OperatorUrls.JWKSUrl); var tokenTask = authentication.RequestHeadlessAuthentication(clientId, clientSecret, authorizationUrl, tokenUrl, config.RedirectUrl, state, nonce, encryptedMSISDN, supportedVersions, authOptions, cancellationToken); // execute both tasks in parallel await Task.WhenAll(tokenTask, jwksTask).ConfigureAwait(false); RequestTokenResponse response = tokenTask.Result; status = HandleTokenResponse(authentication, response, clientId, issuer, nonce, discoveryResponse.ProviderMetadata.MobileConnectVersionSupported.MaxSupportedVersionString, jwksTask.Result, options); } catch (MobileConnectInvalidArgumentException e) { Log.Error(() => $"An invalid argument was passed to RequestHeadlessAuthentication arg={e.Argument}"); return(MobileConnectStatus.Error(ErrorCodes.InvalidArgument, string.Format("An argument was found to be invalid during the process. The argument was {0}.", e.Argument), e)); } catch (MobileConnectEndpointHttpException e) { Log.Error(() => $"A general http error occurred in RequestHeadlessAuthentication state={state} nonce={nonce} authUrl={discoveryResponse.OperatorUrls.AuthorizationUrl} tokenUrl={discoveryResponse.OperatorUrls.RequestTokenUrl}"); return(MobileConnectStatus.Error(ErrorCodes.HttpFailure, "An HTTP failure occured while calling the discovery endpoint, the endpoint may be inaccessible", e)); } catch (Exception e) { Log.Error(() => $"A general error occurred in RequestHeadlessAuthentication state={state} nonce={nonce} authUrl={discoveryResponse.OperatorUrls.AuthorizationUrl} tokenUrl={discoveryResponse.OperatorUrls.RequestTokenUrl}"); return(MobileConnectStatus.Error(ErrorCodes.Unknown, "An unknown error occured while generating an authorization url", e)); } if (status.ResponseType == MobileConnectResponseType.Error || !options.AutoRetrieveIdentityHeadless || string.IsNullOrEmpty(discoveryResponse.OperatorUrls.PremiumInfoUrl)) { return(status); } var identityStatus = await RequestIdentity(identity, discoveryResponse, status.TokenResponse.ResponseData.AccessToken, config, options); status.IdentityResponse = identityStatus.IdentityResponse; return(status); }
/// <summary> /// Merges API version information from the specified attributes with the current conventions. /// </summary> /// <param name="attributes">The <see cref="IReadOnlyList{T}">read-only list</see> of attributes to merge.</param> protected virtual void MergeAttributesWithConventions(IReadOnlyList <object> attributes) { if (attributes == null) { throw new ArgumentNullException(nameof(attributes)); } if (VersionNeutral) { return; } const ApiVersionProviderOptions DeprecatedAdvertised = Deprecated | Advertised; var supported = default(List <ApiVersion>); var deprecated = default(List <ApiVersion>); var advertised = default(List <ApiVersion>); var deprecatedAdvertised = default(List <ApiVersion>); for (var i = 0; i < attributes.Count; i++) { switch (attributes[i]) { case IApiVersionNeutral: VersionNeutral = true; return; case IApiVersionProvider provider: List <ApiVersion> target; IReadOnlyList <ApiVersion> source; switch (provider.Options) { case None: target = supported ??= new(); source = provider.Versions; break; case Deprecated: target = deprecated ??= new(); source = provider.Versions; break; case Advertised: target = advertised ??= new(); source = provider.Versions; break; case DeprecatedAdvertised: target = deprecatedAdvertised ??= new(); source = provider.Versions; break; default: continue; } for (var j = 0; j < source.Count; j++) { target.Add(source[j]); } break; } } if (supported is not null && supported.Count > 0) { SupportedVersions.UnionWith(supported); } if (deprecated is not null && deprecated.Count > 0) { DeprecatedVersions.UnionWith(deprecated); } if (advertised is not null && advertised.Count > 0) { AdvertisedVersions.UnionWith(advertised); } if (deprecatedAdvertised is not null && deprecatedAdvertised.Count > 0) { DeprecatedAdvertisedVersions.UnionWith(deprecatedAdvertised); } }
/// <inheritdoc/> public StartAuthenticationResponse StartAuthentication(string clientId, string authorizeUrl, string redirectUrl, string state, string nonce, string encryptedMsisdn, SupportedVersions versions, AuthenticationOptions options, string currentVersion) { Validate.RejectNullOrEmpty(clientId, "clientId"); Validate.RejectNullOrEmpty(authorizeUrl, "authorizeUrl"); Validate.RejectNullOrEmpty(redirectUrl, "redirectUrl"); Validate.RejectNullOrEmpty(state, "state"); Validate.RejectNullOrEmpty(nonce, "nonce"); options = options ?? new AuthenticationOptions(); options.Scope = options.Scope ?? ""; bool shouldUseAuthorize = options.Scope.ToLower().Equals(Constants.Scope.AUTHZ.ToLower()); if (shouldUseAuthorize) { Validate.RejectNullOrEmpty(options.Context, "options.Context"); Validate.RejectNullOrEmpty(options.ClientName, "options.ClientName"); Validate.RejectNullOrEmpty(options.BindingMessage, "options.BindingMessage"); } if (options != null) { KYCClaimsParameter kycClaims = options.KycClaims; if (kycClaims != null) { bool isNamePresent = false; bool isAddressPresent = false; if (currentVersion.Equals(DefaultOptions.V2_3) && options.Scope.Contains(Constants.Scope.KYCPLAIN)) { isNamePresent = StringUtils.requireNonEmpty("name || given_name and family_name", kycClaims.Name, kycClaims.GivenName, kycClaims.FamilyName); isAddressPresent = StringUtils.requireNonEmpty( "address || houseno_or_housename, postal_code, country, town", kycClaims.Address, kycClaims.HousenoOrHouseName, kycClaims.PostalCode, kycClaims.Country, kycClaims.Town); } if (currentVersion.Equals(DefaultOptions.V2_3) && options.Scope.Contains(Constants.Scope.KYCHASHED)) { isNamePresent = StringUtils.requireNonEmpty("name_hashed || given_name_hashed and family_name_hashed", kycClaims.NameHashed, kycClaims.GivenNameHashed, kycClaims.FamilyNameHashed); isAddressPresent = StringUtils.requireNonEmpty( "address_hashed || houseno_or_housename_hashed, postal_code_hashed, country_hashed, town_hashed", kycClaims.AddressHashed, kycClaims.HousenoOrHouseNameHashed, kycClaims.PostalCodeHashed, kycClaims.CountryHashed, kycClaims.TownHashed); } if ((isNamePresent & !isAddressPresent) | (!isNamePresent & isAddressPresent)) { throw new MobileConnectInvalidArgumentException("(split|concatenated, plain|hashed) name or address is empty"); } } } options.State = state; options.Nonce = nonce; if (options.LoginHintToken == null) { options.LoginHint = options.LoginHint ?? LoginHint.GenerateForEncryptedMsisdn(encryptedMsisdn); } options.RedirectUrl = redirectUrl; options.ClientId = clientId; UriBuilder build = new UriBuilder(authorizeUrl); build.AddQueryParams(GetAuthenticationQueryParams(options, shouldUseAuthorize, options.Version)); Log.Info(() => $"Authentication URI={build.Uri.AbsoluteUri}"); return(new StartAuthenticationResponse() { Url = build.Uri.AbsoluteUri }); }
public static ISqlCeDatabase Create(SupportedVersions version) { var type = GetImplementation(version); return(Activator.CreateInstance(type) as ISqlCeDatabase); }
public AirCreateReservationRsp AirBookingReservationRequest(OFly.AirService.AirPricingSolution airPricingSolution, OFly.AirService.AirItinerary airItinerary, string CommissionOrDiscount, string Amount, List<OFly.Models.BookingTravellerInfos> TravellerList, OFly.Models.FormOfPaymentInfo formOfPaymentInfo) { AirCreateReservationReq request = new AirCreateReservationReq(); AirCreateReservationRsp airCreateReservationRsp = new AirCreateReservationRsp(); try { OFly.AirService.AirPricingSolution aps = airPricingSolution; List<OFly.AirService.typeBaseAirSegment> segmentList = airItinerary.AirSegment.ToList(); List<OFly.AirService.AirPricingInfo> pricingInfo = aps.AirPricingInfo.ToList(); List<ActionStatus> actionStatus = new List<ActionStatus>(); List<BookingTraveler> bookingTraveler = new List<BookingTraveler>(); request.AuthorizedBy = "user"; request.ProviderCode = segmentList[0].ProviderCode; request.RetainReservation = typeRetainReservation.Both; request.TargetBranch = OFly.Utilities.CommonUtility.GetConfigValue(OFly.Utilities.ProjectConstants.G_TARGET_BRANCH); BillingPointOfSaleInfo billSaleInfo = new BillingPointOfSaleInfo(); billSaleInfo.OriginApplication = ConfigurationManager.AppSettings["OriginApplication"]; request.BillingPointOfSaleInfo = billSaleInfo; AirPricingSolution apsu = new AirPricingSolution(); // converted SegmentList from AirService to UniversalRecordService string SegmentListXMLString = SegmentListConvertToXML(segmentList); List<typeBaseAirSegment> tbas = LoadFromXMLToSegmentList(SegmentListXMLString); // converted PriceInfoList from AirService to UniversalRecordService string PricingInfoXMLString = PricingInfoListConvertToXML(pricingInfo); List<AirPricingInfo> api = LoadFromXMLToPricingInfo(PricingInfoXMLString); //// need to add dynamic travelers as per textbox bookingTraveler = BookingTravelerList(TravellerList); request.BookingTraveler = bookingTraveler.ToArray(); //apsu.AirItinerarySolutionRef apsu.AirPricingInfo = api.ToArray(); //apsu.AirPricingResultMessage apsu.AirSegment = tbas.ToArray(); apsu.AirSegmentRef = null; apsu.ApproximateBasePrice = aps.ApproximateBasePrice; apsu.ApproximateFees = aps.ApproximateFees; apsu.ApproximateTaxes = aps.ApproximateTaxes; apsu.ApproximateTotalPrice = aps.ApproximateTotalPrice; //apsu.AvailableSSR apsu.BasePrice = aps.BasePrice; apsu.CompleteItinerary = aps.CompleteItinerary; //apsu.Connection apsu.EquivalentBasePrice = aps.EquivalentBasePrice; apsu.FareNote = null; apsu.FareNoteRef = null; //apsu.FeeInfo apsu.Fees = aps.Fees; //apsu.HostToken //apsu.Itinerary apsu.ItinerarySpecified = aps.ItinerarySpecified; //apsu.Journey apsu.Key = aps.Key; //apsu.LegRef //apsu.MetaData //apsu.OptionalServices //apsu.PricingDetails apsu.QuoteDate = aps.QuoteDate; apsu.QuoteDateSpecified = aps.QuoteDateSpecified; apsu.Services = aps.Services; apsu.Taxes = aps.Taxes; //apsu.TaxInfo apsu.TotalPrice = aps.TotalPrice; request.AirPricingSolution = apsu; //// Applying Commission/Discount if applicable. //if (CommissionOrDiscount != null && CommissionOrDiscount != "" && Amount != null && Amount != "") //{ // List<ManualFareAdjustment> fareAdjustmentList = new List<ManualFareAdjustment>(); // ManualFareAdjustment adjustment = new ManualFareAdjustment(); // if (CommissionOrDiscount == "Amount") // { // adjustment.AdjustmentType = typeAdjustmentType.Amount; // } // else // { // adjustment.AdjustmentType = typeAdjustmentType.Percentage; // } // adjustment.AppliedOn = typeAdjustmentTarget.Base; // adjustment.Value = Convert.ToInt32(Amount); // adjustment.PassengerRef = "1"; // fareAdjustmentList.Add(adjustment); // api[0].AirPricingModifiers = new AirPricingModifiers() // { // ManualFareAdjustment = fareAdjustmentList.ToArray() // }; //} actionStatus.Add(new ActionStatus { Type = ActionStatusType.ACTIVE, TicketDate = "T*", ProviderCode = request.ProviderCode }); request.ActionStatus = actionStatus.ToArray(); request.FormOfPayment = AddFormOfPayment(formOfPaymentInfo); AirCreateReservationPortTypeClient client = new AirCreateReservationPortTypeClient("AirCreateReservationPort", OFly.Utilities.WsdlService.AIR_ENDPOINT); client.ClientCredentials.UserName.UserName = OFly.Utilities.Helper.RetrunUsername(); client.ClientCredentials.UserName.Password = OFly.Utilities.Helper.ReturnPassword(); var httpHeaders = OFly.Utilities.Helper.ReturnHttpHeader(); client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders)); SupportedVersions supportedVersions = new SupportedVersions(); supportedVersions.airVersion = "air_v31_0"; airCreateReservationRsp = client.service(supportedVersions, request); return airCreateReservationRsp; } catch (Exception se) { throw se; } }
/// <inheritdoc/> public async Task <RequestTokenResponse> RequestHeadlessAuthentication(string clientId, string clientSecret, string authorizeUrl, string tokenUrl, string redirectUrl, string state, string nonce, string encryptedMsisdn, SupportedVersions versions, AuthenticationOptions options, CancellationToken cancellationToken = default(CancellationToken)) { options = options ?? new AuthenticationOptions(); bool shouldUseAuthorize = ShouldUseAuthorize(options); if (shouldUseAuthorize) { options.Prompt = "mobile"; } string authUrl = StartAuthentication(clientId, authorizeUrl, redirectUrl, state, nonce, encryptedMsisdn, versions, options).Url; Uri finalRedirect = null; try { finalRedirect = await _client.GetFinalRedirect(authUrl, redirectUrl, options.PollFrequencyInMs, options.MaxRedirects, cancellationToken); } catch (Exception e) when(e is System.Net.WebException || e is TaskCanceledException) { Log.Error("Headless authentication was cancelled", e); return(new RequestTokenResponse(new ErrorResponse { Error = Constants.ErrorCodes.AuthCancelled, ErrorDescription = "Headless authentication was cancelled or a timeout occurred" })); } catch (HttpRequestException e) { Log.Error("Headless authentication failed", e); throw new MobileConnectEndpointHttpException(e.Message, e); } var error = ErrorResponse.CreateFromUrl(finalRedirect.AbsoluteUri); if (error != null) { return(new RequestTokenResponse(error)); } var code = HttpUtils.ExtractQueryValue(finalRedirect.AbsoluteUri, "code"); return(await RequestTokenAsync(clientId, clientSecret, tokenUrl, redirectUrl, code)); }