public interface SaslServer
一个服务器的LDAP服务器获取该类的实例来执行身份验证的具体机制定义。在SaslServer实例调用方法产生的挑战根据SaslServer实施机制。作为认证的收益,例如封装了该服务器的身份验证交换状态。
这里有一个例子,一个LDAP服务器可以使用一个SaslServer。首先获取一个客户端所请求的机制SaslServer实例:
SaslServer ss = Sasl.createSaslServer(mechanism,
"ldap", myFQDN, props, callbackHandler);
可以进行身份验证使用的服务器。例如,假设LDAP服务器收到一个LDAP绑定请求中包含的机制和一个名称(可选)的初始反应。然后,可以使用服务器如下:
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
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
处置任何系统资源或安全敏感信息的saslserver可能使用。
|
byte[] |
evaluateResponse(byte[] response)
评估响应数据,并生成一个挑战。
|
String |
getAuthorizationID()
报告此会话的客户端的授权标识。
|
String |
getMechanismName()
返回IANA注册机制这个SASL服务器名称。
|
Object |
getNegotiatedProperty(String propName)
检索协商的属性。
|
boolean |
isComplete()
确定身份验证交换是否已完成。
|
byte[] |
unwrap(byte[] incoming, int offset, int len)
打开从客户端接收到一个字节数组。
|
byte[] |
wrap(byte[] outgoing, int offset, int len)
将一个字节数组封装到客户端。
|
String getMechanismName()
byte[] evaluateResponse(byte[] response)
throws SaslException
isComplete()应该每次调用
evaluateResponse()后调用,以确定是否有任何进一步的响应是从客户需要。
response -非空(但也可能是空的)响应客户端发送的。
SaslException如果发生错误处理响应时,或产生一个挑战。
boolean isComplete()
evaluateResponse()确定是否认证成功完成后调用或应继续。
String getAuthorizationID()
IllegalStateException如果认证过程尚未完成
byte[] unwrap(byte[] incoming,
int offset,
int len)
throws SaslException
isComplete()返回true),只有认证交流协商的完整性和/或隐私保护的质量;否则,一个
IllegalStateException抛出。
incoming是SASL缓冲区的内容定义在RFC 2222中没有领先的四字节字段表示的长度。offset和len指定要使用的incoming部分。
incoming -非空字节数组从客户端包含已编码的字节。
offset -起始位置的字节
incoming使用。
len从
incoming字节数的使用。
SaslException -如果
incoming不能顺利展开。
IllegalStateException -如果身份验证交换尚未完成,或者如果协商质量的保护既不完整也不隐私
byte[] wrap(byte[] outgoing,
int offset,
int len)
throws SaslException
isComplete()返回true),只有认证交流协商的完整性和/或隐私保护的质量;否则,一个
SaslException抛出。
这种方法的结果将使SASL缓冲区的内容定义在RFC 2222中没有领先的四字节字段表示的长度。offset和len指定要使用的outgoing部分。
outgoing -非空字节数组包含的字节编码。
offset -起始位置的字节
outgoing使用。
len从
outgoing字节数的使用。
SaslException -如果
outgoing不能成功的包裹。
IllegalStateException -如果身份验证交换尚未完成,或者如果协商质量的保护既不完整也不隐私。
Object getNegotiatedProperty(String propName)
isComplete()返回true);否则,一个
IllegalStateException抛出。
propName -属性
IllegalStateException如果身份验证交换尚未完成
void dispose()
throws SaslException
SaslException如果配置资源时遇到了一个问题。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.