本文整理汇总了Java中org.xmpp.packet.Packet.getFrom方法的典型用法代码示例。如果您正苦于以下问题:Java Packet.getFrom方法的具体用法?Java Packet.getFrom怎么用?Java Packet.getFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xmpp.packet.Packet
的用法示例。
在下文中一共展示了Packet.getFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldBlockPacket
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
* Returns true if the specified packet must be blocked based on this privacy list rules.
* Rules are going to be analyzed based on their order (in ascending order). When a rule
* is matched then communication will be blocked or allowed based on that rule. No more
* further analysis is going to be made.
*
* @param packet the packet to analyze if it must be blocked.
* @return true if the specified packet must be blocked based on this privacy list rules.
*/
public boolean shouldBlockPacket(Packet packet) {
if (packet.getFrom() == null) {
// Sender is the server so it's not denied
return false;
}
// Iterate over the rules and check each rule condition
Roster roster = getRoster();
for (PrivacyItem item : items) {
if (item.matchesCondition(packet, roster, userJID)) {
if (item.isAllow()) {
return false;
}
if (Log.isDebugEnabled()) {
Log.debug("PrivacyList: Packet was blocked: " + packet);
}
return true;
}
}
// If no rule blocked the communication then allow the packet to flow
return false;
}
示例2: process
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
public void process(Packet packet) throws UnauthorizedException, PacketException {
boolean handled = false;
String host = packet.getTo().getDomain();
for (Channel<Packet> channel : transports.values()) {
if (channel.getName().equalsIgnoreCase(host)) {
channel.add(packet);
handled = true;
}
}
if (!handled) {
JID recipient = packet.getTo();
JID sender = packet.getFrom();
packet.setError(PacketError.Condition.remote_server_timeout);
packet.setFrom(recipient);
packet.setTo(sender);
try {
deliverer.deliver(packet);
}
catch (PacketException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
}
}
示例3: interceptPacket
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
* Checks to see if the sender of the packet is a banned user. If they are, a
* PacketRejectedException is thrown and email notifications may be sent.
*/
public void interceptPacket(String workgroup, Packet packet, boolean read, boolean processed)
throws PacketRejectedException {
if (!read || processed) {
// Ignore packets that are being sent or have been processed
return;
}
JID jid = packet.getFrom();
if (jidBanMap.containsKey(jid.toBareJID()) || domainBanMap.containsKey(jid.getDomain())) {
sendNotifications(packet, jid.toString());
PacketRejectedException exception = new PacketRejectedException("User '" +
packet.getFrom().toBareJID() +
"' not allowed to join queue.");
if (rejectionMessage != null) {
exception.setRejectionMessage(rejectionMessage);
}
throw exception;
}
}
示例4: process
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void process(Packet packet) throws UnauthorizedException, PacketException {
boolean handled = false;
String host = packet.getTo().getDomain();
for (Channel channel : transports.values()) {
if (channel.getName().equalsIgnoreCase(host)) {
channel.add(packet);
handled = true;
}
}
if (!handled) {
JID recipient = packet.getTo();
JID sender = packet.getFrom();
packet.setError(PacketError.Condition.remote_server_timeout);
packet.setFrom(recipient);
packet.setTo(sender);
try {
deliverer.deliver(packet);
}
catch (PacketException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
}
}
示例5: send
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
* Sends the given XMPP packet over the backing transport. This accepts a
* callback which is guaranteed to be invoked at a later point, either through
* a normal response, error response, or timeout.
*
* @param packet packet to be sent
* @param callback callback to be invoked on response or timeout
* @param timeout timeout, in seconds, for this callback
*/
public void send(Packet packet, final PacketCallback callback, int timeout) {
final String key = packet.getID() + "#" + packet.getTo() + "#" + packet.getFrom();
final OutgoingCall call = new OutgoingCall(packet.getClass(), callback);
if (callbacks.putIfAbsent(key, call) == null) {
// Timeout runnable to be invoked on packet expiry.
Runnable timeoutTask = new Runnable() {
@Override
public void run() {
if (callbacks.remove(key, call)) {
callback.error(
FederationErrors.newFederationError(FederationError.Code.REMOTE_SERVER_TIMEOUT));
} else {
// Likely race condition where success has actually occurred. Ignore.
}
}
};
call.start(timeoutExecutor.schedule(timeoutTask, timeout, TimeUnit.SECONDS));
transport.sendPacket(packet);
} else {
String msg = "Could not send packet, ID already in-flight: " + key;
LOG.warning(msg);
// Invoke the callback with an internal error.
callback.error(
FederationErrors.newFederationError(FederationError.Code.UNDEFINED_CONDITION, msg));
}
}
示例6: causeImmediateTimeout
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
* Cause an immediate timeout for the given packet, which is presumed to have
* already been sent via {@link #send}.
*/
@VisibleForTesting
void causeImmediateTimeout(Packet packet) {
String key = packet.getID() + "#" + packet.getTo() + "#" + packet.getFrom();
OutgoingCall call = callbacks.remove(key);
if (call != null) {
call.callback.error(FederationErrors.newFederationError(
FederationError.Code.REMOTE_SERVER_TIMEOUT, "Forced immediate timeout"));
}
}
示例7: response
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
* Invoke the callback for a packet already identified as a response. This may
* either invoke the error or normal callback as necessary.
*/
private void response(Packet packet) {
String key = packet.getID() + "#" + packet.getFrom() + "#" + packet.getTo();
OutgoingCall call = callbacks.remove(key);
if (call == null) {
LOG.warning("Received response packet without paired request: " + packet.getID());
} else {
// Cancel the outstanding timeout.
call.timeout.cancel(false);
// Look for error condition and invoke the relevant callback.
Element element = packet.getElement().element("error");
if (element != null) {
LOG.fine("Invoking error callback for: " + packet.getID());
call.callback.error(toFederationError(new PacketError(element)));
} else {
if (call.responseType.equals(packet.getClass())) {
LOG.fine("Invoking normal callback for: " + packet.getID());
call.callback.run(packet);
} else {
String msg =
"Received mismatched response packet type: expected " + call.responseType
+ ", given " + packet.getClass();
LOG.warning(msg);
call.callback.error(FederationErrors.newFederationError(
FederationError.Code.UNDEFINED_CONDITION, msg));
}
}
// Clear call's reference to callback, otherwise callback only
// becomes eligible for GC once the timeout expires, because
// timeoutExecutor holds on to the call object till then, even
// though we cancelled the timeout.
call.callback = null;
}
}
示例8: interceptPacket
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
public void interceptPacket(Packet packet, Session session, boolean read, boolean processed) {
if (!processed) {
// Ignore packets sent or received by users that are present in the ignore list
JID from = packet.getFrom();
JID to = packet.getTo();
if ((from == null || !ignoreList.contains(from.getNode())) &&
(to == null || !ignoreList.contains(to.getNode()))) {
auditor.audit(packet, session);
}
}
}
示例9: sendPacket
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
public void sendPacket(Component component, Packet packet) {
if (packet != null && packet.getFrom() == null) {
throw new IllegalArgumentException("Packet with no FROM address was received from component.");
}
PacketRouter router = XMPPServer.getInstance().getPacketRouter();
if (router != null) {
router.route(packet);
}
}
示例10: findMatch
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public Rule findMatch(Packet packet) {
if (packet.getTo() == null || packet.getFrom() == null)
return null;
// TODO Would it be better to keep a local copy of the rules?
for (Rule rule : ruleManager.getRules()) {
if (!rule.isDisabled() && typeMatch(rule.getPackeType(), packet)
&& sourceDestMatch(rule.getDestType(), rule.getDestination(), packet.getTo())
&& sourceDestMatch(rule.getSourceType(), rule.getSource(), packet.getFrom())) {
return rule;
}
}
return null;
}
示例11: interceptPacket
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void interceptPacket(Packet packet, Session session, boolean read, boolean processed) {
if (!processed) {
// Ignore packets sent or received by users that are present in the ignore list
JID from = packet.getFrom();
JID to = packet.getTo();
if ((from == null || !ignoreList.contains(from.getNode())) &&
(to == null || !ignoreList.contains(to.getNode()))) {
auditor.audit(packet, session);
}
}
}
示例12: sendPacket
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void sendPacket(Component component, Packet packet) {
if (packet != null && packet.getFrom() == null) {
throw new IllegalArgumentException("Packet with no FROM address was received from component.");
}
PacketRouter router = XMPPServer.getInstance().getPacketRouter();
if (router != null) {
router.route(packet);
}
}
示例13: accept
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public boolean accept(Packet packet) {
if (packet.getFrom() == null) {
return false;
} else if (matchBareJID) {
// Check if the bare JID of the sender of the packet matches the
// specified JID
return packet.getFrom().toBareJID().toLowerCase()
.startsWith(address);
} else {
// Check if the full JID of the sender of the packet matches the
// specified JID
return address.equals(packet.getFrom().toFullJID().toLowerCase());
}
}
示例14: accept
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public boolean accept(Packet packet) {
if (packet.getFrom() == null) {
return false;
} else {
return packet.getFrom().toFullJID().toLowerCase().indexOf(from) != -1;
}
}
示例15: findMatch
import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public Rule findMatch(Packet packet) {
if (packet.getTo() == null || packet.getFrom() == null)
return null;
// TODO Would it be better to keep a local copy of the rules?
for (Rule rule : ruleManager.getRules()) {
if (!rule.isDisabled() && typeMatch(rule.getPackeType(), packet)
&& sourceDestMatch(rule.getDestType(), rule.getDestination(), packet.getTo())
&& sourceDestMatch(rule.getSourceType(), rule.getSource(), packet.getFrom())) {
return rule;
}
}
return null;
}