mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 22:27:55 +01:00
Fix Browser detection filter.
This commit is contained in:
parent
f49448d22f
commit
a5bf5b8d57
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.wisemapping.filter;
|
package com.wisemapping.filter;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -26,17 +27,17 @@ import javax.servlet.http.HttpSession;
|
|||||||
|
|
||||||
import com.wisemapping.exceptions.UnsupportedBrowserException;
|
import com.wisemapping.exceptions.UnsupportedBrowserException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
|
public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
|
||||||
private List<String> exclude;
|
private Set<String> exclude;
|
||||||
public static final String USER_AGENT = "wisemapping.userAgent";
|
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();
|
final String requestUri = request.getRequestURI();
|
||||||
if (exclude != null && !exclude.contains(servletPath)) {
|
if (exclude != null && !exclude.contains(requestUri)) {
|
||||||
final HttpSession session = httpServletRequest.getSession(false);
|
final HttpSession session = request.getSession(false);
|
||||||
|
|
||||||
// Try to loaded from the request ...
|
// Try to loaded from the request ...
|
||||||
UserAgent userAgent = null;
|
UserAgent userAgent = null;
|
||||||
@ -46,7 +47,7 @@ public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
|
|||||||
|
|
||||||
// I could not loaded. I will create a new one...
|
// I could not loaded. I will create a new one...
|
||||||
if (userAgent == null) {
|
if (userAgent == null) {
|
||||||
userAgent = UserAgent.create(httpServletRequest);
|
userAgent = UserAgent.create(request);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.setAttribute(USER_AGENT, userAgent);
|
session.setAttribute(USER_AGENT, userAgent);
|
||||||
}
|
}
|
||||||
@ -61,11 +62,7 @@ public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> getExclude() {
|
public void setExclude(Set<String> exclude) {
|
||||||
return exclude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExclude(List<String> exclude) {
|
|
||||||
this.exclude = exclude;
|
this.exclude = exclude;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class UserAgent implements Serializable {
|
|||||||
|
|
||||||
this.os = parseOS(productDetails);
|
this.os = parseOS(productDetails);
|
||||||
|
|
||||||
if (userAgentHeader.indexOf("MSIE") != -1) {
|
if (userAgentHeader.contains("MSIE")) {
|
||||||
// Explorer Browser : http://msdn2.microsoft.com/en-us/library/ms537503.aspx
|
// Explorer Browser : http://msdn2.microsoft.com/en-us/library/ms537503.aspx
|
||||||
// Format: Mozilla/MozVer (compatible; MSIE IEVer[; Provider]; Platform[; Extension]*) [Addition]
|
// 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;)
|
// 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 ...
|
// Explorer Parse ...
|
||||||
this.product = Product.EXPLORER;
|
this.product = Product.EXPLORER;
|
||||||
this.hasGCFInstalled = productDetails.indexOf("chromeframe") != -1;
|
this.hasGCFInstalled = productDetails.contains("chromeframe");
|
||||||
} else if (userAgentHeader.indexOf("iCab") != -1 || userAgentHeader.indexOf("Safari") != -1) {
|
} else if (userAgentHeader.contains("iCab") || userAgentHeader.contains("Safari")) {
|
||||||
// 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
|
//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:
|
//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"
|
//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 = "";
|
String versionStr = "";
|
||||||
if (userAgentHeader.indexOf("Chrome") != -1) {
|
if (userAgentHeader.contains("Chrome")) {
|
||||||
this.product = Product.CHROME;
|
this.product = Product.CHROME;
|
||||||
versionStr = userAgentHeader.substring(userAgentHeader.indexOf("Chrome") + 7, userAgentHeader.lastIndexOf(" "));
|
versionStr = userAgentHeader.substring(userAgentHeader.indexOf("Chrome") + 7, userAgentHeader.lastIndexOf(" "));
|
||||||
} else {
|
} else {
|
||||||
@ -145,11 +145,11 @@ public class UserAgent implements Serializable {
|
|||||||
|
|
||||||
parseVersion(versionStr);
|
parseVersion(versionStr);
|
||||||
|
|
||||||
} else if (userAgentHeader.indexOf("Konqueror") != -1) {
|
} else if (userAgentHeader.contains("Konqueror")) {
|
||||||
this.product = Product.KONQUEOR;
|
this.product = Product.KONQUEOR;
|
||||||
} else if (userAgentHeader.indexOf("KMeleon") != -1) {
|
} else if (userAgentHeader.contains("KMeleon")) {
|
||||||
this.product = Product.KMELEON;
|
this.product = Product.KMELEON;
|
||||||
} else if (userAgentHeader.indexOf("Gecko") != -1) {
|
} else if (userAgentHeader.contains("Gecko")) {
|
||||||
// Firefox/Mozilla/Camino:
|
// Firefox/Mozilla/Camino:
|
||||||
// Mozilla/MozVer (Platform; Security; SubPlatform; Language; rv:Revision[; Extension]*) Gecko/GeckVer [Product/ProdVer]
|
// 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
|
// 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:
|
// Opera:
|
||||||
// Samples: Opera/9.0 (Windows NT 5.1; U; en)
|
// Samples: Opera/9.0 (Windows NT 5.1; U; en)
|
||||||
// Opera/8.5 (Macintosh; PPC Mac OS X; U; en)
|
// Opera/8.5 (Macintosh; PPC Mac OS X; U; en)
|
||||||
@ -212,14 +212,14 @@ public class UserAgent implements Serializable {
|
|||||||
}
|
}
|
||||||
parseVersion(productVersion);
|
parseVersion(productVersion);
|
||||||
|
|
||||||
} else if (userAgentHeader.indexOf("4.7") != -1) {
|
} else if (userAgentHeader.contains("4.7")) {
|
||||||
this.product = Product.NETSCAPE;
|
this.product = Product.NETSCAPE;
|
||||||
} else if (userAgentHeader.indexOf("Lynx") != -1) {
|
} else if (userAgentHeader.contains("Lynx")) {
|
||||||
this.product = Product.LYNX;
|
this.product = Product.LYNX;
|
||||||
} else {
|
} else {
|
||||||
// It's a robot ..
|
// It's a robot ..
|
||||||
for (String botAgent : botAgents) {
|
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
|
// set a key in the session, so the next time we don't have to manually
|
||||||
// detect the robot again
|
// detect the robot again
|
||||||
this.product = Product.ROBOT;
|
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!
|
TAGS_DETAILS=Add tags you maps is very simple. Try!
|
||||||
TAG_IT=Tag It
|
TAG_IT=Tag It
|
||||||
PUBLISH_IT=Publish 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.
|
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
|
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
|
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!
|
TAGS_DETAILS=Agregar etiquetas a sus mapas en muy facil! Intentelo!
|
||||||
TAG_IT=Etiquetalo!
|
TAG_IT=Etiquetalo!
|
||||||
PUBLISH_IT=Publicalo!
|
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.
|
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
|
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
|
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.
|
TAGS_DETAILS = Ajoutez des mots-cl\u00e9s \u00e0 vos maps en 1 clic.
|
||||||
TAG_IT = Taguer
|
TAG_IT = Taguer
|
||||||
PUBLISH_IT = Publier
|
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.
|
FIELD_REQUIRED_MSG=Les champs marqu\u00e9s avec une ast\u00e9risque sont requis.
|
||||||
|
|
||||||
COMMA_SEPARATED_EMAILS = S\u00e9parer les adresses email par une virgule
|
COMMA_SEPARATED_EMAILS = S\u00e9parer les adresses email par une virgule
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<definition name="mindmapEditor" template="/jsp/mindmapEditor.jsp"/>
|
<definition name="mindmapEditor" template="/jsp/mindmapEditor.jsp"/>
|
||||||
<definition name="mindmapPrint" template="/jsp/mindmapPrint.jsp"/>
|
<definition name="mindmapPrint" template="/jsp/mindmapPrint.jsp"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- Template Declaration -->
|
<!-- Template Declaration -->
|
||||||
<definition name="pageTemplate" template="/jsp/template.jsp">
|
<definition name="pageTemplate" template="/jsp/template.jsp">
|
||||||
<put-attribute name="title" value="" type="string"/>
|
<put-attribute name="title" value="" type="string"/>
|
||||||
@ -57,6 +58,11 @@
|
|||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<!-- Main Pages -->
|
<!-- 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">
|
<definition name="forgotPasswordError" extends="errorTemplate">
|
||||||
<put-attribute name="title" value="INVALID_EMAIL_ERROR"/>
|
<put-attribute name="title" value="INVALID_EMAIL_ERROR"/>
|
||||||
<put-attribute name="body" value="/jsp/userForgotPasswordError.jsp"/>
|
<put-attribute name="body" value="/jsp/userForgotPasswordError.jsp"/>
|
||||||
@ -82,9 +88,14 @@
|
|||||||
<put-attribute name="body" value="/jsp/userRegistrationSuccess.jsp"/>
|
<put-attribute name="body" value="/jsp/userRegistrationSuccess.jsp"/>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="login" extends="pageTemplate">
|
<definition name="userRegistrationSuccess" extends="pageTemplate">
|
||||||
<put-attribute name="title" value="LOGIN"/>
|
<put-attribute name="title" value="USER_REGISTRATION"/>
|
||||||
<put-attribute name="body" value="/jsp/login.jsp"/>
|
<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>
|
</definition>
|
||||||
|
|
||||||
<!-- Dialog Forms -->
|
<!-- Dialog Forms -->
|
||||||
|
@ -15,6 +15,29 @@
|
|||||||
<context:annotation-config/>
|
<context:annotation-config/>
|
||||||
<mvc:annotation-driven/>
|
<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">
|
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||||
<property name="location" value="/WEB-INF/app.properties"/>
|
<property name="location" value="/WEB-INF/app.properties"/>
|
||||||
@ -50,11 +73,6 @@
|
|||||||
<property name="defaultLocale" value="en"/>
|
<property name="defaultLocale" value="en"/>
|
||||||
</bean>
|
</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">
|
<bean id="reCaptcha" class="net.tanesha.recaptcha.ReCaptchaImpl">
|
||||||
<property name="privateKey" value="${registration.recaptcha.privateKey}"/>
|
<property name="privateKey" value="${registration.recaptcha.privateKey}"/>
|
||||||
<property name="publicKey" value="${registration.recaptcha.publicKey}"/>
|
<property name="publicKey" value="${registration.recaptcha.publicKey}"/>
|
||||||
@ -67,26 +85,6 @@
|
|||||||
<property name="maxUploadSize" value="522240"/>
|
<property name="maxUploadSize" value="522240"/>
|
||||||
</bean>
|
</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">
|
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||||
<property name="basenames">
|
<property name="basenames">
|
||||||
<list>
|
<list>
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
<%@ include file="/jsp/init.jsp" %>
|
||||||
|
|
||||||
<h1>
|
<h2>Opps!!!. Your browser is not currently supported</h2>
|
||||||
<spring:message code="USUPPORTED_BROWSER"/>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<h2>You are using an unsupported browser.</h2>
|
<p>Your browser has not been fully tested and it might not be completely functional. WiseMapping has been optimized
|
||||||
|
for:</p>
|
||||||
<p>Although you can use our site with that browser, some features may not be functional.</p>
|
|
||||||
WiseMapping is optimized for use with:
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Internet Explorer 7.0 or greater</li>
|
<li>Chrome 19 or greater</li>
|
||||||
<li>Firefox 3.0 or greater</li>
|
<li>Firefox 11.0 or greater</li>
|
||||||
<li>Opera 11 or greater</li>
|
<li>Opera 11 or greater</li>
|
||||||
<li>Safari 5 or greater</li>
|
<li>Safari 5 or greater</li>
|
||||||
|
<li>Internet Explorer 8.0 or greater</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>
|
||||||
|
Try again with one of the browsers previously listed.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
We are working to support more browser in the future. Stay tuned !
|
<span class="label label-info">Note:</span> Browsers are listed based on performance and
|
||||||
|
hours of testing invested by our team.
|
||||||
<p>
|
</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user