Beispiel #1
0
        /// <summary>
        /// Gets whether this instance and the specified instance are equal.
        /// </summary>
        /// <param name="other">The other instance.</param>
        /// <returns><c>true</c> if the instance are equal; <c>false</c> otherwise.</returns>
        public bool Equals(ISecurityId other)
        {
            if (other == null)
            {
                return(false);
            }

            return(this.Value == other.Value);
        }
        /// <summary>
        /// Initializes the <see cref="IntegratedSecurityIds" /> type.
        /// </summary>
        static IntegratedSecurityIds()
        {
            // Get the container.
            var container = HttpContext.Current.ApplicationInstance.GetModule<IApplicationModule>().Container;

            // Set up the security IDs.
            _anonymous = container.Resolve<ISecurityId>();
            _anonymous.Value = new Guid("{9f435196-00b2-4482-9edd-c2c935566452}");
        }
Beispiel #3
0
        /// <summary>
        /// Gets whether this instance and the specified instance are equal.
        /// </summary>
        /// <param name="other">The other instance.</param>
        /// <returns><c>true</c> if the instance are equal; <c>false</c> otherwise.</returns>
        public bool Equals(ISecurityId other)
        {
            if (other == null)
            {
                return false;
            }

            return this.Value == other.Value;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes the <see cref="IntegratedSecurityIds" /> type.
        /// </summary>
        static IntegratedSecurityIds()
        {
            // Get the container.
            var container = HttpContext.Current.ApplicationInstance.GetModule <IApplicationModule>().Container;

            // Set up the security IDs.
            _anonymous       = container.Resolve <ISecurityId>();
            _anonymous.Value = new Guid("{9f435196-00b2-4482-9edd-c2c935566452}");
        }
Beispiel #5
0
        /// <summary>
        /// Gets the claims for the user with the specified security ID.
        /// </summary>
        /// <param name="securityId">The security ID.</param>
        /// <returns>The claims.</returns>
        public IEnumerable<Claim> GetClaims(ISecurityId securityId)
        {
            // Get the user provider.
            var userProvider = this._container.Resolve<IUserProvider>();

            // Read the claims.
            var claims = userProvider.ReadClaimsBySecurityId(securityId);

            // Return the claims to the caller.
            return claims;
        }
Beispiel #6
0
        /// <summary>
        /// Gets the claims for the user with the specified security ID.
        /// </summary>
        /// <param name="securityId">The security ID.</param>
        /// <returns>The claims.</returns>
        public IEnumerable <Claim> GetClaims(ISecurityId securityId)
        {
            // Get the user provider.
            var userProvider = this._container.Resolve <IUserProvider>();

            // Read the claims.
            var claims = userProvider.ReadClaimsBySecurityId(securityId);

            // Return the claims to the caller.
            return(claims);
        }
        /// <summary>
        /// Reads the claims for the user with the specified security ID.
        /// </summary>
        /// <param name="securityId">The security ID.</param>
        /// <returns>A list of claims.</returns>
        public IEnumerable <Claim> ReadClaimsBySecurityId(ISecurityId securityId)
        {
            this._readerWriterLockSlim.EnterReadLock();

            try
            {
                // Get the user data context.
                TUserDataContext userDataContext = this.GetUserDataContext();

                // Read the claims by the security ID.
                var claims = ReadClaimsBySecurityId(userDataContext, securityId);

                // Dispose the user data context.
                this.DisposeUserDataContext(userDataContext);

                // Return the claims to the caller.
                return(claims);
            }
            finally
            {
                this._readerWriterLockSlim.ExitReadLock();
            }
        }
Beispiel #8
0
 /// <summary>
 /// Reads the claims for the user with the specified security ID.
 /// </summary>
 /// <param name="userDataContext">The user data context.</param>
 /// <param name="securityId">The security ID.</param>
 /// <returns>A list of claims.</returns>
 protected override IEnumerable <Claim> ReadClaimsBySecurityId(SqlConnection userDataContext, ISecurityId securityId)
 {
     throw new NotImplementedException();
 }
Beispiel #9
0
 /// <summary>
 /// Reads the claims for the user with the specified security ID.
 /// </summary>
 /// <param name="userDataContext">The user data context.</param>
 /// <param name="securityId">The security ID.</param>
 /// <returns>A list of claims.</returns>
 protected override IEnumerable <Claim> ReadClaimsBySecurityId(object userDataContext, ISecurityId securityId)
 {
     // Get the claims for the requested user and return them to the caller.
     return
         ((from u in this._users
           where u.SecurityId.Equals(securityId)
           select u.Claims).Single());
 }
 /// <summary>
 /// Reads the claims for the user with the specified security ID.
 /// </summary>
 /// <param name="userDataContext">The user data context.</param>
 /// <param name="securityId">The security ID.</param>
 /// <returns>A list of claims.</returns>
 protected abstract IEnumerable <Claim> ReadClaimsBySecurityId(TUserDataContext userDataContext, ISecurityId securityId);
Beispiel #11
0
        /// <summary>
        /// Reads the claims for the user with the specified security ID.
        /// </summary>
        /// <param name="userDataContext">The user data context.</param>
        /// <param name="securityId">The security ID.</param>
        /// <returns>A list of claims.</returns>
        protected override IEnumerable <Claim> ReadClaimsBySecurityId(XElement userDataContext, ISecurityId securityId)
        {
            // Get the login.
            var login =
                (from u in userDataContext.Elements(this._userNamespace, "user")
                 where u.Element(this._userNamespace, "securityId").Value.ToOrDefault <Guid>() == securityId.Value
                 select u.Element(this._userNamespace, "credentials").Element(this._userNamespace, "login").Value).Single();

            // Get the claims as XML.
            var claimsAsXml =
                (from u in userDataContext.Elements(this._userNamespace, "user")
                 where u.Element(this._userNamespace, "securityId").Value.ToOrDefault <Guid>() == securityId.Value
                 select u).Single().Element(this._userNamespace, "claims").Elements(this._userNamespace, "claim");

            // Create the list of claims.
            var claims = new List <Claim>();

            // Add security id and login.
            claims.Add(new Claim(
                           silkveil.net.Contracts.Identity.ClaimTypes.SecurityId, securityId.Value.ToString()));
            claims.Add(new Claim(
                           silkveil.net.Contracts.Identity.ClaimTypes.Login, login));

            // Add all other claims.
            foreach (var claimAsXml in claimsAsXml)
            {
                claims.Add(new Claim(
                               claimAsXml.Attribute("type").Value, claimAsXml.Attribute("value").Value));
            }

            // Return the claims to the caller.
            return(claims);
        }