You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Raghu <ga...@gmail.com> on 2015/02/24 17:27:55 UTC

struts2-ssl-plugin problem

I am using google code provided struts2-ssl-plugin-1.2.1 jar file for ssl
configuration i.e switching from http to https.

But when I submit the page with method="post" form field values are not
getting submitted, I see null values are submitted to the properties of
action. 

In one of the thread it is mentioned that it is taken care in the latest
jar. What is the latest jar file?

How to fix the issue?

Thanks in advance
Rag
 





--
View this message in context: http://struts.1045723.n5.nabble.com/struts2-ssl-plugin-problem-tp5717467.html
Sent from the Struts - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts2-ssl-plugin problem

Posted by Christoph Nenning <Ch...@lex-com.net>.
> I am using google code provided struts2-ssl-plugin-1.2.1 jar file for 
ssl
> configuration i.e switching from http to https.
> 
> But when I submit the page with method="post" form field values are not
> getting submitted, I see null values are submitted to the properties of
> action. 
> 
> In one of the thread it is mentioned that it is taken care in the latest
> jar. What is the latest jar file?
> 
> How to fix the issue?
> 
> Thanks in advance
> Rag
> 
> 
> 
> 
> 


I don't know that plugin and cannot say what their latest version is. But 
it is quite simple to implement your own HttpsInterceptor, it could look 
like this:




public class HttpsInterceptor extends AbstractInterceptor
{
        private final static String SCHEME_HTTPS = "https";
        private final static int HTTPS_PORT;

        private final Logger log = LoggerFactory.getLogger(getClass());

        static {
                // note: you could load another port from config here
                HTTPS_PORT = 443;
        }

        @Override
        public String intercept(ActionInvocation invocation) throws 
Exception
        {
                HttpServletRequest request = ServletActionContext.
getRequest();
                HttpServletResponse response = ServletActionContext.
getResponse();

                String scheme = request.getScheme().toLowerCase();

                if (!SCHEME_HTTPS.equals(scheme)) {
                        URI uri = new URI(
                                SCHEME_HTTPS,
                                null,
                                request.getServerName(),
                                HTTPS_PORT,
                                response.encodeRedirectURL(request
.getRequestURI()),
                                request.getQueryString(),
                                null);

                        log.info("redirecting to https url: '{}'", uri);

                        response.sendRedirect(uri.toString());
                        return null;
                }

                return invocation.invoke();
        }
}


This Email was scanned by Sophos Anti Virus