public static void SignedKeyParamsParser(SupportedAuthScheme scheme, string parameter, NephosUriComponents uriComponents, out string accountName, out string signature) { NephosAssertionException.Assert(scheme.Equals(SupportedAuthScheme.SignedKey)); NephosAssertionException.Assert((uriComponents == null ? false : !string.IsNullOrEmpty(uriComponents.AccountName))); if (string.IsNullOrEmpty(parameter)) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; object[] objArray = new object[] { "Authorization", string.Format("{0} {1}", scheme, parameter) }; throw new InvalidAuthenticationInfoException(string.Format(invariantCulture, "{0} value '{1}' is invalid.", objArray)); } accountName = uriComponents.AccountName; signature = parameter; }
public static void SharedKeyParamsParser(SupportedAuthScheme scheme, string parameter, NephosUriComponents uriComponents, out string accountName, out string signature) { NephosAssertionException.Assert((scheme.Equals(SupportedAuthScheme.SharedKey) ? true : scheme.Equals(SupportedAuthScheme.SharedKeyLite))); NephosAssertionException.Assert(!string.IsNullOrEmpty(parameter)); string[] strArrays = parameter.Split(HttpRequestAccessorCommon.colonDelimiter, StringSplitOptions.RemoveEmptyEntries); if ((int)strArrays.Length != 2) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; object[] objArray = new object[] { "Authorization", string.Format("{0} {1}", scheme, parameter) }; throw new InvalidAuthenticationInfoException(string.Format(invariantCulture, "{0} value '{1}' is invalid.", objArray)); } accountName = strArrays[0]; signature = strArrays[1]; }
public AuthenticationInformation(string authScheme, SupportedAuthScheme originalRequestAuthScheme, Collection <AuthDataEntry> authData, Microsoft.Cis.Services.Nephos.Common.RequestContext requestContext, NephosUriComponents uriComponents, bool isInterStampAuthentication) { this.authScheme = authScheme; this.authData = authData; this.requestContext = requestContext; this.uriComponents = uriComponents; this.authKeyName = null; if (originalRequestAuthScheme == SupportedAuthScheme.SignedKey && requestContext.QueryParameters["sv"] != null) { this.authKeyName = AuthenticationManagerHelper.ExtractKeyNameFromParamsWithConversion(requestContext.QueryParameters); if (this.authKeyName != null) { Logger <IRestProtocolHeadLogger> .Instance.Verbose.Log("Using secret key with KeyName '{0}' to authenticate SAS/DSAS.", new object[] { this.authKeyName }); } } }
public static string GetStringToSignForStandardSignedKeyAuth(RequestContext requestContext, NephosUriComponents uriComponents, SupportedAuthScheme requestAuthScheme, bool isFileService = false) { return(AuthenticationManagerHelper.GetStringToSignForStandardSharedKeyAuth(requestContext, uriComponents, SupportedAuthScheme.SharedKey, isFileService)); }
public static string GetStringToSignForStandardSharedKeyAuth(RequestContext requestContext, NephosUriComponents uriComponents, SupportedAuthScheme requestAuthScheme, bool isFileService = false) { if (MessageCanonicalizer.IsVersionBeforeSep09(requestContext.RequestHeaders)) { if (requestAuthScheme != SupportedAuthScheme.SharedKey) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; object[] str = new object[] { requestAuthScheme.ToString() }; throw new NotSupportedException(string.Format(invariantCulture, "GetStringToSignForDefaultSharedKeyAuth must not be used for {0} auth scheme", str)); } return(MessageCanonicalizer.CanonicalizeHttpRequest(requestContext, uriComponents, isFileService)); } if (requestAuthScheme != SupportedAuthScheme.SharedKey && requestAuthScheme != SupportedAuthScheme.SharedKeyLite) { CultureInfo cultureInfo = CultureInfo.InvariantCulture; object[] objArray = new object[] { requestAuthScheme.ToString() }; throw new NotSupportedException(string.Format(cultureInfo, "GetStringToSignForDefaultSharedKeyAuth must not be used for {0} auth scheme", objArray)); } if (requestAuthScheme != SupportedAuthScheme.SharedKeyLite) { return(MessageCanonicalizer.CanonicalizeHttpRequest(requestContext, uriComponents, isFileService)); } return(MessageCanonicalizer.CanonicalizeHttpRequestDefault(requestContext.RequestUrl, uriComponents, requestContext.HttpMethod, requestContext.RequestContentType, requestContext.RequestHeaders, isFileService, requestContext.RequestRawUrlString)); }
private static AuthenticationInformation GetAuthInfoForScheme(IStorageAccount account, SupportedAuthScheme authScheme, RequestContext requestContext, NephosUriComponents uriComponents, bool isInterStampAuthentication) { if (authScheme != SupportedAuthScheme.SharedKey && authScheme != SupportedAuthScheme.SharedKeyLite && authScheme != SupportedAuthScheme.SignedKey) { return(null); } Collection <AuthDataEntry> authDataEntries = new Collection <AuthDataEntry>(); if (account.SecretKeysV3 == null) { Logger <IRestProtocolHeadLogger> .Instance.Critical.Log("Attempting to authenticate against account {0} which does not have secretKeyListV3", new object[] { account.Name }); } else { foreach (SecretKeyV3 secretKeysV3 in account.SecretKeysV3) { authDataEntries.Add(new AuthDataEntry(secretKeysV3.Name, secretKeysV3.Value, secretKeysV3.Permissions)); } } return(new AuthenticationInformation("SharedKey", authScheme, authDataEntries, requestContext, uriComponents, isInterStampAuthentication)); }