Exemple #1
0
 def __init__(self, http, airplay_player):
     """Initialize a new AirPlayInternal instance."""
     self.player = airplay_player
     self.identifier = None
     self.srp = SRPAuthHandler()
     self.verifier = AuthenticationVerifier(http, self.srp)
     self.auther = DeviceAuthenticator(http, self.srp)
Exemple #2
0
    async def test_verify_authenticated(self):
        http = HttpSession(self.session,
                           'http://127.0.0.1:{0}/'.format(self.server.port))
        handler = srp.SRPAuthHandler()
        handler.initialize(binascii.unhexlify(DEVICE_AUTH_KEY))

        verifier = AuthenticationVerifier(http, handler)
        self.assertTrue((await verifier.verify_authed()))
Exemple #3
0
    async def test_verify_invalid(self):
        http = HttpSession(self.session,
                           'http://127.0.0.1:{0}/'.format(self.server.port))
        handler = srp.SRPAuthHandler()
        handler.initialize(INVALID_AUTH_KEY)

        verifier = AuthenticationVerifier(http, handler)
        with self.assertRaises(AuthenticationError):
            await verifier.verify_authed()
Exemple #4
0
    async def _player(self, session: ClientSession) -> AirPlayPlayer:
        http = net.HttpSession(
            session, f"http://{self.config.address}:{self.service.port}/")
        player = AirPlayPlayer(self.loop, http)

        # If credentials have been loaded, do device verification first
        if self.credentials:
            srp = SRPAuthHandler()
            srp.initialize(binascii.unhexlify(self.credentials))
            verifier = AuthenticationVerifier(http, srp)
            await verifier.verify_authed()

        return player
Exemple #5
0
    async def _player(self, session):
        http = net.HttpSession(
            session, 'http://{0}:{1}/'.format(
                self.config.address, self.service.port))
        player = AirPlayPlayer(self.loop, http)

        # If credentials have been loaded, do device verification first
        credentials = self._get_credentials()
        if credentials:
            srp = SRPAuthHandler()
            srp.initialize(binascii.unhexlify(credentials))
            verifier = AuthenticationVerifier(http, srp)
            await verifier.verify_authed()

        return player