Пример #1
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Rogers

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('Rogers')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))#,
                                      #urllib2.HTTPHandler(debuglevel=1),
                                      #urllib2.HTTPSHandler(debuglevel=1))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        viewstate = re.search('<input.*__VIEWSTATE.*?value=\"(.*?)\".*?>', html, re.MULTILINE)
        if not viewstate:
            return None

        validation = re.search('<input.*__EVENTVALIDATION.*?value=\"(.*?)\".*?>', html, re.MULTILINE)
        if not validation:
            return None

        return Rogers.getOAuthToken(username, password, viewstate.group(1), validation.group(1), resp.url)
Пример #2
0
    def deviceShortAuthorize(self, streamProvider, mso_id):
        """
        Authorise for a particular channel... a second time.
        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @return the session token required to authorise video the stream
        """
        settings = Settings.instance().get('adobe')

        values = {
            'requestor_id': streamProvider.getRequestorID(),
            'signed_requestor_id': streamProvider.getSignedRequestorID(),
            'session_guid': uuid.uuid4(),
            'hashed_guid': 'false',
            'authz_token': settings['AUTHZ_TOKEN'],
            'mso_id': mso_id,
            'device_id': streamProvider.getDeviceID()
        }

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.DEVICE_SHORT_AUTHORIZE,
                               urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return ''
Пример #3
0
    def callback(username, password):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(Sportsnet.USER_AGENT))]

        values = { 'callback' : 'mvpdSignInCallback',
                   'username' :  username,
                   'password' : password,
                   't' : str(int(time.time())) }
        try:
            resp = opener.open('https://now.sportsnet.ca/secure/mvpd/myrogers?'+urllib.urlencode(values))
        except:
            print "Unable to login with signinmvpd"
            return False

        res = resp.read()
        json_data  = re.search('mvpdSignInCallback\((.*?)\)', res, re.MULTILINE)
        if not json_data:
            return False

        jsres = json.loads(json_data.group(1))

        if not 'code' in jsres.keys():
            return True

        if jsres['code'] != 'loginsuccess':
            return False

        return True
Пример #4
0
    def authorizeDevice(self, streamProvider, mso_id, channel):
        """
        Authorise the device for a particular channel.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @param channel the channel identifier
        """
        settings = Settings.instance().get('adobe')

        values = {
            'resource_id': channel,
            'requestor_id': streamProvider.getRequestorID(),
            'signed_requestor_id': streamProvider.getSignedRequestorID(),
            'mso_id': mso_id,
            'authentication_token': settings['AUTHN_TOKEN'],
            'device_id': streamProvider.getDeviceID(),
            'userMeta': '1'
        }

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.AUTHORIZE_URI, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return False
Пример #5
0
    def authorizeDevice(self, streamProvider, mso_id, channel):
        """
        Authorise the device for a particular channel.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @param channel the channel identifier
        """
        settings = Settings.instance().get('adobe')

        values = { 'resource_id' : channel,
                   'requestor_id' : streamProvider.getRequestorID(),
                   'signed_requestor_id' : streamProvider.getSignedRequestorID(),
                   'mso_id' : mso_id,
                   'authentication_token' : settings['AUTHN_TOKEN'],
                   'device_id' : streamProvider.getDeviceID(),
                   'userMeta' : '1' }

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.AUTHORIZE_URI, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return False
Пример #6
0
    def getEntitlement(username, password, saml, relay, idp, url):
        """
        Get entitlement
        @param username the username
        @param password the password
        @param saml the SAML request (form data)
        @param relay the relay state (form data)
        @param idp the logon type (form data)
        @param url the entitlement URL
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {
            'adobeRequestSaml': saml,
            'relayState': relay,
            'username': username,
            'password': password,
            'IdpAdapterid': idp
        }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #7
0
    def deviceShortAuthorize(self, streamProvider, mso_id):
        """
        Authorise for a particular channel... a second time.
        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @return the session token required to authorise video the stream
        """
        settings = Settings.instance().get('adobe')

        values = { 'requestor_id' : streamProvider.getRequestorID(),
                   'signed_requestor_id' : streamProvider.getSignedRequestorID(),
                   'session_guid' : uuid.uuid4(),
                   'hashed_guid' : 'false',
                   'authz_token' : settings['AUTHZ_TOKEN'],
                   'mso_id' : mso_id,
                   'device_id' : streamProvider.getDeviceID() }

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.DEVICE_SHORT_AUTHORIZE, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return ''
Пример #8
0
    def preAuthorize(self, streamProvider, resource_ids):
        """
        Pre-authroize.  This _should_ get a list of authorised channels.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param resource_ids a list of resources to preauthorise
        @return a dictionary with each resource id as a key and boolean value
                indicating if the resource could be authorised
        """
        settings = Settings.instance().get('adobe')

        values = { 'authentication_token' : settings['AUTHN_TOKEN'],
                   'requestor_id' : streamProvider.getRequestorID() }

        value_str = urllib.urlencode(values)
        for resource_id in resource_ids:
            value_str += '&' + urllib.urlencode({ 'resource_id' : resource_id })

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.PREAUTHORIZE_URI, value_str)
        except urllib2.URLError, e:
            print e.args
            return False
Пример #9
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Telus

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('telus_auth-gateway_net')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get Telus OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        values = parseForm(['SAMLRequest', 'RelayState'], html)
        action = values.pop('action')
        if values == None:
            print "Form parsing failed in authorize"
            return None

        return Telus.getBookend(username, password, values, action)
Пример #10
0
    def preAuthorize(self, streamProvider, resource_ids):
        """
        Pre-authroize.  This _should_ get a list of authorised channels.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param resource_ids a list of resources to preauthorise
        @return a dictionary with each resource id as a key and boolean value
                indicating if the resource could be authorised
        """
        settings = Settings.instance().get('adobe')

        values = {
            'authentication_token': settings['AUTHN_TOKEN'],
            'requestor_id': streamProvider.getRequestorID()
        }

        value_str = urllib.urlencode(values)
        for k in resource_ids.keys():
            value_str += '&' + urllib.urlencode(
                {'resource_id': resource_ids[k]})

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.PREAUTHORIZE_URI, value_str)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #11
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Telus

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('telus_auth-gateway_net')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get Telus OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        values = parseForm(['SAMLRequest', 'RelayState'], html)
        action = values.pop('action')
        if values == None:
            print "Form parsing failed in authorize"
            return None

        return Telus.getBookend(username, password, values, action)
Пример #12
0
    def completeBackgroundLogin():
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open('https://sp.auth.adobe.com/adobe-services/completeBackgroundLogin')
        except urllib2.URLError, e:
            print e.args
Пример #13
0
    def completeBackgroundLogin():
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(
                'https://sp.auth.adobe.com/adobe-services/completeBackgroundLogin'
            )
        except urllib2.URLError, e:
            print e.args
Пример #14
0
    def authGateway(values, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            if e.reason[1] == "No address associated with hostname":
                return True
            return None
Пример #15
0
    def postLogin(username, password, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'username': username, 'password': password}

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #16
0
    def getSAMLAssertionConsumer(saml, relay, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'SAMLResponse': saml, 'RelayState': relay}

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #17
0
    def authGateway(values, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            if e.reason[1] == "No address associated with hostname":
                return True
            return None
Пример #18
0
    def getChannels(self):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [("User-Agent", urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.CHANNELS_URI)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #19
0
    def getChannels(self):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.CHANNELS_URI)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #20
0
    def discoveryAssociations(url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = { 'AuthState' : url[url.find('='):] }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #21
0
    def discoveryAssociations(url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'AuthState': url[url.find('='):]}

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #22
0
    def getBookendAgain(username, password, values, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = urllib.urlencode(values)
        url += '?' + values

        try:
            resp = opener.open(url, values)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #23
0
    def getSAMLAssertionConsumer(saml, relay, url): 

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'SAMLResponse' : saml,
                  'RelayState' : relay }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #24
0
    def postAuthSaml(username, password, saml, relay, url):

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'SAMLRequest': saml, 'RelayState': relay}

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #25
0
    def getBookendAgain(username, password, values, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = urllib.urlencode(values)
        url += '?' + values

        try:
            resp = opener.open(url, values)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #26
0
    def postLogin(username, password, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {
            'username' : username, 
            'password' : password 
        }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #27
0
    def lastBookend(values, url):
        """
        Make the lastBookend call
        """
        values['history'] = '7'
        url = url + '?' + urllib.urlencode(values)

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(url)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #28
0
    def postAuthSaml(username, password, saml, relay, url):
        
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {
            'SAMLRequest' : saml, 
            'RelayState' : relay 
        }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #29
0
    def lastBookend(values, url):
        """
        Make the lastBookend call
        """
        values['history'] = '7'
        url = url + '?' + urllib.urlencode(values)

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(url)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #30
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Cogeco

        @param streamProvider the stream provider object.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI("Cogeco")

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))  #,
        #urllib2.HTTPHandler(debuglevel=1),
        #urllib2.HTTPSHandler(debuglevel=1))

        # TODO: move this into a method that can be reused.. multiple calls..
        try:
            resp = opener.open(uri)
        except:
            print "Unable to redirect to auth page."
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        # TODO: this could be made a function to to parse and return the value based on an expression
        action = re.search('<form.*?action=\"(.*?)"', html, re.MULTILINE)
        if not action:
            print "Unable to find action form"
            return None
        action = action.group(1)

        saml = re.search('<input.*?name=\"SAMLRequest\".*?value=\"(.*?)\"',
                         html, re.MULTILINE)
        if not saml:
            print "Unable to find SAML requst."
            return None
        saml = saml.group(1)

        relay = re.search('<input.*?name=\"RelayState\".*?value=\"(.*?)\"',
                          html, re.MULTILINE)
        if not relay:
            print "Unable to find relay state."
            return None
        relay = relay.group(1)

        return Cogeco.postAuthSaml(username, password, saml, relay, action)
Пример #31
0
    def getGuideData(self):
        """
        Get the guid data for the channels right now.
        """
        now = self.getServerTime()
        url = self.EPG_PREFIX + now.strftime("%Y/%m/%d.xml")

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(url)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #32
0
    def signinmvpd():
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(Sportsnet.USER_AGENT))]

        values = { 'id' : 'myrogers' }
        try:
            resp = opener.open('https://now.sportsnet.ca/signinmvpd?',
                               urllib.urlencode(values))
        except:
            print "Unable to login with signinmvpd"
            return False

        res = resp.read()

        return True
Пример #33
0
    def getGuideData(self):
        """
        Get the guid data for the channels right now.
        """
        now = self.getServerTime()
        url = self.EPG_PREFIX + now.strftime("%Y/%m/%d.xml")

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(url)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #34
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with ShawGo

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('ShawGo')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))  #,
        #urllib2.HTTPHandler(debuglevel=1),
        #urllib2.HTTPSHandler(debuglevel=1))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        action = re.search('<form.*?action=\"(.*?)"', html, re.MULTILINE)
        if not action:
            print "Unable to find action form"
            return None
        action = action.group(1)

        saml = re.search('<input.*?name=\"SAMLRequest\".*?value=\"(.*?)\"',
                         html, re.MULTILINE)
        if not saml:
            print "Unable to find SAML requst."
            return None
        saml = saml.group(1)

        relay = re.search('<input.*?name=\"RelayState\".*?value=\"(.*?)\"',
                          html, re.MULTILINE)
        if not relay:
            print "Unable to find relay state."
            return None
        relay = relay.group(1)

        return ShawGo.getAuthn(username, password, saml, relay, action)
Пример #35
0
    def getBookend(username, password, values, url):
        """
        Perform OAuth
        @param username the username
        @param password the password
        @param saml the SAML request (form data)
        @param relay the relay state (form data)
        @param url the entitlement URL
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #36
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Cogeco

        @param streamProvider the stream provider object.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri =  streamProvider.getAuthURI("Cogeco")

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))#,
                                      #urllib2.HTTPHandler(debuglevel=1),
                                      #urllib2.HTTPSHandler(debuglevel=1))

        # TODO: move this into a method that can be reused.. multiple calls..
        try:
            resp = opener.open(uri)
        except:
            print "Unable to redirect to auth page."
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        # TODO: this could be made a function to to parse and return the value based on an expression
        action = re.search('<form.*?action=\"(.*?)"', html, re.MULTILINE)
        if not action:
            print "Unable to find action form"
            return None
        action = action.group(1)

        saml = re.search('<input.*?name=\"SAMLRequest\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not saml:
            print "Unable to find SAML requst."
            return None
        saml = saml.group(1)

        relay = re.search('<input.*?name=\"RelayState\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not relay:
            print "Unable to find relay state."
            return None
        relay = relay.group(1)

        return Cogeco.postAuthSaml(username, password, saml, relay, action)
Пример #37
0
    def getBookend(username, password, values, url):
        """
        Perform OAuth
        @param username the username
        @param password the password
        @param saml the SAML request (form data)
        @param relay the relay state (form data)
        @param url the entitlement URL
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #38
0
    def getPublishPoint(self, id, name, token):
        """
        Get the stream address.
        @param name the channel name
        @param token the token to authorize the stream
        """
        values = {"id": id, "type": "channel", "nt": "1", "aprid": name, "aptoken": token}

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [("User-Agent", urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.PUBLISH_POINT, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return ""
Пример #39
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with ShawGo

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('ShawGo')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))#,
                                      #urllib2.HTTPHandler(debuglevel=1),
                                      #urllib2.HTTPSHandler(debuglevel=1))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        action = re.search('<form.*?action=\"(.*?)"', html, re.MULTILINE)
        if not action:
            print "Unable to find action form"
            return None
        action = action.group(1)

        saml = re.search('<input.*?name=\"SAMLRequest\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not saml:
            print "Unable to find SAML requst."
            return None
        saml = saml.group(1)

        relay = re.search('<input.*?name=\"RelayState\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not relay:
            print "Unable to find relay state."
            return None
        relay = relay.group(1)

        return ShawGo.getAuthn(username, password, saml, relay, action)
Пример #40
0
    def getChannelResourceMap(self):
        """
        Get the mapping from ID to channel abbreviation
        """
        settings = Settings.instance().get(self.getRequestorID())
        chan_map = {}
        if settings and 'CHAN_MAP' in settings.keys():
            return settings['CHAN_MAP']

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.CONFIG_URI)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #41
0
    def checkMSOs(self):
        """
        Check the available MSOs. We don't actually use anything from this
        request other than the cookies returned.
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.AUTHORIZED_MSO_URI)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        mso_xml = resp.read()
        return None
Пример #42
0
    def checkMSOs(self):
        """
        Check the available MSOs. We don't actually use anything from this
        request other than the cookies returned.
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [("User-Agent", urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.AUTHORIZED_MSO_URI)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        mso_xml = resp.read()
        return None
Пример #43
0
    def getChannelResourceMap(self):
        """
        Get the mapping from ID to channel abbreviation
        """
        settings = Settings.instance().get(self.getRequestorID())
        chan_map = {}
        if settings and 'CHAN_MAP' in settings.keys():
            return settings['CHAN_MAP']

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.CONFIG_URI)
        except urllib2.URLError, e:
            print e.args
            return None
Пример #44
0
    def login(username, password, html):

        values = parseForm(['login_type', 'remember_me', 'source',
                                  'source_button'], html)
        if values == None:
            print "Form parsing failed in login"
            return None
        action = values.pop('action', None)
        values['username'] = username
        values['password'] = password

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(action, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #45
0
    def login(username, password, html):

        values = parseForm(
            ['login_type', 'remember_me', 'source', 'source_button'], html)
        if values == None:
            print "Form parsing failed in login"
            return None
        action = values.pop('action', None)
        values['username'] = username
        values['password'] = password

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(action, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return None
Пример #46
0
    def mvpd():
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(Sportsnet.USER_AGENT))]

        values = { 'id' : 'myrogers',
                   'format' : 'json',
                   'callback' : 'listenRogersSigninCallback',
                   't' : str(int(time.time())) }

        try:
            resp = opener.open('https://now.sportsnet.ca/mvpd?',
                               urllib.urlencode(values))
        except:
            print "Unable to login with mvpd"
            return False

        res = resp.read()

        return True
Пример #47
0
    def getPublishPoint(self, id, name, token):
        """
        Get the stream address. Do not call directly.
        @param name the channel name
        @param token the token to authorize the stream
        """
        values = {'format': 'json', 'id': id, 'type': 'channel', 'nt': '1'}

        if token:
            values['aprid'] = name
            values['aptoken'] = token

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.PUBLISH_POINT, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return ''
Пример #48
0
    def getOAuthToken(username, password, viewstate, validation, url):
        """
        Perform OAuth
        @param username the username
        @param password the password
        @param viewstate the viewstate (form data)
        @param validation the validation (form data)
        @param url the OAuth URL
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'__VIEWSTATE' : viewstate,
                  '__EVENTVALIDATION' : validation,
                  'UserName' : username,
                  'UserPassword' : password,
                  'Login' : 'Sign+in' }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #49
0
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Rogers

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('Rogers')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))  #,
        #urllib2.HTTPHandler(debuglevel=1),
        #urllib2.HTTPSHandler(debuglevel=1))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        viewstate = re.search('<input.*__VIEWSTATE.*?value=\"(.*?)\".*?>',
                              html, re.MULTILINE)
        if not viewstate:
            return None

        validation = re.search(
            '<input.*__EVENTVALIDATION.*?value=\"(.*?)\".*?>', html,
            re.MULTILINE)
        if not validation:
            return None

        return Rogers.getOAuthToken(username, password, viewstate.group(1),
                                    validation.group(1), resp.url)
Пример #50
0
    def sessionDevice(self, streamProvider):
        """
        Session Device.
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))#,
                                      #urllib2.HTTPHandler(debuglevel=1),
                                      #urllib2.HTTPSHandler(debuglevel=1))


        values = { 'requestor_id' : streamProvider.getRequestorID(),
                   'signed_requestor_id' : streamProvider.getSignedRequestorID(),
                   '_method' : 'GET',
                   'device_id' : streamProvider.getDeviceID()}

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]


        try:
            resp = opener.open(self.SESSION_DEVICE_URI, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return False
Пример #51
0
    def getEntitlement(username, password, saml, relay, idp, url):
        """
        Get entitlement
        @param username the username
        @param password the password
        @param saml the SAML request (form data)
        @param relay the relay state (form data)
        @param idp the logon type (form data)
        @param url the entitlement URL
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'adobeRequestSaml' : saml,
                  'relayState' : relay,
                  'username' : username,
                  'password' : password,
                  'IdpAdapterid' : idp }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #52
0
    def sessionDevice(self, streamProvider):
        """
        Session Device.
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))  #,
        #urllib2.HTTPHandler(debuglevel=1),
        #urllib2.HTTPSHandler(debuglevel=1))

        values = {
            'requestor_id': streamProvider.getRequestorID(),
            'signed_requestor_id': streamProvider.getSignedRequestorID(),
            '_method': 'GET',
            'device_id': streamProvider.getDeviceID()
        }

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.SESSION_DEVICE_URI,
                               urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return False
Пример #53
0
    def getOAuthToken(username, password, viewstate, validation, url):
        """
        Perform OAuth
        @param username the username
        @param password the password
        @param viewstate the viewstate (form data)
        @param validation the validation (form data)
        @param url the OAuth URL
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {
            '__VIEWSTATE': viewstate,
            '__EVENTVALIDATION': validation,
            'UserName': username,
            'UserPassword': password,
            'Login': '******'
        }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
Пример #54
0
    def getPublishPoint(self, id, name, token):
        """
        Get the stream address. Do not call directly.
        @param name the channel name
        @param token the token to authorize the stream
        """
        values = { 'format' : 'json',
                   'id' : id,
                   'type' : 'channel',
                   'nt' : '1'}

        if token:
            values['aprid'] = name
            values['aptoken'] = token

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.PUBLISH_POINT, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return ''