public KeystoneIdentityProvider(Domain domain)
            : base(domain)
        {
            InitializeMembers();

            settings = (KeystoneSettings)domain.Settings[Constants.SettingsKeystone].Value;
        }
Esempio n. 2
0
        public bool CheckEmailDuplicate(Domain domain, string email)
        {
            var sql = @"spCheckUserEmailDuplicate";

            using (var cmd = Context.CreateStoredProcedureCommand(sql))
            {
                cmd.Parameters.Add("@ParentGuid", SqlDbType.UniqueIdentifier).Value = domain.Guid;
                cmd.Parameters.Add("@Email", SqlDbType.NVarChar, 128).Value = email;
                cmd.Parameters.Add("RETVAL", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;

                cmd.ExecuteNonQuery();

                return (int)cmd.Parameters["RETVAL"].Value > 0;
            }
        }
Esempio n. 3
0
        public User FindUserByIdentity(Domain domain, string protocol, string authority, string identifier)
        {
            var user = new User(Context);

            var sql = "spFindUser_byIdentity";

            using (var cmd = Context.CreateStoredProcedureCommand(sql))
            {
                cmd.Parameters.Add("@DomainGuid", SqlDbType.UniqueIdentifier).Value = domain.Guid;
                cmd.Parameters.Add("@Protocol", SqlDbType.NVarChar, 25).Value = protocol;
                cmd.Parameters.Add("@Authority", SqlDbType.NVarChar, 250).Value = authority;
                cmd.Parameters.Add("@Identifier", SqlDbType.NVarChar, 250).Value = identifier;

                using (var dr = cmd.ExecuteReader())
                {
                    dr.Read();
                    user.LoadFromDataReader(dr);
                    dr.Close();
                }
            }

            return user;
        }
Esempio n. 4
0
 public User FindUserByEmail(Domain domain, string email)
 {
     return FindUserByEmailInternal(domain, email);
 }
Esempio n. 5
0
 public User FindUserByActivationCode(Domain domain, string code)
 {
     return FindUserByActivationCodeInternal(domain, code);
 }
Esempio n. 6
0
 /// <summary>
 /// Constructor for creating a new entity with object context and parent entity set.
 /// </summary>
 /// <param name="context">An object context class containing session information.</param>
 /// <param name="parent">The parent entity in the entity hierarchy.</param>
 public Federation(Domain parent)
     : base(parent.Context, parent)
 {
     InitializeMembers();
 }
Esempio n. 7
0
        /// <summary>
        /// Loads the user from the graywulf registry
        /// </summary>
        /// <param name="identity"></param>
        /// <remarks>
        /// If the identity is not found, it will be marked as non-authenticated
        /// </remarks>
        public void LoadUser(Domain domain)
        {
            using (var registryContext = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                var uf = new UserFactory(registryContext);

                try
                {
                    switch (protocol)
                    {
                        case Constants.ProtocolNameForms:
                            userProperty.Value = uf.LoadUser(identifier);
                            break;
                        case Constants.ProtocolNameWindows:
                            // TODO: implement NTLM auth
                            throw new NotImplementedException();
                        default:
                            // All other cases use lookup by protocol name
                            userProperty.Value = uf.FindUserByIdentity(domain, protocol, authorityUri, identifier);
                            break;
                    }

                    IsAuthenticated = true;
                }
                catch (EntityNotFoundException)
                {
                    isAuthenticated = false;
                }
            }
        }
Esempio n. 8
0
 public DomainInstaller(Domain domain)
     : base(domain.Context)
 {
     this.domain = domain;
 }
Esempio n. 9
0
 public User LoginUser(Domain domain, string nameOrEmail, string password)
 {
     return LoginUserInternal(domain, nameOrEmail, password);
 }
Esempio n. 10
0
 public User FindUserByActivationCode(Domain domain, string code)
 {
     return(FindUserByActivationCodeInternal(domain, code));
 }
Esempio n. 11
0
 public User FindUserByEmail(Domain domain, string email)
 {
     return(FindUserByEmailInternal(domain, email));
 }
Esempio n. 12
0
 /// <summary>
 /// Constructor for creating a new <b>User Group</b> object and setting the
 /// context and the parent (Domain).
 /// </summary>
 /// <param name="context">An object context class containing session information.</param>
 /// <param name="parent">The parent entity of the <b>User Group</b> of type Domain.</param>
 public UserGroup(Domain parent)
     : base(parent.Context, parent)
 {
     InitializeMembers();
 }
Esempio n. 13
0
        public Cluster Install(bool system, string clusterName, string username, string email, string password)
        {
            cluster = new Cluster(Context)
            {
                Name = clusterName,
                System = system,
            };
            cluster.Save();

            // Create machine roles and machines

            //      -- controller role
            var mrcont = new MachineRole(cluster)
            {
                Name = Constants.ControllerMachineRoleName,
                System = system,
                MachineRoleType = MachineRoleType.StandAlone,
            };
            mrcont.Save();

            var sv = new ServerVersion(mrcont)
            {
                Name = Constants.ServerVersionName,
                System = system,
            };
            sv.Save();

            var mcont = new Machine(mrcont)
            {
                Name = Constants.ControllerMachineName,
            };
            mcont.Save();

            var sicont = new ServerInstance(mcont)
            {
                Name = Constants.ServerInstanceName,
                ServerVersion = sv,
            };
            sicont.Save();

            //      -- node role
            var mrnode = new MachineRole(cluster)
            {
                Name = Constants.NodeMachineRoleName,
                MachineRoleType = MachineRoleType.MirroredSet,
            };
            mrnode.Save();

            var nodesv = new ServerVersion(mrnode)
            {
                Name = Constants.ServerVersionName,
            };
            nodesv.Save();

            //      -- Create a node
            /*
            Machine mnode = new Machine(Context, mrnode);
            mnode.Name = Constants.NodeMachineName;
            mnode.Save();

            si = new ServerInstance(Context, mnode);
            si.Name = Constants.ServerInstanceName;
            si.ServerVersionReference.Value = sv;
            si.Save();*/

            // Create the shared domain for cluster level databases and users
            var domain = new Domain(cluster)
            {
                Name = Constants.SharedDomainName,
                Email = email,
                System = system,
            };
            domain.Save();

            // Create administrator group and user
            GenerateAdminGroup(system);
            GenerateAdmin(system, username, email, password);

            // Create the shared feredation
            var federation = new Federation(domain)
            {
                Name = Constants.SharedFederationName,
                Email = email,
                System = system,
                ControllerMachine = mcont,
                SchemaSourceServerInstance = sicont,
            };
            federation.Save();

            // Temp database definition
            var tempdd = new DatabaseDefinition(federation)
            {
                Name = Constants.TempDbName,
                System = system,
                LayoutType = DatabaseLayoutType.Monolithic,
                DatabaseInstanceNamePattern = Constants.TempDbInstanceNamePattern,
                DatabaseNamePattern = Constants.TempDbNamePattern,
                SliceCount = 1,
                PartitionCount = 1,
            };
            tempdd.Save();

            var tempddi = new DatabaseDefinitionInstaller(tempdd);
            tempddi.GenerateDefaultChildren(nodesv, Constants.TempDbName);

            // Create cluster level jobs and queues

            //      -- admin queue definition
            QueueDefinition qd = new QueueDefinition(cluster)
            {
                Name = Constants.MaintenanceQueueDefinitionName,
                System = system,
            };
            qd.Save();

            QueueInstance qi = new QueueInstance(mcont)
            {
                Name = Constants.MaintenanceQueueName,
                RunningState = Registry.RunningState.Running,
            };
            qi.QueueDefinitionReference.Value = qd;
            qi.Save();

            //      -- long queue definition
            qd = new QueueDefinition(cluster)
            {
                Name = Constants.LongQueueDefinitionName
            };
            qd.Save();

            qi = new QueueInstance(mcont)
            {
                Name = Constants.LongQueueName,
                RunningState = Registry.RunningState.Running,
            };
            qi.QueueDefinitionReference.Value = qd;
            qi.Save();

            //      -- quick queue definition
            qd = new QueueDefinition(cluster)
            {
                Name = Constants.QuickQueueDefinitionName,
            };
            qd.Save();

            qi = new QueueInstance(mcont)
            {
                Name = Constants.QuickQueueName,
                RunningState = Registry.RunningState.Running,
            };
            qi.QueueDefinitionReference.Value = qd;
            qi.Save();

            //      -- database mirror job
            var jd = new JobDefinition(federation)
            {
                Name = typeof(Jhu.Graywulf.Jobs.MirrorDatabase.MirrorDatabaseJob).Name,
                System = system,
                WorkflowTypeName = typeof(Jhu.Graywulf.Jobs.MirrorDatabase.MirrorDatabaseJob).AssemblyQualifiedName,
            };
            jd.DiscoverWorkflowParameters();
            jd.Save();

            //      -- test job
            jd = new JobDefinition(federation)
            {
                Name = typeof(Jhu.Graywulf.Jobs.Test.TestJob).Name,
                System = system,
                WorkflowTypeName = typeof(Jhu.Graywulf.Jobs.Test.TestJob).AssemblyQualifiedName,
            };
            jd.DiscoverWorkflowParameters();
            jd.Save();

            return cluster;
        }
Esempio n. 14
0
 /// <summary>
 /// Copy contructor for doing deep copy of the <b>Domain</b> objects.
 /// </summary>
 /// <param name="old">The <b>Domain</b> to copy from.</param>
 public Domain(Domain old)
     : base(old)
 {
     CopyMembers(old);
 }
Esempio n. 15
0
 /// <summary>
 /// Creates a deep copy of the passed object.
 /// </summary>
 /// <param name="old">A <b>Domain</b> object to create the deep copy from.</param>
 private void CopyMembers(Domain old)
 {
     this.shortTitle = old.shortTitle;
     this.longTitle = old.longTitle;
     this.email = old.email;
 }
Esempio n. 16
0
 /// <summary>
 /// Creates a deep copy of the passed object.
 /// </summary>
 /// <param name="old">A <b>Domain</b> object to create the deep copy from.</param>
 private void CopyMembers(Domain old)
 {
     this.shortTitle = old.shortTitle;
     this.longTitle = old.longTitle;
     this.email = old.email;
     this.copyright = old.copyright;
     this.disclaimer = old.disclaimer;
 }
Esempio n. 17
0
 public User FindUserByName(Domain domain, string name)
 {
     var ef = new EntityFactory(Context);
     return ef.LoadEntity<User>(domain.GetFullyQualifiedName(), name);
 }
Esempio n. 18
0
        public User FindUserByName(Domain domain, string name)
        {
            var ef = new EntityFactory(Context);

            return(ef.LoadEntity <User>(domain.GetFullyQualifiedName(), name));
        }
Esempio n. 19
0
 /// <summary>
 /// Constructor for creating a new <b>User Group</b> object and setting the
 /// context and the parent (Domain).
 /// </summary>
 /// <param name="context">An object context class containing session information.</param>
 /// <param name="parent">The parent entity of the <b>User Group</b> of type Domain.</param>
 public UserGroup(Domain parent)
     : base(parent.Context, parent)
 {
     InitializeMembers();
 }
Esempio n. 20
0
 public User LoginUser(Domain domain, string nameOrEmail, string password)
 {
     return(LoginUserInternal(domain, nameOrEmail, password));
 }