private void CheckIfFlagWasObtainedIfRequested(ContextFlags flag)
 {
     if ((this.m_RequestedFlags & flag) != (ContextFlags)0 && (this.m_ContextFlags & (int)flag) == 0)
     {
         throw new AdomdConnectionException(XmlaSR.Authentication_Sspi_FlagNotEstablished(flag.ToString()), null, ConnectionExceptionCause.AuthenticationFailed);
     }
 }
 private void CheckIfCapabilityIsSupported(string packageName, PackageCapabilities capability)
 {
     if ((this.m_Capabilities & (int)capability) == 0)
     {
         throw new AdomdConnectionException(XmlaSR.Authentication_Sspi_PackageDoesntSupportCapability(packageName, capability.ToString()), null, ConnectionExceptionCause.AuthenticationFailed);
     }
 }
        private void Decompress(int compressedDataSize, int decompressedDataSize)
        {
            int num = this.XpressWrapper.Decompress(this.decompressHandle, this.compressedBuffer, compressedDataSize, this.decompressedBuffer, decompressedDataSize, decompressedDataSize);

            if (num != decompressedDataSize)
            {
                throw new XmlaStreamException(XmlaSR.Decompression_Failed(compressedDataSize, decompressedDataSize, num));
            }
        }
        private object LoadAndValidateEnumValue(Type enumType, string enumValueName)
        {
            object obj = Enum.GetValues(enumType).Cast <object>().FirstOrDefault((object val) => val.ToString() == enumValueName);

            if (obj == null)
            {
                throw new AdomdConnectionException(XmlaSR.Authentication_ClaimsToken_AdalLoadingError(string.Format("{0}.{1} enum value", enumType.Name, enumValueName)));
            }
            return(obj);
        }
        private PropertyInfo LoadAndValidateProperty(Type type, string propertyName)
        {
            PropertyInfo property = type.GetProperty(propertyName);

            if (property == null)
            {
                throw new AdomdConnectionException(XmlaSR.Authentication_ClaimsToken_AdalLoadingError(string.Format("{0}.{1} property", type.Name, propertyName)));
            }
            return(property);
        }
        private Type LoadAndValidateType(Assembly assembly, string typeName)
        {
            Type type = assembly.GetType(typeName);

            if (type == null)
            {
                throw new AdomdConnectionException(XmlaSR.Authentication_ClaimsToken_AdalLoadingError(string.Format("{0} type", typeName)));
            }
            return(type);
        }
        private MethodInfo LoadAndValidateMethod(Type type, string methodName, params Type[] argTypes)
        {
            MethodInfo methodInfo = (argTypes.Length == 0) ? type.GetMethod(methodName) : type.GetMethod(methodName, argTypes);

            if (methodInfo == null)
            {
                throw new AdomdConnectionException(XmlaSR.Authentication_ClaimsToken_AdalLoadingError(string.Format("{0}.{1}({2}) method", type.Name, methodName, string.Join(", ", (from t in argTypes
                                                                                                                                                                                     select t.Name).ToArray <string>()))));
            }
            return(methodInfo);
        }
        internal static string GetExtendedErrorInfo(HttpWebResponse httpResponse)
        {
            string text  = httpResponse.Headers["x-ms-root-activity-id"];
            string text2 = httpResponse.Headers["x-ms-current-utc-date"];

            if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2))
            {
                return(string.Empty);
            }
            return(XmlaSR.HttpStream_ASAzure_TechnicalDetailsText(text, text2));
        }
        private static Stream GetResourceAsStream(string resourceName)
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
            string   text = manifestResourceNames.FirstOrDefault((string rn) => rn.EndsWith(resourceName));

            if (text == null)
            {
                throw new AdomdConnectionException(XmlaSR.Authentication_ClaimsToken_AdalLoadingError(string.Format("{0} from embedded resource", resourceName)));
            }
            return(executingAssembly.GetManifestResourceStream(text));
        }
 private void InitializePackageSpecificMembers(string packageName)
 {
     if (NTAuthentication.m_SupportedSecurityPackages != null)
     {
         int i   = 0;
         int num = NTAuthentication.m_SupportedSecurityPackages.Length;
         while (i < num)
         {
             if (string.Compare(NTAuthentication.m_SupportedSecurityPackages[i].Name, packageName, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 this.m_TokenSize    = NTAuthentication.m_SupportedSecurityPackages[i].MaxToken;
                 this.m_Capabilities = NTAuthentication.m_SupportedSecurityPackages[i].Capabilities;
                 return;
             }
             i++;
         }
     }
     throw new AdomdConnectionException(XmlaSR.Authentication_Sspi_PackageNotFound(packageName), null, ConnectionExceptionCause.AuthenticationFailed);
 }
        public static string GetDataTypeFromEnum(DataType dataType)
        {
            switch (dataType)
            {
            case DataType.TextXml:
                return("text/xml");

            case DataType.BinaryXml:
                return("application/sx");

            case DataType.CompressedXml:
                return("application/xml+xpress");

            case DataType.CompressedBinaryXml:
                return("application/sx+xpress");

            default:
                throw new ArgumentOutOfRangeException("dataType", XmlaSR.Dime_DataTypeNotSupported(dataType.ToString()));
            }
        }
 public LocalCubeStream(string cubeFile, MsmdlocalWrapper.OpenFlags settings, int timeout, string password, string serverName)
 {
     try
     {
         this.cubeFile        = cubeFile;
         this.msmdlocalWraper = MsmdlocalWrapper.LocalWrapper;
         this.hLocalServer    = this.msmdlocalWraper.MSMDOpenLocal(cubeFile, settings, password, serverName);
     }
     catch (Win32Exception innerException)
     {
         this.msmdlocalWraper = null;
         this.hLocalServer    = IntPtr.Zero;
         throw new XmlaStreamException(XmlaSR.LocalCube_FileNotOpened(cubeFile), innerException);
     }
     catch
     {
         this.msmdlocalWraper = null;
         this.hLocalServer    = IntPtr.Zero;
         throw;
     }
 }
示例#13
0
        public override DataType GetResponseDataType()
        {
            DataType result;

            try
            {
                this.GetResponseStream();
                Match match = HttpStream.contentTypeRegex.Match(this.httpResponse.ContentType);
                if (!match.Success)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.UnsupportedDataFormat(this.httpResponse.ContentType), "");
                }
                DataType dataTypeFromString = DataTypes.GetDataTypeFromString(match.Groups["content_type"].Value);
                if (dataTypeFromString == DataType.Undetermined || dataTypeFromString == DataType.Unknown)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.UnsupportedDataFormat(this.httpResponse.ContentType), "");
                }
                result = dataTypeFromString;
            }
            catch (XmlaStreamException)
            {
                throw;
            }
            catch (IOException innerException)
            {
                throw new XmlaStreamException(innerException);
            }
            catch (WebException innerException2)
            {
                throw new XmlaStreamException(innerException2);
            }
            catch (ProtocolViolationException innerException3)
            {
                throw new XmlaStreamException(innerException3);
            }
            return(result);
        }
示例#14
0
        public override DataType GetResponseDataType()
        {
            DataType result;

            try
            {
                if (this.endOfStream)
                {
                    result = DataType.Undetermined;
                }
                else
                {
                    if (this.dimeReader == null)
                    {
                        this.dimeReader        = new DimeReader(this.bufferedStream);
                        this.dimeRecordForRead = this.dimeReader.ReadRecord();
                        if (TcpStream.TRACESWITCH.TraceVerbose)
                        {
                            StackTrace stackTrace = new StackTrace();
                            stackTrace.GetFrame(1).GetMethod();
                        }
                        this.DetermineNegotiatedOptions();
                    }
                    if (this.dimeRecordForRead == null)
                    {
                        if (TcpStream.TRACESWITCH.TraceVerbose)
                        {
                            StackTrace stackTrace2 = new StackTrace();
                            stackTrace2.GetFrame(1).GetMethod();
                        }
                        this.dimeReader.Close();
                        this.dimeReader  = null;
                        this.endOfStream = true;
                        result           = DataType.Undetermined;
                    }
                    else
                    {
                        DataType dataTypeFromString = DataTypes.GetDataTypeFromString(this.dimeRecordForRead.Type);
                        if (TcpStream.TRACESWITCH.TraceVerbose)
                        {
                            StackTrace stackTrace3 = new StackTrace();
                            stackTrace3.GetFrame(1).GetMethod();
                        }
                        if (dataTypeFromString == DataType.Unknown)
                        {
                            throw new AdomdUnknownResponseException(XmlaSR.Dime_DataTypeNotSupported(this.dimeRecordForRead.Type), "");
                        }
                        result = dataTypeFromString;
                    }
                }
            }
            catch (XmlaStreamException)
            {
                throw;
            }
            catch (IOException innerException)
            {
                throw new XmlaStreamException(innerException);
            }
            catch (SocketException innerException2)
            {
                throw new XmlaStreamException(innerException2);
            }
            return(result);
        }
示例#15
0
        private void ReadHeader()
        {
            byte[] array = new byte[12];
            DimeRecord.ForceRead(this.m_stream, array, 12);
            this.m_version = (byte)((array[0] & 248) >> 3);
            if (this.m_version != 1)
            {
                throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_VersionNotSupported((int)this.m_version), "");
            }
            DimeRecord.HeaderFlagsEnum headerFlagsEnum = (DimeRecord.HeaderFlagsEnum)(array[0] & 7);
            this.m_chunked        = ((byte)(headerFlagsEnum & DimeRecord.HeaderFlagsEnum.ChunkedRecord) != 0);
            this.m_beginOfMessage = ((byte)(headerFlagsEnum & DimeRecord.HeaderFlagsEnum.BeginOfMessage) != 0);
            this.m_endOfMessage   = ((byte)(headerFlagsEnum & DimeRecord.HeaderFlagsEnum.EndOfMessage) != 0);
            if (this.m_chunked && this.m_endOfMessage)
            {
                throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_InvalidHeaderFlags(this.m_beginOfMessage ? 1 : 0, 1, 1), "");
            }
            if ((!this.m_chunked && !this.m_endOfMessage) || (!this.m_firstChunk && this.m_beginOfMessage))
            {
                throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_OnlySingleRecordMessagesAreSupported, "");
            }
            this.m_typeFormat = (TypeFormatEnum)((array[1] & 240) >> 4);
            this.m_reserved   = (byte)(array[1] & 15);
            int num  = ((int)array[2] << 8) + (int)array[3];
            int num2 = ((int)array[4] << 8) + (int)array[5];
            int num3 = ((int)array[6] << 8) + (int)array[7];

            this.m_contentLength = ((int)array[8] << 24) + ((int)array[9] << 16) + ((int)array[10] << 8) + (int)array[11];
            if (this.m_firstChunk)
            {
                if (this.m_typeFormat != TypeFormatEnum.MediaType)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_TypeFormatShouldBeMedia(this.m_typeFormat.ToString()), "");
                }
                if (num3 <= 0)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_DataTypeShouldBeSpecifiedOnTheFirstChunk, "");
                }
            }
            else
            {
                if (this.m_typeFormat != TypeFormatEnum.Unchanged)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_TypeFormatShouldBeUnchanged(this.m_typeFormat.ToString()), "");
                }
                if (num3 != 0)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_DataTypeIsOnlyForTheFirstChunk, "");
                }
                if (num2 != 0)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_IDIsOnlyForFirstChunk, "");
                }
                if (num != 0)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, "Unexpected non-zero options length");
                }
            }
            if (this.m_reserved != 0)
            {
                throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_ReservedFlagShouldBeZero(this.m_reserved), "");
            }
            if (num > 0)
            {
                array = new byte[DimeRecord.RoundUp(num)];
                DimeRecord.ForceRead(this.m_stream, array, array.Length);
                this.m_Options.FromBytes(array);
            }
            if (num2 > 0)
            {
                array = new byte[DimeRecord.RoundUp(num2)];
                DimeRecord.ForceRead(this.m_stream, array, array.Length);
            }
            if (num3 > 0)
            {
                array = new byte[DimeRecord.RoundUp(num3)];
                DimeRecord.ForceRead(this.m_stream, array, array.Length);
                this.m_type = Encoding.ASCII.GetString(array, 0, num3);
                if (!DataTypes.IsSupportedDataType(this.m_type))
                {
                    throw new AdomdUnknownResponseException(XmlaSR.DimeRecord_DataTypeNotSupported(this.m_type), "");
                }
            }
            this.m_firstChunk = false;
        }
        public override int Read(byte[] buffer, int offset, int size)
        {
            if (this.disposed)
            {
                throw new ObjectDisposedException(null);
            }
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size");
            }
            if (size + offset > buffer.Length)
            {
                throw new ArgumentException(XmlaSR.InvalidArgument, "buffer");
            }
            if (size == 0)
            {
                return(0);
            }
            int result;

            try
            {
                int num = 0;
                if (this.decompressedBufferSize > 0)
                {
                    num = this.ReadFromCache(buffer, offset, size);
                }
                else
                {
                    DataType responseDataType = this.baseXmlaStream.GetResponseDataType();
                    switch (responseDataType)
                    {
                    case DataType.Undetermined:
                        break;

                    case DataType.TextXml:
                    case DataType.BinaryXml:
                        num = this.baseXmlaStream.Read(buffer, offset, size);
                        break;

                    case DataType.CompressedXml:
                    case DataType.CompressedBinaryXml:
                        if (this.decompressHandle == IntPtr.Zero)
                        {
                            this.InitDecompress();
                        }
                        while (this.decompressedBufferSize <= 0 && this.ReadCompressedPacket())
                        {
                        }
                        if (this.decompressedBufferSize > 0)
                        {
                            num = this.ReadFromCache(buffer, offset, size);
                        }
                        break;

                    default:
                        throw new NotImplementedException(XmlaSR.UnsupportedDataFormat(responseDataType.ToString()));
                    }
                }
                result = num;
            }
            catch (Win32Exception innerException)
            {
                throw new XmlaStreamException(innerException);
            }
            return(result);
        }