• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Core.SecurityCredentials类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Alchemi.Core.SecurityCredentials的典型用法代码示例。如果您正苦于以下问题:C# SecurityCredentials类的具体用法?C# SecurityCredentials怎么用?C# SecurityCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SecurityCredentials类属于Alchemi.Core命名空间,在下文中一共展示了SecurityCredentials类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Admon_AddUsers

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the list of users to the Alchemi database
        /// 
        /// </summary>
        /// <param name="sc">security credentials to verify if the user has permissions to perform this operation.
        /// (i.e add list of users, which is associated with the permission: ManageUsers).</param>
        /// <param name="adds">a DataTable object containing the list of users to be added</param>
        public void Admon_AddUsers(SecurityCredentials sc, UserStorageView[] adds)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ManageUsers);

            ManagerStorageFactory.ManagerStorage().AddUsers(adds);
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:15,代码来源:GManager.cs


示例2: AddJob

 //-----------------------------------------------------------------------------------------------
 /// <summary>
 /// Adds a job to the manager
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="sc">security credentials used to perform this operation</param>
 /// <param name="taskId"></param>
 /// <param name="jobId"></param>
 /// <param name="priority"></param>
 /// <param name="jobXml"></param>
 public static void AddJob(IManager manager, SecurityCredentials sc, string taskId, int jobId, int priority, string jobXml)
 {
     manager.Owner_SetThread(
         sc,
         new ThreadIdentifier(taskId, jobId, priority),
         Utils.SerializeToByteArray(JobFromXml(jobId, jobXml))
         );
 }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:18,代码来源:CrossPlatformHelper.cs


示例3: Admon_DeleteApplication

        public void Admon_DeleteApplication(SecurityCredentials sc, ApplicationStorageView applicationToDelete)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ManageAllApps);

            logger.Debug(String.Format("Deleting application {0}.", applicationToDelete.ApplicationId));

            ManagerStorageFactory.ManagerStorage().DeleteApplication(applicationToDelete);
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:9,代码来源:GManager.cs


示例4: Admon_GetLiveApplicationListTestSimpleScenario

        public void Admon_GetLiveApplicationListTestSimpleScenario()
        {
            SetupApplicationsGroupsAndUsers(Permission.ManageOwnApp);

            SecurityCredentials sc = new SecurityCredentials("username1", HashUtil.GetHash("password1", HashType.MD5));

            ApplicationStorageView[] result = Admon_GetUserApplicationList(sc);

            Assert.AreEqual(1, result.Length);
        }
开发者ID:JamesTryand,项目名称:alchemi,代码行数:10,代码来源:GManagerTester.cs


示例5: Owner_GetFinishedThreads

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the finished threads as a byte array.
        /// </summary>
        /// <param name="sc">security credentials to verify if the owner has permission to perform this operation 
        /// (i.e get finished threads, which is associated with the ManageOwnApp / ManageAllApps permission)</param>
        /// <param name="appId">id of the application whose completed threads need to be retrieved</param>
        /// <returns>2-D byte array representing all the finished threads in serialized form.</returns>
        public byte[][] Owner_GetFinishedThreads(SecurityCredentials sc, string appId)
        {
            AuthenticateUser(sc);
            ApplicationAuthorizationCheck(sc, appId);

            //logger.Debug("getting finished thread for app:"+appId);
            return _Applications[appId].FinishedThreads;
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:16,代码来源:GManager.cs


示例6: Owner_GetFinishedThreadCount

        /// <summary>
        /// Gets the count of the finished threads.
        /// </summary>
        /// <param name="sc"></param>
        /// <param name="appId"></param>
        /// <returns>Number of threads finished</returns>
        public int Owner_GetFinishedThreadCount(SecurityCredentials sc, string appId)
        {
            AuthenticateUser(sc);
            ApplicationAuthorizationCheck(sc, appId);

            //logger.Debug("Getting count of total finished threads for app: " + appId);
            int totCount = 0;

            //get the count of threads which have the state "dead" in the database
            //..i.e returned to owner after finishing or aborted.
            totCount = _Applications[appId].ThreadCount(ThreadState.Dead);

            return totCount;
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:20,代码来源:GManager.cs


示例7: GExecutor

        /// <summary>
        /// Creates an instance of the GExecutor with the given end points 
        /// (one for itself, and one for the manager), credentials and other options.
        /// </summary>
        /// <param name="managerEP">Manager end point</param>
        /// <param name="ownEP">Own end point</param>
        /// <param name="id">executor id</param>
        /// <param name="dedicated">Specifies whether the executor is dedicated</param>
        /// <param name="sc">Security credentials</param>
        /// <param name="baseDir">Working directory for the executor</param>
        public GExecutor(EndPoint managerEP, EndPoint ownEP, string id, bool dedicated, bool autoRevertToNDE, SecurityCredentials sc, string baseDir)
            : base(managerEP, ownEP, sc)
        {
            _AutoRevertToNDE = autoRevertToNDE;
            _Dedicated = dedicated;
            _Id = id;

            if (String.IsNullOrEmpty(_Id))
            {
                logger.Info("Registering new executor");
                _Id = Manager.Executor_RegisterNewExecutor(this.Credentials, null, this.Info);
                logger.Info("Successfully Registered new executor:" + _Id);
            }

            _GridAppDomains = new Dictionary<string, GridAppDomain>();
            _ActiveWorkers = new Dictionary<ThreadIdentifier, ExecutorWorker>();

            //handle exception since we want to connect to the manager
            //even if it doesnt succeed the first time.
            //that is, we need to handle InvalidExecutor and ConnectBack Exceptions.
            //WCF requires this to execute in another thread.
            Thread t = new Thread(new ThreadStart(DoConnectThread));
            t.Start();
            t.Join();
        }
开发者ID:JamesTryand,项目名称:alchemi,代码行数:35,代码来源:GExecutor.cs


示例8: CheckPermission

        public bool CheckPermission(SecurityCredentials sc, Permission perm)
        {
            // get the user's groupId
            int groupId = -1;
            foreach(UserStorageView user in _users)
            {
                if(String.Compare(user.Username, sc.Username, true) == 0 && user.PasswordMd5Hash == sc.Password)
                {
                    groupId = user.GroupId;
                    break;
                }
            }

            if (groupId == -1)
            {
                return false;
            }

            foreach(Permission permission in GetGroupPermissions(groupId))
            {
                // in the SQL implementation the higher leverl permissions are considered to
                // include the lower leverl permissions
                if ((int)permission >= (int)perm)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:JamesTryand,项目名称:alchemi,代码行数:30,代码来源:InMemoryManagerStorage.cs


示例9: CheckPermission

        /// <summary>
        /// Check if a permisson is set.
        /// </summary>
        /// <param name="sc">Security credentials to use in the check.</param>
        /// <param name="perm">Permission to check for</param>
        /// <returns>true if the permission is set, false otherwise</returns>
        public bool CheckPermission(SecurityCredentials sc, Permission perm)
        {
            string query = String.Format("select count(*) as permitted from usr inner join grp on grp.grp_id = usr.grp_id inner join grp_prm on grp_prm.grp_id = grp.grp_id inner join prm on prm.prm_id = grp_prm.prm_id where usr.usr_name = '{0}' and prm.prm_id >= {1}",
                Utils.MakeSqlSafe(sc.Username),
                (int)perm);

            return Convert.ToBoolean(RunSqlReturnScalar(query));
        }
开发者ID:JamesTryand,项目名称:alchemi,代码行数:14,代码来源:GenericManagerDatabaseStorage.cs


示例10: Owner_SetApplicationManifest

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the manifest for the application, which consists for the input/output dependencies for this application.
        /// </summary>
        /// <param name="sc">security credentials to verify if the owner has permission to perform this operation 
        /// (i.e SetApplicationManifest, which is associated with the ManageOwnApp permission)</param>
        /// <param name="appId">application whose manifest needs to be set</param>
        /// <param name="manifest">the manifest to set</param>
        public void Owner_SetApplicationManifest(SecurityCredentials sc, string appId, FileDependencyCollection manifest)
        {
            AuthenticateUser(sc);
            ApplicationAuthorizationCheck(sc, appId);

            logger.Debug("Setting manifest for application: "+appId);
            _Applications[appId].Manifest = manifest;
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:16,代码来源:GManager.cs


示例11: Main

        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(DefaultErrorHandler);

            Console.WriteLine("\nAlchemi [.NET Grid Computing Framework]");
            Console.WriteLine("http://www.alchemi.net\n");

            Console.WriteLine("Job Submitter v{0}", Utils.AssemblyVersion);

            IManager manager;
            SecurityCredentials sc;

            if (args.Length < 4)
            {
                Usage();
                return;
            }

            try
            {
                manager = (IManager) GNode.GetRemoteRef(new RemoteEndPoint(args[0], int.Parse(args[1]), RemotingMechanism.TcpBinary));
                manager.PingManager();
                sc = new SecurityCredentials(args[2], args[3]);
                manager.AuthenticateUser(sc);
                Console.Write("Connected to Manager at {0}:{1}\n", args[0], args[1]);
            }
            catch (Exception e)
            {
                Error("Could not connect to Manager", e);
                return;
            }

            Aliases aliases = Aliases.FromFile(Path.Combine(System.Windows.Forms.Application.StartupPath, "aliases.dat"));

            string[] cmd;
            bool interactive;

            if (args.Length > 4)
            {
                cmd = new string[args.Length - 4];
                for (int i=0; i<args.Length - 4; i++)
                {
                    cmd[i] = args[i+4];
                }
                interactive = false;
            }
            else
            {
                cmd = new string[] {""};
                interactive = true;
            }

            while (true)
            {
                if (interactive)
                {
                    Console.Write("\n> ");
                    string line = Console.ReadLine();
                    cmd = line.Split();
                    cmd[0] = cmd[0].ToLower();
                }

                try
                {
                    string appId;

                    switch (cmd[0])
                    {
                        case "st":
                        case "submittask": // taskXmlFile
                            string task = EmbedFiles(Utils.ReadStringFromFile(cmd[1]));
                            appId = CrossPlatformHelper.CreateTask(manager, sc, task);
                            string newAlias = aliases.NewAlias(appId);
                            try
                            {
                                WriteLine("Task submitted (alias = {1}).", appId, newAlias);
                            }
                            catch
                            {
                            }
                            break;

                        case "gfj":
                        case "getfinishedjobs": // alias, (directory, default=".")
                            appId = (string) aliases.Table[cmd[1]];

                            string taskDir = cmd.Length > 2 ? cmd[2] : ".";

                            string taskXml = CrossPlatformHelper.GetFinishedJobs(manager, sc, appId);
                            XmlDocument fin = new XmlDocument();
                            fin.LoadXml(taskXml);

                            WriteLine("Got {0} job(s).", fin.SelectNodes("task/job").Count);
                            Console.WriteLine("Job XML: \n" + taskXml);

                            foreach (XmlNode outputFileNode in fin.SelectNodes("task/job/output/embedded_file"))
                            {
                                //string jobDir = string.Format("{0}\\job_{1}", taskDir, outputFileNode.ParentNode.ParentNode.Attributes["id"].Value);
                                string jobDir = taskDir;
                                if (!Directory.Exists(jobDir))
//.........这里部分代码省略.........
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:101,代码来源:JobSubmitter.cs


示例12: GetGroupUsers

        public UserStorageView[] GetGroupUsers(SecurityCredentials sc, Int32 groupId)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ManageUsers);

            logger.Debug(String.Format("Getting group {0} users.", groupId));

            return ManagerStorageFactory.ManagerStorage().GetGroupUsers(groupId);
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:9,代码来源:GManager.cs


示例13: Owner_GetThreadState

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the state of the given thread.
        /// </summary>
        /// <param name="sc">security credentials to verify if the owner has permission to perform this operation 
        /// (i.e get thread state, which is associated with the ManageOwnApp / ManageAllApps permission)</param>
        /// <param name="ti">ThreadIdentifier of thread whose state is to be retrieved</param>
        /// <returns>state of the given thread</returns>
        public ThreadState Owner_GetThreadState(SecurityCredentials sc, ThreadIdentifier ti)
        {
            AuthenticateUser(sc);
            ApplicationAuthorizationCheck(sc, ti.ApplicationId);

            logger.Debug("Getting state for thread: "+ti.ThreadId);
            return _Applications[ti.ApplicationId][ti.ThreadId].State;
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:16,代码来源:GManager.cs


示例14: Executor_GetThread

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the thread with the given identifier, as a byte array.
        /// This is called by a remote executor requesting a thread from the manager.
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e GetThread, which is associated with the ExecuteThread permission)</param>
        /// <param name="ti">ThreadIdentifier</param>
        /// <returns>A byte array representing the serialized thread</returns>
        public byte[] Executor_GetThread(SecurityCredentials sc, ThreadIdentifier ti)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ExecuteThread);

            byte[] retval;
            MThread t = _Applications[ti.ApplicationId][ti.ThreadId];

            // TODO: hierarchical grids ignored until after v1.0.0
            //if (_Applications[ti.ApplicationId].IsPrimary)
            //{
            retval = t.Value;
            //}
            //else
            //{
            //    retval =  Manager.Executor_GetThread(null, ti);
            //}
            t.State = ThreadState.Started;

            logger.Debug("set thread status to started. returning the byte array:"+ti.ThreadId);
            return retval;
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:31,代码来源:GManager.cs


示例15: Executor_SetFinishedThread

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the given thread to a finished state.
        /// This is called by a remote executor after completing execution of this thread.
        /// The thread may be successfully finished or failed.
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e SetFinishedThread, which is associated with the ExecuteThread permission)</param>
        /// <param name="ti">ThreadIdentifier</param>
        /// <param name="thread">the byte array representing the serialized thread</param>
        /// <param name="e">Any exception that may have occured during the execution of the thread</param>
        public void Executor_SetFinishedThread(SecurityCredentials sc, ThreadIdentifier ti, byte[] thread, Exception e)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ExecuteThread);

            MApplication app = _Applications[ti.ApplicationId];
            MThread t = _Applications[ti.ApplicationId][ti.ThreadId];

            if (app == null)
            {
                //invalid application id passed. normally this should not happen.
                throw new InvalidApplicationException("Invalid application id: "+ti.ApplicationId, null);
            }

            if (t == null)
            {
                //invalid thread id. this should normally not happen.
                throw new InvalidThreadException("Invalid thread id: "+ti.ApplicationId+":"+ti.ThreadId, null);
            }

            if (app.IsPrimary)
            {
                if (thread!=null)
                {
                    try
                    {
                        t.Value = thread;
                    }
                    catch(Exception ex)
                    {
                        logger.Debug("Error saving thread to disk:"+ex.Message);
                        //thread could not be saved to disk on the Manager
                        //so set it as failed!

                        //if e is not null, then let us get the exception which caused it to fail anyway.
                        if (e==null)
                            e = ex;
                    }
                }

                if (e != null)
                {
                    try
                    {
                        logger.Debug("thread failed. ti: " + ti.ThreadId + "," + e.Message);
                        t.FailedThreadException = e;
                    }
                    catch (Exception ex)
                    {
                        logger.Debug("error saving thread-exception for failed thread to disk: threadId="+ti.ThreadId+", thread-fail-reason:" + e.Message, ex);
                    }
                }
                else
                {
                    logger.Debug("thread completed successfully. ti:"+ti.ThreadId );
                }
            }
            else
            {
                // TODO: hierarchical grids ignored until after v1.0.0
                //Manager.Executor_SetFinishedThread(null, ti, thread, e);
            }

            t.State = ThreadState.Finished;
            InternalShared.Instance.DedicatedSchedulerActive.Set();
            logger.Debug("Set the thread ("+ti.ThreadId +") state to finished. And set the dedicatedSchedulerActive.");
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:78,代码来源:GManager.cs


示例16: Executor_RelinquishThread

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Resets a thread which is executing.
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e RelinquishThread, which is associated with the ExecuteThread permission)</param>
        /// <param name="ti">ThreadIdentifier of the thread to relinquish</param>
        public void Executor_RelinquishThread(SecurityCredentials sc, ThreadIdentifier ti)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ExecuteThread);

            new MThread(ti).Reset();
            logger.Debug("Reset thread: "+ti.ThreadId);
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:15,代码来源:GManager.cs


示例17: Executor_RegisterNewExecutor

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Register a new executor with this manager
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e register executor, which is associated with the ExecuteThread permission)</param>
        /// <param name="info">executor information</param>
        /// <returns>the id of the executor registered</returns>
        public string Executor_RegisterNewExecutor(SecurityCredentials sc, string existingExecutorId, ExecutorInfo info)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ExecuteThread);

            //logger.Debug("Registering new executor");
            return _Executors.RegisterNew(sc, existingExecutorId, info);
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:16,代码来源:GManager.cs


示例18: Executor_Heartbeat

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the heartbeat info of an executor
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e HeartBeat, which is associated with the ExecuteThread permission)</param>
        /// <param name="executorId">executor id</param>
        /// <param name="info">heartbeat info</param>
        public void Executor_Heartbeat(SecurityCredentials sc, string executorId, HeartbeatInfo info)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ExecuteThread);

            _Executors[executorId].HeartbeatUpdate(info);
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:15,代码来源:GManager.cs


示例19: Owner_HasApplicationManifest

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Determines whether the manager has the application manifest for the given application id.
        /// </summary>
        /// <param name="sc">security credentials</param>
        /// <param name="appId">application id</param>
        /// <returns>whether the manager has the application manifest</returns>
        public bool Owner_HasApplicationManifest(SecurityCredentials sc, string appId)
        {
            // This method only returns whether an application has a manifest or not and should not require authentication or authorization.

            //AuthenticateUser(sc);
            //ApplicationAuthorizationCheck(sc, appId);

            logger.Debug("Checking application for manifest: " + appId);

            try
            {
                MApplication app = _Applications[appId];
                return ((app != null) && (app.Manifest != null));
            }
            catch
            {
                return false;
            }
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:26,代码来源:GManager.cs


示例20: Owner_AbortThread

        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Aborts the thread. This is called by the owner of the thread.
        /// </summary>
        /// <param name="sc">security credentials to verify if the owner has permission to perform this operation 
        /// (i.e abort thread, which is associated with the ManageOwnApp / ManageAllApps permission)</param>
        /// <param name="ti">ThreadIdentifier of the thread to abort</param>
        public void Owner_AbortThread(SecurityCredentials sc, ThreadIdentifier ti)
        {
            AuthenticateUser(sc);
            ApplicationAuthorizationCheck(sc, ti.ApplicationId);

            MThread thread = _Applications[ti.ApplicationId][ti.ThreadId];

            logger.Debug("Owner called abort thread:"+ti.ThreadId);

            // if running on an executor, ask it to abort the thread
            if (thread.State != ThreadState.Dead && thread.State != ThreadState.Finished)
            {
                AbortThread(ti, thread.CurrentExecutorId);
                thread.State = ThreadState.Dead;
            }
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:23,代码来源:GManager.cs



注:本文中的Alchemi.Core.SecurityCredentials类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AlcionaDAL.DirtyApartments类代码示例发布时间:2022-05-24
下一篇:
C# Net.Address类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap