14. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
全部チェックしてみます。
15. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
といいつつ
一旦、1つ飛ばして 2つ目からご説明します
16. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
HTTPBasic
18. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
そして1つ目に戻ります
20. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
22. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
25. // 【A】カスタムの認証情報(例:ユーザー名とパスワード)を作成
let credential = NSURLCredential(
user: "niwatako",
password: "jellyfish",
persistence: .ForSession
)
// 【B】カスタム認証情報保存用の NSURLProtectionSpace (認証の掛かった通信先を表す) を作成
let HTMLFormSpace = NSURLProtectionSpace(
host: "niwatako.tako",
port: 443,
`protocol`: "https",
realm: nil, // realm... Digest認証などで必要、サーバー側のAuthNameにあたる
authenticationMethod: NSURLAuthenticationMethodHTMLForm
)
// CredentialStorage へ、【B】 に紐付ける形で【A】を保存
let credentialStorage = NSURLCredentialStorage.sharedCredentialStorage()
credentialStorage.setCredential(credential, forProtectionSpace: HTMLFormSpace)
/* —————————————————————————————————————————————————————————————————————————————— */
// CredentialStorage から、【B】 を指定して【A】を取り出し
if let credentials = credentialStorage.credentialsForProtectionSpace(HTMLFormSpace) {
for case let (username, credential) in credentials {
print("(username)'s password is (credential.password ?? "NULL")")
}
}
※上記の方法でID情報を保存できるとしても、
表示中のWebサイトのログイン情報の保存や自動入力は
独自にWebサイトのフォームを解析して実装する必要がありそうです。
26. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
29. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
31. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
35. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
40. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
コンプリートしました!
45. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
認証の種類 (NSURLAuthenticationMethod) 毎の
必要になる認証情報は?
46. 4つに分けられますね!
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
47. 実際のURLリクエストでは発生しない、カスタマイズ用
let NSURLAuthenticationMethodHTMLForm: String
let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
除外
4つに分けられますね!
48. let NSURLAuthenticationMethodDefault: String
let NSURLAuthenticationMethodHTTPBasic: String
let NSURLAuthenticationMethodHTTPDigest: String
let NSURLAuthenticationMethodNegotiate: String
let NSURLAuthenticationMethodNTLM: String
let NSURLAuthenticationMethodClientCertificate: String
let NSURLAuthenticationMethodServerTrust: String
NSURLCredential = 認証情報
どのタイプの認証情報を作ればよいのか?
ユーザー名とパスワード
クライアント証明書
サーバー証明書