Files
mRemoteNG/mRemoteV1/Credential/StaticSerializerKeyProviderDecorator.cs
David Sparer 8439d6d3aa lots of reworked interfaces around cred repo serialization
- decryptors now expose a property that represents what key they will use for decrypt. this can be used by decorators to properly encapsulate password prompts
- added some basic acceptance tests around cred repos
- added some stubby implementations for IDataProvider and the key provider decorators
2017-04-03 20:09:47 -06:00

41 lines
1.2 KiB
C#

using System;
using System.Security;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Security;
namespace mRemoteNG.Credential
{
public class StaticSerializerKeyProviderDecorator<TIn, TOut> : ISerializer<TIn, TOut>, IHasKey
{
private readonly ISerializer<TIn, TOut> _baseSerializer;
private readonly IHasKey _objThatNeedsKey;
private SecureString _key = new SecureString();
public SecureString Key
{
get { return _key; }
set
{
if (value == null) return;
_key = value;
}
}
public StaticSerializerKeyProviderDecorator(IHasKey objThatNeedsKey, ISerializer<TIn, TOut> baseSerializer)
{
if (objThatNeedsKey == null)
throw new ArgumentNullException(nameof(objThatNeedsKey));
if (baseSerializer == null)
throw new ArgumentNullException(nameof(baseSerializer));
_objThatNeedsKey = objThatNeedsKey;
_baseSerializer = baseSerializer;
}
public TOut Serialize(TIn model)
{
_objThatNeedsKey.Key = Key;
return _baseSerializer.Serialize(model);
}
}
}