Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RavenDB-2919 Initial infrastructure for encryption support in RavenFS
- Loading branch information
Arkadiusz Palinski
committed
Nov 25, 2014
1 parent
82ca917
commit 46d29cf
Showing
18 changed files
with
248 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
Raven.Database/FileSystem/Bundles/Encryption/Plugin/FileEncryption.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="FileEncryption.cs" company="Hibernating Rhinos LTD"> | ||
// Copyright (c) Hibernating Rhinos LTD. All rights reserved. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
using System.ComponentModel.Composition; | ||
using System.IO; | ||
using Raven.Bundles.Encryption.Settings; | ||
using Raven.Database.FileSystem.Plugins; | ||
using Raven.Json.Linq; | ||
|
||
namespace Raven.Database.FileSystem.Bundles.Encryption.Plugin | ||
{ | ||
[InheritedExport(typeof(AbstractFileCodec))] | ||
[ExportMetadata("Order", 5000)] | ||
[ExportMetadata("Bundle", "Encryption")] | ||
public class FileEncryption : AbstractFileCodec | ||
{ | ||
private EncryptionSettings settings; | ||
|
||
public override void Initialize() | ||
{ | ||
settings = EncryptionSettingsManager.GetEncryptionSettingsForResource(FileSystem); | ||
} | ||
|
||
public override void SecondStageInit() | ||
{ | ||
EncryptionSettingsManager.VerifyEncryptionKey(FileSystem, settings); | ||
} | ||
|
||
public override Stream Encode(string key, Stream data, RavenJObject metadata) | ||
{ | ||
if (EncryptionSettings.DontEncrypt(key)) | ||
return data; | ||
|
||
return settings.Codec.Encode(key, data); | ||
} | ||
|
||
public override Stream Decode(string key, Stream encodedDataStream, RavenJObject metadata) | ||
{ | ||
if (EncryptionSettings.DontEncrypt(key)) | ||
return encodedDataStream; | ||
|
||
return settings.Codec.Decode(key, encodedDataStream); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="AbstractFileCodec.cs" company="Hibernating Rhinos LTD"> | ||
// Copyright (c) Hibernating Rhinos LTD. All rights reserved. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
using System.ComponentModel.Composition; | ||
using System.IO; | ||
using Raven.Json.Linq; | ||
|
||
namespace Raven.Database.FileSystem.Plugins | ||
{ | ||
[InheritedExport] | ||
public abstract class AbstractFileCodec : IRequiresFileSystemInitialization | ||
{ | ||
public RavenFileSystem FileSystem { get; set; } | ||
|
||
public virtual void Initialize(RavenFileSystem fileSystem) | ||
{ | ||
FileSystem = fileSystem; | ||
Initialize(); | ||
} | ||
|
||
public virtual void Initialize() | ||
{ | ||
|
||
} | ||
|
||
public virtual void SecondStageInit() | ||
{ | ||
|
||
} | ||
|
||
public abstract Stream Encode(string key, Stream data, RavenJObject metadata); | ||
|
||
public abstract Stream Decode(string key, Stream encodedDataStream, RavenJObject metadata); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Raven.Database/FileSystem/Plugins/AbstractFileSystemIndexCodec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="AbstractFileSystemIndexCodec.cs" company="Hibernating Rhinos LTD"> | ||
// Copyright (c) Hibernating Rhinos LTD. All rights reserved. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
using System.IO; | ||
|
||
namespace Raven.Database.FileSystem.Plugins | ||
{ | ||
public abstract class AbstractFileSystemIndexCodec : IRequiresFileSystemInitialization | ||
{ | ||
public void Initialize(RavenFileSystem fileSystem) | ||
{ | ||
} | ||
|
||
public void SecondStageInit() | ||
{ | ||
} | ||
|
||
public abstract Stream Encode(string key, Stream dataStream); | ||
|
||
public abstract Stream Decode(string key, Stream dataStream); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Raven.Database/FileSystem/Plugins/IRequiresFileSystemInitialization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="IRequiresFileSystemInitialization.cs" company="Hibernating Rhinos LTD"> | ||
// Copyright (c) Hibernating Rhinos LTD. All rights reserved. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
namespace Raven.Database.FileSystem.Plugins | ||
{ | ||
public interface IRequiresFileSystemInitialization | ||
{ | ||
void Initialize(RavenFileSystem fileSystem); | ||
|
||
void SecondStageInit(); | ||
} | ||
} |
Oops, something went wrong.