|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
public interface ExtendedRequest
此介面表示在 RFC 2251 中定義的 LDAPv3 擴展操作請求。
ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
requestName [0] LDAPOID,
requestValue [1] OCTET STRING OPTIONAL }
它包含物件標識符字元串和可選的 ASN.1 BER 編碼值。
服務提供者使用此類別中的方法建構發送到 LDAP 伺服器的位。應用程序通常僅處理實作此介面的類別,向它們提供特定擴展操作請求所需的任何資訊。然後,它將這種類別作為參數傳遞給 LdapContext.extendedOperation() 方法,從而執行 LDAPv3 擴展操作。
例如,假定 LDAP 伺服器支持“獲取時間”擴展操作。它將提供 GetTimeRequest 和 GetTimeResponse 類別:
public class GetTimeRequest implements ExtendedRequest {
public GetTimeRequest() {... };
public ExtendedResponse createExtendedResponse(String id,
byte[] berValue, int offset, int length)
throws NamingException {
return new GetTimeResponse(id, berValue, offset, length);
}
...
}
public class GetTimeResponse implements ExtendedResponse {
long time;
public GetTimeResponse(String id, byte[] berValue, int offset,
int length) throws NamingException {
time = ... // decode berValue to get time
}
public java.util.Date getDate() { return new java.util.Date(time) };
public long getTime() { return time };
...
}
然後,程序將使用以下這些類別:
GetTimeResponse resp =
(GetTimeResponse) ectx.extendedOperation(new GetTimeRequest());
long time = resp.getTime();
ExtendedResponse,
LdapContext.extendedOperation(javax.naming.ldap.ExtendedRequest)| 方法摘要 | |
|---|---|
ExtendedResponse |
createExtendedResponse(String id,
byte[] berValue,
int offset,
int length)
創建與此請求對應的回應物件。 |
byte[] |
getEncodedValue()
檢索 LDAP 擴展操作請求的 ASN.1 BER 編碼值。 |
String |
getID()
檢索請求的物件標識符。 |
| 方法詳細資訊 |
|---|
String getID()
byte[] getEncodedValue()
IllegalStateException - 如果因請求包含不足或無效的資料/狀態而無法檢索編碼值。
ExtendedResponse createExtendedResponse(String id,
byte[] berValue,
int offset,
int length)
throws NamingException
在服務提供者將擴展操作請求發送到 LDAP 伺服器後,它將從伺服器收到回應。如果操作失敗,則提供者將拋出 NamingException。如果操作成功,則提供者將使用從回應取回的資料調用此方法。此方法的任務是返回實作適合擴展操作請求的 ExtendedResponse 介面的類別。
例如,Start TLS 擴展請求類別需要知道如何處理 Start TLS 擴展回應。它通過創建實作 ExtendedResponse 的類別完成此操作。
id - 回應控制元件的物件標識符(可能為 null)。berValue - 回應控制元件的 ASN.1 BER 編碼值(可能為 null)。此為原始 BER 位元組,包括回應值的標記和長度。它不包括回應 OID。offset - berValue 中要使用的位元組的開始位置。length - berValue 中要使用的位元組數。
NamingException - 如果因出錯而無法創建擴展回應。ExtendedResponse
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。