Commit a300bcea authored by PGoski's avatar PGoski

add token

parent d2415bae
...@@ -23,6 +23,7 @@ import javax.ws.rs.client.ClientBuilder; ...@@ -23,6 +23,7 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget; import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.File; import java.io.File;
import java.util.UUID;
import java.util.concurrent.Future; import java.util.concurrent.Future;
public class CallbackOnOffline implements Plugin, PacketInterceptor { public class CallbackOnOffline implements Plugin, PacketInterceptor {
...@@ -31,6 +32,7 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor { ...@@ -31,6 +32,7 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor {
private boolean debug; private boolean debug;
private String url; private String url;
private String token;
private InterceptorManager interceptorManager; private InterceptorManager interceptorManager;
private UserManager userManager; private UserManager userManager;
private PresenceManager presenceManager; private PresenceManager presenceManager;
...@@ -47,12 +49,8 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor { ...@@ -47,12 +49,8 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor {
userManager = XMPPServer.getInstance().getUserManager(); userManager = XMPPServer.getInstance().getUserManager();
client = ClientBuilder.newClient(); client = ClientBuilder.newClient();
String code = "plugin.callback_on_offline.url"; url = getProperty("plugin.callback_on_offline.url", "http://localhost:8080/user/offline/callback/url");
url = JiveGlobals.getProperty(code, null); token = getProperty("plugin.callback_on_offline.token", UUID.randomUUID().toString());
if (url == null || url.length() == 0) {
String url = "http://localhost:8080/user/offline/callback/url"; //default url
JiveGlobals.setProperty(code, url);
}
// register with interceptor manager // register with interceptor manager
interceptorManager.addInterceptor(this); interceptorManager.addInterceptor(this);
...@@ -62,6 +60,16 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor { ...@@ -62,6 +60,16 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor {
} }
} }
private String getProperty(String code, String defaultSetValue) {
String value = JiveGlobals.getProperty(code, null);
if (value == null || value.length() == 0) {
JiveGlobals.setProperty(code, defaultSetValue);
value = defaultSetValue;
}
return value;
}
public void destroyPlugin() { public void destroyPlugin() {
// unregister with interceptor manager // unregister with interceptor manager
interceptorManager.removeInterceptor(this); interceptorManager.removeInterceptor(this);
...@@ -97,6 +105,7 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor { ...@@ -97,6 +105,7 @@ public class CallbackOnOffline implements Plugin, PacketInterceptor {
JID from = packet.getFrom(); JID from = packet.getFrom();
WebTarget target = client.target(url) WebTarget target = client.target(url)
.queryParam("token", token)
.queryParam("from", from.toBareJID()) .queryParam("from", from.toBareJID())
.queryParam("to", to.toBareJID()); .queryParam("to", to.toBareJID());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment