diff --git a/src/Microsoft.AspNet.Security.DataProtection.Azure/BlobStorageXmlRepository.cs b/src/Microsoft.AspNet.Security.DataProtection.Azure/BlobStorageXmlRepository.cs index 952b8ce28f..8e728836da 100644 --- a/src/Microsoft.AspNet.Security.DataProtection.Azure/BlobStorageXmlRepository.cs +++ b/src/Microsoft.AspNet.Security.DataProtection.Azure/BlobStorageXmlRepository.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Security.DataProtection.Azure { blobRef.DownloadToStream(memoryStream); } - catch (StorageException ex) if (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound) + catch (StorageException ex) when (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound) { // 404s are not a fatal error - empty keyring return null; diff --git a/src/Microsoft.AspNet.Security.DataProtection/Cng/CngAuthenticatedEncryptorBase.cs b/src/Microsoft.AspNet.Security.DataProtection/Cng/CngAuthenticatedEncryptorBase.cs index 2e00fb1cb3..37450636a3 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/Cng/CngAuthenticatedEncryptorBase.cs +++ b/src/Microsoft.AspNet.Security.DataProtection/Cng/CngAuthenticatedEncryptorBase.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Security.DataProtection.Cng pbAdditionalAuthenticatedData: (pbAdditionalAuthenticatedDataArray != null) ? &pbAdditionalAuthenticatedDataArray[additionalAuthenticatedData.Offset] : &dummy, cbAdditionalAuthenticatedData: (uint)additionalAuthenticatedData.Count); } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize to CryptographicException. throw Error.CryptCommon_GenericError(ex); @@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Security.DataProtection.Cng cbPreBuffer: preBufferSize, cbPostBuffer: postBufferSize); } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize to CryptographicException. throw Error.CryptCommon_GenericError(ex); diff --git a/src/Microsoft.AspNet.Security.DataProtection/DataProtectionExtensions.cs b/src/Microsoft.AspNet.Security.DataProtection/DataProtectionExtensions.cs index f46852c797..dbfd3a1918 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/DataProtectionExtensions.cs +++ b/src/Microsoft.AspNet.Security.DataProtection/DataProtectionExtensions.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Security.DataProtection byte[] protectedDataAsBytes = protector.Protect(unprotectedDataAsBytes); return WebEncoders.Base64UrlEncode(protectedDataAsBytes); } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize exceptions to CryptographicException throw Error.CryptCommon_GenericError(ex); @@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Security.DataProtection byte[] unprotectedDataAsBytes = protector.Unprotect(protectedDataAsBytes); return CryptoUtil.SecureUtf8Encoding.GetString(unprotectedDataAsBytes); } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize exceptions to CryptographicException throw Error.CryptCommon_GenericError(ex); diff --git a/src/Microsoft.AspNet.Security.DataProtection/Dpapi/DpapiDataProtector.cs b/src/Microsoft.AspNet.Security.DataProtection/Dpapi/DpapiDataProtector.cs index 172a1289cc..cf734290cc 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/Dpapi/DpapiDataProtector.cs +++ b/src/Microsoft.AspNet.Security.DataProtection/Dpapi/DpapiDataProtector.cs @@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Security.DataProtection.Dpapi return _shim.Protect(unprotectedData, _combinedPurposes, _scope) ?? CryptoUtil.Fail("Null return value."); } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize to CryptographicException throw Error.CryptCommon_GenericError(ex); @@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Security.DataProtection.Dpapi return _shim.Unprotect(protectedData, _combinedPurposes, _scope) ?? CryptoUtil.Fail("Null return value."); } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize to CryptographicException throw Error.CryptCommon_GenericError(ex); diff --git a/src/Microsoft.AspNet.Security.DataProtection/KeyManagement/KeyRingBasedDataProtector.cs b/src/Microsoft.AspNet.Security.DataProtection/KeyManagement/KeyRingBasedDataProtector.cs index cd5a78e5c1..e5891f2d02 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/KeyManagement/KeyRingBasedDataProtector.cs +++ b/src/Microsoft.AspNet.Security.DataProtection/KeyManagement/KeyRingBasedDataProtector.cs @@ -131,7 +131,7 @@ namespace Microsoft.AspNet.Security.DataProtection.KeyManagement postBufferSize: 0); CryptoUtil.Assert(retVal != null && retVal.Length >= sizeof(uint) + sizeof(Guid), "retVal != null && retVal.Length >= sizeof(uint) + sizeof(Guid)"); } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // homogenize all errors to CryptographicException throw Error.Common_EncryptionFailed(ex); @@ -247,7 +247,7 @@ namespace Microsoft.AspNet.Security.DataProtection.KeyManagement CryptoUtil.Assert(retVal != null, "retVal != null"); return retVal; } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // homogenize all failures to CryptographicException throw Error.DecryptionFailed(ex); diff --git a/src/Microsoft.AspNet.Security.DataProtection/Managed/ManagedAuthenticatedEncryptor.cs b/src/Microsoft.AspNet.Security.DataProtection/Managed/ManagedAuthenticatedEncryptor.cs index 6d43753665..d384a5ff4a 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/Managed/ManagedAuthenticatedEncryptor.cs +++ b/src/Microsoft.AspNet.Security.DataProtection/Managed/ManagedAuthenticatedEncryptor.cs @@ -278,7 +278,7 @@ namespace Microsoft.AspNet.Security.DataProtection.Managed } } } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize all exceptions to CryptographicException. throw Error.CryptCommon_GenericError(ex); @@ -382,7 +382,7 @@ namespace Microsoft.AspNet.Security.DataProtection.Managed } } } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize all exceptions to CryptographicException. throw Error.CryptCommon_GenericError(ex); diff --git a/src/Microsoft.AspNet.Security.DataProtection/TimeLimitedDataProtector.cs b/src/Microsoft.AspNet.Security.DataProtection/TimeLimitedDataProtector.cs index 2bcf57dadd..09bab47aa8 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/TimeLimitedDataProtector.cs +++ b/src/Microsoft.AspNet.Security.DataProtection/TimeLimitedDataProtector.cs @@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Security.DataProtection expiration = new DateTimeOffset((long)utcTicksExpiration, TimeSpan.Zero); return retVal; } - catch (Exception ex) if (!(ex is CryptographicException)) + catch (Exception ex) when (!(ex is CryptographicException)) { // Homogenize all failures to CryptographicException throw Error.CryptCommon_GenericError(ex); diff --git a/src/Microsoft.AspNet.Security.DataProtection/project.json b/src/Microsoft.AspNet.Security.DataProtection/project.json index 8d8bcd50a1..13c7159bec 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/project.json +++ b/src/Microsoft.AspNet.Security.DataProtection/project.json @@ -23,6 +23,7 @@ "aspnetcore50": { "dependencies": { "Microsoft.Win32.Registry": "4.0.0-beta-*", + "System.IO": "4.0.10-beta-*", "System.Security.Cryptography.X509Certificates": "4.0.0-beta-*", "System.Security.Cryptography.Encryption.Aes": "4.0.0-beta-*", "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*",