public IdentityProviderDto Probe(ServerDto server, string tenant, IdentityProviderDto provider, Token token) { var schemaSerialized = SerializeSchema(provider.Schema); var attributeSerailized = SerializeAttributes(provider.AttributesMap, "attributesMap"); provider.Schema = null; provider.AttributesMap = null; tenant = Uri.EscapeDataString(tenant); var url = string.Format(ServiceConfigManager.IdentityProvidersEndPoint, server.Protocol, server.ServerName, server.Port, tenant); url += "?probe=true"; var dto = typeof(IdentityProviderDto).Assembly; var json = JsonConvert.Serialize(provider, "root", dto.GetTypes(), true); json = SerializationJsonHelper.Cleanup(json); json = json.Substring(0, json.Length - 1); var attributeString = "\"attributesMap\":null,"; if (json.Contains(attributeString)) { json = json.Replace(attributeString, attributeSerailized + (string.IsNullOrEmpty(attributeSerailized)? string.Empty : ",")); } else { json += attributeSerailized; } var schemaString = "\"schema\":null,"; if (json.Contains(schemaString)) { json = json.Replace(schemaString, schemaSerialized + (string.IsNullOrEmpty(schemaSerialized)? string.Empty : ",")); } else { json += schemaSerialized; } json += "}"; ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Post }; var headers = ServiceHelper.AddHeaders(ServiceConfigManager.JsonContentType); json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json; var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json); response = SerializationJsonHelper.JsonToDictionary("attributesMap", response); response = CleanupSchemaJson(response); return(JsonConvert.Deserialize <IdentityProviderDto>(response, "root", dto.GetTypes(), true)); }
public bool Create(ServerDto serverDto, string tenantName, CertificateDto certificate, Token token) { tenantName = Uri.EscapeDataString(tenantName); var url = string.Format(ServiceConfigManager.CertificatesEndPoint, serverDto.Protocol, serverDto.ServerName, serverDto.Port, tenantName); var json = JsonConvert.Serialize(certificate); json = SerializationJsonHelper.Cleanup(json); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Post, }; var headers = ServiceHelper.AddHeaders(ServiceConfigManager.JsonContentType); json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json; var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json); return(string.IsNullOrEmpty(response)); }
public ExternalIdentityProviderDto Update(ServerDto serverDto, string tenant, ExternalIdentityProviderDto externalIdentityProvider, Token token) { var url = string.Format(_serviceConfigManager.GetExternalIdentityProviderEndPoint(), serverDto.Protocol, serverDto.ServerName, serverDto.Port, tenant, externalIdentityProvider.EntityID); var json = JsonConvert.JsonSerialize(externalIdentityProvider); json = SerializationJsonHelper.Cleanup(json); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Put, }; var headers = ServiceHelper.AddHeaders(ServiceConstants.JsonContentType); json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json; var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json); return(JsonConvert.JsonDeserialize <ExternalIdentityProviderDto> (response)); }
public RelyingPartyDto Create(ServerDto server, string tenant, RelyingPartyDto relyingParty, Token token) { tenant = Uri.EscapeDataString(tenant); var url = string.Format(_serviceConfigManager.GetRelyingPartysEndPoint(), server.Protocol, server.ServerName, server.Port, tenant); var json = JsonConvert.Serialize(relyingParty); json = SerializationJsonHelper.Cleanup(json); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Post, }; var headers = ServiceHelper.AddHeaders(ServiceConstants.JsonContentType); json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json; var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json); return(JsonConvert.Deserialize <RelyingPartyDto>(response)); }
public ExternalIdentityProviderDto Get(ServerDto serverDto, string tenantName, ExternalIdentityProviderDto externalIdentityProvider, Token token) { var name = Uri.EscapeDataString(externalIdentityProvider.EntityID); tenantName = Uri.EscapeDataString(tenantName); var url = string.Format(ServiceConfigManager.GetExternalIdentityProviderPostEndPoint, serverDto.Protocol, serverDto.ServerName, serverDto.Port, tenantName, externalIdentityProvider.EntityID); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Post, }; var headers = ServiceHelper.AddHeaders(ServiceConfigManager.JsonContentType); var postData = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower(); var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, postData); response = SerializationJsonHelper.JsonToDictionary("subjectFormats", response); var dto = typeof(ExternalIdentityProviderDto).Assembly; return(JsonConvert.Deserialize <ExternalIdentityProviderDto>(response, "root", dto.GetTypes(), true)); }
public ExternalIdentityProviderDto Create(ServerDto server, string tenantName, ExternalIdentityProviderDto externalIdentityProvider, Token token) { tenantName = Uri.EscapeDataString(tenantName); var url = string.Format(ServiceConfigManager.ExternalIdentityProvidersEndPoint, server.Protocol, server.ServerName, server.Port, tenantName); var dto = typeof(ExternalIdentityProviderDto).Assembly; var json = JsonConvert.Serialize(externalIdentityProvider, "root", dto.GetTypes(), true); json = SerializationJsonHelper.Cleanup(json); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Post, }; var headers = ServiceHelper.AddHeaders(ServiceConfigManager.JsonContentType); json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json; var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json); return(JsonConvert.JsonDeserialize <ExternalIdentityProviderDto> (response)); }