<s> """<STR_LIT>""" <EOL> from gdata . tlslite . Checker import Checker <EOL> class ClientHelper : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , <EOL> username = None , password = None , sharedKey = None , <EOL> certChain = None , privateKey = None , <EOL> cryptoID = None , protocol = None , <EOL> x509Fingerprint = None , <EOL> x509TrustList = None , x509CommonName = None , <EOL> settings = None ) : <EOL> """<STR_LIT>""" <EOL> self . username = None <EOL> self . password = None <EOL> self . sharedKey = None <EOL> self . certChain = None <EOL> self . privateKey = None <EOL> self . checker = None <EOL> if username and password and not ( sharedKey or certChain or privateKey ) : <EOL> self . username = username <EOL> self . password = password <EOL> elif username and sharedKey and not ( password or certChain or privateKey ) : <EOL> self . username = username <EOL> self . sharedKey = sharedKey <EOL> elif certChain and privateKey and not ( username or password or sharedKey ) : <EOL> self . certChain = certChain <EOL> self . privateKey = privateKey <EOL> elif not password and not username and not sharedKey and not certChain and not privateKey : <EOL> pass <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if sharedKey and ( cryptoID or protocol or x509Fingerprint ) : <EOL> raise ValueError ( "<STR_LIT>" "<STR_LIT>" ) <EOL> self . checker = Checker ( cryptoID , protocol , x509Fingerprint , <EOL> x509TrustList , x509CommonName ) <EOL> self . settings = settings <EOL> self . tlsSession = None <EOL> def _handshake ( self , tlsConnection ) : <EOL> if self . username and self . password : <EOL> tlsConnection . handshakeClientSRP ( username = self . username , <EOL> password = self . password , <EOL> checker = self . checker , <EOL> settings = self . settings , <EOL> session = self . tlsSession ) <EOL> elif self . username and self . sharedKey : <EOL> tlsConnection . handshakeClientSharedKey ( username = self . username , <EOL> sharedKey = self . sharedKey , <EOL> settings = self . settings ) <EOL> else : <EOL> tlsConnection . handshakeClientCert ( certChain = self . certChain , <EOL> privateKey = self . privateKey , <EOL> checker = self . checker , <EOL> settings = self . settings , <EOL> session = self . tlsSession ) <EOL> self . tlsSession = tlsConnection . session </s>
