我正在尝试用Java执行SAML重定向,但是失败了。
初始请求有效,并且得到以下响应:
2019-06-29 18:34:59,069 18:34:59.069 [main] INFO (GetCaAgileDataManualTest.java:16) - Starting test...
2019-06-29 18:35:04,596 18:35:04.596 [main] INFO (GetCaAgileDataManualTest.java:19) - Sending request to: https://sso.rallydev.com/sp/startSSO.ping?PartnerIdpId=my.company.identifier
2019-06-29 18:35:05,420 18:35:05.420 [main] INFO (GetCaAgileDataManualTest.java:22) - Got response:
<!-- template name: form.autopost.template.html -->
<html>
<head>
<title>Submit Form</title>
</head>
<body onload="javascript:document.forms[0].submit()">
<noscript>
<p>
<strong>Note:</strong> Since your browser does not support JavaScript, you must press the Resume button once to proceed.
</p>
</noscript>
<form method="post" action="https://ssopacorp2extra.mycompany.com/idp/SSO.saml2">
<input type="hidden" name="SAMLRequest" value="aBigLONgStrINGOfGobblidyGOok=="/>
<input type="hidden" name="RelayState" value="aShortERSTRingOfGOBBlidygOOK"/>
<noscript><input type="submit" value="Resume"/></noscript>
</form>
</body>
</html>
如果我随后从响应中发送表单数据,我将得到一个无标题且状态为0的空答复。
如果我随后尝试访问该页面,则实际上是在尝试获取以下错误。
2019-06-29 19:05:33,242 19:05:33.242 [main] INFO (GetCaAgileDataManualTest.java:41) - Sending request to: https://ssopacorp2extra.mycompany.com/idp/SSO.saml2
2019-06-29 19:05:33,664 19:05:33.664 [main] INFO (GetCaAgileDataManualTest.java:44) - STATUS: 0
2019-06-29 19:05:33,664 19:05:33.664 [main] INFO (GetCaAgileDataManualTest.java:45) - Got response:
2019-06-29 19:05:33,664 19:05:33.664 [main] INFO (GetCaAgileDataManualTest.java:46) - Done with saml2 request
2019-06-29 19:05:33,664 19:05:33.664 [main] INFO (GetCaAgileDataManualTest.java:50) - Getting ca agile data...
2019-06-29 19:05:33,669 19:05:33.669 [main] INFO (GetCaAgileDataManualTest.java:54) - Sending request to: https://rally1.rallydev.com/#/165441981268d/dashboard
2019-06-29 19:05:33,733 19:05:33.733 [main] INFO (RetryExec.java:97) - I/O exception (java.net.SocketException) caught when processing request to {s}->https://rally1.rallydev.com:443: Connection reset
2019-06-29 19:05:33,734 19:05:33.734 [main] INFO (RetryExec.java:113) - Retrying request to {s}->https://rally1.rallydev.com:443
2019-06-29 19:05:33,796 19:05:33.796 [main] INFO (RetryExec.java:97) - I/O exception (java.net.SocketException) caught when processing request to {s}->https://rally1.rallydev.com:443: Connection reset
2019-06-29 19:05:33,796 19:05:33.796 [main] INFO (RetryExec.java:113) - Retrying request to {s}->https://rally1.rallydev.com:443
2019-06-29 19:05:33,862 19:05:33.862 [main] INFO (RetryExec.java:97) - I/O exception (java.net.SocketException) caught when processing request to {s}->https://rally1.rallydev.com:443: Connection reset
2019-06-29 19:05:33,862 19:05:33.862 [main] INFO (RetryExec.java:113) - Retrying request to {s}->https://rally1.rallydev.com:443
Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Connection reset
at com.mycompany.myproject.util.http.HttpRequestClient.doGet(HttpRequestClient.java:162)
at com.mycompany.myproject.excel.GetCaAgileDataManualTest.getCaAgileData(GetCaAgileDataManualTest.java:55)
at com.mycompany.myproject.excel.GetCaAgileDataManualTest.main(GetCaAgileDataManualTest.java:24)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at com.mycompany.myproject.util.http.HttpRequestClient.doGet(HttpRequestClient.java:158)
... 2 more