private void CreateTestKey( string keyName, string keyId, string keyStorageProviderName, string keyType, string algorithm, IAuthorizer keyAuth, int?expirationTimeInDays) { keyAuth.ThrowIfNull(nameof(keyAuth)); keys.Add(keyName, new Dictionary <string, KeyStoreData>()); keys[keyName][keyId] = new KeyStoreData( new KSPKey(keyId, keyStorageProviderName), keyId, keyType, algorithm, keyAuth, expirationTimeInDays); //Multiple keys with the same name can be in the app settings, the first one for the current name is active, the rest have been rolled if (!activeKeys.ContainsKey(keyName)) { activeKeys[keyName] = keyId; } }
public void CanUserAccessKey(ClaimsPrincipal user, KeyStoreData key) { string email = null; user.ThrowIfNull(nameof(user)); foreach (var claim in user.Claims) { if (claim.Type == EmailClaim) { email = claim.Value; break; } else if (claim.Type == UpnClaim) { email = claim.Value; break; } } if (email == null) { throw new System.ArgumentException("The email or upn claim is required"); } if (!validEmails.Contains(email.Trim())) { throw new CustomerKeyStore.Models.KeyAccessException("User does not have access to the key"); } }
private void CreateTestKey( string keyName, string keyId, string publicKey, string privateKey, string keyType, string algorithm, IAuthorizer keyAuth, int?expirationTimeInDays) { keyAuth.ThrowIfNull(nameof(keyAuth)); _logger.LogInformation("call CreateTestKey function in testStore with keyName = " + keyName + " and keyId = " + keyId); keys.Add(keyName, new Dictionary <string, KeyStoreData>()); keys[keyName][keyId] = new KeyStoreData( new TestKey(publicKey, privateKey), keyId, keyType, algorithm, keyAuth, expirationTimeInDays); //Multiple keys with the same name can be in the app settings, the first one for the current name is active, the rest have been rolled if (!activeKeys.ContainsKey(keyName)) { activeKeys[keyName] = keyId; } }
public void CanUserAccessKey(ClaimsPrincipal user, KeyStoreData key) { user.ThrowIfNull(nameof(user)); string sid = null; foreach (var claim in user.Claims) { if (claim.Type == SidClaim) { sid = claim.Value; break; } } if (sid == null) { throw new System.ArgumentException(SidClaim + " claim not found"); } CanUserAccessKey(sid); }