hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stone, Robert" <t_rst...@qualcomm.com>
Subject HttpClient and SiteMinder
Date Thu, 17 Mar 2005 22:56:10 GMT
Hi all,

 

I'm trying to execute POST method on SiteMinder login.fcc page.

 

The way it works - when user hits the SM protected page, SM agent
intercepts the request and forward is to the login page. That page
contains few form fields and has its action set to
"<somehost>/sm/forms/login.fcc". 

I'm trying to do this last POST programmatically using HttpClient

Problem is that once I do httpClient.executeMethod(postMethod) I never
get response back and program hangs until the session timeout. That, I
understand is due to the fact that instead of replying to POST request,
SM agent does it thing and redirects to the original targeted page.

So what I need is to execute POST method end exit without waiting for
the response to come. Is it possible and if yes can someone tell me how
to do it?

 

Here's method that will never pass executeMethod line

 

     * @param command

     * @param errors

     */

    public void processLogin(HttpServletRequest request,

            HttpServletResponse response, Object command, BindException
errors) {

        HttpClientParams params = client.getParams();

        params.setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS,

                new Boolean(true));

        params.setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT,

                new Long(3000));

        params.setParameter(HttpClientParams.REJECT_RELATIVE_REDIRECT,

                new Boolean(false));

        client.setParams(params);

        UserData userData = (UserData) command;

        PostMethod post = new PostMethod(smPath);

        post.addParameter("SMAUTHREASON", "0");

        // getting right back at ya

        post

                .addParameter("TARGET", "$SM$"

                        + request.getRequestURL().toString());

        post.addParameter("USER", userData.getUserName());

        post.addParameter("PASSWORD", userData.getUserPassword());

        try {

            if (logger.isInfoEnabled())

                logger.info("Making POST request to " + smPath);

            client.executeMethod(post);

            post.releaseConnection();

            if (logger.isInfoEnabled())

                logger.info("Back from executing post");

            if (post.getStatusCode() == HttpStatus.SC_OK) {

                List headers = Arrays.asList(post.getResponseHeaders());

                for (Iterator i = headers.iterator(); i.hasNext();) {

                    processResponseHeaders(errors, i);

                }

                if (logger.isInfoEnabled())

                    if (!errors.hasErrors())

                        logger.info("Successful login for user "

                                + userData.getUserName());

            } else {

                errors.rejectValue("userName", "errors.logging.failed",

                        new String[] { post.getStatusText() }, post

                                .getStatusText());

            }

        } catch (Exception e) {

            logger.error(e);

            errors.rejectValue("userName", "errors.logging.final",

                    new String[] { e.getMessage() }, e.getMessage());

        }

    }


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