|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
public interface SaslServer
以伺服器的身份執行 SASL 驗證。
為了執行具體 SASL 機制所定義的驗證,伺服器(例如 LDAP 伺服器)要獲得此類別的一個實例。調用 SaslServer 實例上的方法可產生與 SaslServer 所實作的 SASL 機制相對應的 challenge。隨著驗證的進行,該實例會封裝 SASL 伺服器的驗證交換狀態。
以下是 LDAP 伺服器如何使用 SaslServer 的一個範例。它首先為客戶端請求的 SASL 機制獲得一個 SaslServer 實例:
SaslServer ss = Sasl.createSaslServer(mechanism,
"ldap", myFQDN, props, callbackHandler);
然後可繼續為驗證使用該伺服器。例如,假設 LDAP 伺服器接收到一個 LDAP BIND 請求,其中包含 SASL 機制的名稱和(可選的)初始回應。然後它可按如下方式使用伺服器:
while (!ss.isComplete()) {
try {
byte[] challenge = ss.evaluateResponse(response);
if (ss.isComplete()) {
status = ldap.sendBindResponse(mechanism, challenge, SUCCESS);
} else {
status = ldap.sendBindResponse(mechanism, challenge,
SASL_BIND_IN_PROGRESS);
response = ldap.readBindRequest();
}
} catch (SaslException e) {
status = ldap.sendErrorResponse(e);
break;
}
}
if (ss.isComplete() && status == SUCCESS) {
String qop = (String) sc.getNegotiatedProperty(Sasl.QOP);
if (qop != null
&& (qop.equalsIgnoreCase("auth-int")
|| qop.equalsIgnoreCase("auth-conf"))) {
// Use SaslServer.wrap() and SaslServer.unwrap() for future
// communication with client
ldap.in = new SecureInputStream(ss, ldap.in);
ldap.out = new SecureOutputStream(ss, ldap.out);
}
}
Sasl,
SaslServerFactory| 方法摘要 | |
|---|---|
void |
dispose()
處置 SaslServer 可能使用的所有系統資源或安全敏感資訊。 |
byte[] |
evaluateResponse(byte[] response)
評估回應資料並產生一個 challenge。 |
String |
getAuthorizationID()
報告此Session客戶端的有效授權 ID。 |
String |
getMechanismName()
返回此 SASL 伺服器的 IANA 註冊機制名。 |
Object |
getNegotiatedProperty(String propName)
獲取已協商的屬性。 |
boolean |
isComplete()
確定驗證交換是否已完成。 |
byte[] |
unwrap(byte[] incoming,
int offset,
int len)
解包接收自客戶端的 byte 陣列。 |
byte[] |
wrap(byte[] outgoing,
int offset,
int len)
包裹要發送到客戶端的 byte 陣列。 |
| 方法詳細資訊 |
|---|
String getMechanismName()
byte[] evaluateResponse(byte[] response)
throws SaslException
response - 客戶端發送的非 null(但可能為空)回應。
SaslException - 如果處理回應或產生 challenge 時發生錯誤。boolean isComplete()
String getAuthorizationID()
IllegalStateException - 如果未完成此次驗證Session
byte[] unwrap(byte[] incoming,
int offset,
int len)
throws SaslException
incoming 是 SASL 緩衝區的內容(在 RFC 2222 中定義),沒有表示長度的前導 4 個八位組欄位。offset 和 len 指定了要使用的 incoming 部分。
incoming - 非 null 的 byte 陣列,包含取自客戶端的已編碼位元組。offset - 所用位元組在 incoming 中的開始位置。len - 使用 incoming 中的位元組數。
SaslException - 如果無法成功解包 incoming。
IllegalStateException - 如果驗證交換未完成,如果協商的保護級別既沒有完整性,也沒有機密性
byte[] wrap(byte[] outgoing,
int offset,
int len)
throws SaslException
此方法的結果會組成 SASL 緩衝區的內容(在 RFC 2222 中定義),沒有表示長度的前導 4 個八位組欄位。offset 和 len 指定了要使用的 outgoing 部分。
outgoing - 非 null 的 byte 陣列,包含要編碼的位元組。offset - 所用位元組在 outgoing 中的開始位置。len - 使用 outgoing 中的位元組數。
SaslException - 如果無法成功包裹 outgoing。
IllegalStateException - 如果驗證交換未完成,如果協商的保護級別既沒有完整性,也沒有機密性。Object getNegotiatedProperty(String propName)
propName - 屬性
IllegalStateException - 如果未完成此驗證交換
void dispose()
throws SaslException
SaslException - 如果釋放資源時遇到問題。
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。