mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 13:32:07 +01:00
Improve logging of IoTProvisioningManager
This commit is contained in:
parent
48a46e43ab
commit
44d6a9d7c1
1 changed files with 17 additions and 8 deletions
|
@ -122,7 +122,7 @@ public final class IoTProvisioningManager extends Manager {
|
||||||
connection.addAsyncStanzaListener(new StanzaListener() {
|
connection.addAsyncStanzaListener(new StanzaListener() {
|
||||||
@Override
|
@Override
|
||||||
public void processPacket(Stanza stanza) throws NotConnectedException, InterruptedException {
|
public void processPacket(Stanza stanza) throws NotConnectedException, InterruptedException {
|
||||||
if (!isFromProvisioningService(stanza)) {
|
if (!isFromProvisioningService(stanza, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public final class IoTProvisioningManager extends Manager {
|
||||||
final Friend friend = Friend.from(friendMessage);
|
final Friend friend = Friend.from(friendMessage);
|
||||||
final BareJid friendJid = friend.getFriend();
|
final BareJid friendJid = friend.getFriend();
|
||||||
|
|
||||||
if (isFromProvisioningService(friendMessage)) {
|
if (isFromProvisioningService(friendMessage, false)) {
|
||||||
// We received a recommendation from a provisioning server.
|
// We received a recommendation from a provisioning server.
|
||||||
// Notify the recommended friend that we will now accept his
|
// Notify the recommended friend that we will now accept his
|
||||||
// friendship requests.
|
// friendship requests.
|
||||||
|
@ -178,6 +178,10 @@ public final class IoTProvisioningManager extends Manager {
|
||||||
// the bare 'from' JID should be equals to the JID of the
|
// the bare 'from' JID should be equals to the JID of the
|
||||||
// recommended friend.
|
// recommended friend.
|
||||||
if (!bareFrom.equals(friendJid)) {
|
if (!bareFrom.equals(friendJid)) {
|
||||||
|
LOGGER.log(Level.WARNING,
|
||||||
|
"Ignoring friendship recommendation " + friendMessage
|
||||||
|
+ " because it does not recommend itself, but "
|
||||||
|
+ friendJid + '.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +195,7 @@ public final class IoTProvisioningManager extends Manager {
|
||||||
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, Type.set, Mode.async) {
|
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, Type.set, Mode.async) {
|
||||||
@Override
|
@Override
|
||||||
public IQ handleIQRequest(IQ iqRequest) {
|
public IQ handleIQRequest(IQ iqRequest) {
|
||||||
if (!isFromProvisioningService(iqRequest)) {
|
if (!isFromProvisioningService(iqRequest, true)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +395,7 @@ public final class IoTProvisioningManager extends Manager {
|
||||||
return wasUnfriendedListeners.remove(wasUnfriendedListener);
|
return wasUnfriendedListeners.remove(wasUnfriendedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFromProvisioningService(Stanza stanza) {
|
private boolean isFromProvisioningService(Stanza stanza, boolean log) {
|
||||||
Jid provisioningServer;
|
Jid provisioningServer;
|
||||||
try {
|
try {
|
||||||
provisioningServer = getConfiguredProvisioningServer();
|
provisioningServer = getConfiguredProvisioningServer();
|
||||||
|
@ -401,13 +405,18 @@ public final class IoTProvisioningManager extends Manager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (provisioningServer == null) {
|
if (provisioningServer == null) {
|
||||||
LOGGER.warning("Ignoring request '" + stanza
|
if (log) {
|
||||||
+ "' because no provisioning server configured.");
|
LOGGER.warning("Ignoring request '" + stanza
|
||||||
|
+ "' because no provisioning server configured.");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!provisioningServer.equals(stanza.getFrom())) {
|
if (!provisioningServer.equals(stanza.getFrom())) {
|
||||||
LOGGER.warning("Ignoring request '" + stanza + "' because not from provising server '"
|
if (log) {
|
||||||
+ provisioningServer + "'.");
|
LOGGER.warning("Ignoring request '" + stanza
|
||||||
|
+ "' because not from provising server '" + provisioningServer
|
||||||
|
+ "'.");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue