public async Task AppendToStream(IIdentity id, long expectedVersion, ICollection<IEvent> events)
        {
            if (events.Count == 0)
            {
                return;
            }

            var name = id.ToString();
            var data = this.serializer.SerializeEvent(events.ToArray());

            try
            {
                await this.appender.Append(name, data, expectedVersion);
            }
            catch (AppendOnlyStoreConcurrencyException e)
            {
                // load server events
                var server = await this.LoadEventStream(id, 0, int.MaxValue);
                // throw a real problem
                throw OptimisticConcurrencyException.Create(server.Version, e.ExpectedStreamVersion, id, server.Events);
            }

            foreach (var @event in events)
            {
                Logger.DebugFormat("{0} r{1} Event: {2}", id, expectedVersion, @event);
            }
        }
 public TaskController(ICommandBus commandBus, IMappingEngine mappingEngine, IIdentity identity, IViewModelData viewModelData)
 {
     _commandBus = commandBus;
     _mappingEngine = mappingEngine;
     _identity = identity;
     _viewModelData = viewModelData;
 }
		public static void Queue(string id, int maxThreads, IIdentity identity, Action method)
		{
			// add our method to a queue along with its task
			// signal our threads;
			// if they are all busy make a new one if we are not at max count
			// all threads should check the queue before going idle
		}
Example #4
0
 private SuiteProvider(IIdentity identity, string text, bool ignored)
     : base(identity, text, ignored)
 {
     _contextProviders = new IOperationProvider[0];
       _suiteProviders = new ISuiteProvider[0];
       _testProviders = new ITestProvider[0];
 }
 /// <summary>
 /// Asserts that <paramref name="identity"/> is not authenticated.
 /// </summary>		
 public static void IsNotAuthenticated(IIdentity identity)
 {
     Assert.IsNotNull(identity);
     Assert.IsFalse(identity.IsAuthenticated,
                   "Identity {0} authentitcated",
                   identity.Name);
 }
Example #6
0
 /// <summary>
 /// Creates a new instance of the ServerSession class.
 /// </summary>
 /// <param name="sessionID">Session ID</param>
 /// <param name="timestamp">Zeitstempel der Sitzung</param>
 /// <param name="identity">Client identity</param>
 /// <param name="sessionVariableAdapter">Adapter for accessing session variables</param>
 internal ServerSession(Guid sessionID, DateTime timestamp, IIdentity identity, SessionVariableAdapter sessionVariableAdapter)
 {
     _timestamp = timestamp;
     _sessionID = sessionID;
     _identity = identity;
     _sessionVariableAdapter = sessionVariableAdapter;
 }
		internal ServletPrincipal (BaseWorkerRequest req) {
			_request = req;
			string authType = req.GetAuthType ();
			if (authType == null)
				authType = String.Empty;
			_identity = new GenericIdentity (req.GetRemoteUser (), authType);
		}
        public OAuthRequestToken(
            string token,
            string secret,
            IConsumer consumer,
            TokenStatus status,
            OAuthParameters associatedParameters,
            IIdentity authenticatedUser,
            string[] roles)
            : this()
        {
            if (string.IsNullOrEmpty(token))
                throw new ArgumentException("token must not be null or empty", "token");

            if (secret == null)
                throw new ArgumentNullException("secret", "secret must not be null");

            if (consumer == null)
                throw new ArgumentNullException("consumer", "consumer must not be null");

            if (roles == null)
                throw new ArgumentNullException("roles", "roles must not be null");

            this.Token = token;
            this.Secret = secret;
            this.Status = status;
            this.ConsumerKey = consumer.Key;
            this.AssociatedParameters = associatedParameters;
            this.AuthenticatedUser = authenticatedUser;
            this.Roles = roles;
        }
Example #9
0
        /// <summary>
        /// Add an additional ClaimsIdentity to the ClaimsPrincipal in the "server.User" environment key
        /// </summary>
        /// <param name="identity"></param>
        public void AddUserIdentity(IIdentity identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            var newClaimsPrincipal = new ClaimsPrincipal(identity);

            IPrincipal existingPrincipal = _context.Request.User;
            if (existingPrincipal != null)
            {
                var existingClaimsPrincipal = existingPrincipal as ClaimsPrincipal;
                if (existingClaimsPrincipal == null)
                {
                    IIdentity existingIdentity = existingPrincipal.Identity;
                    if (existingIdentity.IsAuthenticated)
                    {
                        newClaimsPrincipal.AddIdentity(existingIdentity as ClaimsIdentity ?? new ClaimsIdentity(existingIdentity));
                    }
                }
                else
                {
                    foreach (var existingClaimsIdentity in existingClaimsPrincipal.Identities)
                    {
                        if (existingClaimsIdentity.IsAuthenticated)
                        {
                            newClaimsPrincipal.AddIdentity(existingClaimsIdentity);
                        }
                    }
                }
            }
            _context.Request.User = newClaimsPrincipal;
        }
Example #10
0
 /// <summary>
 /// Initializes LoginEventArgs instance.
 /// </summary>
 /// <param name="eventType">Login event type.</param>
 /// <param name="identity">Client's identity.</param>
 /// <param name="timestamp">Event timestamp.</param>
 public LoginEventArgs(LoginEventType eventType, IIdentity identity, DateTime timestamp)
 {
     EventType = eventType;
     Identity = identity;
     ClientAddress = string.Empty;
     Timestamp = timestamp;
 }
        public IRecordStorage GetOrCreateStorage(IIdentity id)
        {
            if (!s_storages.ContainsKey(id))
                s_storages.Add(id, new MemoryRecordStorage(id));

            return s_storages[id];
        }
        /// <summary>
        ///     The is user in role.
        /// </summary>
        /// <param name="identity">
        ///     The identity.
        /// </param>
        /// <param name="roles">
        ///     The roles.
        /// </param>
        /// <returns>
        ///     The <see cref="bool" />.
        /// </returns>
        public bool IsUserInRole(IIdentity identity, string roles)
        {
            Contract.Requires<ArgumentNullException>(identity != null, "identity");
            Contract.Requires<ArgumentNullException>(roles != null, "roles");

            return true;
        }
Example #13
0
        public CustomPrincipal(IIdentity identity, String[] roles)
        {
            if (identity == null) throw new ArgumentNullException("identity");

            this.m_Identity = identity;
            this.m_Roles = roles;
        }
 public CustomIdentity(IIdentity identity)
 {
     this.AuthenticationType = identity.AuthenticationType;
     this.IsAuthenticated = identity.IsAuthenticated;
     this.Name = identity.Name;
     this.Role = "admin";
 }
		public HttpHandlerContext(Server server, HttpRequestProcessor.Host host, Connection connection, IIdentity identity)
		{
			Server = server;
			Host = host;
			Connection = connection;
			Identity = identity;
		}
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="identity"></param>
 /// <param name="user"></param> 
 public UserPrincipal(
     IIdentity identity,
     IdentityUser user)
 {
     _owrIdentity = identity;
     _user = user;
 }
 public DuplicateOperationException(
     ISourceId sourceId, IIdentity aggregateId, string message)
     : base(message)
 {
     SourceId = sourceId;
     AggregateId = aggregateId;
 }
Example #18
0
        /// <summary>
        /// Creates an instance of <see cref="IBoilerplateContext"/>
        /// </summary>
        /// <param name="identity">The current identity being used (rights and roles contract requirements/restrictions will apply to this identity)</param>
        /// <param name="accessProvider">An access provider for specific types (available through IBoilerplateContext.Open&lt;T&gt;())</param>
        /// <param name="permissionsProvider">The provider that will be used for all permissions verification attempts</param>
        /// <param name="visibility">The visibility level that this context has. This will affect operations that rely on visibility (e.g. logging).</param>
        /// <returns>An instance of <see cref="IBoilerplateContext"/></returns>
        public static IBoilerplateContext New(IIdentity identity = null, 
                                              ITypeAccessProvider accessProvider = null, 
                                              IPermissionsProvider permissionsProvider = null,
                                              Visibility visibility = Visibility.None)
        {   
            var actualIdentity = identity ?? Identity.Default;
            var actualTypeAccessProvider = accessProvider ?? TypeAccessProvider.Empty;
            var actualPermissionsProvider = permissionsProvider ?? PermissionsProvider.Default;

            var functionGenerator = new FunctionGenerator();

            //Core providers
            var translationProvider = new TranslationProvider(functionGenerator);
            var validationProvider = new ValidationProvider(functionGenerator);
            var logProvider = new LogProvider(functionGenerator, visibility);

            //Set up error handling
            var tryCatchProvider = new TryCatchBlockProvider(functionGenerator);
            var exceptionHandlerProvider = new ExceptionHandlerProvider(logProvider);
            var errorContext = new ImmutableErrorContext(logProvider, tryCatchProvider, exceptionHandlerProvider);

            var bundle = new ContextBundle(permissionsProvider: actualPermissionsProvider,
                                           errorContext: errorContext,
                                           translationProvider: translationProvider,
                                           accessProvider: actualTypeAccessProvider,
                                           validationProvider: validationProvider,
                                           logProvider: logProvider,
                                           visibility: visibility);

            return new InitialBoilerplateContext<ContractContext>(bundle, actualIdentity);
        }
Example #19
0
 public SenderIdentity(IIdentity identity)
 {
     if (identity == null) throw new ArgumentNullException("identity");
     _name = identity.Name;
     _authenticationType = identity.AuthenticationType;
     _isAuthenticated = identity.IsAuthenticated;
 }
        /// <summary>
        /// Helper method to ensure that the <seealso cref="IIdentity"/> can authenticate against
        /// the <seealso cref="Membership"/> and that the <seealso cref="IIdentity"/> is also
        /// authorized to make the requested changes against the account retrieved
        /// from the accountId
        /// </summary>
        /// <param name="identity">
        /// The <c>IIdentity</c> of the user authorized to delete the <c>EmailAddress</c> 
        /// from the repository
        /// </param>
        /// <param name="accountId">
        /// The id of the <seealso cref="Account"/> to use for authorization
        /// </param>
        /// <exception cref="SecurityException">
        /// Thrown if the <seealso cref="IIdentity"/> cannot be authenticated or is not authorized 
        /// to access the records requested
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown if the <seealso cref="Account"/> with the provided id cannot be retrieved from the 
        /// repository
        /// </exception>
        public virtual void AuthorizeAction(IIdentity identity, int accountId)
        {
            var user = Membership.GetUser(identity.Name, false);

            if (user == null)
            {
                throw new SecurityException(
                    string.Format(
                        "The user {0} is not properly authenticated against the membership provider.", identity.Name));
            }

            var ownerAccount = accountReadRepository.FindBy(account => account.Id.Equals(accountId));

            if (ownerAccount == null)
            {
                throw new ArgumentException(
                    string.Format("The account with id {0} cannot be found", accountId), "accountId");
            }

            // ReSharper disable PossibleNullReferenceException
            if (!ownerAccount.UserId.Equals((Guid)user.ProviderUserKey) && !Roles.IsUserInRole("Admin"))
            // ReSharper restore PossibleNullReferenceException)
            {
                throw new SecurityException(
                    string.Format(
                        "The user {0} is not authorized to access the method called for the account owned by {1}",
                        identity.Name,
                        ownerAccount.Name));
            }
        }
 public Controller(IIdentity currentUser)
 {
     if (currentUser.IsAuthenticated)
     {
         loadCurrentUser();
     }
 }
Example #22
0
 public WebPrincipal(IIdentity identity, string token, string userName, string displayName)
 {
     _token = token;
     _identity = identity;
     _displayName = displayName;
     _userName = userName;
 }
Example #23
0
        /// <summary>
        /// helper method to add roles 
        /// </summary>
        void AddIdentityWithRoles(IIdentity identity, string[] roles)
        {
            ClaimsIdentity claimsIdentity = identity as ClaimsIdentity;

            if (claimsIdentity != null)
            {
                claimsIdentity = claimsIdentity.Clone();
            }
            else
            {
                claimsIdentity = new ClaimsIdentity(identity);
            }

            // Add 'roles' as external claims so they are not serialized
            // TODO - brentsch, we should be able to replace GenericPrincipal and GenericIdentity with ClaimsPrincipal and ClaimsIdentity
            // hence I am not too concerned about perf.
            List<Claim> roleClaims = new List<Claim>();
            if (roles != null && roles.Length > 0)
            {
                foreach (string role in roles)
                {
                    if (!string.IsNullOrWhiteSpace(role))
                    {
                        roleClaims.Add(new Claim(claimsIdentity.RoleClaimType, role, ClaimValueTypes.String, ClaimsIdentity.DefaultIssuer, ClaimsIdentity.DefaultIssuer, claimsIdentity));
                    }
                }

                claimsIdentity.ExternalClaims.Add(roleClaims);
            }

            base.AddIdentity(claimsIdentity);
        }
Example #24
0
 public override async Task<ITestAggregateReadModel> GetTestAggregateReadModelAsync(IIdentity id)
 {
     return await _queryProcessor.ProcessAsync(
         new ReadModelByIdQuery<InMemoryTestAggregateReadModel>(id.Value),
         CancellationToken.None)
         .ConfigureAwait(false);
 }
            public override void SetUp()
            {
                base.SetUp();

                _orderModel = Fixture.Create<PurchaseOrderModel>();
                _currentUser = new Mock<IIdentity>().Object;
            }
 public RolePrincipal(IIdentity identity)
 {
     if (identity == null)
         throw new ArgumentNullException( "identity" );
     _Identity = identity;
     Init();
 }
Example #27
0
        /// <summary>
        /// Creates Principal and Identity based on the user name and roles from the 
        /// asp.net authentication cookie;
        /// </summary>
        /// <returns>The current principal</returns>
        public static IPrincipal GetPrincipalFromCookie(IIdentity identity)
        {
            string cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = HttpContext.Current.Request.Cookies[cookieName];

            if (authCookie == null)
            {
                // There is no authentication cookie.
                return SetEmptyPrincipal();
            }

            FormsAuthenticationTicket authTicket = null;
            try
            {
                authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            }
            catch
            {
                // error occured. Let user authenticate again
                return SetEmptyPrincipal();
            }

            if (authTicket == null)
            {
                // Cookie failed to decrypt.
                return SetEmptyPrincipal();
            }

            // Whenever we load cookie we always load the Roles instead of loading it from Userdata
            string[] roles = Roles.GetRolesForUser(identity.Name);

            IPrincipal principal = new VKeCRMPrincipal(identity, roles);
            HttpContext.Current.User = principal;
            return principal;
        }
        private ClaimSet MapClaims(EvaluationContext evaluationContext, out IIdentity identity)
        {

            List<IIdentity> identities = evaluationContext.Properties["Identities"] as List<IIdentity>;
            
            if (identities.Count == 0)
                throw new SecurityException("Authorization failed, identity missing from evaluation context.");

            identity = new CustomIdentity(identities[0].Name);
            
            // TODO: check identity against credential store and 
            // determine the appropriate claims to allocate
            
            // NOTE: in this sample, only partner certificates are provided,
            // and at this point have passed authorization, so we will grant
            // all custom claims 
            
            List<Claim> listClaims = new List<Claim>();

            listClaims.Add(new Claim(CustomClaimTypes.Create, "Application", Rights.PossessProperty));
            listClaims.Add(new Claim(CustomClaimTypes.Delete, "Application", Rights.PossessProperty));
            listClaims.Add(new Claim(CustomClaimTypes.Read, "Application", Rights.PossessProperty));
            listClaims.Add(new Claim(CustomClaimTypes.Update, "Application", Rights.PossessProperty));

            return new DefaultClaimSet(this.m_issuer, listClaims);
        }
        public void AppendToStream(IIdentity id, long expectedVersion, IList<IEvent> newEvents)
        {
            var server = this.client.GetServer();
            var db = server.GetDatabase("EventStore");
            var query = Query<MongoEventDocument>.EQ(s => s.id, id);
            
            var events = db.GetCollection<MongoEventDocument>("Events",_commitSettings);

            //events.Insert<MongoEventDocument>(new MongoEventDocument
            //{
            //    events = newEvents.ToList<IEvent>(),
            //    id = id,
            //    version = 1
            //});

            var doc = events.FindOneAs<MongoEventDocument>(query);
            if (doc == null) events.Insert<MongoEventDocument>(new MongoEventDocument
            {
                events = newEvents.ToList<IEvent>(),
                id = id,
                version = 1
            });
            if (doc != null)
            {
                doc.events.AddRange(newEvents);
                doc.version += 1;
                events.Save(doc);
            }


        }
Example #30
0
		internal Identity(IIdentity identity, X509Certificate2 clientCertificate)
		{
			this.AuthenticationType = identity.AuthenticationType;
			this.IsAuthenticated = identity.IsAuthenticated;
			this.Name = identity.Name;
			this.Certificate = clientCertificate;
		}
Example #31
0
        public static string GetUserProfilePhoto(this IIdentity identity)
        {
            var ProfilePhoto = ((ClaimsIdentity)identity).FindFirst("Photo");

            return((ProfilePhoto != null) ? ProfilePhoto.Value : string.Empty);
        }
 public TAggregate GetById <TAggregate>(string bucketId, IIdentity id) where TAggregate : class, IAggregateEx
 {
     return(this.GetById <TAggregate>(bucketId, id, int.MaxValue));
 }
 public virtual TAggregate GetById <TAggregate>(IIdentity id, int versionToLoad) where TAggregate : class, IAggregateEx
 {
     return(this.GetById <TAggregate>(Bucket.Default, id, versionToLoad));
 }
Example #34
0
        /// <summary>
        /// Handles the connection process of clients
        /// </summary>
        private void HandleClientComm(object sender)
        {
            //This conntects the client
            //first we need an rescue timer

            _BootUpTimer = new Timer(new TimerCallback(_BootUpTimer_Elapsed), null, 0, 100);

            bool leaveInnerStreamOpen = false;

            try
            {
                _SocketTCPClient.LingerState = new LingerOption(true, 10);

                // encryption
                if (_Mode == VaserOptions.ModeKerberos)
                {
                    _ConnectionStream = new NetworkStream(_SocketTCPClient);
                    QueueSend         = QueueSendKerberos;
                    _AuthStream       = new NegotiateStream(_ConnectionStream, leaveInnerStreamOpen);
                }

                if (_Mode == VaserOptions.ModeSSL)
                {
                    _ConnectionStream = new NetworkStream(_SocketTCPClient);
                    QueueSend         = QueueSendSSL;
                    _sslStream        = new SslStream(_ConnectionStream, leaveInnerStreamOpen);
                }

                if (_Mode == VaserOptions.ModeNotEncrypted)
                {
                    QueueSend = QueueSendNotEncrypted;
                    //_NotEncryptedStream = _ConnectionStream;
                }

                if (IsServer)
                { //server
                    if (_Mode == VaserOptions.ModeKerberos)
                    {
                        if (_vKerberosS._policy == null)
                        {
                            if (_vKerberosS._credential == null)
                            {
                                _AuthStream.AuthenticateAsServerAsync();
                            }
                            else
                            {
                                _AuthStream.AuthenticateAsServerAsync(_vKerberosS._credential, _vKerberosS._requiredProtectionLevel, _vKerberosS._requiredImpersonationLevel);
                            }
                        }
                        else
                        {
                            if (_vKerberosS._credential == null)
                            {
                                _AuthStream.AuthenticateAsServerAsync(_vKerberosS._policy);
                            }
                            else
                            {
                                _AuthStream.AuthenticateAsServerAsync(_vKerberosS._credential, _vKerberosS._policy, _vKerberosS._requiredProtectionLevel, _vKerberosS._requiredImpersonationLevel);
                            }
                        }

                        link.IsAuthenticated         = _AuthStream.IsAuthenticated;
                        link.IsEncrypted             = _AuthStream.IsEncrypted;
                        link.IsMutuallyAuthenticated = _AuthStream.IsMutuallyAuthenticated;
                        link.IsSigned = _AuthStream.IsSigned;
                        link.IsServer = _AuthStream.IsServer;

                        IIdentity id = _AuthStream.RemoteIdentity;

                        link.UserName = id.Name;
                    }


                    if (_Mode == VaserOptions.ModeSSL)
                    {
                        if (_vSSLS._enabledSslProtocols == SslProtocols.None)
                        {
                            _sslStream.AuthenticateAsServerAsync(_vSSLS._serverCertificate);
                        }
                        else
                        {
                            _sslStream.AuthenticateAsServerAsync(_vSSLS._serverCertificate, _vSSLS._clientCertificateRequired, _vSSLS._enabledSslProtocols, _vSSLS._checkCertificateRevocation);
                        }

                        link.IsEncrypted = true;
                        link.IsServer    = true;
                    }

                    if (_Mode == VaserOptions.ModeNotEncrypted)
                    {
                        link.IsServer = true;
                    }

                    link.vServer = server;

                    BootupDone = true;
                    server.AddNewLink(link);
                }
                else
                { //client
                    if (_Mode == VaserOptions.ModeKerberos)
                    {
                        if (_vKerberosC._binding == null)
                        {
                            if (_vKerberosC._credential == null)
                            {
                                _AuthStream.AuthenticateAsClientAsync();
                            }
                            else
                            {
                                if (_vKerberosC._requiredProtectionLevel == ProtectionLevel.None && _vKerberosC._requiredImpersonationLevel == TokenImpersonationLevel.None)
                                {
                                    _AuthStream.AuthenticateAsClientAsync(_vKerberosC._credential, _vKerberosC._targetName);
                                }
                                else
                                {
                                    _AuthStream.AuthenticateAsClientAsync(_vKerberosC._credential, _vKerberosC._targetName, _vKerberosC._requiredProtectionLevel, _vKerberosC._requiredImpersonationLevel);
                                }
                            }
                        }
                        else
                        {
                            if (_vKerberosC._requiredProtectionLevel == ProtectionLevel.None && _vKerberosC._requiredImpersonationLevel == TokenImpersonationLevel.None)
                            {
                                _AuthStream.AuthenticateAsClientAsync(_vKerberosC._credential, _vKerberosC._binding, _vKerberosC._targetName);
                            }
                            else
                            {
                                _AuthStream.AuthenticateAsClientAsync(_vKerberosC._credential, _vKerberosC._binding, _vKerberosC._targetName, _vKerberosC._requiredProtectionLevel, _vKerberosC._requiredImpersonationLevel);
                            }
                        }

                        link.IsAuthenticated         = _AuthStream.IsAuthenticated;
                        link.IsEncrypted             = _AuthStream.IsEncrypted;
                        link.IsMutuallyAuthenticated = _AuthStream.IsMutuallyAuthenticated;
                        link.IsSigned = _AuthStream.IsSigned;
                        link.IsServer = _AuthStream.IsServer;

                        IIdentity id = _AuthStream.RemoteIdentity;
                    }

                    if (_Mode == VaserOptions.ModeSSL)
                    {
                        if (_vSSLC._clientCertificates == null)
                        {
                            _sslStream.AuthenticateAsClientAsync(_vSSLC._targetHost);
                        }
                        else
                        {
                            _sslStream.AuthenticateAsClientAsync(_vSSLC._targetHost, _vSSLC._clientCertificates, _vSSLC._enabledSslProtocols, _vSSLC._checkCertificateRevocation);
                        }


                        link.IsEncrypted = true;
                    }

                    //Thread.Sleep(50);
                    BootupDone = true;

                    _IsAccepted = true;
                    if (_Mode == VaserOptions.ModeNotEncrypted)
                    {
                        ThreadPool.QueueUserWorkItem(ReceiveNotEncrypted);
                    }
                    if (_Mode == VaserOptions.ModeKerberos)
                    {
                        ThreadPool.QueueUserWorkItem(ReceiveKerberos);
                    }
                    if (_Mode == VaserOptions.ModeSSL)
                    {
                        ThreadPool.QueueUserWorkItem(ReceiveSSL);
                    }
                }

                if (EnableHeartbeat)
                {
                    HeartbeatTimer = new Timer(new TimerCallback(OnHeartbeatEvent), null, HeartbeatMilliseconds, HeartbeatMilliseconds);
                }
            }
            catch (AuthenticationException e)
            {
                Debug.WriteLine("Authentication failed. " + e.ToString());
                _BootUpTimer.Dispose();

                Stop();
                return;
            }
            catch (Exception e)
            {
                Debug.WriteLine("Authentication failed. " + e.ToString());
                _BootUpTimer.Dispose();

                Stop();
                return;
            }
            // encryption END
            _BootUpTimer.Dispose();
            _BootUpTimer = null;
        }
        public static void SetCookie(this IAbpAntiForgeryManager manager, HttpContext context, IIdentity identity = null)
        {
            if (identity != null)
            {
                context.User = new ClaimsPrincipal(identity);
            }

            context.Response.Cookies.Append(manager.Configuration.TokenCookieName, manager.GenerateToken());
        }
Example #36
0
 public RunResult(IIdentity identity, string text, State state, IEnumerable <ISuiteResult> suiteResults)
     : base(identity, text, state)
 {
     SuiteResults = suiteResults;
 }
Example #37
0
        public static string GetEmailAddress(this IIdentity identity)
        {
            var EmailAddress = ((ClaimsIdentity)identity).FindFirst("Email");

            return((EmailAddress != null) ? EmailAddress.Value : string.Empty);
        }
Example #38
0
 internal void ConnectionEstablishedCallback(object sender, IIdentity identity)
 {
     Events.ConnectionEstablished(identity.Id);
     this.actionBlock.Post(identity);
 }
Example #39
0
 public static bool IsAllowed(this IIdentity identity, string[] allowedUserNames, bool throwIfFalse = false)
 => identity.IsAllowed(allowedUserNames, throwIfFalse ? new PermissionDeniedException() : null);
Example #40
0
 public OpenGenericPrincipal(IIdentity identity, string[] roles)
 {
     _roles = roles;
     _base  = new GenericPrincipal(identity, roles);
 }
 bool ValidateCredentials(SharedAccessSignature sharedAccessSignature, ServiceIdentity serviceIdentity, IIdentity identity) =>
 this.ValidateTokenWithSecurityIdentity(sharedAccessSignature, serviceIdentity) &&
 this.ValidateAudience(sharedAccessSignature.Audience, identity) &&
 this.ValidateExpiry(sharedAccessSignature, identity);
Example #42
0
 public CustomIdentity(IIdentity identity)
 {
     Identity = identity;
     UserId   = Membership.GetUser(identity.Name).ProviderUserKey.ToString();
 }
 public CustomPrincipal(IIdentity identity)
 {
     // TODO: Complete member initialization
     this.Identity = identity;
 }
Example #44
0
 public FakePrincipal(IIdentity identity, string[] roles)
 {
     _identity = identity;
     _roles    = roles;
 }
 public CustomPrincipal(string username)
 {
     Identity = new GenericIdentity(username);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="clerkIdentity"></param>
 /// <returns></returns>
 public Clerk Lookup(IIdentity clerkIdentity)
 {
     return(clerkIdentity == null ? null : Lookup(clerkIdentity.Name));
 }
Example #47
0
        public static string GetTeamName(this IIdentity identity)
        {
            var claim = ((ClaimsIdentity)identity).FindFirst("TeamName");

            return((claim != null) ? claim.Value : string.Empty);
        }
Example #48
0
 public BizManPrinciple(String Username)
 {
     this.Identity = new GenericIdentity(Username);
 }
Example #49
0
 private BusinessPrincipal(IIdentity identity)
     : base(identity)
 {
 }
Example #50
0
        public static string GetTotalMatches(this IIdentity identity)
        {
            var claim = ((ClaimsIdentity)identity).FindFirst("TotalMatches");

            return((claim != null) ? claim.Value : string.Empty);
        }
Example #51
0
 public static string NameWithoutDomainTruncated(this IIdentity identity, int maxLength)
 {
     return(NameWithoutDomain(identity).PadRight(maxLength).Substring(0, maxLength).Trim());
 }
Example #52
0
 public static string GetId(this IIdentity identity)
 {
     return(identity.GetUserId());
 }
Example #53
0
 public Serializer(ISerializer <RootClass> serializer, IIdentity name)
 {
     _serializer = serializer;
     _name       = name;
 }
Example #54
0
 public static int Id(this IIdentity identity)
 {
     return(identity.IsAuthenticated ? Convert.ToInt32(identity.Name) : 0);
 }
Example #55
0
        public static ClaimsIdentity GetClaims(IIdentity userIdentity)
        {
            var user = (ClaimsIdentity)userIdentity;

            return(user);
        }
Example #56
0
 public static string NameWithoutDomainToUpper(this IIdentity identity)
 {
     return(NameWithoutDomain(identity).ToUpperInvariant());
 }
 public static IEnumerable <string> GetRoles(this IIdentity identity)
 {
     return(FindValues(identity as ClaimsIdentity, TokenConstants.Claims.Role));
 }
Example #58
0
 public Composer(IIdentity name) => _name = name;
        public static string GetOrganizationName(this IIdentity identity)
        {
            var ci = identity as ClaimsIdentity;

            return(ci?.FindFirstValue(TokenConstants.Claims.OrganizationName));
        }
Example #60
0
 public static bool IsSuperAdministrator(IIdentity userIdentity)
 {
     return(IsSuperAdministrator(GetUserInfoId(userIdentity)));
 }