private void detectAndAssert(final String userAgentString, final UserAgentBrowser expectedBrowser, final String expectedVersion) { final UserAgentDetection detection = UserAgentDetection.browserDetect(userAgentString); assertEquals(expectedBrowser, detection.getUserAgentBrowser()); assertEquals(expectedVersion, detection.getUserAgentBrowserVersion()); } }
public static UserAgentDetection browserDetect(final String userAgentString) final UserAgentDetection detection = new UserAgentDetection(); if (userAgentString == null) { return detection;
public MySession(final Request request) { super(request); setLocale(request); final ClientInfo info = getClientInfo(); if (info instanceof WebClientInfo) { clientProperties = ((WebClientInfo) clientInfo).getProperties(); clientProperties.setTimeZone(ThreadLocalUserContext.getTimeZone()); userAgent = ((WebClientInfo) info).getUserAgent(); userAgentDevice = UserAgentDevice.getUserAgentDevice(userAgent); userAgentOS = UserAgentOS.getUserAgentOS(userAgent); mobileUserAgent = userAgentDevice.isMobile(); final UserAgentDetection userAgentDetection = UserAgentDetection.browserDetect(userAgent); userAgentBrowser = userAgentDetection.getUserAgentBrowser(); userAgentBrowserVersionString = userAgentDetection.getUserAgentBrowserVersion(); } else { log.error("Oups, ClientInfo is not from type WebClientInfo: " + info); } setUserContext(ThreadLocalUserContext.getUserContext()); initActualTenant(); this.csrfToken = NumberHelper.getSecureRandomUrlSaveString(20); }