<s> """<STR_LIT>""" <EOL> from jasmin . protocols . validation import AbstractCredentialValidator <EOL> from jasmin . protocols . smpp . error import * <EOL> from jasmin . vendor . smpp . pdu . constants import priority_flag_value_map <EOL> from jasmin . vendor . smpp . pdu . pdu_types import RegisteredDeliveryReceipt , RegisteredDelivery <EOL> class SmppsCredentialValidator ( AbstractCredentialValidator ) : <EOL> "<STR_LIT>" <EOL> def __init__ ( self , action , user , submit_sm ) : <EOL> AbstractCredentialValidator . __init__ ( self , action , user ) <EOL> self . submit_sm = submit_sm <EOL> def _checkSendAuthorizations ( self ) : <EOL> "<STR_LIT>" <EOL> if not self . user . mt_credential . getAuthorization ( '<STR_LIT>' ) : <EOL> raise AuthorizationError ( <EOL> '<STR_LIT>' % self . user ) <EOL> if ( not self . user . mt_credential . getAuthorization ( '<STR_LIT>' ) and <EOL> self . submit_sm . params [ '<STR_LIT>' ] != RegisteredDelivery ( RegisteredDeliveryReceipt . NO_SMSC_DELIVERY_RECEIPT_REQUESTED ) ) : <EOL> raise AuthorizationError ( <EOL> '<STR_LIT>' % self . user ) <EOL> if ( not self . user . mt_credential . getAuthorization ( '<STR_LIT>' ) and <EOL> len ( self . submit_sm . params [ '<STR_LIT>' ] ) > <NUM_LIT:0> ) : <EOL> raise AuthorizationError ( <EOL> '<STR_LIT>' % self . user ) <EOL> if ( not self . user . mt_credential . getAuthorization ( '<STR_LIT>' ) and <EOL> str ( self . submit_sm . params [ '<STR_LIT>' ] ) != priority_flag_value_map [ <NUM_LIT:0> ] ) : <EOL> raise AuthorizationError ( <EOL> '<STR_LIT>' % self . user ) <EOL> def _checkSendFilters ( self ) : <EOL> "<STR_LIT>" <EOL> if ( self . user . mt_credential . getValueFilter ( '<STR_LIT>' ) is None or <EOL> not self . user . mt_credential . getValueFilter ( '<STR_LIT>' ) . match ( self . submit_sm . params [ '<STR_LIT>' ] ) ) : <EOL> raise FilterError ( <EOL> '<STR_LIT>' % self . user , <EOL> '<STR_LIT>' ) <EOL> if ( self . user . mt_credential . getValueFilter ( '<STR_LIT>' ) is None or <EOL> not self . user . mt_credential . getValueFilter ( '<STR_LIT>' ) . match ( self . submit_sm . params [ '<STR_LIT>' ] ) ) : <EOL> raise FilterError ( <EOL> '<STR_LIT>' % self . user , <EOL> '<STR_LIT>' ) <EOL> if ( self . user . mt_credential . getValueFilter ( '<STR_LIT>' ) is None or <EOL> not self . user . mt_credential . getValueFilter ( '<STR_LIT>' ) . match ( <EOL> str ( self . submit_sm . params [ '<STR_LIT>' ] . index ) ) ) : <EOL> raise FilterError ( <EOL> '<STR_LIT>' % self . user , <EOL> '<STR_LIT>' ) <EOL> if ( self . user . mt_credential . getValueFilter ( '<STR_LIT:content>' ) is None or <EOL> not self . user . mt_credential . getValueFilter ( '<STR_LIT:content>' ) . match ( self . submit_sm . params [ '<STR_LIT>' ] ) ) : <EOL> raise FilterError ( <EOL> '<STR_LIT>' % self . user , <EOL> '<STR_LIT:content>' ) <EOL> def updatePDUWithUserDefaults ( self , PDU ) : <EOL> """<STR_LIT>""" <EOL> if ( self . user . mt_credential . getDefaultValue ( '<STR_LIT>' ) is not None and <EOL> ( PDU . params [ '<STR_LIT>' ] is None or len ( PDU . params [ '<STR_LIT>' ] ) == <NUM_LIT:0> ) ) : <EOL> PDU . params [ '<STR_LIT>' ] = self . user . mt_credential . getDefaultValue ( '<STR_LIT>' ) <EOL> return PDU <EOL> def validate ( self ) : <EOL> "<STR_LIT>" <EOL> if self . action == '<STR_LIT>' : <EOL> self . _checkSendAuthorizations ( ) <EOL> self . _checkSendFilters ( ) <EOL> else : <EOL> raise CredentialValidationError ( '<STR_LIT>' % self . action ) </s>
