コード例 #1
0
        /// <summary>
        /// This method registers an encryption handler with the collection.
        /// </summary>
        /// <param name="identifier">The identifier for the handler.</param>
        /// <param name="handler">The handler to register.</param>
        public void RegisterEncryptionHandler(string identifier, IEncryptionHandler handler)
        {
            if (string.IsNullOrEmpty(identifier))
            {
                throw new ArgumentNullException("identifier");
            }

            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            if (mEncryptionHandlers.ContainsKey(identifier))
            {
                throw new EncryptionHandlerAlreadyExistsException(identifier);
            }

            try
            {
                mEncryptionHandlers.Add(identifier, handler);
            }
            catch (Exception ex)
            {
                Collector?.LogException($"{nameof(RegisterEncryptionHandler)} unexpected error.", ex);
                throw;
            }
        }
コード例 #2
0
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentials.</param>
 /// <param name="keyMaker"></param>
 /// <param name="keyDeserializer"></param>
 /// <param name="storageIdMaker"></param>
 /// <param name="keySerializer"></param>
 /// <param name="entityName">The options entity name. If this is not presented then the entity name will be used.</param>
 /// <param name="versionPolicy">The versioning policy.</param>
 /// <param name="defaultTimeout">The default timeout for async requests.</param>
 /// <param name="accessType">The azure access type. BlobContainerPublicAccessType.Off is the default.</param>
 /// <param name="options">The optional blob request options.</param>
 /// <param name="context">The optional operation context.</param>
 /// <param name="persistenceRetryPolicy">Persistence retry policy</param>
 /// <param name="resourceProfile"></param>
 /// <param name="cacheManager"></param>
 /// <param name="referenceMaker"></param>
 /// <param name="encryption"></param>
 public PersistenceMessageHandlerAzureBlobStorageBase(StorageCredentials credentials
                                                      , Func <E, K> keyMaker
                                                      , Func <string, K> keyDeserializer
                                                      , Func <K, string> storageIdMaker = null
                                                      , Func <K, string> keySerializer  = null
                                                      , string entityName = null
                                                      , VersionPolicy <E> versionPolicy               = null
                                                      , TimeSpan?defaultTimeout                       = null
                                                      , BlobContainerPublicAccessType accessType      = BlobContainerPublicAccessType.Off
                                                      , BlobRequestOptions options                    = null
                                                      , OperationContext context                      = null
                                                      , PersistenceRetryPolicy persistenceRetryPolicy = null
                                                      , ResourceProfile resourceProfile               = null
                                                      , ICacheManager <K, E> cacheManager             = null
                                                      , Func <E, IEnumerable <Tuple <string, string> > > referenceMaker = null
                                                      , IEncryptionHandler encryption = null
                                                      )
     : base(keyMaker, keyDeserializer
            , entityName: entityName
            , versionPolicy: versionPolicy
            , defaultTimeout: defaultTimeout
            , persistenceRetryPolicy: persistenceRetryPolicy
            , resourceProfile: resourceProfile
            , cacheManager: cacheManager
            , referenceMaker: referenceMaker
            , keySerializer: keySerializer
            )
 {
     mDirectory      = entityName ?? typeof(E).Name;
     mStorage        = new StorageServiceBase(credentials, "persistence", accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mStorageIdMaker = storageIdMaker ?? mTransform.KeySerializer;
 }
コード例 #3
0
        /// <summary>
        /// This is the default constructor.
        /// </summary>
        /// <param name="credentials">The azure credentials</param>
        /// <param name="containerName">The container name to store the entities.</param>
        /// <param name="accessType">The azure storage access type.</param>
        /// <param name="options">The blob request options.</param>
        /// <param name="context">The operation context.</param>
        /// <param name="defaultTimeout">The default timeout for the operations.</param>
        /// <param name="encryption">Encryption to be used when storing the blob</param>
        public StorageServiceBase(StorageCredentials credentials
                                  , string containerName
                                  , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                  , BlobRequestOptions options    = null
                                  , OperationContext context      = null
                                  , TimeSpan?defaultTimeout       = null
                                  , IEncryptionHandler encryption = null)
        {
            if (credentials == null)
            {
                throw new ArgumentNullException("StorageServiceBase: Storage credentials cannot be null.");
            }

            if (containerName == null)
            {
                throw new ArgumentNullException("StorageServiceBase: Storage containerName cannot be null.");
            }

            mCredentails    = credentials;
            mContainerName  = ValidateAzureContainerName(containerName);
            mAccessType     = accessType;
            mOptions        = options ?? BlobRequestOptionsDefault;
            mContext        = context;
            mDefaultTimeout = defaultTimeout;
            mEncryption     = encryption;
        }
コード例 #4
0
ファイル: PdfTokenScanner.cs プロジェクト: huzhiguan/PdfPig
 public PdfTokenScanner(IInputBytes inputBytes, IObjectLocationProvider objectLocationProvider, IFilterProvider filterProvider,
                        IEncryptionHandler encryptionHandler)
 {
     this.inputBytes             = inputBytes;
     this.objectLocationProvider = objectLocationProvider;
     this.filterProvider         = filterProvider;
     this.encryptionHandler      = encryptionHandler;
     coreTokenScanner            = new CoreTokenScanner(inputBytes);
 }
コード例 #5
0
 public OrganisationBusinessLogic(IDataRepository dataRepo,
                                  ISubmissionBusinessLogic submissionLogic,
                                  IEncryptionHandler encryptionHandler,
                                  IObfuscator obfuscator = null)
 {
     _DataRepository    = dataRepo;
     _submissionLogic   = submissionLogic;
     _obfuscator        = obfuscator;
     _encryptionHandler = encryptionHandler;
 }
コード例 #6
0
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentails.</param>
 /// <param name="serviceName">The service name to log under.</param>
 /// <param name="defaultTimeout">The default timeout for each message.</param>
 /// <param name="accessType">The blog storage access type. By default this is set to private.</param>
 /// <param name="options">The blod request options.</param>
 /// <param name="context">The options context.</param>
 /// <param name="encryption">Encryption to be used when logging dead letters</param>
 public DeadLetterLoggerMessageHandler(StorageCredentials credentials, string serviceName
                                       , TimeSpan?defaultTimeout = null
                                       , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                       , BlobRequestOptions options    = null
                                       , OperationContext context      = null
                                       , IEncryptionHandler encryption = null)
 {
     mStorage     = new StorageServiceBase(credentials, "DeadLetter", accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mServiceName = serviceName;
 }
コード例 #7
0
 public PersistenceMondayMorningBluesBlob(StorageCredentials credentials
                                          , VersionPolicy <MondayMorningBlues> versionPolicy      = null
                                          , ICacheManager <Guid, MondayMorningBlues> cacheManager = null
                                          , IEncryptionHandler encryption = null)
     : base(credentials, (k) => k.Id, (s) => new Guid(s), keySerializer: (g) => g.ToString("N").ToUpperInvariant(), cacheManager: cacheManager
            , versionPolicy: versionPolicy
            , referenceMaker: MondayMorningBluesHelper.ToReferences
            , encryption: encryption
            )
 {
 }
コード例 #8
0
        /// <summary>
        /// This method adds the encryption handler to the Microservice.
        /// </summary>
        /// <typeparam name="P">The pipeline type.</typeparam>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="identifier">The encryption type identifier.
        /// This is will be used when assigning the handler to a channel or collector.</param>
        /// <param name="handler">The handler instance.</param>
        /// <param name="action">The action on the handler.</param>
        /// <returns>The pipeline.</returns>
        public static P AddEncryptionHandler <P>(this P pipeline
                                                 , string identifier
                                                 , IEncryptionHandler handler
                                                 , Action <IEncryptionHandler> action = null)
            where P : IPipeline
        {
            action?.Invoke(handler);

            pipeline.Service.Security.RegisterEncryptionHandler(identifier, handler);

            return(pipeline);
        }
コード例 #9
0
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentials.</param>
 /// <param name="directoryMaker"></param>
 /// <param name="defaultTimeout">The default timeout for async requests.</param>
 /// <param name="accessType">The azure access type. BlobContainerPublicAccessType.Off is the default.</param>
 /// <param name="options">The optional blob request options.</param>
 /// <param name="context">The optional operation context.</param>
 /// <param name="containerName"></param>
 /// <param name="serviceName"></param>
 /// <param name="idMaker"></param>
 /// <param name="resourceProfile"></param>
 /// <param name="encryption"></param>
 protected AzureStorageLoggingBase(StorageCredentials credentials
                                   , string containerName
                                   , string serviceName
                                   , Func <E, string> idMaker                 = null
                                   , Func <E, string> directoryMaker          = null
                                   , TimeSpan?defaultTimeout                  = null
                                   , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                   , BlobRequestOptions options               = null
                                   , OperationContext context                 = null
                                   , ResourceProfile resourceProfile          = null
                                   , IEncryptionHandler encryption            = null)
 {
     mStorage         = new StorageServiceBase(credentials, containerName, accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mIdMaker         = idMaker ?? IdMaker;
     mDirectoryMaker  = directoryMaker ?? DirectoryMaker;
     mServiceName     = serviceName;
     mResourceProfile = resourceProfile;
 }
コード例 #10
0
 public EncryptionController(IEncryptionHandler encryptionHandler)
 {
     _encryptionHandler = encryptionHandler;
 }
コード例 #11
0
ファイル: PdfTokenScanner.cs プロジェクト: huzhiguan/PdfPig
 public void UpdateEncryptionHandler(IEncryptionHandler newHandler)
 {
     encryptionHandler = newHandler ?? throw new ArgumentNullException(nameof(newHandler));
 }
コード例 #12
0
 public AzureStorageLogger(StorageCredentials credentials, string serviceName, string containerName = "log"
                           , ResourceProfile resourceProfile = null, IEncryptionHandler encryption = null)
     : base(credentials, containerName, serviceName, resourceProfile: resourceProfile, encryption: encryption)
 {
 }
コード例 #13
0
 /// <summary>
 /// This method registers a symmetric encryption handler with the Security container.
 /// </summary>
 /// <param name="identifier">The identifier. This is used to identify the handler so that it can be assigned to multiple channels.</param>
 /// <param name="handler">The actual handler.</param>
 public void RegisterEncryptionHandler(string identifier, IEncryptionHandler handler)
 {
     mSecurity.RegisterEncryptionHandler(identifier, handler);
 }