struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Nenning <Christoph.Nenn...@lex-com.net>
Subject Re: struts2-ssl-plugin problem
Date Tue, 24 Feb 2015 16:41:47 GMT
> 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message