WISPrのSmart Clientを実装する
WISPrとは?
Wi-Fi based Wireless Internet Service Provider(WISP)のローミングについてのベストプラクティスです。 あくまでも、RFCのような標準ではなくベストプラクティスだそうです。
具体的には?
次のようなケースで使われています。
- 公衆無線LANに接続する
- 任意のURLにアクセスする
- ログインページ(
Captive Portal
)が表示される
このとき、Captive Portal
のHTMLには次のようなXMLが埋め込まれています。
<?xml version="1.0" encoding="UTF-8"?> <WISPAccessGatewayParam xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation="http://www.acmewisp.com/WISPAccessGatewa yParam.xsd"> Alliance Wireless ISP Roaming <Redirect> <AccessProcedure>1.0</AccessProcedure> <AccessLocation>12</AccessLocation> <LocationName> ACMEWISP,Gate_14_Terminal_C_of_Newark_Airport </LocationName> <LoginURL>http://www.acmewisp.com/login/</LoginURL> <AbortLoginURL> http://www.acmewisp.com/abortlogin/ </AbortLoginURL> <MessageType>100</MessageType> <ResponseCode>0</ResponseCode> </Redirect> </WISPAccessGatewayParam>
このXMLがWISPr
の仕様の一部です。
Smart Clientとは?
上記のXMLを使ったやりとりを利用して、自動ログインの方法を提供することで、ユーザーの利便性を向上しようというのがSmart Client
になります。
WIPr 1.0の仕様書はなかなか読みづらいですが、Smart Client
を実装するだけであれば、Appendix D以降を読むだけで大丈夫です。
次にSmart Client
を実装するのに必要な情報をまとめました。
Smart Clientの実装
基本的な流れは次のとおりです。
- 任意のURLにGETリクエストを投げる
- (ログイン済みでなければ)ログインURLにリダイレクトされる
- ログインURLが返すHTML内にXMLが埋め込まれているので、XMLの内容にしたがって認証情報のリクエストを行う
フルスペックで実装するには次の1〜5の手続きを実装すればよさそうです。
- Login Request: Successful Case
- Login Request: Successful Case With プロキシ Reply
- Login Request: Successful Case With Polling
- Login Request: Reject
- Login Request: Reject With Polling
Login Request: Successful Case
ログイン正常系。 おそらく、日本の公衆無線LANの場合はこれを実装しておけばほとんどこと足りそう。
XMLのサンプル
<?xml version="1.0" encoding="UTF-8"?>
<WISPAccessGatewayParam
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespaceSchemaLocation="http://www.acmewisp.com/WISPAccessGatewa
yParam.xsd">
<Redirect>
<AccessProcedure>1.0</AccessProcedure>
<AccessLocation>12</AccessLocation>
<LocationName>
ACMEWISP,Gate_14_Terminal_C_of_Newark_Airport
</LocationName>
<LoginURL>http://www.acmewisp.com/login/</LoginURL>
<AbortLoginURL>
http://www.acmewisp.com/abortlogin/
</AbortLoginURL>
<MessageType>100</MessageType>
<ResponseCode>0</ResponseCode>
</Redirect>
</WISPAccessGatewayParam>
資格情報
次のパラメータをapplication/x-www-form-urulencoded
形式で送信する。
パラメータ名 | 説明 | 例 |
---|---|---|
UserName | ユーザー名 | example@domain |
Pasword | パスワード | abcdefgh-123456 |
button | ボタン(固定値) | Login |
FNAME | フォーム名(固定値) | 0 |
OriginatingServer | もともとアクセスしようとしていた先のURL | https://www.google.co.jp |
Login Request: Successful Case With プロキシ Reply
Proxy Reply
が返ってくるケース。
NextURLを挟んではいるが基本はLogin Request: Successful Case
と一緒。
XMLのサンプル
<?xml version="1.0" encoding="UTF-8"?>
<WISPAccessGatewayParam
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespaceSchemaLocation=
"http://www.acmewisp.com/WISPAccessGatewayParam.xsd">
<Proxy>
<MessageType>110</MessageType>
<NextURL>http://www.acmewisp.com/proxypoll</NextURL>
<ResponseCode>200</ResponseCode>
<Delay>5</Delay>
</Proxy>
</WISPAccessGatewayParam>
Login Request: Successful Case With Polling
即座に認証結果が返されずポーリングすることを要求されるケース。
Polling URL
はレスポンスにLoginResultsURL
が含まれていればLoginResultsURL
を使用する。
含まれていなければLoginURL
を使用する。
XMLのサンプル
<?xml version="1.0" encoding="UTF-8"?>
<WISPAccessGatewayParam
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xsi:noNamespaceSchemaLocation="http://www.acmewisp.com/WISPAccessGate
wayParam.xsd">
<AuthenticationPollReply>
<MessageType>140</MessageType>
<ResponseCode>201</ResponseCode>
<ReplyMessage>Authentication Pending</ReplyMessage>
<Delay>5</Delay>
<LoginResultsURL>http://wi2net/RLogin/1/</LoginResultsURL>
<LogoffURL>http://www.acmewisp.com/logoff/</LogoffURL>
</AuthenticationPollReply>
</WISPAccessGatewayParam>
Login Request: Reject
資格情報を送ったがログイン失敗するケース。
XMLのサンプル
<?xml version="1.0" encoding="UTF-8"?>
<WISPAccessGatewayParam
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xsi:noNamespaceSchemaLocation="http://www.acmewisp.com/WISPAccessGate
wayParam.xsd">
<AuthenticationReply>
<MessageType>120</MessageType>
<ResponseCode>100</ResponseCode>
<ReplyMessage>Invalid Password</ReplyMessage>
<LoginResultsURL>
http://www.acmewisp.com/loginresults/
</LoginResultsURL>
<LogoffURL>http://www.acmewisp.com/logoff/</LogoffURL>
</AuthenticationReply>
</WISPAccessGatewayParam>
Login Request: Reject With Polling
即座に認証結果が返されずポーリングすることを要求されて、ポーリングを繰り返すが、最終的にログイン失敗するケース。
リポジトリ
以上をSwiftで実装したのが次のリポジトリです。
Q&A
- WISPrで使うユーザー名とパスワードはどうやって入手するの?
存じ上げません。