简体   繁体   中英

Jersey client stuck on SAML GET request

I'm having a problem with sending a GET request in Java, with an ApacheHttpClient4 , to a SAML url ( https://en.wikipedia.org/wiki/SAML_2.0 ). I fetch the url from a Location header that I get on a previous request, returning 302. Then I do a GET on the url, which is on the format https://some.domain/?SAMLRequest=...&RelayState=... . Jersey somehow gets stuck on it and does never send the actual request (I have checked both Charles and enabled a logging filter but the GET never happens, it doesn't even try). It gets stuck on the following line:

PoolingClientConnectionManager - Connection request: [route: {tls}->http://127.0.0.1:8888->https://some.domain][total kept alive: 3; route allocated: 2 of 2; total allocated: 7 of 20]

This was a tough one, but I finally managed to solve it by adding a ClientFilter to the Client which only does the following:

/**
 * This class is only used to solve cases where a Client gets stuck in a redirect process.
 */
public class MyClientFilter extends ClientFilter {

    @Override
    public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException {
        return getNext().handle(clientRequest);
    }
}

Somehow it manages to force the client to continue following the redirects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM