예제 #1
0
        public Task <UserManagementMetadata> GetMetadataAsync()
        {
            var createUserProperties = new List <PropertyMetadata>
            {
                new PropertyMetadata(PropertyTypes.String, Core.Constants.ClaimTypes.Name, "Name", true),
                new PropertyMetadata(PropertyTypes.Password, Core.Constants.ClaimTypes.Password, "Password", true),
                new PropertyMetadata(PropertyTypes.Email, Core.Constants.ClaimTypes.Email, "Email", true),
                new PropertyMetadata(PropertyTypes.String, Core.Constants.ClaimTypes.Role, "Role", false)
            };

            var updateUserProperties = new List <PropertyMetadata>
            {
                new PropertyMetadata(PropertyTypes.String, Core.Constants.ClaimTypes.Name, "Name", true)
            };


            var createRoleProperties = new List <PropertyMetadata>
            {
                new PropertyMetadata(PropertyTypes.String, Core.Constants.ClaimTypes.Name, "Name", true),
                new PropertyMetadata(PropertyTypes.String, Core.Constants.ClaimTypes.Description, "Description", true)
            };

            var updateRoleProperties = new List <PropertyMetadata>
            {
                new PropertyMetadata(PropertyTypes.String, Core.Constants.ClaimTypes.Description, "Description", true)
            };

            var userMetadata = new UserMetadata(true, true, true, updateUserProperties, createUserProperties);
            var roleMetadata = new RoleMetadata(true, true, Core.Constants.ClaimTypes.Role, updateRoleProperties, createRoleProperties);

            return(Task.FromResult(new UserManagementMetadata(userMetadata, roleMetadata)));
        }
예제 #2
0
        private void ValidateUpdateProperty(RoleMetadata roleMetadata, string type, string value)
        {
            if (roleMetadata == null)
            {
                throw new ArgumentNullException(nameof(roleMetadata));
            }

            if (IsNullOrWhiteSpace(type))
            {
                ModelState.AddModelError("", Messages.PropertyTypeRequired);
                return;
            }

            var prop = roleMetadata.UpdateProperties.SingleOrDefault(x => x.Type == type);

            if (prop == null)
            {
                ModelState.AddModelError("", Format(Messages.PropertyInvalid, type));
            }
            else
            {
                var error = prop.Validate(value);
                if (error != null)
                {
                    ModelState.AddModelError("", error);
                }
            }
        }
예제 #3
0
        public RoleDetailResource(RoleDetail role, UrlHelper url, RoleMetadata meta)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            if (meta == null)
            {
                throw new ArgumentNullException("meta");
            }

            Data = new RoleDetailDataResource(role, url, meta);

            var links = new Dictionary <string, string>();

            if (meta.SupportsDelete)
            {
                links["Delete"] = url.Link(Constants.RouteNames.DeleteRole, new { subject = role.Subject });
            }
            this.Links = links;
        }
        public RoleDetailResource(RoleDetail role, IUrlHelper url, RoleMetadata meta)
        {
            if (role == null)
            {
                throw new ArgumentNullException(nameof(role));
            }
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (meta == null)
            {
                throw new ArgumentNullException(nameof(meta));
            }

            Data = new RoleDetailDataResource(role, url, meta);

            var links = new Dictionary <string, string>();

            if (meta.SupportsDelete)
            {
                links["delete"] = url.Link(IdentityManagerConstants.RouteNames.DeleteRole, new { subject = role.Subject });
            }
            Links = links;
        }
예제 #5
0
 private void IssueSpreadsheetRowsToShowRoleMetadata(RoleMetadata thedata)
 {
     // Workspace name:_____
     // Workspace status:  either WORK-IN-PROGRESS or PUBLISHED
     // Workspace owner: ______
     // Workspace creation date:  OR  Workspace publish date:
     // Role name: _______
     // THEN FOR EACH OWNER/APPROVER:
     //     Role XXXXXXownerXXXXX: EID and name and geography
 }
예제 #6
0
        public IdentityManagerMetadata GetStandardMetadata(bool includeAccountProperties = true)
        {
            var update = new List <PropertyMetadata>();

            if (this.userManager.SupportsUserPassword)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Password, x => null, SetPassword, name: "Password", dataType: PropertyDataType.Password, required: true));
            }
            if (this.userManager.SupportsUserEmail)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Email, GetEmail, SetEmail, name: "Email", dataType: PropertyDataType.Email));
            }
            if (this.userManager.SupportsUserPhoneNumber)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Phone, GetPhone, SetPhone, name: "Phone", dataType: PropertyDataType.String));
            }

            if (includeAccountProperties)
            {
                update.AddRange(PropertyMetadata.FromType <TUser>());
            }

            var create = new List <PropertyMetadata>();

            create.Add(PropertyMetadata.FromProperty <TUser>(x => x.UserName, type: Constants.ClaimTypes.Username, required: true));
            create.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Password, x => null, SetPassword, name: "Password", dataType: PropertyDataType.Password, required: true));

            var user = new UserMetadata
            {
                SupportsCreate   = true,
                SupportsDelete   = true,
                SupportsClaims   = this.userManager.SupportsUserClaim,
                CreateProperties = create,
                UpdateProperties = update
            };

            var role = new RoleMetadata
            {
                RoleClaimType    = Constants.ClaimTypes.Role,
                SupportsCreate   = true,
                SupportsDelete   = true,
                CreateProperties = new PropertyMetadata[] {
                    PropertyMetadata.FromProperty <TRole>(x => x.Name, type: Constants.ClaimTypes.Name, required: true),
                }
            };

            var meta = new IdentityManagerMetadata
            {
                UserMetadata = user,
                RoleMetadata = role
            };

            return(meta);
        }
예제 #7
0
        public async Task <IRoleProvider> Create(RoleMetadata metadata)
        {
            Role empty = new Role();

            _context.Roles.Add(empty);
            await _context.SaveChangesAsync();

            RoleProvider res = new RoleProvider(_workspace, _context, empty);
            await res.SetMetadata(metadata);

            return(res);
        }
예제 #8
0
        private IEnumerable <string> ValidateCreateProperties(RoleMetadata roleMetadata, IEnumerable <PropertyValue> properties)
        {
            if (roleMetadata == null)
            {
                throw new ArgumentNullException(nameof(roleMetadata));
            }
            properties = properties ?? Enumerable.Empty <PropertyValue>();

            var meta = roleMetadata.GetCreateProperties();

            return(meta.Validate(properties));
        }
        public static IEnumerable <PropertyMetadata> GetCreateProperties(this RoleMetadata roleMetadata)
        {
            if (roleMetadata == null)
            {
                throw new ArgumentNullException("roleMetadata");
            }

            var exclude    = roleMetadata.CreateProperties.Select(x => x.Type);
            var additional = roleMetadata.UpdateProperties.Where(x => !exclude.Contains(x.Type) && x.Required);

            return(roleMetadata.CreateProperties.Union(additional).ToList());
        }
예제 #10
0
        public async Task <ActionResult <RoleMetadata> > Create([FromBody] RoleMetadata data)
        {
            try
            {
                IRoleProvider res = await _workspace.Roles.Create(data);

                return(Created($"users/{res.Id}", await res.GetMetadata()));
            }
            catch
            {
                return(Forbid());
            }
        }
예제 #11
0
파일: Storage.cs 프로젝트: iqman/MACMSC
 private static void TranslateToMetadata(RoleMetadata rm, Role role)
 {
     rm.AssignUnassignRole   = role.AssignUnassignRole;
     rm.CanCreateRoot        = role.CanCreateRoot;
     rm.CanManageSubRoles    = role.CanManageSubRoles;
     rm.CanCreateUsers       = role.CanCreateUsers;
     rm.ChildRoles           = new Collection <ChildId>(role.ChildRoles.Select(id => new ChildId(id)).ToList());
     rm.DataEntities         = new Collection <EntityId>(role.DataEntities.Select(id => new EntityId(id)).ToList());
     rm.DataEntityPermission = role.DataEntityPermission;
     rm.Id     = role.Id;
     rm.IsRoot = role.IsRoot;
     rm.Name   = ConvertBinary(role.Name);
     rm.Users  = new Collection <ChildId>(role.Users.Select(id => new ChildId(id)).ToList());
 }
예제 #12
0
        public Task <UserManagementMetadata> GetMetadataAsync()
        {
            var createProperties = new List <PropertyMetadata>
            {
                new PropertyMetadata(PropertyTypes.String, ClaimTypes.Name, "Name", true),
                new PropertyMetadata(PropertyTypes.Password, ClaimTypes.Password, "Password", true),
                new PropertyMetadata(PropertyTypes.Email, ClaimTypes.Email, "Email", false)
            };

            var userMetadata = new UserMetadata(true, false, false, Enumerable.Empty <PropertyMetadata>(), createProperties);
            var roleMetadata = new RoleMetadata(false, false, ClaimTypes.Role, Enumerable.Empty <PropertyMetadata>(), Enumerable.Empty <PropertyMetadata>());

            return(Task.FromResult(new UserManagementMetadata(userMetadata, roleMetadata)));
        }
예제 #13
0
        public CreateRoleLink(IUrlHelper url, RoleMetadata roleMetadata)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (roleMetadata == null)
            {
                throw new ArgumentNullException(nameof(roleMetadata));
            }

            this["href"] = url.Link(IdentityManagerConstants.RouteNames.CreateRole, null);
            this["meta"] = roleMetadata.GetCreateProperties();
        }
        public RoleDetailDataResource(RoleDetail role, IUrlHelper url, RoleMetadata meta)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            if (meta == null)
            {
                throw new ArgumentNullException("meta");
            }

            this["name"]    = role.Name;
            this["subject"] = role.Subject;

            if (role.Properties != null)
            {
                var props =
                    from p in role.Properties
                    let m = (from m in meta.UpdateProperties where m.Type == p.Type select m).SingleOrDefault()
                            where m != null
                            select new
                {
                    Data  = m.Convert(p.Value),
                    Meta  = m,
                    Links = new
                    {
                        update = url.Link(Constants.RouteNames.UpdateRoleProperty,
                                          new
                        {
                            subject = role.Subject,
                            type    = p.Type.ToBase64UrlEncoded()
                        })
                    }
                };

                if (props.Any())
                {
                    this["properties"] = props.ToArray();
                }
            }
        }
예제 #15
0
파일: Storage.cs 프로젝트: iqman/MACMSC
        private static Role TranslateFromMetadata(RoleMetadata rm)
        {
            Role r = new Role();

            r.AssignUnassignRole   = rm.AssignUnassignRole;
            r.CanCreateRoot        = rm.CanCreateRoot;
            r.CanManageSubRoles    = rm.CanManageSubRoles;
            r.CanCreateUsers       = rm.CanCreateUsers;
            r.ChildRoles           = rm.ChildRoles.Select(c => c.Id).ToList();
            r.DataEntities         = rm.DataEntities.Select(d => d.Id).ToList();
            r.DataEntityPermission = rm.DataEntityPermission;
            r.Id     = rm.Id;
            r.IsRoot = rm.IsRoot;
            r.Name   = ConvertBinary(rm.Name);
            r.Users  = rm.Users.Select(u => u.Id).ToList();

            return(r);
        }
예제 #16
0
        private void EmitMetadata(Worksheet sheetEASetMetadata, ref RoleMetadata mdat, OdbcDataReader dr,
                                  int colnumFormula)
        {
            WorksheetRow row;

            GenMetadataSpreadsheetRow(sheetEASetMetadata, "Process:", dr.GetValue(colnumFormula + 2).ToString());
            GenMetadataSpreadsheetRow(sheetEASetMetadata, "SubProcess:", dr.GetValue(colnumFormula + 1).ToString());
            GenMetadataSpreadsheetRow(sheetEASetMetadata, "----------", "---------");
            GenMetadataSpreadsheetRow(sheetEASetMetadata, "EntSet ID:", mdat.WSid.ToString());
            GenMetadataSpreadsheetRow(sheetEASetMetadata, "EntSet Status:", mdat.WSstatus);
            GenMetadataSpreadsheetRow(sheetEASetMetadata, "EntSet Owner:", mdat.WSownerident);
            if (mdat.WSstatus == "WORKSPACE")
            {
                GenMetadataSpreadsheetRow(sheetEASetMetadata, "EntSet start time:", mdat.WSdateOfImport);
            }
            else
            {
                GenMetadataSpreadsheetRow(sheetEASetMetadata, "EntSet lock time:", mdat.WSdateOfImport);
            }
        }
예제 #17
0
파일: Storage.cs 프로젝트: iqman/MACMSC
        public void CreateRole(Role role)
        {
            LoadMetadata();

            RoleMetadata        md;
            List <RoleMetadata> mds = this.metadata.Roles.Where(m => m.Id == role.Id).ToList();

            if (mds.Count == 1)
            {
                md = mds[0];
            }
            else
            {
                md = new RoleMetadata();
                this.metadata.Roles.Add(md);
            }

            TranslateToMetadata(md, role);

            SaveMetadata();
        }
예제 #18
0
        public async Task <ActionResult> Update([FromBody] RoleMetadata data)
        {
            try
            {
                IRoleProvider prov = await _workspace.Roles.Get(data.Id);

                if (prov != null)
                {
                    await prov.SetMetadata(data);

                    return(Accepted());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch
            {
                return(Forbid());
            }
        }
예제 #19
0
        public RoleQueryResultResourceData(QueryResult <RoleSummary> result, IUrlHelper url, RoleMetadata meta)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (meta == null)
            {
                throw new ArgumentNullException(nameof(meta));
            }

            RoleResultMappers.MapToResultData(result, this);

            foreach (var role in Items)
            {
                var links = new Dictionary <string, string>
                {
                    { "detail", url.Link(IdentityManagerConstants.RouteNames.GetRole, new { subject = role.Data.Subject }) }
                };

                if (meta.SupportsDelete)
                {
                    links.Add("delete", url.Link(IdentityManagerConstants.RouteNames.DeleteRole, new { subject = role.Data.Subject }));
                }
                role.Links = links;
            }
        }
예제 #20
0
        public RoleQueryResultResource(QueryResult <RoleSummary> result, IUrlHelper url, RoleMetadata meta)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (meta == null)
            {
                throw new ArgumentNullException(nameof(meta));
            }

            Data = new RoleQueryResultResourceData(result, url, meta);

            var links = new Dictionary <string, object>();

            if (meta.SupportsCreate)
            {
                links["create"] = new CreateRoleLink(url, meta);
            }
            ;
            Links = links;
        }
예제 #21
0
        private Workbook XLSXgenerate
            (HttpContext context, OdbcDataReader dr, IMVFormula ENGINEmanif, IEntitlement ENGINEwsent,
            bool singlesheet, int idWS, string strRoleList)
        {
            Workbook book = new Workbook();

            Worksheet sheet = null;

            Worksheet sheetRoleMetadata = null;

            Worksheet sheetEASetMetadata = null;

            int IDsubprocess = -1;



            int colnumFormula      = -1;
            int colnumStatus       = -1;
            int colnumBusRole      = -1;
            int colnumIdSubprocess = -1;

            string currolename = null;

            WorksheetRow row;

            sheetEASetMetadata = book.Worksheets.Add("Context");

            // Create an annotation row with info about the snapshot context.
            RoleMetadata mdat = this.GenerateRoleMetadata(null, idWS);
            bool         boolMetadataHasBeenEmitted = false;


            sheetRoleMetadata = book.Worksheets.Add("Role Metadata");


            if (singlesheet)
            {
                sheet = book.Worksheets.Add("Technical Framework");



                row = sheet.Table.Rows.Add();

                for (int i = 0; i < dr.VisibleFieldCount; i++)
                {
                    switch (dr.GetName(i) as string)
                    {
                    case "Formula":
                        colnumFormula = i;
                        break;

                    case "Mod":
                        colnumStatus = i;
                        row.Cells.Add(dr.GetName(i));
                        break;

                    /*
                     * case "EntID":
                     * break;
                     */
                    case "BusRole":
                        colnumBusRole = i;
                        row.Cells.Add(dr.GetName(i));
                        break;

                    case "IDSubProcess":
                        colnumIdSubprocess = i;
                        break;

                    default:
                        row.Cells.Add(dr.GetName(i));
                        break;
                    }
                }
                row.Cells.Add("Manifest");
                row.Cells.Add("AutoCorrectedNulls");
            }



            if (colnumBusRole < 0)
            {
                // We haven't even gone through the SQL result's columns to determine
                // key column numbers yet!  Special case donehere.
                for (int i = 0; i < dr.VisibleFieldCount; i++)
                {
                    switch (dr.GetName(i) as string)
                    {
                    case "Formula":
                        colnumFormula = i;
                        break;

                    case "Mod":
                        colnumStatus = i;
                        break;

                    /*
                     * case "EntID":
                     * break;
                     * */
                    case "Business_Role_Name":
                        colnumBusRole = i;
                        break;

                    case "IDSubProcess":
                        colnumIdSubprocess = i;
                        break;

                    default:
                        break;
                    }
                }
            }


            // FOR EACH ROW

            while (dr.Read())
            {
                try
                {
                    if (!boolMetadataHasBeenEmitted)
                    {
                        EmitMetadata(sheetEASetMetadata, ref mdat, dr, colnumFormula);
                        boolMetadataHasBeenEmitted = true;
                    }


                    string newrolename = dr.GetValue(colnumBusRole) as string;

                    IDsubprocess = (int)dr.GetValue(colnumIdSubprocess);

                    if (singlesheet)
                    {
                        bool isBabySheet = false;
                        if (currolename == null)
                        {
                            currolename = newrolename;
                            isBabySheet = true;
                        }
                        else if (currolename != newrolename)
                        {
                            currolename = newrolename;
                            isBabySheet = true;
                        }

                        if (isBabySheet)
                        {
                            WorksheetRow row2 = null;

                            if (sheetRoleMetadata.Table.Rows.Count < 3)
                            {
                                row2 = sheetRoleMetadata.Table.Rows.Add();
                                row2.Cells.Add("ROLE OWNERS/APPROVERS");
                                row2 = sheetRoleMetadata.Table.Rows.Add();
                                row2 = sheetRoleMetadata.Table.Rows.Add();
                                row2.Cells.Add("Role Name");
                                row2.Cells.Add("Type");
                                row2.Cells.Add("EID");
                                row2.Cells.Add("Name");
                                row2.Cells.Add("Geography");
                            }

                            mdat = this.GenerateRoleMetadata(newrolename, idWS);
                            foreach (RoleMetadataOwner x in mdat.ROLEownersident)
                            {
                                row2 = sheetRoleMetadata.Table.Rows.Add();
                                row2.Cells.Add(newrolename);
                                row2.Cells.Add(x.rank);
                                row2.Cells.Add(x.EID);
                                row2.Cells.Add(x.name);
                                row2.Cells.Add(x.geography);
                            }
                        }
                        //                    GenMetadataSpreadsheetRow(sheetRoleMetadata, "--------", "-----------------------");
                    }



                    if (!singlesheet)
                    {
                        bool isBabySheet = false;

                        //Note: Excel cannot handle worksheet names longer than 31 chars
                        string truncsheetname = newrolename;
                        if (truncsheetname.Length > 31)
                        {
                            truncsheetname = truncsheetname.Substring(truncsheetname.Length - 31);
                        }

                        if (currolename == null)
                        {
                            sheet       = book.Worksheets.Add(truncsheetname);
                            currolename = newrolename;
                            isBabySheet = true;
                        }
                        else if (currolename != newrolename)
                        {
                            sheet       = book.Worksheets.Add(truncsheetname);
                            isBabySheet = true;
                        }


                        if (isBabySheet)
                        {
                            // Create an annotation row with info about the snapshot context.
                            mdat = this.GenerateRoleMetadata(newrolename, idWS);

                            GenMetadataSpreadsheetRow(sheet, "Role name:", mdat.rolename);
                            if (mdat.ROLEownersident.Count == 0)
                            {
                                GenMetadataSpreadsheetRow(sheet, "Role owners:", "NOT YET ENTERED");
                            }
                            else
                            {
                                foreach (object x in mdat.ROLEownersident)
                                {
                                    GenMetadataSpreadsheetRow(sheet, "Principal: ", x.ToString());
                                }
                            }
                            GenMetadataSpreadsheetRow(sheet, "----------", "---------------------");


                            /*
                             *
                             * row = sheet.Table.Rows.Add();
                             * row.Cells.Add(annotation);
                             */


                            currolename = newrolename;
                            row         = sheet.Table.Rows.Add();

                            for (int i = 0; i < dr.VisibleFieldCount; i++)
                            {
                                switch (dr.GetName(i) as string)
                                {
                                case "Formula":
                                    colnumFormula = i;
                                    break;

                                case "Mod":
                                    colnumStatus = i;
                                    row.Cells.Add(dr.GetName(i));
                                    break;

                                /*
                                 * case "EntID":
                                 * break;
                                 * */
                                case "BusRole":
                                    colnumBusRole = i;
                                    row.Cells.Add(dr.GetName(i));
                                    break;

                                case "IDSubProcess":
                                    colnumIdSubprocess = i;
                                    break;

                                default:
                                    row.Cells.Add(dr.GetName(i));
                                    break;
                                }
                            }
                            row.Cells.Add("Manifest");
                        }
                    }


                    row = sheet.Table.Rows.Add();

                    int IDwsentrow = (int)(dr.GetValue(0));

                    returnGetEntitlement OBJwsent =
                        ENGINEwsent.GetEntitlement(IDwsentrow);

                    string appname = OBJwsent.Application;

                    returnListMVFormula[] LISTformulas =
                        ENGINEmanif.ListMVFormula(null, "\"KEYapplication\" = ?",
                                                  new string[] { appname }, "");

                    string STRformula = "";

                    try
                    {
                        returnListMVFormula TheFormula = LISTformulas[0];
                        if (TheFormula.Formula == null)
                        {
                            TheFormula.Formula = "";
                        }

                        STRformula = HttpUtility.HtmlDecode(TheFormula.Formula.Trim());
                    }
                    catch (Exception eee) { }

                    if (STRformula == "")
                    {
                        STRformula = "\"TBD - " + appname + "\"";
                        //context.Response.Write("Error: the manifest formula for this application has NOT been specified.");
                        //return;
                    }

                    // We have the formula; now we can evaluate.
                    Evaluator ev = new Evaluator(Eval3.eParserSyntax.cSharp, false);
                    ev.AddEnvironmentFunctions(this);
                    ev.AddEnvironmentFunctions(new ManifestFormulaEvaluatorFunctions(OBJwsent));

                    opCode lCode;

                    bool doMakeNullRepair2ndTry = false;

                    try
                    {
                        lCode = ev.Parse(STRformula);
                    }
                    catch (Exception e)
                    {
                        row.Cells.Add("The formula for " + appname + " has parse errors: " + e.ToString());
                        return(book);
                    }

                    object RESLT = null;
                    try
                    {
                        RESLT = lCode.value;
                    }
                    catch (NullReferenceException enull)
                    {
                        //row.Cells.Add("Interpreting the formula for this application resulted in an error because of references to one or more fields that are NULL in value.");
                        //RESLT = "[ERROR: reference to one or more fields with null values]";
                        //row = sheet.Table.Rows.Add();
                        doMakeNullRepair2ndTry = true;
                    }
                    catch (Exception e)
                    {
                        row.Cells.Add("Interpreting the formula for this application resulted in this exception: " + e.ToString());
                        RESLT = "[ERROR: see line above for details]";
                        row   = sheet.Table.Rows.Add();
                    }



                    if (doMakeNullRepair2ndTry)
                    {
                        int repairCount = 0;
                        // NULLs caused failures in the 1st try.
                        // We will thus now repair all nulls and try again.
                        // If succeeds, we will generate a useable row but the final column
                        //   will alert the users to the fact that autorepair was performed.

                        TurnNullsToEmptyStrings(ref OBJwsent, ref repairCount);
                        if (repairCount == 0)
                        {
                            throw new Exception("ASSERTION FAILURE: null fields expected but not found");
                        }


                        opCode lCode2;

                        ev = new Evaluator(Eval3.eParserSyntax.cSharp, false);
                        ev.AddEnvironmentFunctions(this);
                        ev.AddEnvironmentFunctions(new ManifestFormulaEvaluatorFunctions(OBJwsent));
                        lCode2 = ev.Parse(STRformula);

                        try
                        {
                            RESLT = lCode2.value;
                        }
                        catch (Exception e)
                        {
                            row.Cells.Add("2nd try: Interpreting the formula for this application resulted in this exception: " + e.ToString());
                            RESLT = "[ERROR: see line above for details]";
                            row   = sheet.Table.Rows.Add();
                        }
                    }


                    // NOW READY TO EMIT THE COLUMNS

                    for (int i = 0; i < dr.VisibleFieldCount; i++)
                    {
                        if (i != -342350) /*used to be != 0 */
                        {
                            if ((i != colnumFormula) && (i != colnumIdSubprocess))
                            {
                                if (i == colnumStatus)
                                {
                                    string statSemantics = "ERR";
                                    switch (dr.GetValue(i) as string)
                                    {
                                    case "N":
                                        statSemantics = "New"; break;

                                    case "P":
                                        statSemantics = "New"; break;

                                    case "X":
                                        statSemantics = "Deleted"; break;

                                    case "A":
                                        statSemantics = ""; break;
                                    }
                                    row.Cells.Add(statSemantics);
                                }
                                else
                                {
                                    row.Cells.Add(dr.GetValue(i).ToString());
                                }
                            }
                        }
                    }

                    row.Cells.Add(RESLT as string);
                    row.Cells.Add(doMakeNullRepair2ndTry ? "Y" : "");
                }
                catch (Exception e)
                {
                    row = sheet.Table.Rows.Add();
                    row.Cells.Add(e.ToString() + e.StackTrace.ToString());
                }
            }



            EmitRoleMetadata_AdditionalRoles
                (sheetRoleMetadata, strRoleList, idWS, IDsubprocess);
            EmitRoleMetadata_FuncAppEntsByRole
                (sheetRoleMetadata, strRoleList, idWS, IDsubprocess);
            EmitRoleMetadata_SubProcessActivities
                (sheetRoleMetadata, strRoleList, idWS, IDsubprocess);



            return(book);
        }
 public CreateRoleLink(UrlHelper url, RoleMetadata roleMetadata)
 {
     this["href"] = url.Link(Constants.RouteNames.CreateRole, null);
     this["meta"] = roleMetadata.GetCreateProperties();
 }
        public virtual Task <IdentityManagerMetadata> GetStandardMetadata(bool includeAccountProperties = true)
        {
            var update = new List <PropertyMetadata>();

            if (UserManager.SupportsUserPassword)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Password, u => Task.FromResult <string>(null), SetPassword, "Password", PropertyDataType.Password, true));
            }
            if (UserManager.SupportsUserEmail)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Email, u => GetEmail(u), SetEmail, "Email", PropertyDataType.Email));
            }
            if (UserManager.SupportsUserPhoneNumber)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Phone, u => GetPhone(u), SetPhone, "Phone", PropertyDataType.String));
            }
            if (UserManager.SupportsUserTwoFactor)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, bool>("two_factor", u => GetTwoFactorEnabled(u), SetTwoFactorEnabled, "Two Factor Enabled", PropertyDataType.Boolean));
            }
            if (UserManager.SupportsUserLockout)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, bool>("locked_enabled", GetLockoutEnabled, (user1, enabled) => SetLockoutEnabled(user1, enabled), "Lockout Enabled", PropertyDataType.Boolean));
                update.Add(PropertyMetadata.FromFunctions <TUser, bool>("locked", GetLockedOut, (user1, locked) => SetLockedOut(user1, locked), "Locked Out", PropertyDataType.Boolean));
            }

            if (includeAccountProperties)
            {
                update.AddRange(PropertyMetadata.FromType <TUser>());
            }

            var create = new List <PropertyMetadata>();

            create.Add(PropertyMetadata.FromProperty <TUser>(x => x.UserName, name: Constants.ClaimTypes.Username, required: true));
            create.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Password, u => Task.FromResult <string>(null), SetPassword, "Password", PropertyDataType.Password, true));

            var user = new UserMetadata
            {
                SupportsCreate   = true,
                SupportsDelete   = true,
                SupportsClaims   = UserManager.SupportsUserClaim,
                CreateProperties = create,
                UpdateProperties = update
            };

            var role = new RoleMetadata
            {
                RoleClaimType    = RoleClaimType,
                SupportsCreate   = true,
                SupportsDelete   = true,
                CreateProperties = new[] {
                    PropertyMetadata.FromProperty <TRole>(x => x.Name, name: Constants.ClaimTypes.Name, required: true),
                }
            };

            var meta = new IdentityManagerMetadata
            {
                UserMetadata = user,
                RoleMetadata = role
            };

            return(Task.FromResult(meta));
        }
예제 #24
0
 public async Task SetMetadata(RoleMetadata value)
 {
     _role.Name           = value.Name;
     _role.NormalizedName = value.NormalizedName;
     await _context.SaveChangesAsync();
 }
        public UserManagementMetadata GetStandardMetadata(bool includeAccountProperties = true)
        {
            var update = new List <PropertyMetadata>();

            if (_userAccountService.Configuration.EmailIsUsername)
            {
                update.AddRange(new[] {
                    new ExpressionPropertyMetadata <TAccount, string>(PropertyTypes.Email, ClaimTypes.Username, "Email", true, GetUsername, SetUsername),
                    new ExpressionPropertyMetadata <TAccount, string>(PropertyTypes.Password, ClaimTypes.Password, "Password", true, x => null, SetPassword)
                });
            }
            else
            {
                update.AddRange(new[] {
                    new ExpressionPropertyMetadata <TAccount, string>(PropertyTypes.String, ClaimTypes.Username, "Username", true, GetUsername, SetUsername),
                    new ExpressionPropertyMetadata <TAccount, string>(PropertyTypes.Password, ClaimTypes.Password, "Password", true, x => null, SetPassword),
                    new ExpressionPropertyMetadata <TAccount, string>(PropertyTypes.Email, ClaimTypes.Email, "Email", _userAccountService.Configuration.RequireAccountVerification, GetEmail, SetConfirmedEmail)
                });
            }

            var create = new List <PropertyMetadata>();

            if (!_userAccountService.Configuration.EmailIsUsername && !_userAccountService.Configuration.RequireAccountVerification)
            {
                create.AddRange(update.Where(x => x.Required).ToArray());
                create.AddRange(new[] {
                    new ExpressionPropertyMetadata <TAccount, string>(PropertyTypes.Email, ClaimTypes.Email, "Email", false, GetEmail, SetConfirmedEmail)
                });
            }

            update.AddRange(new PropertyMetadata[] {
                new ExpressionPropertyMetadata <TAccount, string>(PropertyTypes.String, ClaimTypes.Phone, "Phone", false, GetPhone, SetConfirmedPhone),
                new ExpressionPropertyMetadata <TAccount, bool>(PropertyTypes.Boolean, "IsLoginAllowed", "Is Login Allowed", false, GetIsLoginAllowed, SetIsLoginAllowed)
            });

            if (includeAccountProperties)
            {
                update.AddRange(PropertyMetaDataCreation.FromType <TAccount>());
            }

            var userMetadata = new UserMetadata(true, true, true,
                                                createProperties: create,
                                                updateProperties: update);

            if (_groupService != null && _groupQuery != null)
            {
                var roleMetadata = new RoleMetadata(true, true, ClaimTypes.Role,
                                                    createProperties: new[] {
                    new PropertyMetadata(
                        PropertyTypes.String,
                        ClaimTypes.Name,
                        "Name",
                        true)
                },
                                                    updateProperties: Enumerable.Empty <PropertyMetadata>());

                return(new UserManagementMetadata(userMetadata, roleMetadata));
            }

            return(new UserManagementMetadata(userMetadata, null));
        }
        public virtual IdentityManagerMetadata GetStandardMetadata(bool includeAccountProperties = true)
        {
            var update = new List <PropertyMetadata>();

            if (this.userManager.SupportsUserPassword)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Password, x => null, this.SetPassword, "Password", PropertyDataType.Password, true));
            }
            if (this.userManager.SupportsUserEmail)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Email, this.GetEmail, this.SetEmail, "Email", PropertyDataType.Email));
            }
            if (this.userManager.SupportsUserPhoneNumber)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Phone, this.GetPhone, this.SetPhone, "Phone", PropertyDataType.String));
            }
            if (this.userManager.SupportsUserTwoFactor)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, bool>("two_factor", this.GetTwoFactorEnabled, this.SetTwoFactorEnabled, "Two Factor Enabled", PropertyDataType.Boolean));
            }
            if (this.userManager.SupportsUserLockout)
            {
                update.Add(PropertyMetadata.FromFunctions <TUser, bool>("locked_enabled", this.GetLockoutEnabled, this.SetLockoutEnabled, "Lockout Enabled", PropertyDataType.Boolean));
                update.Add(PropertyMetadata.FromFunctions <TUser, bool>("locked", this.GetLockedOut, this.SetLockedOut, "Locked Out", PropertyDataType.Boolean));
            }

            if (includeAccountProperties)
            {
                update.AddRange(PropertyMetadata.FromType <TUser>());
            }

            var create = new List <PropertyMetadata>
            {
                PropertyMetadata.FromProperty <TUser>(x => x.UserName, Constants.ClaimTypes.Username, required: true),
                PropertyMetadata.FromFunctions <TUser, string>(Constants.ClaimTypes.Password, x => null, this.SetPassword, "Password", PropertyDataType.Password, true)
            };

            var user = new UserMetadata
            {
                SupportsCreate   = true,
                SupportsDelete   = true,
                SupportsClaims   = this.userManager.SupportsUserClaim,
                CreateProperties = create,
                UpdateProperties = update
            };

            var role = new RoleMetadata
            {
                RoleClaimType    = this.RoleClaimType,
                SupportsCreate   = true,
                SupportsDelete   = true,
                CreateProperties = new[]
                {
                    PropertyMetadata.FromProperty <TRole>(x => x.Name, Constants.ClaimTypes.Name, required: true)
                }
            };

            var meta = new IdentityManagerMetadata
            {
                UserMetadata = user,
                RoleMetadata = role
            };

            return(meta);
        }
예제 #27
0
        /* Passing rolename as null is OK: generates just metadata about the entset context */
        private RoleMetadata GenerateRoleMetadata(string rolename, int wsID)
        {
            OdbcConnection tempconn = HELPERS.NewOdbcConn();

            RoleMetadata newbee = new RoleMetadata();

            IEntAssignmentSet engineEASet = new IEntAssignmentSet(tempconn);

            returnGetEntAssignmentSet eas = engineEASet.GetEntAssignmentSet(wsID);

            newbee.WSid         = wsID;
            newbee.WSstatus     = eas.Status;
            newbee.WSownerident =
                UserIdentificationString(eas.UserID, tempconn);
            newbee.WSdateOfImport =
                (eas.Status == "WORKSPACE") ? eas.DATETIMEbirth.ToString() :
                eas.DATETIMElock.ToString();


            newbee.ROLEownersident = new Queue <RoleMetadataOwner>();

            if (rolename != null)
            {
                int roleID;


                IBusRole            engineBR = new IBusRole(tempconn);
                returnListBusRole[] retFindBRole
                    = engineBR.ListBusRole(null, "\"Name\" = ?", new string[] { rolename }, "");

                if (retFindBRole.Length < 1)
                {
                    // If we get here, it's probably the case that rolename ends in "//DEL",
                    // i.e. representing a deleted role.
                    // throw new Exception("Rolename " + rolename + " not found");
                    roleID = -1;
                    // By setting roleID to this, we ensure that the list of role owners
                    // (computed by the logic immediately below)
                    // will just create an empty list.
                }
                else
                {
                    roleID = retFindBRole[0].ID;
                }

                newbee.rolename = rolename;

                IBusRoleOwner engineBRole = new IBusRoleOwner(tempconn);
                returnListBusRoleOwnerByBusRole[] roleowners
                    = engineBRole.ListBusRoleOwnerByBusRole(null, roleID);

                if (roleowners.Length < 1)
                {
                    RoleMetadataOwner baby = new RoleMetadataOwner();
                    baby.EID       = "";
                    baby.geography = "";
                    baby.rank      = "";
                    baby.name      = "";
                    newbee.ROLEownersident.Enqueue(baby);
                }
                else
                {
                    foreach (returnListBusRoleOwnerByBusRole roleowner in roleowners)
                    {
                        RoleMetadataOwner baby = new RoleMetadataOwner();
                        baby.EID       = roleowner.EID;
                        baby.geography = roleowner.Geography;
                        baby.rank      = roleowner.RankFriendly;
                        baby.name      = UserFriendlyName(roleowner.EID, tempconn);
                        newbee.ROLEownersident.Enqueue(baby);
                    }
                }
            }

            return(newbee);
        }
        public RoleQueryResultResourceData(QueryResult <RoleSummary> result, UrlHelper url, RoleMetadata meta)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            if (meta == null)
            {
                throw new ArgumentNullException("meta");
            }

            AutoMapper.Mapper.Map(result, this);

            foreach (var role in this.Items)
            {
                var links = new Dictionary <string, string>();
                links.Add("detail", url.Link(Constants.RouteNames.GetRole, new { subject = role.Data.Subject }));
                if (meta.SupportsDelete)
                {
                    links.Add("delete", url.Link(Constants.RouteNames.DeleteRole, new { subject = role.Data.Subject }));
                }
                role.Links = links;
            }
        }