private static IAuthenticationToken CreateCrentialsFromId(string identifier, IAuthenticationToken authToken)
        {
            if (authToken == null ||
                string.IsNullOrEmpty(authToken.AuthorizationKey) ||
                string.IsNullOrEmpty(authToken.AuthorizationSecret))
            {
                IAuthenticationContext authContext;
                if (_credentialsStore.TryGetValue(identifier, out authContext))
                {
                    authToken = authContext.Token;
                    return(authToken);
                }

                if (identifier != null)
                {
                    throw new ArgumentException("Identifier could not be matched to any stored AuthenticationContext.");
                }

                throw new ArgumentException("The credentials needs the AuthorizationKey and AuthorizationSecret to be set up as the URL does not contain the credentials identifier.");
            }

            return(authToken);
        }
Exemple #2
0
        private static IConsumerCredentials GetCrentialsFromId(string identifier, IConsumerCredentials appCredentials)
        {
            if (appCredentials == null ||
                string.IsNullOrEmpty(appCredentials.AuthorizationKey) ||
                string.IsNullOrEmpty(appCredentials.AuthorizationSecret))
            {
                IConsumerCredentials creds;
                if (_credentialsStore.TryGetValue(identifier, out creds))
                {
                    appCredentials = creds;
                }
                else
                {
                    if (appCredentials == null)
                    {
                        throw new ArgumentException("The credentials are required as the URL does not contain the credentials identifier.");
                    }

                    throw new ArgumentException("The credentials needs the AuthorizationKey and AuthorizationSecret to be set up as the URL does not contain the credentials identifier.");
                }
            }

            return(appCredentials);
        }