|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.net.Authenticator
public abstract class Authenticator
Authenticator 類別表示懂得如何獲得網路連接驗證的物件。通常,它通過提示使用者輸入資訊來完成此操作。
應用程序通過覆寫子類別中的 getPasswordAuthentication() 使用此類別。此方法通常使用各種 getXXX() 存取器方法獲取關於請求驗證的實體的資訊。然後,它必須通過與使用者交互或者某些其他非交互手段獲取使用者名和密碼。之後憑據將以 PasswordAuthentication 返回值的形式返回。
接下來通過調用 setDefault(Authenticator) 向系統註冊此具體子類別的實例。需要進行驗證時,系統將調用其中一個 requestPasswordAuthentication() 方法,這些方法將依次調用註冊物件的 getPasswordAuthentication() 方法。
請求驗證的所有方法都有一個失敗的預設實作。
setDefault(java.net.Authenticator),
getPasswordAuthentication()| 巢狀類別摘要 | |
|---|---|
static class |
Authenticator.RequestorType
請求驗證的實體的型別。 |
| 建構子摘要 | |
|---|---|
Authenticator()
|
|
| 方法摘要 | |
|---|---|
protected PasswordAuthentication |
getPasswordAuthentication()
需要密碼授權時調用。 |
protected String |
getRequestingHost()
獲取請求驗證的站點或代理的 hostname;如果不可用,則為 null。 |
protected int |
getRequestingPort()
獲取所請求的連接的埠號號。 |
protected String |
getRequestingPrompt()
獲取請求方給出的提示字元串。 |
protected String |
getRequestingProtocol()
給出正在請求連接的協議。 |
protected String |
getRequestingScheme()
獲取請求方的方案(例如,HTTP 防火牆的 HTTP 方案)。 |
protected InetAddress |
getRequestingSite()
獲取請求授權的站點的 InetAddress;如果不可用,則為 null。 |
protected URL |
getRequestingURL()
返回導致請求驗證的 URL。 |
protected Authenticator.RequestorType |
getRequestorType()
返回請求方是代理還是伺服器。 |
static PasswordAuthentication |
requestPasswordAuthentication(InetAddress addr,
int port,
String protocol,
String prompt,
String scheme)
要求已經向系統註冊的 authenticator 提供密碼。 |
static PasswordAuthentication |
requestPasswordAuthentication(String host,
InetAddress addr,
int port,
String protocol,
String prompt,
String scheme)
要求已經向系統註冊的 authenticator 提供密碼。 |
static PasswordAuthentication |
requestPasswordAuthentication(String host,
InetAddress addr,
int port,
String protocol,
String prompt,
String scheme,
URL url,
Authenticator.RequestorType reqType)
要求已經向系統註冊的 authenticator 提供密碼。 |
static void |
setDefault(Authenticator a)
設置在代理或 HTTP 伺服器請求驗證時連網密碼使用的 authenticator。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 建構子詳細資訊 |
|---|
public Authenticator()
| 方法詳細資訊 |
|---|
public static void setDefault(Authenticator a)
首先,如果存在安全管理器,則在 NetPermission("setDefaultAuthenticator") 權限下調用 checkPermission 方法。這可能導致 java.lang.SecurityException。
a - 要設置的 authenticator。如果 a 為 null,則移除以前設置的所有 authenticator。
SecurityException - 如果安全管理器存在並且其 checkPermission 方法不允許設置預設 authenticator。SecurityManager.checkPermission(java.security.Permission),
NetPermission
public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr,
int port,
String protocol,
String prompt,
String scheme)
首先,如果存在安全管理器,則在 NetPermission("requestPasswordAuthentication") 權限下調用 checkPermission 方法。這可能導致 java.lang.SecurityException。
addr - 請求授權的站點的 InetAddress;如果未知則為 null。port - 所請求的連接的埠號protocol - 正在請求連接的協議 (getRequestingProtocol())prompt - 使用者的提示字元串scheme - 驗證方案
SecurityException - 如果安全管理器存在並且其 checkPermission 方法不允許密碼驗證請求。SecurityManager.checkPermission(java.security.Permission),
NetPermission
public static PasswordAuthentication requestPasswordAuthentication(String host,
InetAddress addr,
int port,
String protocol,
String prompt,
String scheme)
首先,如果存在安全管理器,則在 NetPermission("requestPasswordAuthentication") 權限下調用 checkPermission 方法。這可能導致 java.lang.SecurityException。
host - 請求驗證的站點的主機名。addr - 請求授權的站點的 InetAddress;如果未知則為 null。port - 所請求的連接的埠號。protocol - 請求連接的協議 (getRequestingProtocol())prompt - 標識驗證域 (authentication realm) 的使用者的提示字元串。scheme - 驗證方案
SecurityException - 如果安全管理器存在並且其 checkPermission 方法不允許密碼驗證請求。SecurityManager.checkPermission(java.security.Permission),
NetPermission
public static PasswordAuthentication requestPasswordAuthentication(String host,
InetAddress addr,
int port,
String protocol,
String prompt,
String scheme,
URL url,
Authenticator.RequestorType reqType)
首先,如果存在安全管理器,則在 NetPermission("requestPasswordAuthentication") 權限下調用 checkPermission 方法。這可能導致 java.lang.SecurityException。
host - 請求驗證的站點的主機名。addr - 請求授權的站點的 InetAddress;或者未知則為 null。port - 所請求的連接的埠號protocol - 請求連接的協議 (getRequestingProtocol())prompt - 使用者的提示字元串scheme - 驗證方案url - 導致驗證的請求 URLreqType - 請求驗證的實體的型別(伺服器或代理)。
SecurityException - 如果安全管理器存在並且其 checkPermission 方法不允許密碼驗證請求。SecurityManager.checkPermission(java.security.Permission),
NetPermissionprotected final String getRequestingHost()
hostname;如果不可用,則為 null。
protected final InetAddress getRequestingSite()
InetAddress;如果不可用,則為 null。
protected final int getRequestingPort()
int。protected final String getRequestingProtocol()
URL.getProtocol()protected final String getRequestingPrompt()
protected final String getRequestingScheme()
protected PasswordAuthentication getPasswordAuthentication()
protected URL getRequestingURL()
protected Authenticator.RequestorType getRequestorType()
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。