Ejemplo n.º 1
0
            private static string GetGssApiDisplayStatus(Status majorStatus, Status minorStatus)
            {
                string majorError = GetGssApiDisplayStatus(majorStatus, isMinor: false);
                string minorError = GetGssApiDisplayStatus(minorStatus, isMinor: true);

                return((majorError != null && minorError != null) ?
                       SRHelper.Format(SR.net_gssapi_operation_failed_detailed, majorError, minorError) :
                       SRHelper.Format(SR.net_gssapi_operation_failed, majorStatus.ToString("x"), minorStatus.ToString("x")));
            }
Ejemplo n.º 2
0
        internal static InvalidUdtException Create(Type udtType, string resourceReason)
        {
            string reason         = SRHelper.GetString(resourceReason);
            string message        = SRHelper.GetString(SR.SqlUdt_InvalidUdtMessage, udtType.FullName, reason);
            InvalidUdtException e = new InvalidUdtException(message);

            ADP.TraceExceptionAsReturnValue(e);
            return(e);
        }
Ejemplo n.º 3
0
            internal int Copy(byte[] destination, int offset)
            {
                Debug.Assert(destination != null, "target destination cannot be null");
                Debug.Assert((offset >= 0 && offset < destination.Length) || destination.Length == 0, "invalid offset " + offset);

                if (_data == IntPtr.Zero || _length == 0)
                {
                    return(0);
                }

                // Using Convert.ToInt32 to throw an exception in the unlikely event of too large value of _length
                int sourceLength         = Convert.ToInt32(_length);
                int destinationAvailable = destination.Length - offset;  // amount of space in the given buffer

                if (sourceLength > destinationAvailable)
                {
                    throw new NetSecurityNative.GssApiException(SRHelper.Format(SR.net_context_buffer_too_small, sourceLength, destinationAvailable));
                }

                Marshal.Copy(_data, destination, offset, sourceLength);
                return(sourceLength);
            }
Ejemplo n.º 4
0
        public unsafe int QueryContextAttributes(SafeDeleteContext context, Interop.SspiCli.ContextAttribute attribute, byte[] buffer, Type handleType, out SafeHandle refHandle)
        {
            refHandle = null;
            if (handleType != null)
            {
                if (handleType == typeof(SafeFreeContextBuffer))
                {
                    refHandle = SafeFreeContextBuffer.CreateEmptyHandle();
                }
                else if (handleType == typeof(SafeFreeCertContext))
                {
                    refHandle = new SafeFreeCertContext();
                }
                else
                {
                    throw new ArgumentException(SRHelper.Format(SR.SSPIInvalidHandleType, handleType.FullName), nameof(handleType));
                }
            }

            fixed(byte *bufferPtr = buffer)
            {
                return(SafeFreeContextBuffer.QueryContextAttributes(context, attribute, bufferPtr, refHandle));
            }
        }
Ejemplo n.º 5
0
        internal static Normalizer GetNormalizer(Type t)
        {
            Normalizer n = null;

            if (t.IsPrimitive)
            {
                if (t == typeof(byte))
                {
                    n = new ByteNormalizer();
                }
                else if (t == typeof(sbyte))
                {
                    n = new SByteNormalizer();
                }
                else if (t == typeof(bool))
                {
                    n = new BooleanNormalizer();
                }
                else if (t == typeof(short))
                {
                    n = new ShortNormalizer();
                }
                else if (t == typeof(ushort))
                {
                    n = new UShortNormalizer();
                }
                else if (t == typeof(int))
                {
                    n = new IntNormalizer();
                }
                else if (t == typeof(uint))
                {
                    n = new UIntNormalizer();
                }
                else if (t == typeof(float))
                {
                    n = new FloatNormalizer();
                }
                else if (t == typeof(double))
                {
                    n = new DoubleNormalizer();
                }
                else if (t == typeof(long))
                {
                    n = new LongNormalizer();
                }
                else if (t == typeof(ulong))
                {
                    n = new ULongNormalizer();
                }
            }
            else if (t.IsValueType)
            {
                n = new BinaryOrderedUdtNormalizer(t, false);
            }
            if (n == null)
            {
                throw new Exception(SRHelper.GetString(SR.SQL_CannotCreateNormalizer, t.FullName));
            }
            n._skipNormalize = false;
            return(n);
        }
Ejemplo n.º 6
0
 public static Exception InvalidOffsetLength()
 {
     return(_Argument(SRHelper.GetString(SR.Data_InvalidOffsetLength)));
 }
Ejemplo n.º 7
0
 private void DontDoIt()
 {
     throw new Exception(SRHelper.GetString(SR.Sql_InternalError));
 }