public CouchSessionFactory(string uriBase, IUserCredential userCredential, AuthenticationLevel authLevel)
            : base(uriBase, userCredential, authLevel)
        {
            if (string.IsNullOrWhiteSpace(uriBase))
                throw new CouchParameterException("UriBase on IJSessionConfig cannot be empty or null.", "uriBase");

            if (userCredential == null)
                throw new CouchParameterException("userCredential on IJSessionConfig cannot be null.", "userCredential");

            try
            {
                this.EchoCouch();
            }
            catch (Exception ex)
            {
                throw new CouchException(ex.Message, ex);
            }

            serializerSettings = new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                    TypeNameHandling = TypeNameHandling.None,
                    ContractResolver = new CamelCasePropertyNamesContractResolver(),
                    ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
                };

            this.sessionUsers = new HashSet<IJDocumentSession>();
        }
Exemple #2
0
 public ProfileModel(Guid id, string email, string firstName, string familyName, string url, string password, byte[] passwordSalt, string profilePictureSrc, DateTime creationDate, bool isConfirmed, AuthenticationLevel authenticationLevel, Guid?homeFacultyId)
     : base(id)
 {
     Email               = email;
     Password            = password;
     PasswordSalt        = passwordSalt;
     CreationDate        = creationDate;
     IsConfirmed         = isConfirmed;
     AuthenticationLevel = authenticationLevel;
     HomeFacultyId       = homeFacultyId;
     ProfilePictureSrc   = profilePictureSrc;
     FirstName           = firstName;
     FamilyName          = familyName;
     Url                      = url;
     CourseVisits             = new List <CourseVisitModel>();
     Feedbacks                = new List <FeedbackModel>();
     CreatedCourses           = new List <CourseModel>();
     Posts                    = new List <PostModel>();
     PostLikes                = new List <PostLikeModel>();
     PostComments             = new List <PostCommentModel>();
     PostCommentLikes         = new List <PostCommentLikeModel>();
     EmailConfirmationSecrets = new List <EmailConfirmationSecretModel>();
     NewPasswordSecrets       = new List <NewPasswordSecretModel>();
     EmailConfirmationSecrets = new List <EmailConfirmationSecretModel>();
     NewPasswordSecrets       = new List <NewPasswordSecretModel>();
 }
Exemple #3
0
        internal void Login(string sourceAlias, string username, string password)
        {
            try
            {
                //See if we can log into the selected source.
                AuthenticationLevel authLevel = LoginToIndividualSource(sourceAlias, username, password);

                if (authLevel != AuthenticationLevel.None)
                {
                    CaseSourcesObject caseSource = FindSource(sourceAlias);

                    if (caseSource != null)
                    {
                        caseSource.IsLoggedIn = true;
                    }

                    //If we are successful in logging in, spin off a thread to try the login with other sources.
                    Thread loginSourcesThread = new Thread(new ParameterizedThreadStart(delegate { LoginSources(username, password); }));
                    loginSourcesThread.Start();
                }
            }
            catch (Exception exp)
            {
                //TODO: Log error into error log whenever we finally do that.
                throw exp;
            }
        }
Exemple #4
0
        //parameterized
        /// <summary>
        ///    <para>Constructs a new options object to be used for a WMI
        ///       connection with the specified values.</para>
        /// </summary>
        /// <param name='locale'>Indicates the locale to be used for this connection</param>
        /// <param name=' username'>Specifies the user name to be used for the connection. If null the currently logged on user's credentials are used.</param>
        /// <param name=' password'>Specifies the password for the given username. If null the currently logged on user's credentials are used.</param>
        /// <param name=' authority'><para>The authority to be used to authenticate the specified user</para></param>
        /// <param name=' impersonation'>The DCOM impersonation level to be used for this connection</param>
        /// <param name=' authentication'>The DCOM authentication level to be used for this connection</param>
        /// <param name=' enablePrivileges'>Specifies whether to enable special user privileges. This should only be used when performing an operation that requires special NT user privileges.</param>
        /// <param name=' context'>A provider-specific named value pairs object to be passed through to the provider.</param>
        /// <param name=' timeout'>Reserved for future use.</param>
        public ConnectionOptions(string locale,
                                 string username, string password, string authority,
                                 ImpersonationLevel impersonation, AuthenticationLevel authentication,
                                 bool enablePrivileges,
                                 ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout)
        {
            if (locale != null)
            {
                this.locale = locale;
            }

            this.username         = username;
            this.enablePrivileges = enablePrivileges;

            this.password = new EncryptedData(password);

            if (authority != null)
            {
                this.authority = authority;
            }

            if (impersonation != 0)
            {
                this.impersonation = impersonation;
            }

            if (authentication != 0)
            {
                this.authentication = authentication;
            }
        }
        /// <summary>
        /// Executes the logic for this workflow activity
        /// </summary>
        /// <param name="context">CodeActivityContext</param>
        protected override void Execute(CodeActivityContext context)
        {
            this.ActivityContext = context;
            try
            {
                if (!string.IsNullOrEmpty(context.GetValue(this.AuthenticationLevel)))
                {
                    this.authLevel = (AuthenticationLevel)Enum.Parse(typeof(AuthenticationLevel), context.GetValue(this.AuthenticationLevel));
                }

                this.InternalExecute();
            }
            catch (Exception ex)
            {
                if (!this.failingbuild)
                {
                    if (this.LogExceptionStack.Get(context))
                    {
                        string innerException = string.Empty;
                        if (ex.InnerException != null)
                        {
                            innerException = string.Format("Inner Exception: {0}", ex.InnerException.Message);
                        }

                        this.LogBuildError(string.Format("Error: {0}. Stack Trace: {1}. {2}", ex.Message, ex.StackTrace, innerException));
                    }
                }

                if (this.IgnoreExceptions.Get(context) != true)
                {
                    throw;
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Executes a query to retrieve objects.
        /// </summary>
        /// <param name="query">The query which will be executed.</param>
        /// <returns>An object collection that contains the result set of the query.</returns>
        /// <exception cref="System.ObjectDisposedException">Object already disposed.</exception>
        /// <exception cref="System.ArgumentNullException"><paramref name="query"/> is null.</exception>
        #endregion
        internal IWbemClassObjectEnumerator InternalExecuteQuery(WmiQuery query)
        {
            if (this.isDisposed)
            {
                throw new ObjectDisposedException(typeof(WmiConnection).FullName);
            }

            if (query == null)
            {
                throw new ArgumentNullException(MethodBase.GetCurrentMethod().GetParameters()[0].Name);
            }

            this.Open();

            IWbemClassObjectEnumerator enumerator;

            WbemClassObjectEnumeratorBehaviorOption behaviorOption = (WbemClassObjectEnumeratorBehaviorOption)query.EnumeratorBehaviorOption;

            if (this.IsRemote)
            {
                AuthenticationLevel authLevel = this.options.EnablePackageEncryption ? AuthenticationLevel.PacketPrivacy : AuthenticationLevel.PacketIntegrity;

                // use the native function by the extension method for a faster call
                enumerator = this.wbemServices.ExecQuery(query.ToString(), behaviorOption, this.context, authLevel, ImpersonationLevel.Impersonate, this.credential.UserName, this.credential.Password, this.Authority);
            }
            else
            {
                enumerator = this.wbemServices.ExecQuery(query.ToString(), behaviorOption, this.context);
            }

            return(enumerator);
        }
Exemple #7
0
 public Authentication(AuthenticationLevel authenticationLevel, string userID, string sessionID, string ip)
 {
     AuthenticationLevel = authenticationLevel;
     UserID    = userID;
     SessionID = sessionID;
     IP        = ip;
 }
Exemple #8
0
        public static ManagementClass GetClass(string nameSpace,
                                               string className,
                                               NetworkCredential credential            = null,
                                               ImpersonationLevel impersonationLevel   = ImpersonationLevel.Impersonate,
                                               AuthenticationLevel authenticationLevel = AuthenticationLevel.Default)
        {
            try
            {
                var options = new ConnectionOptions
                {
                    Impersonation    = impersonationLevel,
                    Authentication   = authenticationLevel,
                    Username         = credential?.UserName,
                    Password         = credential?.Password,
                    SecurePassword   = credential?.SecurePassword,
                    EnablePrivileges = true
                };
                var scope = new ManagementScope(nameSpace, options);
                scope.Connect();

                var option = new ObjectGetOptions(null, TimeSpan.MaxValue, true);
                var path   = new ManagementPath(className);
                var cls    = new ManagementClass(scope, path, option);
                return(cls);
            }
            catch (Exception ex)
            {
            }

            return(null);
        }
Exemple #9
0
 public ConnectionOptions(string locale, string username, SecureString password, string authority, ImpersonationLevel impersonation, AuthenticationLevel authentication, bool enablePrivileges, ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout)
 {
     if (locale != null)
     {
         this.locale = locale;
     }
     this.username         = username;
     this.enablePrivileges = enablePrivileges;
     if (password != null)
     {
         this.securePassword = password.Copy();
     }
     if (authority != null)
     {
         this.authority = authority;
     }
     if (impersonation != ImpersonationLevel.Default)
     {
         this.impersonation = impersonation;
     }
     if (authentication != AuthenticationLevel.Default)
     {
         this.authentication = authentication;
     }
 }
 public ConnectionOptions(string locale, string username, string password, string authority, ImpersonationLevel impersonation, AuthenticationLevel authentication, bool enablePrivileges, ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout)
 {
     if (locale != null)
     {
         this.locale = locale;
     }
     this.username = username;
     this.enablePrivileges = enablePrivileges;
     if (password != null)
     {
         this.securePassword = new SecureString();
         for (int i = 0; i < password.Length; i++)
         {
             this.securePassword.AppendChar(password[i]);
         }
     }
     if (authority != null)
     {
         this.authority = authority;
     }
     if (impersonation != ImpersonationLevel.Default)
     {
         this.impersonation = impersonation;
     }
     if (authentication != AuthenticationLevel.Default)
     {
         this.authentication = authentication;
     }
 }
Exemple #11
0
 public Invoice(string subject, string fileType, string path, decimal amount, string account, DateTime duedate, string kid = null,
                AuthenticationLevel authenticationLevel = AuthenticationLevel.Password,
                SensitivityLevel sensitivityLevel       = SensitivityLevel.Normal, ISmsNotification smsNotification = null)
     : this(
         subject, fileType, ExtractBytesFromPath(path), amount, account, duedate, kid, authenticationLevel,
         sensitivityLevel, smsNotification)
 {
 }
 public RequestContext(LoginTokenModel?loginToken, AuthenticationLevel authenticationLevel, string requestId, Language language, IPAddress ipAddress)
 {
     LoginToken          = loginToken;
     AuthenticationLevel = authenticationLevel;
     RequestId           = requestId;
     Language            = language;
     IpAddress           = ipAddress;
 }
Exemple #13
0
        // constructors

        /// <devdoc>
        ///    <para>
        ///       Initializes a new instance of the <see cref='System.Net.WebRequest'/>
        ///       class.
        ///    </para>
        /// </devdoc>

        protected WebRequest()
        {
#if !FEATURE_PAL
            // Defautl values are set as per V1.0 behavior
            m_ImpersonationLevel  = TokenImpersonationLevel.Delegation;
            m_AuthenticationLevel = AuthenticationLevel.MutualAuthRequested;
#endif
        }
Exemple #14
0
        private AuthenticationLevel LoginToIndividualSource(string sourceAlias, string username, string password)
        {
            AuthenticationLevel ret = AuthenticationLevel.None;

            try
            {
                string          wsId     = m_SysConfig.GetDefaultConfig().WorkstationAlias;
                UserInfo        userInfo = new UserInfo(username, password);
                WorkstationInfo wsInfo   = new WorkstationInfo(wsId, userInfo);

                LoginResponse loginResponse = m_DataSourceAccess.Login(sourceAlias, wsInfo);

                ret = loginResponse.UserAuthenticationLevel;

                if (!ret.Equals(AuthenticationLevel.None))
                {
                    SysConfiguration sysConfig = new SysConfiguration();
                    sysConfig.ID = sourceAlias;
                    sysConfig.ContainerDBConnectionString = loginResponse.systemConfiguration.ContainerDBConnectString;
                    sysConfig.ContainerRefreshPeriodmsecs = loginResponse.systemConfiguration.ContainerRefreshPeriodSeconds * 1000;

                    if (m_SysConfig.Contains(sourceAlias))
                    {
                        m_SysConfig.Delete(sourceAlias);
                    }

                    m_SysConfig.Add(sysConfig);

                    if (m_SysConfig.UserProfileManager.Profile == null)
                    {
                        ProfileObject profile = ProfileTranslator.Translate(loginResponse.UserProfile, 4);
                        profile.SourceAlias = sourceAlias;
                        profile.UserName    = wsInfo.userInfo.UserName;
                        profile.Password    = wsInfo.userInfo.Password;

                        m_SysConfig.UserProfileManager.Profile = profile;
                        m_SysConfig.UserProfileManager.Profile.ProfileUpdatedEvent += new ProfileUpdated(ProfileUpdated);
                    }

                    DataSet caselist = null;
                    m_DataSourceAccess.GetCaseList(sourceAlias, out caselist);

                    if (caselist != null)
                    {
                        CaseListDataSet caseListDataSet = (CaseListDataSet)caselist;
                        caseListDataSet.CaseListTable.CaseListTableRowChanged +=
                            new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_CaseListTableRowChanged);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(ret);
        }
Exemple #15
0
 /// <summary>
 /// Creates a WMIHelper object targeting the desired scope on the specified hostname with optional authentication level. Beware that in order to make WMI calls work, the user running the application must have the corresponding privileges on the client machine. Otherwise it will throw an 'Access Denied' exception.
 /// </summary>
 /// <param name="scope">WMI namespace</param>
 /// <param name="hostname">Client machine</param>
 /// <param name="auth">Athentication level</param>
 public WMIHelper(string scope, string hostname, AuthenticationLevel auth = AuthenticationLevel.Default)
 {
     Scope = new ManagementScope(String.Format("\\\\{0}\\{1}", hostname, scope));
     Scope.Options = new ConnectionOptions
     {
         Impersonation = ImpersonationLevel.Impersonate,
         Authentication = auth
     };
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="uriBase"></param>
        /// <param name="userCredential"></param>
        /// <param name="authLevel"></param>
        protected internal CouchStoreChannel(string uriBase, IUserCredential userCredential, AuthenticationLevel authLevel)
        {
            if (string.IsNullOrWhiteSpace(uriBase))
                throw new CouchParameterException("UriBase on IJSessionConfig cannot be empty or null.", "uriBase");

            this.uriBase = uriBase;
            this.userCredential = userCredential;
            this.authLevel = authLevel;
        }
Exemple #17
0
        private void LoginSources(string username, string password)
        {
            CaseSourcesList wsCommSourceList;

            m_DataSourceAccess.RequestSources(SourceType.WSComm, out wsCommSourceList);

            foreach (CaseSourcesObject caseSourceObj in wsCommSourceList)
            {
                if (!caseSourceObj.IsLoggedIn)
                {
                    try
                    {
                        AuthenticationLevel authLevel = LoginToIndividualSource(caseSourceObj.Name, username, password);
                        if (!authLevel.Equals(AuthenticationLevel.None))
                        {
                            caseSourceObj.IsLoggedIn = true;
                        }
                        else
                        {
                            caseSourceObj.IsLoggedIn = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        caseSourceObj.IsLoggedIn = false;
                    }
                }
            }

            CaseSourcesList acsCommSourceList;

            m_DataSourceAccess.RequestSources(SourceType.ArchiveCase, out acsCommSourceList);

            foreach (CaseSourcesObject caseSourceObj in acsCommSourceList)
            {
                if (!caseSourceObj.IsLoggedIn)
                {
                    try
                    {
                        AuthenticationLevel authLevel = LoginToIndividualSource(caseSourceObj.Name, username, password);
                        if (!authLevel.Equals(AuthenticationLevel.None))
                        {
                            caseSourceObj.IsLoggedIn = true;
                        }
                        else
                        {
                            caseSourceObj.IsLoggedIn = false;
                        }
                    }
                    catch
                    {
                        caseSourceObj.IsLoggedIn = false;
                    }
                }
            }
        }
Exemple #18
0
 public Invoice(string subject, string fileType, byte[] contentBytes, decimal amount, string account, DateTime duedate, string kid = null,
                AuthenticationLevel authenticationLevel = AuthenticationLevel.Password,
                SensitivityLevel sensitivityLevel       = SensitivityLevel.Normal, ISmsNotification smsNotification = null)
     : base(subject, fileType, contentBytes, authenticationLevel, sensitivityLevel, smsNotification)
 {
     Kid     = kid;
     Amount  = amount;
     Account = account;
     Duedate = duedate;
 }
Exemple #19
0
 public WebRequestChannel()
 {
     // Set HWR default values
     this.allowPipelining                      = true;
     this.authenticationLevel                  = AuthenticationLevel.MutualAuthRequested;
     this.cachePolicy                          = WebRequest.DefaultCachePolicy;
     this.impersonationLevel                   = TokenImpersonationLevel.Delegation;
     this.maxResponseHeadersLength             = HttpWebRequest.DefaultMaximumResponseHeadersLength;
     this.readWriteTimeout                     = 5 * 60 * 1000; // 5 minutes
     this.unsafeAuthenticatedConnectionSharing = false;
 }
		public ConnectionOptions (string locale,
					  string username,
					  string password,
					  string authority,
					  ImpersonationLevel impersonation,
					  AuthenticationLevel authentication,
					  bool enablePrivileges,
					  ManagementNamedValueCollection context,
					  TimeSpan timeout)
		{
		}
Exemple #21
0
 public ConnectionOptions(string locale,
                          string username,
                          SecureString password,
                          string authority,
                          ImpersonationLevel impersonation,
                          AuthenticationLevel authentication,
                          bool enablePrivileges,
                          ManagementNamedValueCollection context,
                          TimeSpan timeout)
 {
 }
Exemple #22
0
 public StopComputerCommand()
 {
     this._asjob          = false;
     this._authentication = AuthenticationLevel.Packet;
     string[] strArrays = new string[1];
     strArrays[0]        = ".";
     this._computername  = strArrays;
     this._impersonation = ImpersonationLevel.Impersonate;
     this._throttlelimit = 32;
     this._force         = false;
 }
Exemple #23
0
        /// <summary>
        /// Description:
        ///     none
        ///	Arguments:
        ///		none
        ///	Exceptions:
        ///		none
        ///	Return:
        ///		none
        /// </summary>
        public AuthenticationLevel Login(String Username, String Password)
        {
            AuthenticationLevel authLevel = m_Host.Login(Username, Password);

            if (authLevel.Equals(AuthenticationLevel.NONE))
            {
                throw new Exception("Invalid Login");
            }

            return(authLevel);
        }
Exemple #24
0
 public WebRequestChannel()
 {
     // Set HWR default values
     this.allowPipelining = true;
     this.authenticationLevel = AuthenticationLevel.MutualAuthRequested;
     this.cachePolicy = WebRequest.DefaultCachePolicy;
     this.impersonationLevel = TokenImpersonationLevel.Delegation;
     this.maxResponseHeadersLength = HttpWebRequest.DefaultMaximumResponseHeadersLength;
     this.readWriteTimeout = 5 * 60 * 1000; // 5 minutes
     this.unsafeAuthenticatedConnectionSharing = false;
 }
Exemple #25
0
 /// <param name="subject">The subject of the document.</param>
 /// <param name="fileType">The file type of the file (e.g pdf,txt.. ).</param>
 /// <param name="contentBytes">The content of file in byteArray.</param>
 /// <param name="authenticationLevel">Required authentication level of the document. Default password.</param>
 /// <param name="sensitivityLevel">Sensitivity level of the document. Default normal.</param>
 /// <param name="smsNotification">Optional notification to receiver of message via SMS. </param>
 /// <param name="dataType">Optional metadata for enriching the document when viewed in Digipost</param>
 public Document(string subject, string fileType, byte[] contentBytes, AuthenticationLevel authenticationLevel = AuthenticationLevel.Password,
                 SensitivityLevel sensitivityLevel = SensitivityLevel.Normal, ISmsNotification smsNotification = null, string dataType = null)
 {
     Guid                = System.Guid.NewGuid().ToString();
     Subject             = subject;
     FileType            = fileType;
     ContentBytes        = contentBytes;
     AuthenticationLevel = authenticationLevel;
     SensitivityLevel    = sensitivityLevel;
     SmsNotification     = smsNotification;
     DataType            = dataType;
 }
Exemple #26
0
 /// <summary>
 /// Creates a WMIHelper object targeting the desired scope on the specified hostname with a domain to use when authorizing WMI calls on the client machine.
 /// Beware that in order to make WMI calls work, the user running the application must have the corresponding privileges on the client machine. Otherwise it will throw an 'Access Denied' exception.
 /// </summary>
 /// <param name="scope"></param>
 /// <param name="hostname"></param>
 /// <param name="domain"></param>
 /// <param name="auth">Athentication level</param>
 public WMISearcher(string scope, string hostname, string domain, AuthenticationLevel auth = AuthenticationLevel.Default)
 {
     Scope = new ManagementScope(String.Format("\\\\{0}\\{1}", hostname, scope))
     {
         Options = new ConnectionOptions
         {
             Impersonation  = ImpersonationLevel.Impersonate,
             Authentication = auth,
             Authority      = $"ntlmdomain:{domain}"
         }
     };
 }
Exemple #27
0
		public WebRequestHandler ()
		{
			allowPipelining = true;
			authenticationLevel = AuthenticationLevel.MutualAuthRequested;
			cachePolicy = System.Net.WebRequest.DefaultCachePolicy;
			continueTimeout = TimeSpan.FromMilliseconds (350);
			impersonationLevel = TokenImpersonationLevel.Delegation;
			maxResponseHeadersLength = HttpWebRequest.DefaultMaximumResponseHeadersLength;
			readWriteTimeout = 300000;
			serverCertificateValidationCallback = null;
			unsafeAuthenticatedConnectionSharing = false;
		}
Exemple #28
0
 public WebRequestHandler()
 {
     allowPipelining                      = true;
     authenticationLevel                  = AuthenticationLevel.MutualAuthRequested;
     cachePolicy                          = System.Net.WebRequest.DefaultCachePolicy;
     continueTimeout                      = TimeSpan.FromMilliseconds(350);
     impersonationLevel                   = TokenImpersonationLevel.Delegation;
     maxResponseHeadersLength             = HttpWebRequest.DefaultMaximumResponseHeadersLength;
     readWriteTimeout                     = 300000;
     serverCertificateValidationCallback  = null;
     unsafeAuthenticatedConnectionSharing = false;
 }
Exemple #29
0
 public WmiBaseCmdlet()
 {
     string[] strArrays = new string[1];
     strArrays[0]             = "localhost";
     this.computerName        = strArrays;
     this.nameSpace           = "root\\cimv2";
     this.impersonationLevel  = ImpersonationLevel.Impersonate;
     this.authenticationLevel = AuthenticationLevel.Packet;
     this.async         = false;
     this.throttleLimit = WmiBaseCmdlet.DEFAULT_THROTTLE_LIMIT;
     this._context      = LocalPipeline.GetExecutionContextFromTLS();
 }
        public ElasticContactIdentification(
            string identity, 
            AuthenticationLevel authLevel, 
            IdentificationLevel idLevel)
        {
            if (string.IsNullOrWhiteSpace(identity) && idLevel != IdentificationLevel.None)
            {
                throw new ArgumentOutOfRangeException("identity", "A contact identity value must be supplied to match the identification level of " + idLevel);    
            }

            this.authLevel = authLevel;
            this.SetIdentity(identity, idLevel);
        }
        public async Task <AuthenticationLevel> AddAuthenticationLevel(string authName)
        {
            var authLevel = new AuthenticationLevel {
                AuthName = authName
            };

            using (var context = new DatabaseContext(DatabaseContext.ops.dbOptions))
            {
                await context.AddAsync(authLevel);

                await context.SaveChangesAsync();
            }
            return(authLevel);
        }
Exemple #32
0
        internal static ConnectionOptions GetConnection(AuthenticationLevel Authentication, ImpersonationLevel Impersonation, PSCredential Credential)
        {
            ConnectionOptions connectionOption = new ConnectionOptions();

            connectionOption.Authentication   = Authentication;
            connectionOption.EnablePrivileges = true;
            connectionOption.Impersonation    = Impersonation;
            if (Credential != null)
            {
                connectionOption.Username = Credential.UserName;
                //connectionOption.SecurePassword = Credential.Password;
            }
            return(connectionOption);
        }
Exemple #33
0
        public static authenticationlevel ToAuthenticationLevel(this AuthenticationLevel authenticationLevel)
        {
            switch (authenticationLevel)
            {
            case AuthenticationLevel.Password:
                return(authenticationlevel.PASSWORD);

            case AuthenticationLevel.TwoFactor:
                return(authenticationlevel.TWO_FACTOR);

            default:
                throw new ArgumentOutOfRangeException(nameof(authenticationLevel), authenticationLevel, null);
            }
        }
        public static authenticationlevel ToAuthenticationlevel(this AuthenticationLevel authenticationLevel)
        {
            switch (authenticationLevel)
            {
            case AuthenticationLevel.Three:
                return(authenticationlevel.Item3);

            case AuthenticationLevel.Four:
                return(authenticationlevel.Item4);

            default:
                throw new ArgumentOutOfRangeException(nameof(authenticationLevel), authenticationLevel, null);
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ret = false;

            AuthenticationLevel accessLevel    = (AuthenticationLevel)value;
            AuthenticationLevel minAccessLevel = (AuthenticationLevel)Enum.Parse(typeof(AuthenticationLevel), (string)parameter, true);

            if ((accessLevel.CompareTo(minAccessLevel) >= 0 && accessLevel != AuthenticationLevel.NONE) ||
                (accessLevel.Equals(minAccessLevel)))
            {
                ret = true;
            }

            return(ret);
        }
 public TestConnectionCommand()
 {
     this.asjob          = false;
     this.authentication = AuthenticationLevel.Packet;
     this.buffersize     = 32;
     this.count          = 4;
     string[] strArrays = new string[1];
     strArrays[0]       = ".";
     this.source        = strArrays;
     this.impersonation = ImpersonationLevel.Impersonate;
     this.throttlelimit = 32;
     this.timetolive    = 80;
     this.delay         = 1;
     this.quietResults  = new Dictionary <string, bool>();
 }
Exemple #37
0
        public IAuthenticator Create(AuthenticationLevel level, Func <IAuthenticator> action)
        {
            IAuthenticator auth;

            switch (level)
            {
            case AuthenticationLevel.Simple:
                auth = action?.Invoke();
                break;

            default:
                auth = new NullAuthenticator();
                break;
            }
            return(auth);
        }
 internal static string ToString(AuthenticationLevel authenticationLevel)
 {
     if (authenticationLevel == AuthenticationLevel.MutualAuthRequested)
     {
         return "mutualAuthRequested";
     }
     if (authenticationLevel == AuthenticationLevel.MutualAuthRequired)
     {
         return "mutualAuthRequired";
     }
     if (authenticationLevel == AuthenticationLevel.None)
     {
         return "none";
     }
     return authenticationLevel.ToString();
 }
        public virtual async Task<IMessageDeliveryResult> Send(byte[] fileContent, string filetype, string subject,IdentificationType identification,
            string identificationValue, SensitivityLevel sensitivity = SensitivityLevel.Normal,
            AuthenticationLevel authentication = AuthenticationLevel.Password, SmsNotification smsNotification = null,PrintDetails printDetails= null)
        {
            var recipient = new RecipientById(identification, identificationValue);

            var primaryDocument = new Document(subject, filetype, fileContent)
            {
                SensitivityLevel = sensitivity,
                AuthenticationLevel = authentication
            };
            if (smsNotification != null)
                primaryDocument.SmsNotification = smsNotification;
            
            var m = new Message(recipient, primaryDocument);

            if (printDetails != null)
                m.PrintDetails = printDetails;


            return await GetClient().SendMessageAsync(m);
        }
Exemple #40
0
 public LoginResponse()
 {
     m_UserAuthenticationLevel = AuthenticationLevel.None;
 }
Exemple #41
0
		internal static ConnectionOptions GetConnection(AuthenticationLevel Authentication, ImpersonationLevel Impersonation, PSCredential Credential)
		{
			ConnectionOptions connectionOption = new ConnectionOptions();
			connectionOption.Authentication = Authentication;
			connectionOption.EnablePrivileges = true;
			connectionOption.Impersonation = Impersonation;
			if (Credential != null)
			{
				connectionOption.Username = Credential.UserName;
				//connectionOption.SecurePassword = Credential.Password;
			}
			return connectionOption;
		}
Exemple #42
0
 /// <summary>
 /// Get the Connection Options
 /// </summary>
 /// <param name="Authentication"></param>
 /// <param name="Impersonation"></param>
 /// <param name="Credential"></param>
 /// <returns></returns>
 internal static ConnectionOptions GetConnectionOptions(AuthenticationLevel Authentication, ImpersonationLevel Impersonation, PSCredential Credential)
 {
     ConnectionOptions options = new ConnectionOptions();
     options.Authentication = Authentication;
     options.EnablePrivileges = true;
     options.Impersonation = Impersonation;
     if (Credential != null)
     {
         options.Username = Credential.UserName;
         options.SecurePassword = Credential.Password;
     }
     return options;
 }
        private static NetworkCredential GetCredentialCore(AuthenticationSchemes authenticationScheme, SecurityTokenProviderContainer credentialProvider, TimeSpan timeout, out TokenImpersonationLevel impersonationLevel, out AuthenticationLevel authenticationLevel)
        {
            impersonationLevel = TokenImpersonationLevel.None;
            authenticationLevel = AuthenticationLevel.None;
            NetworkCredential userNameCredential = null;
            switch (authenticationScheme)
            {
                case AuthenticationSchemes.Digest:
                    userNameCredential = TransportSecurityHelpers.GetSspiCredential(credentialProvider, timeout, out impersonationLevel, out authenticationLevel);
                    ValidateDigestCredential(ref userNameCredential, impersonationLevel);
                    return userNameCredential;

                case AuthenticationSchemes.Negotiate:
                    return TransportSecurityHelpers.GetSspiCredential(credentialProvider, timeout, out impersonationLevel, out authenticationLevel);

                case AuthenticationSchemes.Ntlm:
                    userNameCredential = TransportSecurityHelpers.GetSspiCredential(credentialProvider, timeout, out impersonationLevel, out authenticationLevel);
                    if (authenticationLevel == AuthenticationLevel.MutualAuthRequired)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CredentialDisallowsNtlm")));
                    }
                    return userNameCredential;

                case AuthenticationSchemes.Basic:
                    userNameCredential = TransportSecurityHelpers.GetUserNameCredential(credentialProvider, timeout);
                    impersonationLevel = TokenImpersonationLevel.Delegation;
                    return userNameCredential;
            }
            throw Fx.AssertAndThrow("GetCredential: Invalid authentication scheme");
        }
Exemple #44
0
 public LoginResponse(AuthenticationLevel authenticationLevel)
 {
     m_UserAuthenticationLevel = authenticationLevel;
 }
Exemple #45
0
 public LoginResponse(AuthenticationLevel authenticationLevel, SystemConfiguration systemconfiguration, Profile profile)
 {
     m_UserAuthenticationLevel = authenticationLevel;
     m_SystemConfiguration = systemconfiguration;
     m_Profile = profile;
 }
Exemple #46
0
 public LoginResponse(SystemConfiguration systemconfiguration)
 {
     m_UserAuthenticationLevel = AuthenticationLevel.None;
     m_SystemConfiguration = systemconfiguration;
 }
        /// <summary>
        /// Executes the logic for this workflow activity
        /// </summary>
        /// <param name="context">CodeActivityContext</param>
        protected override void Execute(CodeActivityContext context)
        {
            this.ActivityContext = context;
            try
            {
                if (!string.IsNullOrEmpty(context.GetValue(this.AuthenticationLevel)))
                {
                    this.authLevel = (AuthenticationLevel)Enum.Parse(typeof(AuthenticationLevel), context.GetValue(this.AuthenticationLevel));
                }

                this.InternalExecute();
            }
            catch (Exception ex)
            {
                if (!this.failingbuild)
                {
                    if (this.LogExceptionStack.Get(context))
                    {
                        string innerException = string.Empty;
                        if (ex.InnerException != null)
                        {
                            innerException = string.Format("Inner Exception: {0}", ex.InnerException.Message);
                        }

                        this.LogBuildError(string.Format("Error: {0}. Stack Trace: {1}. {2}", ex.Message, ex.StackTrace, innerException));
                    }
                }

                if (this.IgnoreExceptions.Get(context) != true)
                {
                    throw;
                }
            }
        }
Exemple #48
0
 public LoginInfo()
 {
     _accessLevel = AuthenticationLevel.NONE;
     _isConnected = false;
     _dashboardMode = "Operator";
 }
		public TestConnectionCommand()
		{
			this.asjob = false;
			this.authentication = AuthenticationLevel.Packet;
			this.buffersize = 32;
			this.count = 4;
			string[] strArrays = new string[1];
			strArrays[0] = ".";
			this.source = strArrays;
			this.impersonation = ImpersonationLevel.Impersonate;
			this.throttlelimit = 32;
			this.timetolive = 80;
			this.delay = 1;
			this.quietResults = new Dictionary<string, bool>();
		}
Exemple #50
0
        public static NetworkCredential GetCredential(AuthenticationSchemes authenticationScheme,
            SecurityTokenProviderContainer credentialProvider, TimeSpan timeout,
            out TokenImpersonationLevel impersonationLevel, out AuthenticationLevel authenticationLevel)
        {
            impersonationLevel = TokenImpersonationLevel.None;
            authenticationLevel = AuthenticationLevel.None;

            NetworkCredential result = null;

            if (authenticationScheme != AuthenticationSchemes.Anonymous)
            {
                result = GetCredentialCore(authenticationScheme, credentialProvider, timeout, out impersonationLevel, out authenticationLevel);
            }

            return result;
        }
 public IJDocumentSession OpenSession(string databaseName, IUserCredential credential, AuthenticationLevel level)
 {
     return this.GetSession(databaseName, credential, level);
 }
        private IJDocumentSession GetSession(string databaseName, IUserCredential credential, AuthenticationLevel level)
        {
            IJDocumentSession session = this.sessionUsers.FirstOrDefault(
                advSession =>
                advSession.AuthLevel == level && advSession.DatabaseName.Equals(databaseName) &&
                advSession.UserCredential.Equals(credential));

            if (session == null)
            {
                session = new CouchDocumentSession(this.UriBase, databaseName, credential, level,
                                                   this.SerializerSettings);
                this.sessionUsers.Add(session);
            }

            return session;
        }
Exemple #53
0
		public WmiBaseCmdlet()
		{
			string[] strArrays = new string[1];
			strArrays[0] = "localhost";
			this.computerName = strArrays;
			this.nameSpace = "root\\cimv2";
			this.impersonationLevel = ImpersonationLevel.Impersonate;
			this.authenticationLevel = AuthenticationLevel.Packet;
			this.async = false;
			this.throttleLimit = WmiBaseCmdlet.DEFAULT_THROTTLE_LIMIT;
			this._context = LocalPipeline.GetExecutionContextFromTLS();
		}
Exemple #54
0
        static NetworkCredential GetCredentialCore(AuthenticationSchemes authenticationScheme,
            SecurityTokenProviderContainer credentialProvider, TimeSpan timeout,
            out TokenImpersonationLevel impersonationLevel, out AuthenticationLevel authenticationLevel)
        {
            impersonationLevel = TokenImpersonationLevel.None;
            authenticationLevel = AuthenticationLevel.None;

            NetworkCredential result = null;

            switch (authenticationScheme)
            {
                case AuthenticationSchemes.Basic:
                    result = TransportSecurityHelpers.GetUserNameCredential(credentialProvider, timeout);
                    impersonationLevel = TokenImpersonationLevel.Delegation;
                    break;

                case AuthenticationSchemes.Digest:
                    result = TransportSecurityHelpers.GetSspiCredential(credentialProvider, timeout,
                        out impersonationLevel, out authenticationLevel);

                    HttpChannelUtilities.ValidateDigestCredential(ref result, impersonationLevel);
                    break;

                case AuthenticationSchemes.Negotiate:
                    result = TransportSecurityHelpers.GetSspiCredential(credentialProvider, timeout,
                        out impersonationLevel, out authenticationLevel);
                    break;

                case AuthenticationSchemes.Ntlm:
                    result = TransportSecurityHelpers.GetSspiCredential(credentialProvider, timeout,
                        out impersonationLevel, out authenticationLevel);
                    if (authenticationLevel == AuthenticationLevel.MutualAuthRequired)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                            new InvalidOperationException(SR.GetString(SR.CredentialDisallowsNtlm)));
                    }
                    break;

                default:
                    // The setter for this property should prevent this.
                    throw Fx.AssertAndThrow("GetCredential: Invalid authentication scheme");
            }

            return result;
        }
		public RestartComputerCommand()
		{
			this._asjob = false;
			this._dcomAuthentication = AuthenticationLevel.Packet;
			this._impersonation = ImpersonationLevel.Impersonate;
			this._protocol = "DCOM";
			string[] strArrays = new string[1];
			strArrays[0] = ".";
			this._computername = strArrays;
			this._validatedComputerNames = new List<string>();
			this._waitOnComputers = new List<string>();
			this._uniqueComputerNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			this._throttlelimit = 32;
			this._timeout = -1;
			this._waitFor = WaitForServiceTypes.PowerShell;
			this._delay = 5;
			string[] strArrays1 = new string[4];
			strArrays1[0] = "|";
			strArrays1[1] = "/";
			strArrays1[2] = "-";
			strArrays1[3] = "\\";
			this._indicator = strArrays1;
			this._cancel = new CancellationTokenSource();
			this._waitHandler = new ManualResetEventSlim(false);
			this._computerInfos = new Dictionary<string, RestartComputerCommand.ComputerInfo>(StringComparer.OrdinalIgnoreCase);
			this._shortLocalMachineName = Dns.GetHostName();
			this._fullLocalMachineName = Dns.GetHostEntry("").HostName;
		}
 public RestRequestBuilder WithAuthenticationLevel(AuthenticationLevel authenticationLevel)
 {
     _request.AuthenticationLevel = authenticationLevel;
     return this;
 }
Exemple #57
0
		public StopComputerCommand()
		{
			this._asjob = false;
			this._authentication = AuthenticationLevel.Packet;
			string[] strArrays = new string[1];
			strArrays[0] = ".";
			this._computername = strArrays;
			this._impersonation = ImpersonationLevel.Impersonate;
			this._throttlelimit = 32;
			this._force = false;
		}
        // constructors

        /// <devdoc>
        ///    <para>
        ///       Initializes a new instance of the <see cref='System.Net.WebRequest'/>
        ///       class.
        ///    </para>
        /// </devdoc>

        protected WebRequest()
        {
#if !FEATURE_PAL
            // Defautl values are set as per V1.0 behavior
            m_ImpersonationLevel = TokenImpersonationLevel.Delegation;
            m_AuthenticationLevel= AuthenticationLevel.MutualAuthRequested;
#endif
        }
        //parameterized
        /// <summary>
        /// <para> Initializes a new instance of the <see cref='System.Management.ConnectionOptions'/> class to be used for a WMI
        ///    connection, using the specified values.</para>
        /// </summary>
        /// <param name='locale'>The locale to be used for the connection.</param>
        /// <param name=' username'>The user name to be used for the connection. If null, the credentials of the currently logged-on user are used.</param>
        /// <param name=' securepassword'>The secure password for the given user name. If the user name is also null, the credentials used will be those of the currently logged-on user.</param>
        /// <param name=' authority'><para>The authority to be used to authenticate the specified user.</para></param>
        /// <param name=' impersonation'>The COM impersonation level to be used for the connection.</param>
        /// <param name=' authentication'>The COM authentication level to be used for the connection.</param>
        /// <param name=' enablePrivileges'><see langword='true'/>to enable special user privileges; otherwise, <see langword='false'/> . This parameter should only be used when performing an operation that requires special Windows NT user privileges.</param>
        /// <param name=' context'>A provider-specific, named value pairs object to be passed through to the provider.</param>
        /// <param name=' timeout'>Reserved for future use.</param>
        public ConnectionOptions (string locale,
                string username, SecureString password, string authority,
                ImpersonationLevel impersonation, AuthenticationLevel authentication,
                bool enablePrivileges,
                ManagementNamedValueCollection context, TimeSpan timeout) : base (context, timeout)
        {
            if (locale != null) 
                this.locale = locale;

            this.username = username;
            this.enablePrivileges = enablePrivileges;

            if (password != null)
            {
                this.securePassword = password.Copy();
            }

            if (authority != null) 
                this.authority = authority;

            if (impersonation != 0)
                this.impersonation = impersonation;

            if (authentication != 0)
                this.authentication = authentication;
        }