Pull out signing validation into validator class
This commit is contained in:
parent
8844ecbb7c
commit
2944a4e13d
3 changed files with 39 additions and 15 deletions
20
util/config/validators/validate_signer.py
Normal file
20
util/config/validators/validate_signer.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from StringIO import StringIO
|
||||
|
||||
from app import config_provider
|
||||
from util.config.validators import BaseValidator, ConfigValidationException
|
||||
from util.security.signing import SIGNING_ENGINES
|
||||
|
||||
class SignerValidator(BaseValidator):
|
||||
name = "signer"
|
||||
|
||||
@classmethod
|
||||
def validate(cls, config, user, user_password):
|
||||
""" Validates the GPG public+private key pair used for signing converted ACIs. """
|
||||
if config.get('SIGNING_ENGINE') is None:
|
||||
return
|
||||
|
||||
if config['SIGNING_ENGINE'] not in SIGNING_ENGINES:
|
||||
raise ConfigValidationException('Unknown signing engine: %s' % config['SIGNING_ENGINE'])
|
||||
|
||||
engine = SIGNING_ENGINES[config['SIGNING_ENGINE']](config, config_provider)
|
||||
engine.detached_sign(StringIO('test string'))
|
Reference in a new issue