|
JavaTM 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()
报告此会话客户端的有效授权 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 - 如果未完成此次验证会话
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 Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。