mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-26 12:08:37 +08:00
- 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
41 lines
1.2 KiB
C#
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);
|
|
}
|
|
}
|
|
} |