Example #1
0
        public HsmCryptographer Create()
        {
            var cryptographer = new HsmCryptographer();

            cryptographer.Error += Error;
            cryptographer.Init(this);

            return(cryptographer);
        }
        public void Init(TokenResolverSettings resolverSettings)
        {
            try
            {
                IPropertyManager client           = resolverSettings.ClientSettings.CreatePropertyManagerClient();
                Property[]       properties       = client.GetProperties(new [] { "TokenSettings" });
                string           tokenSettingsXml = properties.SingleOrDefault().Value;
                var tokenSettings = tokenSettingsXml.FromXml <TokenSettings>();

                m_innerSoftwareCryptographer = new SMIMECryptographer(
                    tokenSettings.DefaultEncryption,
                    tokenSettings.DefaultDigest);

                tokenSettings.Error    += ProxyError;
                m_innerHsmCryptographer = tokenSettings.Create();
            }
            catch (Exception ex)
            {
                ProxyError.NotifyEvent(this, ex);
                // Do not remove. Exceptions here can cause the Direct Project to not bind to SMTP.
            }
        }