A relaying apparatus that is connected to a terminal device via a first network, and connected via a second network to an external device that relays communication to a first authentication apparatus that authenticates the terminal device according to a first authentication protocol, and to a second authentication apparatus that performs access authentication to the second network according to a second authentication protocol, thereby relaying communication from the terminal device to the second network, the relaying apparatus comprising:
- an identification-information storage unit that can store identification information for identifying communication for the relaying apparatus to access the second network;
- a request transmitting unit that transmits a first request message to the second authentication apparatus, the first request message requesting access authentication for the relaying apparatus to access the second network;
- a result receiving unit that receives a determination result of whether to approve an access of the relaying apparatus to the second network, which is a response to the first request message, from the second authentication apparatus;
- a communication establishing unit that establishes communication to the second network, and stores the identification information of the established communication in the identification-information storage unit, when the determination result indicating approval of the access of the relaying apparatus to the second network is received;
- a request receiving unit that receives a second request message from the terminal device, the second request message requesting access authentication for the terminal device to access the second network;
- and
- a transfer unit that obtains the identification information from the identification-information storage unit and transfers the second request message added with the obtained identification information to the external device, when the second request message is received.