java/code/src/com/redhat/rhn/frontend/action/LoginAction.java | 8
+++++++
java/code/src/com/redhat/rhn/frontend/action/LoginSetupAction.java | 11
++++++++++
java/code/src/com/redhat/rhn/frontend/security/PxtAuthenticationService.java | 3 ++
java/code/webapp/WEB-INF/pages/common/relogin.jsp | 1
java/code/webapp/WEB-INF/struts-config.xml | 1
5 files changed, 24 insertions(+)
New commits:
commit 614b467c7eae6986dae3d51db129d9e416cb4411
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Aug 26 14:43:07 2011 +0200
709724 - bounce to default url for expired POST requests
We need to bounce to default url for expired POST requests since:
1. After user re-logins, we use HTTP redirect to be able to return to previous page
2. Browser uses a GET method for the url provided in redirect
3. The action which we are about to redirect to may not allow GET
diff --git a/java/code/src/com/redhat/rhn/frontend/action/LoginAction.java
b/java/code/src/com/redhat/rhn/frontend/action/LoginAction.java
index 026e26f..cf84218 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/LoginAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/LoginAction.java
@@ -90,6 +90,7 @@ public class LoginAction extends RhnAction {
String username = (String) f.get("username");
String password = (String) f.get("password");
String urlBounce = (String) f.get("url_bounce");
+ String requestMethod = (String) f.get("request_method");
ActionErrors e = new ActionErrors();
User user = loginUser(username, password, request, response, e);
@@ -102,6 +103,13 @@ public class LoginAction extends RhnAction {
}
urlBounce = DEFAULT_URL_BOUNCE;
}
+ if (requestMethod.equals("POST")) {
+ if (log.isDebugEnabled()) {
+ log.debug("2 - POST method used, using default url bounce
[" +
+ DEFAULT_URL_BOUNCE + "]");
+ }
+ urlBounce = DEFAULT_URL_BOUNCE;
+ }
if (urlBounce.trim().endsWith("Logout.do")) {
if (log.isDebugEnabled()) {
log.debug(" - handling special case of
url_bounce=Logout.do");
diff --git a/java/code/src/com/redhat/rhn/frontend/action/LoginSetupAction.java
b/java/code/src/com/redhat/rhn/frontend/action/LoginSetupAction.java
index 48f4978..3eb8db6 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/LoginSetupAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/LoginSetupAction.java
@@ -65,6 +65,7 @@ public class LoginSetupAction extends RhnAction {
// ok handle the case where we're doing the ReLogin page
String urlBounce = (String) request.getAttribute("url_bounce");
+ String requestMethod = (String)
request.getAttribute("request_method");
if (!StringUtils.isEmpty(urlBounce)) {
@@ -76,6 +77,16 @@ public class LoginSetupAction extends RhnAction {
f.set("url_bounce", urlBounce);
}
+ if (!StringUtils.isEmpty(requestMethod)) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("request.getAttribute(request_method): " +
requestMethod);
+ }
+
+ DynaActionForm f = (DynaActionForm)form;
+ f.set("request_method", requestMethod);
+ }
+
return mapping.findForward("default");
}
diff --git a/java/code/src/com/redhat/rhn/frontend/security/PxtAuthenticationService.java
b/java/code/src/com/redhat/rhn/frontend/security/PxtAuthenticationService.java
index dcee959..fa657e3 100644
--- a/java/code/src/com/redhat/rhn/frontend/security/PxtAuthenticationService.java
+++ b/java/code/src/com/redhat/rhn/frontend/security/PxtAuthenticationService.java
@@ -122,6 +122,7 @@ public class PxtAuthenticationService extends
BaseAuthenticationService {
try {
StringBuffer redirectURI = new StringBuffer(request.getRequestURI());
String params = ServletUtils.requestParamsToQueryString(request);
+ String requestMethod = request.getMethod();
// don't want to put the ? in the url if there are no params
if (!StringUtils.isEmpty(params)) {
redirectURI.append("?");
@@ -135,6 +136,8 @@ public class PxtAuthenticationService extends
BaseAuthenticationService {
request.setAttribute("url_bounce", redirectURI.toString());
}
+ request.setAttribute("request_method", requestMethod);
+
RequestDispatcher dispatcher =
request.getRequestDispatcher("/ReLogin.do");
dispatcher.forward(request, response);
}
diff --git a/java/code/webapp/WEB-INF/pages/common/relogin.jsp
b/java/code/webapp/WEB-INF/pages/common/relogin.jsp
index bd69089..e8a2070 100644
--- a/java/code/webapp/WEB-INF/pages/common/relogin.jsp
+++ b/java/code/webapp/WEB-INF/pages/common/relogin.jsp
@@ -21,6 +21,7 @@
<rhn:csrf />
<%@ include file="/WEB-INF/pages/common/fragments/login_form.jspf"
%>
<html:hidden property="url_bounce" />
+ <html:hidden property="request_method" />
</html:form>
</div><!-- end clearBoxBody -->
</div><!-- end clearBoxInner -->
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index be05813..f991165 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -10,6 +10,7 @@
<form-property name="username"
type="java.lang.String"/>
<form-property name="password"
type="java.lang.String"/>
<form-property name="url_bounce"
type="java.lang.String"/>
+ <form-property name="request_method"
type="java.lang.String"/>
</form-bean>
<form-bean name="activationKeyForm"
type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm">