github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/handlers/library/library.go (about) 1 /* 2 Copyright hechain, SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package library 8 9 import ( 10 "github.com/hechain20/hechain/core/handlers/auth" 11 "github.com/hechain20/hechain/core/handlers/auth/filter" 12 "github.com/hechain20/hechain/core/handlers/decoration" 13 "github.com/hechain20/hechain/core/handlers/decoration/decorator" 14 endorsement "github.com/hechain20/hechain/core/handlers/endorsement/api" 15 eb "github.com/hechain20/hechain/core/handlers/endorsement/builtin" 16 validation "github.com/hechain20/hechain/core/handlers/validation/api" 17 vb "github.com/hechain20/hechain/core/handlers/validation/builtin" 18 ) 19 20 // HandlerLibrary is used to assert 21 // how to create the various handlers 22 type HandlerLibrary struct{} 23 24 // DefaultAuth creates a default auth.Filter 25 // that doesn't do any access control checks - simply 26 // forwards the request further. 27 // It needs to be initialized via a call to Init() 28 // and be passed a peer.EndorserServer 29 func (r *HandlerLibrary) DefaultAuth() auth.Filter { 30 return filter.NewFilter() 31 } 32 33 // ExpirationCheck is an auth filter which blocks requests 34 // from identities with expired x509 certificates 35 func (r *HandlerLibrary) ExpirationCheck() auth.Filter { 36 return filter.NewExpirationCheckFilter() 37 } 38 39 // DefaultDecorator creates a default decorator 40 // that doesn't do anything with the input, simply 41 // returns the input as output. 42 func (r *HandlerLibrary) DefaultDecorator() decoration.Decorator { 43 return decorator.NewDecorator() 44 } 45 46 func (r *HandlerLibrary) DefaultEndorsement() endorsement.PluginFactory { 47 return &eb.DefaultEndorsementFactory{} 48 } 49 50 func (r *HandlerLibrary) DefaultValidation() validation.PluginFactory { 51 return &vb.DefaultValidationFactory{} 52 }