dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15395
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5571: alternative implementation of redirect that does not use the referer header, older phones (nokia)...
------------------------------------------------------------
revno: 5571
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-23 10:51:09 +0100
message:
alternative implementation of redirect that does not use the referer header, older phones (nokia) does not provide this header
modified:
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java 2011-10-13 12:52:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java 2011-12-23 09:51:09 +0000
@@ -27,17 +27,16 @@
package org.hisp.dhis.security;
+import org.springframework.mobile.device.Device;
+import org.springframework.mobile.device.DeviceResolver;
+import org.springframework.security.web.DefaultRedirectStrategy;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.mobile.device.Device;
-import org.springframework.mobile.device.DeviceResolver;
-import org.springframework.security.web.DefaultRedirectStrategy;
-
/**
* @author mortenoh
*/
@@ -87,10 +86,31 @@
if ( device.isMobile() )
{
- url = request.getHeader( "referer" ).replaceFirst( "/dhis-web-commons/security/login.action",
- "/mobile/index.action" );
+ // Older nokia phones do not set the referer header correct, leaving old code here for now
+ // until new code has been tested.
+ //
+ // url = request.getHeader( "referer" ).replaceFirst( "/dhis-web-commons/security/login.action",
+ // "/mobile/index.action" );
+ url = getRootPath( request ) + "/mobile/index.action";
}
super.sendRedirect( request, response, url );
}
+
+ public static String getRootPath( HttpServletRequest request )
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append( request.getScheme() );
+
+ builder.append( "://" ).append( request.getServerName() );
+
+ if ( request.getServerPort() != 80 && request.getServerPort() != 443 )
+ {
+ builder.append( ":" ).append( request.getServerPort() );
+ }
+
+ builder.append( request.getContextPath() );
+
+ return builder.toString();
+ }
}