本文整理汇总了Java中org.jivesoftware.openfire.session.LocalClientSession.isAllowedAnonymous方法的典型用法代码示例。如果您正苦于以下问题:Java LocalClientSession.isAllowedAnonymous方法的具体用法?Java LocalClientSession.isAllowedAnonymous怎么用?Java LocalClientSession.isAllowedAnonymous使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.session.LocalClientSession
的用法示例。
在下文中一共展示了LocalClientSession.isAllowedAnonymous方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateResponse
import org.jivesoftware.openfire.session.LocalClientSession; //导入方法依赖的package包/类
@Override
public byte[] evaluateResponse( byte[] response ) throws SaslException
{
if ( isComplete() )
{
throw new IllegalStateException( "Authentication exchange already completed." );
}
complete = true;
// Verify server-wide policy.
if ( !JiveGlobals.getBooleanProperty( "xmpp.auth.anonymous" ) )
{
throw new SaslException( "Authentication failed" );
}
// Verify that client can connect from his IP address.
final boolean forbidAccess = !LocalClientSession.isAllowedAnonymous( session.getConnection() );
if ( forbidAccess )
{
throw new SaslException( "Authentication failed" );
}
// Just accept the authentication :)
return null;
}
示例2: anonymousLogin
import org.jivesoftware.openfire.session.LocalClientSession; //导入方法依赖的package包/类
private IQ anonymousLogin(LocalClientSession session, IQ packet) {
IQ response = IQ.createResultIQ(packet);
if (JiveGlobals.getBooleanProperty("xmpp.auth.anonymous")) {
// Verify that client can connect from his IP address
boolean forbidAccess = !LocalClientSession.isAllowedAnonymous( session.getConnection() );
if (forbidAccess) {
// Connection forbidden from that IP address
response.setChildElement(packet.getChildElement().createCopy());
response.setError(PacketError.Condition.forbidden);
}
else {
// Anonymous authentication allowed
session.setAnonymousAuth();
response.setTo(session.getAddress());
Element auth = response.setChildElement("query", "jabber:iq:auth");
auth.addElement("resource").setText(session.getAddress().getResource());
}
}
else {
// Anonymous authentication is not allowed
response.setChildElement(packet.getChildElement().createCopy());
response.setError(PacketError.Condition.forbidden);
}
return response;
}