예제 #1
0
 internal bool TrySetObscureKind(ObscureKind obscureKind)
 {
     if (this.PublishedOptions.SearchableUrlEnabled)
     {
         return(false);
     }
     this.obscureKind = new ObscureKind?(obscureKind);
     return(true);
 }
예제 #2
0
        internal ObscureUrl ChangeToKind(ObscureKind obscureKind)
        {
            if (base.DataType == SharingDataType.ReachCalendar || this.ObscureKind == obscureKind)
            {
                return(this);
            }
            string str            = ObscureUrl.CalculateHashString(this.ObscureKind, this.GuidIdentity);
            string str2           = ObscureUrl.CalculateHashString(obscureKind, this.GuidIdentity);
            string originalString = base.Uri.OriginalString;
            string uriString      = originalString.Replace(this.GuidIdentity + str, this.GuidIdentity + str2);

            return(new ObscureUrl(new Uri(uriString, UriKind.Absolute), base.DataType, this.MailboxGuid, this.Domain, this.GuidIdentity, obscureKind, this.ReachUserSid));
        }
예제 #3
0
        internal static bool TryParse(string url, out ObscureUrl obscureUrl)
        {
            obscureUrl = null;
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                ExTraceGlobals.SharingTracer.TraceError <string>(0L, "ObscureUrl.TryParse(): The string '{0}' is not an Absolute Uri.", url);
                return(false);
            }
            Uri    uri       = new Uri(url, UriKind.Absolute);
            string localPath = uri.LocalPath;

            ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): Get path of url: {0}", localPath);
            Match match = ObscureUrl.ObscureUrlRegex.Match(localPath);

            if (!match.Success)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): The string '{0}' is not desired ObscureUrl. ", url);
                return(false);
            }
            SharingDataType sharingDataType = SharingDataType.FromPublishResourceName(match.Result("${datatype}"));
            Guid            guid            = Guid.Empty;
            Exception       ex = null;

            try
            {
                guid = new Guid(match.Result("${mailboxguid}"));
            }
            catch (FormatException ex2)
            {
                ex = ex2;
            }
            catch (OverflowException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string, Exception>(0L, "ObscureUrl.TryParse(): The string '{0}' is not desired ObscureUrl. Exception = {1}.", url, ex);
                return(false);
            }
            string             text = match.Result("${guid}");
            string             x    = match.Result("${hash}");
            SecurityIdentifier securityIdentifier = null;
            string             text2 = match.Result("${sid}");

            if (sharingDataType == SharingDataType.ReachCalendar)
            {
                if (!StringComparer.Ordinal.Equals(x, ObscureUrl.CalculateHashString(ObscureKind.Normal, text)))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): Incorrect hash value for reachUrl:'{0}'", url);
                    return(false);
                }
                if (string.IsNullOrEmpty(text2))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): sid value missing for reachUrl:'{0}'", url);
                    return(false);
                }
                securityIdentifier = new SecurityIdentifier(text2);
                if (!ExternalUser.IsValidReachSid(securityIdentifier))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): Not a valid reach sid:'{0}'", url);
                    return(false);
                }
                obscureUrl = new ObscureUrl(uri, sharingDataType, guid, match.Result("${domain}"), text, ObscureKind.Normal, securityIdentifier);
                ExTraceGlobals.SharingTracer.TraceDebug <string, string>(0L, "ObscureUrl.TryParse(): The url {0} is parsed as ReachCalendar ObscureUrl {1}.", url, obscureUrl.TraceInfo);
                return(true);
            }
            else
            {
                if (sharingDataType != SharingDataType.Calendar)
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <SharingDataType>(0L, "ObscureUrl.TryParse(): Sharing Datatype:{0} is not supported ", sharingDataType);
                    return(false);
                }
                if (!string.IsNullOrEmpty(text2))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): SID is not applicable for published calendar url:'{0}'", url);
                    return(false);
                }
                foreach (object obj in Enum.GetValues(typeof(ObscureKind)))
                {
                    ObscureKind obscureKind = (ObscureKind)obj;
                    if (StringComparer.Ordinal.Equals(x, ObscureUrl.CalculateHashString(obscureKind, text)))
                    {
                        obscureUrl = new ObscureUrl(uri, sharingDataType, guid, match.Result("${domain}"), text, obscureKind, securityIdentifier);
                        ExTraceGlobals.SharingTracer.TraceDebug <string, string>(0L, "ObscureUrl.TryParse(): The url {0} is parsed as Calendar ObscureUrl {1}.", url, obscureUrl.TraceInfo);
                        return(true);
                    }
                }
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): Incorrect hash value for Calendar url:{0}", url);
                return(false);
            }
        }
예제 #4
0
        private static string CalculateHashString(ObscureKind obscureKind, string guidIdentity)
        {
            StringHasher stringHasher = new StringHasher();

            return(stringHasher.GetHash(guidIdentity + obscureKind).ToString(NumberFormatInfo.InvariantInfo));
        }
예제 #5
0
 private ObscureUrl(Uri uri, SharingDataType dataType, Guid mailboxGuid, string domain, string guidIdentity, ObscureKind obscureKind, SecurityIdentifier reachUserSid) : base(uri, dataType, ObscureUrl.CalculateIdentity(dataType, guidIdentity))
 {
     Util.ThrowOnNullOrEmptyArgument(domain, "domain");
     Util.ThrowOnNullOrEmptyArgument(guidIdentity, "guidIdentity");
     this.ReachUserSid = reachUserSid;
     this.mailboxGuid  = mailboxGuid;
     this.domain       = domain;
     this.guidIdentity = guidIdentity;
     this.obscureKind  = obscureKind;
 }