I'm starting a project that is required to take a document (pdf, jpeg, etc) via a WCf service and store it in with encryption in a location.
My question is one of fundamental class layout / design.
My intention is to have the WCF service function (SaveDocument) create call a worker class that handles the encryption / saving. Both the encryption / saving need to be changeable for future proofing i.e. change encryption method or how / where the data is saved (DB / File). Does my design below make sense:-
class DocumentManager
{
private IEncryptionService encrypt;
private IStoreService store;
private Document doc;
public DocumentManager(Document _doc)
{
encrypt = new XXXEncryptionService();
store = new FileStoreService();
doc = _doc;
}
public bool Save()
{
byte[] data = encrypt.Encrypt(doc.data);
return store.Save(data);
}
}
class IEncryptionService
{
public byte[] Encrypt(byte[] stream);
public byte[] Decrypt(byte[] stream);
}
class IStoreManager
{
public bool Save(byte[] stream);
}
Is there any use in the DocumentManager class being interfaced? I assume it would help for unit testing? Any other recommendations?
Many Thanks
Aucun commentaire:
Enregistrer un commentaire