Source:
protected String retrieveResponseFromServer(final URL validationUrl, final String ticket) { final String MESSAGE_TO_SEND = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"<LINK_1>\"><SOAP-ENV:Header/><SOAP-ENV:Body><samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" MajorVersion=\"1\" MinorVersion=\"1\" RequestID=\"" + this.identifierGenerator.generateIdentifier() + "\" IssueInstant=\"" + CommonUtils.formatForUtcTime(new Date()) + "\">" + "<samlp:AssertionArtifact>" + ticket + "</samlp:AssertionArtifact></samlp:Request></SOAP-ENV:Body></SOAP-ENV:Envelope>"; HttpURLConnection conn = null; try { conn = (HttpURLConnection) validationUrl.openConnection(); if (conn instanceof HttpsURLConnection) { HttpsURLConnection httpsConnection = (HttpsURLConnection)conn; SSLSocketFactory socketFactory = CommonUtils.createSslSocketFactory(this.sslConfig); if (socketFactory != null) { httpsConnection.setSSLSocketFactory(socketFactory); } if (hostnameVerifier != null) { httpsConnection.setHostnameVerifier(this.hostnameVerifier); } } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "text/xml"); conn.setRequestProperty("Content-Length", Integer.toString(MESSAGE_TO_SEND.length())); conn.setRequestProperty("SOAPAction", "<LINK_0>"); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); final DataOutputStream out = new DataOutputStream(conn.getOutputStream()); out.writeBytes(MESSAGE_TO_SEND); out.flush(); out.close(); final BufferedReader in = new BufferedReader(CommonUtils.isNotBlank(getEncoding()) ? new InputStreamReader(conn.getInputStream(), Charset.forName(getEncoding())) : new InputStreamReader(conn.getInputStream())); final StringBuilder buffer = new StringBuilder(256); String line; while ((line = in.readLine()) != null) { buffer.append(line); } return buffer.toString(); } catch (final IOException e) { throw new RuntimeException(e); } finally { if (conn != null) { conn.disconnect(); } } }

Target:
protected String retrieveResponseFromServer(final URL validationUrl, final String ticket) { final String MESSAGE_TO_SEND = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"<LINK_1>\"><SOAP-ENV:Header/><SOAP-ENV:Body><samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" MajorVersion=\"1\" MinorVersion=\"1\" RequestID=\"" + this.identifierGenerator.generateIdentifier() + "\" IssueInstant=\"" + CommonUtils.formatForUtcTime(new Date()) + "\">" + "<samlp:AssertionArtifact>" + ticket + "</samlp:AssertionArtifact></samlp:Request></SOAP-ENV:Body></SOAP-ENV:Envelope>"; HttpURLConnection conn = null; try { conn = (HttpURLConnection) validationUrl.openConnection(); CommonUtils.configureHttpsConnection(conn,this.getSslConfig(),this.hostnameVerifier); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "text/xml"); conn.setRequestProperty("Content-Length", Integer.toString(MESSAGE_TO_SEND.length())); conn.setRequestProperty("SOAPAction", "<LINK_0>"); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); final DataOutputStream out = new DataOutputStream(conn.getOutputStream()); out.writeBytes(MESSAGE_TO_SEND); out.flush(); out.close(); final BufferedReader in = new BufferedReader(CommonUtils.isNotBlank(getEncoding()) ? new InputStreamReader(conn.getInputStream(), Charset.forName(getEncoding())) : new InputStreamReader(conn.getInputStream())); final StringBuilder buffer = new StringBuilder(256); String line; while ((line = in.readLine()) != null) { buffer.append(line); } return buffer.toString(); } catch (final IOException e) { throw new RuntimeException(e); } finally { if (conn != null) { conn.disconnect(); } } }