com.jwebmp.plugins.security.ipgeography.implementations.GeoBytesDataWSAuth Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-plugins-ip-geography-security Show documentation
Show all versions of jwebmp-plugins-ip-geography-security Show documentation
This plugin provides information of geography details from GeoBytes provider (first 16k free). It also shows a good way of how to implement it
package com.jwebmp.plugins.security.ipgeography.implementations;
import com.guicedee.guicedinjection.GuiceContext;
import com.guicedee.logger.LogFactory;
import com.guicedee.guicedservlets.websockets.WebSocketsConfiguration;
import com.guicedee.guicedservlets.websockets.services.IWebSocketAuthDataProvider;
import java.util.logging.Level;
import java.util.logging.Logger;
public class GeoBytesDataWSAuth
implements IWebSocketAuthDataProvider
{
private static final Logger log = LogFactory.getLog("GeoBytesDataWSAuth");
@SuppressWarnings("unchecked")
@Override
public StringBuilder getJavascriptToPopulate()
{
try
{
GuiceContext.get(com.jwebmp.core.base.ContentSecurityPolicy.class)
.getConnectSrc()
.add("json.geoiplookup.io");
}
catch (Exception e)
{
log.log(Level.WARNING, "Not in request scope for content security geodata policy update", e);
}
return new StringBuilder(" $.getJSON('https://json.geoiplookup.io', function(data) {" +
"data.localstorage = jw.localstorage['jwamsmk'];" +
// "jw.websocket.newMessage('GeoData',data);" +
"jw.env.scope.geo = data;" +
"});");
}
@Override
public String name()
{
return "GeoNameData";
}
@Override
public boolean enabled()
{
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy