Source:
<code>public Response getSamlpResponse( String relayState, AuthnRequest authnRequest, org.opensaml.saml.saml2.core.Response samlResponse, NewCookie cookie, String responseTemplate) throws WSSecurityException, SimpleSign.SignatureException { LOGGER.debug("Configuring SAML Response for POST."); Document doc = DOMUtils.createDocument(); doc.appendChild(doc.createElement("root")); org.opensaml.saml.saml2.core.Response processingResponse = processPresignPlugins(authnRequest, samlResponse); LOGGER.debug("Signing SAML POST Response."); getSimpleSign().signSamlObject(processingResponse); LOGGER.debug("Converting SAML Response to DOM"); String assertionResponse = DOM2Writer.nodeToString(OpenSAMLUtil.toDom(processingResponse, doc)); String encodedSamlResponse = Base64.getEncoder().encodeToString(assertionResponse.getBytes(StandardCharsets.UTF_8)); String assertionConsumerServiceURL = getAssertionConsumerServiceURL(authnRequest); String submitFormUpdated = responseTemplate.replace("{{" + Idp.ACS_URL + "}}", assertionConsumerServiceURL); submitFormUpdated = submitFormUpdated.replace("{{" + Idp.SAML_TYPE + "}}", "SAMLResponse"); submitFormUpdated = submitFormUpdated.replace("{{" + Idp.SAML_RESPONSE + "}}", encodedSamlResponse); submitFormUpdated = StringUtils.isNotBlank(relayState) ? submitFormUpdated.replace("{{" + Idp.RELAY_STATE + "}}", relayState) <START> : submitFormUpdated.replace("{{" + Idp.RELAY_STATE + "}}", ""); <END> Response.ResponseBuilder ok = Response.ok(submitFormUpdated); if (cookie != null) { ok = ok.cookie(cookie); } return ok.build(); }</code><technical_language>This is nitpicky, I prefer String.format String concatentation (String + String) for minor performance reasons</technical_language>

Target:
public Response getSamlpResponse( String relayState, AuthnRequest authnRequest, org.opensaml.saml.saml2.core.Response samlResponse, NewCookie cookie, String responseTemplate) throws WSSecurityException, SimpleSign.SignatureException { LOGGER.debug("Configuring SAML Response for POST."); Document doc = DOMUtils.createDocument(); doc.appendChild(doc.createElement("root")); org.opensaml.saml.saml2.core.Response processingResponse = processPresignPlugins(authnRequest, samlResponse); LOGGER.debug("Signing SAML POST Response."); getSimpleSign().signSamlObject(processingResponse); LOGGER.debug("Converting SAML Response to DOM"); String assertionResponse = DOM2Writer.nodeToString(OpenSAMLUtil.toDom(processingResponse, doc)); String encodedSamlResponse = Base64.getEncoder().encodeToString(assertionResponse.getBytes(StandardCharsets.UTF_8)); String assertionConsumerServiceURL = getAssertionConsumerServiceURL(authnRequest); String submitFormUpdated = responseTemplate.replace( String.format(SURROUND_WITH_TWO_PARENTHESES, Idp.ACS_URL), assertionConsumerServiceURL); submitFormUpdated = submitFormUpdated.replace( String.format(SURROUND_WITH_TWO_PARENTHESES, Idp.SAML_TYPE), "SAMLResponse"); submitFormUpdated = submitFormUpdated.replace( String.format(SURROUND_WITH_TWO_PARENTHESES, Idp.SAML_RESPONSE), encodedSamlResponse); submitFormUpdated = submitFormUpdated.replace( String.format(SURROUND_WITH_TWO_PARENTHESES, Idp.RELAY_STATE), relayState != null ? relayState : ""); Response.ResponseBuilder ok = Response.ok(submitFormUpdated); if (cookie != null) { ok = ok.cookie(cookie); } return ok.build(); }