All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jwebmp.plugins.security.ipgeography.implementations.GeoBytesDataWSAuth Maven / Gradle / Ivy

Go to download

This plugin provides information of geography details from GeoBytes provider (first 16k free). It also shows a good way of how to implement it

There is a newer version: 1.2.2.1-jre17
Show newest version
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