List of usage examples for com.liferay.portal.kernel.util Validator isIPAddress
public static boolean isIPAddress(String ipAddress)
true if the string is a valid IPv4 or IPv6 IP address. From source file:com.inikah.slayer.service.impl.LocationLocalServiceImpl.java
License:Open Source License
public Location setCoordinates(User user) { String ipAddress = user.getLastLoginIP(); Location location = null;//ww w . j a v a 2 s . com if (existingIPAddress(ipAddress)) { _log.debug("this is an existing IP address in the Address table..."); location = getLocationForIP(ipAddress); } else { String country = "IN"; String region = "Karnataka"; String city = "Bangalore"; if (Validator.isIPAddress(ipAddress) && !ipAddress.equals("127.0.0.1")) { _log.debug("this is a valid IP address ==> " + ipAddress); JSONObject jsonObject = makeWSCall(ipAddress); if (Validator.isNotNull(jsonObject)) { country = jsonObject.getString("country"); region = jsonObject.getString("region"); city = jsonObject.getString("city"); } } if (Validator.isNotNull(country) && Validator.isNotNull(region) && Validator.isNotNull(city)) { location = locationFinder.getCity(country, region, city); } if (Validator.isNull(location)) { location = insertCity(country, region, city); } else if (!location.isActive_()) { location.setActive_(true); try { location = updateLocation(location); } catch (SystemException e) { e.printStackTrace(); } } } updateAddress(user, location); return location; }
From source file:com.liferay.chat.jabber.JabberImpl.java
License:Open Source License
protected ConnectionConfiguration getConnectionConfiguration() throws UnknownHostException { if (_connectionConfiguration != null) { return _connectionConfiguration; }/*from ww w. java 2s. co m*/ String jabberHost = PortletPropsValues.JABBER_HOST; if (!Validator.isIPAddress(jabberHost)) { InetAddress inetAddress = InetAddress.getByName(jabberHost); jabberHost = inetAddress.getHostAddress(); } _connectionConfiguration = new ConnectionConfiguration(jabberHost, PortletPropsValues.JABBER_PORT, PortletPropsValues.JABBER_SERVICE_NAME); _connectionConfiguration.setSendPresence(false); SmackConfiguration.setLocalSocks5ProxyEnabled(PortletPropsValues.JABBER_SOCK5_PROXY_ENABLED); SmackConfiguration.setLocalSocks5ProxyPort(PortletPropsValues.JABBER_SOCK5_PROXY_PORT); return _connectionConfiguration; }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public void validateRemote(long groupId, String remoteAddress, int remotePort, String remotePathContext, boolean secureConnection, long remoteGroupId) throws PortalException { RemoteOptionsException roe = null;/*from ww w .j a v a2 s . c o m*/ if (!Validator.isDomain(remoteAddress) && !Validator.isIPAddress(remoteAddress)) { roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_ADDRESS); roe.setRemoteAddress(remoteAddress); throw roe; } if ((remotePort < 1) || (remotePort > 65535)) { roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_PORT); roe.setRemotePort(remotePort); throw roe; } if (Validator.isNotNull(remotePathContext) && (!remotePathContext.startsWith(StringPool.FORWARD_SLASH) || remotePathContext.endsWith(StringPool.FORWARD_SLASH))) { roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_PATH_CONTEXT); roe.setRemotePathContext(remotePathContext); throw roe; } validateRemoteGroup(groupId, remoteGroupId, remoteAddress, remotePort, remotePathContext, secureConnection); }