Example #1
0
        private void Parse(string address)
        {
            Match match = AddressRegex.Match(address);

            this.userName     = String.Empty;
            this.domainName   = String.Empty;
            this.resourceName = String.Empty;

            if (match != null)
            {
                // The Local part is optional
                if (match.Groups["localpart"] != null)
                {
                    this.userName = Stringprep.NamePrep(match.Groups["localpart"].Value);
                }
                // The Domain part is mandatory
                this.domainName = Stringprep.NodePrep(match.Groups["domainpart"].Value);
                // The Resource part is optional
                if (match.Groups["resourcepart"] != null)
                {
                    this.resourceName = Stringprep.ResourcePrep(match.Groups["resourcepart"].Value);
                }
            }

            this.Update();
        }
Example #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "XmppJid" /> class with
        ///   the given user name, domain name and resource name.
        /// </summary>
        /// <param name = "userName">The user name</param>
        /// <param name = "domainName">The domain name</param>
        /// <param name = "resourceName">The resource name</param>
        public XmppJid(string userName, string domainName, string resourceName)
        {
            this.userName     = Stringprep.NamePrep(userName);
            this.domainName   = Stringprep.NodePrep(domainName);
            this.resourceName = Stringprep.ResourcePrep(resourceName);

            BuildBareAndFullJid();
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XmppAddress"/> class with
        /// the given user name, domain name and resource name.
        /// </summary>
        /// <param name="userName">The user name</param>
        /// <param name="domainName">The domain name</param>
        /// <param name="resourceName">The resource name</param>
        public XmppAddress(string userName, string domainName, string resourceName)
        {
            this.userName     = Stringprep.NamePrep(userName);
            this.domainName   = Stringprep.NodePrep(domainName);
            this.resourceName = Stringprep.ResourcePrep(resourceName);

            this.Update();
        }
 private Jid NodePrep(Jid jid)
 {
     if (jid != null)
     {
         if (jid.HasUser)
         {
             jid.User = Stringprep.NodePrep(jid.User);
         }
         if (jid.HasResource)
         {
             jid.Resource = Stringprep.ResourcePrep(jid.Resource);
         }
         //BUG: Many faults here in log
         jid.Server = Stringprep.NamePrep(jid.Server);
     }
     return(jid);
 }
 private bool ValidateJid(Jid jid)
 {
     if (jid == null)
     {
         return(true);
     }
     if (jid.HasUser)
     {
         if (jid.User != Jid.EscapeNode(jid.User))
         {
             return(false);
         }
         if (jid.User != Stringprep.NodePrep(jid.User))
         {
             return(false);
         }
     }
     return(true);
 }
Example #6
0
File: Jid.cs Project: Toyz/agsXMPP
        /// <summary>
        /// builds a new Jid object
        /// </summary>
        /// <param name="user">XMPP User part</param>
        /// <param name="server">XMPP Domain part</param>
        /// <param name="resource">XMPP Resource part</param>
        public Jid(string user, string server, string resource, bool stringprep = false)
        {
            if (!stringprep)
            {
                if (user != null)
                {
                    user = EscapeNode(user);

                    this.m_User = user.ToLower();
                }

                if (server != null)
                {
                    this.m_Server = server.ToLower();
                }

                if (resource != null)
                {
                    this.m_Resource = resource;
                }
            }
            else
            {
                if (user != null)
                {
                    user = EscapeNode(user);

                    this.m_User = Stringprep.NodePrep(user);
                }

                if (server != null)
                {
                    this.m_Server = Stringprep.NamePrep(server);
                }

                if (resource != null)
                {
                    this.m_Resource = Stringprep.ResourcePrep(resource);
                }
            }

            this.BuildJid();
        }
Example #7
0
        /// <summary>
        /// builds a new Jid object
        /// </summary>
        /// <param name="user">XMPP User part</param>
        /// <param name="server">XMPP Domain part</param>
        /// <param name="resource">XMPP Resource part</param>
        public Jid(string user, string server, string resource)
        {
#if !STRINGPREP
            if (user != null)
            {
                user = EscapeNode(user);

                m_User = user.ToLower();
            }

            if (server != null)
            {
                m_Server = server.ToLower();
            }

            if (resource != null)
            {
                m_Resource = resource;
            }
#else
            if (user != null)
            {
                user = EscapeNode(user);

                m_User = Stringprep.NodePrep(user);
            }

            if (server != null)
            {
                m_Server = Stringprep.NamePrep(server);
            }

            if (resource != null)
            {
                m_Resource = Stringprep.ResourcePrep(resource);
            }
#endif
            BuildJid();
        }
Example #8
0
        private void Parse(string jid)
        {
            Match match = JidRegex.Match(jid);

            if (match != null)
            {
                if (match.Groups["userid"] != null)
                {
                    userName = Stringprep.NamePrep(match.Groups["userid"].Value);
                }
                if (match.Groups["domain"] != null)
                {
                    domainName = Stringprep.NodePrep(match.Groups["domain"].Value);
                }
                if (match.Groups["resource"] != null)
                {
                    resourceName = Stringprep.ResourcePrep(match.Groups["resource"].Value);
                }
            }

            BuildBareAndFullJid();
        }
 public void Authenticate(string userName)
 {
     User          = !string.IsNullOrEmpty(userName) ? Stringprep.NodePrep(userName) : null;
     Authenticated = true;
 }