Improved UserAgent analyze.
This commit is contained in:
parent
07de9414b9
commit
fd19427700
2 changed files with 70 additions and 13 deletions
|
@ -47,6 +47,8 @@ public class UserAgent
|
|||
|
||||
/**
|
||||
* Gets the browser.
|
||||
*
|
||||
* WARNING: MUST BE GREATLY IMPROVED
|
||||
*
|
||||
* @return the browser
|
||||
*/
|
||||
|
@ -54,18 +56,34 @@ public class UserAgent
|
|||
{
|
||||
UserAgentBrowser result;
|
||||
|
||||
if (StringUtils.containsIgnoreCase(this.source, "Firefox"))
|
||||
{
|
||||
result = UserAgentBrowser.FIREFOX;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "Chrome"))
|
||||
if (StringUtils.containsIgnoreCase(this.source, "Chrome/"))
|
||||
{
|
||||
result = UserAgentBrowser.CHROME;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "Chromium/"))
|
||||
{
|
||||
result = UserAgentBrowser.CHROMIUM;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "Firefox/"))
|
||||
{
|
||||
result = UserAgentBrowser.FIREFOX;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "Lynx"))
|
||||
{
|
||||
result = UserAgentBrowser.LYNX;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "MSIE "))
|
||||
{
|
||||
result = UserAgentBrowser.MSIE;
|
||||
}
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "Opera", "OPR/"))
|
||||
{
|
||||
result = UserAgentBrowser.OPERA;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "Safari/"))
|
||||
{
|
||||
result = UserAgentBrowser.SAFARI;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = UserAgentBrowser.OTHER;
|
||||
|
@ -77,6 +95,8 @@ public class UserAgent
|
|||
|
||||
/**
|
||||
* Gets the device.
|
||||
*
|
||||
* WARNING: MUST BE GREATLY IMPROVED
|
||||
*
|
||||
* @return the device
|
||||
*/
|
||||
|
@ -84,13 +104,21 @@ public class UserAgent
|
|||
{
|
||||
UserAgentDevice result;
|
||||
|
||||
if (StringsUtils.containsAnyIgnoreCase(this.source, "iOS", "Android"))
|
||||
if (StringsUtils.containsAnyIgnoreCase(this.source, "Playstation"))
|
||||
{
|
||||
result = UserAgentDevice.CONSOLE;
|
||||
}
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "Desktop"))
|
||||
{
|
||||
result = UserAgentDevice.PC;
|
||||
}
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "Android", "iPhone"))
|
||||
{
|
||||
result = UserAgentDevice.PHONE;
|
||||
}
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "Playstation"))
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "iPad"))
|
||||
{
|
||||
result = UserAgentDevice.CONSOLE;
|
||||
result = UserAgentDevice.TABLET;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -110,18 +138,42 @@ public class UserAgent
|
|||
{
|
||||
UserAgentOS result;
|
||||
|
||||
if (StringUtils.containsIgnoreCase(this.source, "Firefox"))
|
||||
if (StringUtils.containsIgnoreCase(this.source, "Android"))
|
||||
{
|
||||
result = UserAgentOS.ANDROID;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "Chrome"))
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "FreeBSD"))
|
||||
{
|
||||
result = UserAgentOS.FREEBSD;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "Lynx"))
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "Debian", "Gentoo", "Linux aarch", "Linux arm", "Linux i586", "Linux i686", "Linux x64", "Linux x86_64"))
|
||||
{
|
||||
result = UserAgentOS.GNULINUX;
|
||||
}
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "Debian", "Gentoo", "Linux aarch", "Linux arm", "Linux i586", "Linux i686", "Linux x64", "Linux x86_64"))
|
||||
{
|
||||
result = UserAgentOS.GNULINUX;
|
||||
}
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "iPhone"))
|
||||
{
|
||||
result = UserAgentOS.IOS;
|
||||
}
|
||||
else if (StringsUtils.containsAnyIgnoreCase(this.source, "Macintosh", "Mac OS X", "Mac OS Desktop"))
|
||||
{
|
||||
result = UserAgentOS.MACOS;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "windows"))
|
||||
{
|
||||
result = UserAgentOS.MSWINDOWS;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "NetBSD"))
|
||||
{
|
||||
result = UserAgentOS.NETBSD;
|
||||
}
|
||||
else if (StringUtils.containsIgnoreCase(this.source, "OpenBSD"))
|
||||
{
|
||||
result = UserAgentOS.OPENBSD;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = UserAgentOS.OTHER;
|
||||
|
@ -134,6 +186,8 @@ public class UserAgent
|
|||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* WARNING: MUST BE GREATLY IMPROVED
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public UserAgentType getType()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -18,6 +18,9 @@
|
|||
*/
|
||||
package fr.devinsy.statoolinfos.metrics.http;
|
||||
|
||||
/**
|
||||
* The Enum UserAgentOS.
|
||||
*/
|
||||
public enum UserAgentOS
|
||||
{
|
||||
ANDROID,
|
||||
|
@ -28,5 +31,5 @@ public enum UserAgentOS
|
|||
MACOS,
|
||||
NETBSD,
|
||||
OPENBSD,
|
||||
OTHER
|
||||
OTHER,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue