public SCIMUserQueryResponse getUsers(PaginationProperties pageProperties, SCIMFilter filter) { logger.Debug("getUsers by filter "); int totalRecords = 0; try { //List<SCIMUser> uList = users.Values.ToList<SCIMUser>(); List <SCIMUser> uList = _cacheService.GetAllSCIMUsers(); List <SCIMUser> fList = null; if (filter != null) { fList = filterUsers(uList, filter); totalRecords = fList.Count; } else { totalRecords = uList.Count; } int startIndex = pageProperties.startIndex > 0 && pageProperties.startIndex <= totalRecords ? pageProperties.startIndex : 1; int recordCount = startIndex + pageProperties.count <= totalRecords ? pageProperties.count : totalRecords - startIndex + 1; SCIMUserQueryResponse response = new SCIMUserQueryResponse(); //response.schemas = userSchemas; response.schemas = listResponseSchemas; response.totalResults = totalRecords; response.startIndex = startIndex; response.itemsPerPage = recordCount; if (filter != null) { response.Resources = fList.GetRange(startIndex - 1, recordCount); } else { response.Resources = uList.GetRange(startIndex - 1, recordCount); } return(response); } catch (Exception e) { throw new OnPremUserManagementException("getUsers", e); } }
public InMemorySCIMConnector(ICacheService cacheService) { this._cacheService = cacheService; listResponseSchemas = new List <string>(); listResponseSchemas.Add("urn:ietf:params:scim:schemas:core:2.0"); listResponseSchemas.Add("urn:ietf:params:scim:api:messages:2.0:ListResponse"); userSchemas = new List <string>(); userSchemas.Add("urn:ietf:params:scim:schemas:core:2.0"); userSchemas.Add("urn:ietf:params:scim:schemas:core:2.0:User"); userSchemas.Add("urn:ietf:params:scim:schemas:extension:enterprise:2.0"); userSchemas.Add("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"); groupSchemas = new List <string>(); groupSchemas.Add("urn:ietf:params:scim:schemas:core:2.0"); groupSchemas.Add("urn:ietf:params:scim:schemas:core:2.0:Group"); //SCIM1.1 and SCIM2.0 use different schemas //schemas are in the json files string user_json = appSettings["okta.scim_user"]; string group_json = appSettings["okta.scim_group"]; //check for users assume group if (users == null) { users = new ConcurrentDictionary <string, SCIMUser>(); groups = new ConcurrentDictionary <string, SCIMGroup>(); //createGroup(new SCIMGroup { displayName = "admins" }); //createGroup(new SCIMGroup { displayName = "execs" }); String path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString(); //System.Diagnostics.Debug.WriteLine(path); //using (System.IO.StreamReader file = System.IO.File.OpenText(path + "/10Users.json")) using (System.IO.StreamReader file = System.IO.File.OpenText(path + user_json)) { JsonSerializer serializer = new JsonSerializer(); SCIMUserQueryResponse response = (SCIMUserQueryResponse)serializer.Deserialize(file, typeof(SCIMUserQueryResponse)); foreach (SCIMUser u in response.Resources) { //System.Diagnostics.Debug.WriteLine(u.userName); createUser(u); } //userSchemas = response.schemas.ToList<string>(); } using (System.IO.StreamReader file = System.IO.File.OpenText(path + group_json)) { JsonSerializer serializer = new JsonSerializer(); SCIMGroupQueryResponse response = (SCIMGroupQueryResponse)serializer.Deserialize(file, typeof(SCIMGroupQueryResponse)); foreach (SCIMGroup g in response.Resources) { //System.Diagnostics.Debug.WriteLine(u.userName); createGroup(g); } //groupSchemas = response.schemas.ToList<string>(); } } }
public InMemorySCIMConnector(ICacheService cacheService, ILogger <InMemorySCIMConnector> logger, IConfiguration config) { _logger = logger; _config = config; _cacheService = cacheService; _custom_externtion_urn = _config.GetValue <string>("Scim:custom_externtion_urn"); listResponseSchemas = new List <string>(); listResponseSchemas.Add("urn:ietf:params:scim:schemas:core:2.0"); listResponseSchemas.Add("urn:ietf:params:scim:api:messages:2.0:ListResponse"); userSchemas = new List <string>(); userSchemas.Add("urn:ietf:params:scim:schemas:core:2.0"); userSchemas.Add("urn:ietf:params:scim:schemas:core:2.0:User"); userSchemas.Add("urn:ietf:params:scim:schemas:extension:enterprise:2.0"); userSchemas.Add("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"); groupSchemas = new List <string>(); groupSchemas.Add("urn:ietf:params:scim:schemas:core:2.0"); groupSchemas.Add("urn:ietf:params:scim:schemas:core:2.0:Group"); //SCIM1.1 and SCIM2.0 use different schemas //schemas are in the json files //string user_json = appSettings["okta.scim_user"]; //string group_json = appSettings["okta.scim_group"]; string user_json = _config.GetValue <string>("Scim:Users"); string group_json = _config.GetValue <string>("scim:Groups"); //check for users assume group if (_users == null) { _users = new ConcurrentDictionary <string, SCIMUser>(); _groups = new ConcurrentDictionary <string, SCIMGroup>(); FileStream fileStream = new FileStream("App_Data/2Users_SCIM20.json", FileMode.Open); using (StreamReader reader = new StreamReader(fileStream)) { JsonSerializer serializer = new JsonSerializer(); SCIMUserQueryResponse response = (SCIMUserQueryResponse)serializer.Deserialize(reader, typeof(SCIMUserQueryResponse)); foreach (SCIMUser u in response.Resources) { createUser(u); } //userSchemas = response.schemas.ToList<string>(); } FileStream fileStream1 = new FileStream("App_Data/2Groups_SCIM20.json", FileMode.Open); using (StreamReader reader = new StreamReader(fileStream1)) { JsonSerializer serializer = new JsonSerializer(); SCIMGroupQueryResponse response = (SCIMGroupQueryResponse)serializer.Deserialize(reader, typeof(SCIMGroupQueryResponse)); foreach (SCIMGroup g in response.Resources) { createGroup(g); } //groupSchemas = response.schemas.ToList<string>(); } } }