public AppMetadata ReadAppMetadata(string environment, string clientId) { string appMetadataPath = _credentialPathManager.GetAppMetadataPath(environment, clientId); var appMetadataJson = Read(appMetadataPath); return(appMetadataJson.HasValues ? StorageJsonUtils.AppMetadataFromJson(appMetadataJson) : null); }
public void WriteCredentials(IEnumerable <Credential> credentials) { foreach (var credential in credentials) { var credentialJson = StorageJsonUtils.CredentialToJson(credential); string credentialPath = GetCredentialPath(credential); if (credential.CredentialType == CredentialType.OAuth2AccessToken) { ReadModifyWrite( credentialPath, (fileContentJson) => { AddAccessTokenWithScopes(fileContentJson, credentialJson); return(fileContentJson); }); } else { ReadModifyWrite( credentialPath, (fileContentJson) => { JsonMerge(credentialJson, fileContentJson); return(credentialJson); }); } } }
private Credential EmplaceAccessToken(JObject j, HashSet <string> scopes) { string target = string.Join(" ", scopes); var token = MockTestConstants.GetAccessToken(); token.Target = target; j[target] = StorageJsonUtils.CredentialToJson(token); return(token); }
private void ReadCredential(string relativePath, List <Credential> credentials) { var json = Read(relativePath); if (json != null && !json.IsEmpty()) { credentials.Add(StorageJsonUtils.CredentialFromJson(json)); } }
public Credential FindAccessTokenWithScopes(JObject accessTokens, string target) { KeyValuePair <string, JToken>?kvp = FindAccessTokenIterWithScopes(accessTokens, target); if (kvp.HasValue) { return(StorageJsonUtils.CredentialFromJson(JObject.Parse(kvp.Value.Value.ToString()))); } return(null); }
public void WriteAppMetadata(AppMetadata appMetadata) { var appMetadataJson = StorageJsonUtils.AppMetadataToJson(appMetadata); string appMetadataPath = _credentialPathManager.GetAppMetadataPath(appMetadata); ReadModifyWrite( appMetadataPath, fileContent => { JsonMerge(appMetadataJson, fileContent); return(appMetadataJson); }); }
public void WriteAccount(Microsoft.Identity.Client.CacheV2.Schema.Account account) { var accountJson = StorageJsonUtils.AccountToJson(account); string accountPath = _credentialPathManager.GetAccountPath(account); ReadModifyWrite( accountPath, fileContentJson => { JsonMerge(accountJson, fileContentJson); return(accountJson); }); }
private JObject GetAccessTokenJsonWithScopes(HashSet <string> scopes) { return(StorageJsonUtils.CredentialToJson(GetAccessTokenWithScopes(scopes))); }
public Microsoft.Identity.Client.CacheV2.Schema.Account ReadAccount(string homeAccountId, string environment, string realm) { var fileContentJson = Read(_credentialPathManager.GetAccountPath(homeAccountId, environment, realm)); return(fileContentJson.HasValues ? StorageJsonUtils.AccountFromJson(fileContentJson) : null); }