mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-23 03:43:48 +01:00
Fix Browser detection filter.
This commit is contained in:
parent
f49448d22f
commit
a5bf5b8d57
@ -18,6 +18,7 @@
|
||||
|
||||
package com.wisemapping.filter;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -26,17 +27,17 @@ import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.wisemapping.exceptions.UnsupportedBrowserException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
|
||||
private List<String> exclude;
|
||||
private Set<String> exclude;
|
||||
public static final String USER_AGENT = "wisemapping.userAgent";
|
||||
|
||||
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws Exception {
|
||||
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
|
||||
|
||||
final String servletPath = httpServletRequest.getServletPath();
|
||||
if (exclude != null && !exclude.contains(servletPath)) {
|
||||
final HttpSession session = httpServletRequest.getSession(false);
|
||||
final String requestUri = request.getRequestURI();
|
||||
if (exclude != null && !exclude.contains(requestUri)) {
|
||||
final HttpSession session = request.getSession(false);
|
||||
|
||||
// Try to loaded from the request ...
|
||||
UserAgent userAgent = null;
|
||||
@ -46,7 +47,7 @@ public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
// I could not loaded. I will create a new one...
|
||||
if (userAgent == null) {
|
||||
userAgent = UserAgent.create(httpServletRequest);
|
||||
userAgent = UserAgent.create(request);
|
||||
if (session != null) {
|
||||
session.setAttribute(USER_AGENT, userAgent);
|
||||
}
|
||||
@ -61,11 +62,7 @@ public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
|
||||
}
|
||||
|
||||
|
||||
public List<String> getExclude() {
|
||||
return exclude;
|
||||
}
|
||||
|
||||
public void setExclude(List<String> exclude) {
|
||||
public void setExclude(Set<String> exclude) {
|
||||
this.exclude = exclude;
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class UserAgent implements Serializable {
|
||||
|
||||
this.os = parseOS(productDetails);
|
||||
|
||||
if (userAgentHeader.indexOf("MSIE") != -1) {
|
||||
if (userAgentHeader.contains("MSIE")) {
|
||||
// Explorer Browser : http://msdn2.microsoft.com/en-us/library/ms537503.aspx
|
||||
// Format: Mozilla/MozVer (compatible; MSIE IEVer[; Provider]; Platform[; Extension]*) [Addition]
|
||||
// SampleTest: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Google Wireless Transcoder;)
|
||||
@ -128,14 +128,14 @@ public class UserAgent implements Serializable {
|
||||
|
||||
// Explorer Parse ...
|
||||
this.product = Product.EXPLORER;
|
||||
this.hasGCFInstalled = productDetails.indexOf("chromeframe") != -1;
|
||||
} else if (userAgentHeader.indexOf("iCab") != -1 || userAgentHeader.indexOf("Safari") != -1) {
|
||||
this.hasGCFInstalled = productDetails.contains("chromeframe");
|
||||
} else if (userAgentHeader.contains("iCab") || userAgentHeader.contains("Safari")) {
|
||||
// Safari:
|
||||
//Formats: Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.13.1 (KHTML, like Gecko) Version/3.0.2 Safari/522.13.1
|
||||
//Chrome:
|
||||
//Formats: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7"
|
||||
String versionStr = "";
|
||||
if (userAgentHeader.indexOf("Chrome") != -1) {
|
||||
if (userAgentHeader.contains("Chrome")) {
|
||||
this.product = Product.CHROME;
|
||||
versionStr = userAgentHeader.substring(userAgentHeader.indexOf("Chrome") + 7, userAgentHeader.lastIndexOf(" "));
|
||||
} else {
|
||||
@ -145,11 +145,11 @@ public class UserAgent implements Serializable {
|
||||
|
||||
parseVersion(versionStr);
|
||||
|
||||
} else if (userAgentHeader.indexOf("Konqueror") != -1) {
|
||||
} else if (userAgentHeader.contains("Konqueror")) {
|
||||
this.product = Product.KONQUEOR;
|
||||
} else if (userAgentHeader.indexOf("KMeleon") != -1) {
|
||||
} else if (userAgentHeader.contains("KMeleon")) {
|
||||
this.product = Product.KMELEON;
|
||||
} else if (userAgentHeader.indexOf("Gecko") != -1) {
|
||||
} else if (userAgentHeader.contains("Gecko")) {
|
||||
// Firefox/Mozilla/Camino:
|
||||
// Mozilla/MozVer (Platform; Security; SubPlatform; Language; rv:Revision[; Extension]*) Gecko/GeckVer [Product/ProdVer]
|
||||
// SampleTest: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20050302 Firefox/0.9.6
|
||||
@ -195,7 +195,7 @@ public class UserAgent implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
} else if (userAgentHeader.indexOf("Opera") != -1) {
|
||||
} else if (userAgentHeader.contains("Opera")) {
|
||||
// Opera:
|
||||
// Samples: Opera/9.0 (Windows NT 5.1; U; en)
|
||||
// Opera/8.5 (Macintosh; PPC Mac OS X; U; en)
|
||||
@ -212,14 +212,14 @@ public class UserAgent implements Serializable {
|
||||
}
|
||||
parseVersion(productVersion);
|
||||
|
||||
} else if (userAgentHeader.indexOf("4.7") != -1) {
|
||||
} else if (userAgentHeader.contains("4.7")) {
|
||||
this.product = Product.NETSCAPE;
|
||||
} else if (userAgentHeader.indexOf("Lynx") != -1) {
|
||||
} else if (userAgentHeader.contains("Lynx")) {
|
||||
this.product = Product.LYNX;
|
||||
} else {
|
||||
// It's a robot ..
|
||||
for (String botAgent : botAgents) {
|
||||
if (userAgentHeader.indexOf(botAgent) != -1) {
|
||||
if (userAgentHeader.contains(botAgent)) {
|
||||
// set a key in the session, so the next time we don't have to manually
|
||||
// detect the robot again
|
||||
this.product = Product.ROBOT;
|
||||
|
@ -153,7 +153,7 @@ EMPTY_RECENT_MINDMAP_TABLE=No recent maps
|
||||
TAGS_DETAILS=Add tags you maps is very simple. Try!
|
||||
TAG_IT=Tag It
|
||||
PUBLISH_IT=Publish It
|
||||
USUPPORTED_BROWSER=Unsupported Browser
|
||||
UNSUPPORTED_BROWSER=Unsupported Browser
|
||||
FIELD_REQUIRED_MSG=Fields marked with an asterisk <span class="fieldRequired">*</span> are required.
|
||||
TAGS_MSG=Tagging is a simple way to keep your maps in order and help other people to find your public maps
|
||||
COMMA_SEPARATED_EMAILS=Comma separated emails
|
||||
|
@ -151,7 +151,7 @@ EMPTY_RECENT_MINDMAP_TABLE=No hay mapas recientes
|
||||
TAGS_DETAILS=Agregar etiquetas a sus mapas en muy facil! Intentelo!
|
||||
TAG_IT=Etiquetalo!
|
||||
PUBLISH_IT=Publicalo!
|
||||
USUPPORTED_BROWSER=Navegador no soportado
|
||||
UNSUPPORTED_BROWSER=Navegador no soportado
|
||||
FIELD_REQUIRED_MSG=Fields marked with an asterisk <span class="fieldRequired">*</span> are required.
|
||||
TAGS_MSG=Tagging is a simple way to keep your maps in order and help other people to find your public maps
|
||||
COMMA_SEPARATED_EMAILS=E-mails separados por comas
|
||||
|
@ -154,7 +154,7 @@ EMPTY_RECENT_MINDMAP_TABLE = Aucune carte r\u00e9cente
|
||||
TAGS_DETAILS = Ajoutez des mots-cl\u00e9s \u00e0 vos maps en 1 clic.
|
||||
TAG_IT = Taguer
|
||||
PUBLISH_IT = Publier
|
||||
USUPPORTED_BROWSER = Navigateur non support\u00e9
|
||||
UNSUPPORTED_BROWSER = Navigateur non support\u00e9
|
||||
FIELD_REQUIRED_MSG=Les champs marqu\u00e9s avec une ast\u00e9risque sont requis.
|
||||
|
||||
COMMA_SEPARATED_EMAILS = S\u00e9parer les adresses email par une virgule
|
||||
|
@ -10,6 +10,7 @@
|
||||
<definition name="mindmapEditor" template="/jsp/mindmapEditor.jsp"/>
|
||||
<definition name="mindmapPrint" template="/jsp/mindmapPrint.jsp"/>
|
||||
|
||||
|
||||
<!-- Template Declaration -->
|
||||
<definition name="pageTemplate" template="/jsp/template.jsp">
|
||||
<put-attribute name="title" value="" type="string"/>
|
||||
@ -57,6 +58,11 @@
|
||||
</definition>
|
||||
|
||||
<!-- Main Pages -->
|
||||
<definition name="login" extends="pageTemplate">
|
||||
<put-attribute name="title" value="LOGIN"/>
|
||||
<put-attribute name="body" value="/jsp/login.jsp"/>
|
||||
</definition>
|
||||
|
||||
<definition name="forgotPasswordError" extends="errorTemplate">
|
||||
<put-attribute name="title" value="INVALID_EMAIL_ERROR"/>
|
||||
<put-attribute name="body" value="/jsp/userForgotPasswordError.jsp"/>
|
||||
@ -82,9 +88,14 @@
|
||||
<put-attribute name="body" value="/jsp/userRegistrationSuccess.jsp"/>
|
||||
</definition>
|
||||
|
||||
<definition name="login" extends="pageTemplate">
|
||||
<put-attribute name="title" value="LOGIN"/>
|
||||
<put-attribute name="body" value="/jsp/login.jsp"/>
|
||||
<definition name="userRegistrationSuccess" extends="pageTemplate">
|
||||
<put-attribute name="title" value="USER_REGISTRATION"/>
|
||||
<put-attribute name="body" value="/jsp/userRegistrationSuccess.jsp"/>
|
||||
</definition>
|
||||
|
||||
<definition name="browserNotSupported" extends="pageTemplate">
|
||||
<put-attribute name="title" value="UNSUPPORTED_BROWSER"/>
|
||||
<put-attribute name="body" value="/jsp/browserNotSupported.jsp"/>
|
||||
</definition>
|
||||
|
||||
<!-- Dialog Forms -->
|
||||
|
@ -15,6 +15,29 @@
|
||||
<context:annotation-config/>
|
||||
<mvc:annotation-driven/>
|
||||
|
||||
<!-- Interceptors Registration -->
|
||||
<mvc:interceptors>
|
||||
<bean id="browserSupportInterceptor" class="com.wisemapping.filter.BrowserSupportInterceptor">
|
||||
<property name="exclude">
|
||||
<set>
|
||||
<value>/</value>
|
||||
<value>/index.jsp</value>
|
||||
<value>/c/home</value>
|
||||
<value>/c/j_spring_security</value>
|
||||
<value>/c/login</value>
|
||||
<value>/service/</value>
|
||||
<value>/c/maps/*/embed</value>
|
||||
<value>/c/maps/*/public</value>
|
||||
<value>/c/embeddedView</value>
|
||||
<value>/c/user/resetPassword</value>
|
||||
<value>/c/user/registration</value>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
|
||||
<property name="paramName" value="locale"/>
|
||||
</bean>
|
||||
</mvc:interceptors>
|
||||
|
||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="/WEB-INF/app.properties"/>
|
||||
@ -50,11 +73,6 @@
|
||||
<property name="defaultLocale" value="en"/>
|
||||
</bean>
|
||||
|
||||
<bean id="localeChangeInterceptor"
|
||||
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
|
||||
<property name="paramName" value="language"/>
|
||||
</bean>
|
||||
|
||||
<bean id="reCaptcha" class="net.tanesha.recaptcha.ReCaptchaImpl">
|
||||
<property name="privateKey" value="${registration.recaptcha.privateKey}"/>
|
||||
<property name="publicKey" value="${registration.recaptcha.publicKey}"/>
|
||||
@ -67,26 +85,6 @@
|
||||
<property name="maxUploadSize" value="522240"/>
|
||||
</bean>
|
||||
|
||||
<bean id="browserSupportInterceptor" class="com.wisemapping.filter.BrowserSupportInterceptor">
|
||||
<property name="exclude">
|
||||
<list>
|
||||
<value>/</value>
|
||||
<value>/index.jsp</value>
|
||||
<value>/c/home</value>
|
||||
<value>/c/login</value>
|
||||
<value>/c/user/registration</value>
|
||||
<value>/c/captcha</value>
|
||||
<value>/c/publicView</value>
|
||||
<value>/service/*</value>
|
||||
<value>/c/search</value>
|
||||
<value>/c/keyboard</value>
|
||||
<value>/c/renameMap</value>
|
||||
<value>/c/embeddedView</value>
|
||||
<value>/c/user/resetPassword</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||
<property name="basenames">
|
||||
<list>
|
||||
|
@ -1,21 +1,21 @@
|
||||
<%@ include file="/jsp/init.jsp" %>
|
||||
|
||||
<h1>
|
||||
<spring:message code="USUPPORTED_BROWSER"/>
|
||||
</h1>
|
||||
<h2>Opps!!!. Your browser is not currently supported</h2>
|
||||
|
||||
<h2>You are using an unsupported browser.</h2>
|
||||
|
||||
<p>Although you can use our site with that browser, some features may not be functional.</p>
|
||||
WiseMapping is optimized for use with:
|
||||
<p>Your browser has not been fully tested and it might not be completely functional. WiseMapping has been optimized
|
||||
for:</p>
|
||||
<ul>
|
||||
<li>Internet Explorer 7.0 or greater</li>
|
||||
<li>Firefox 3.0 or greater</li>
|
||||
<li>Chrome 19 or greater</li>
|
||||
<li>Firefox 11.0 or greater</li>
|
||||
<li>Opera 11 or greater</li>
|
||||
<li>Safari 5 or greater</li>
|
||||
<li>Internet Explorer 8.0 or greater</li>
|
||||
</ul>
|
||||
<p>
|
||||
Try again with one of the browsers previously listed.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
We are working to support more browser in the future. Stay tuned !
|
||||
|
||||
<p>
|
||||
<span class="label label-info">Note:</span> Browsers are listed based on performance and
|
||||
hours of testing invested by our team.
|
||||
</p>
|
||||
|
Loading…
Reference in New Issue
Block a user