I updated the OpenSAML dependency in my project from 2.6.5 to 3.3.0 and managed to migrate the most of my code including initialization of the library. The one only last method I am unable to migrate is the method responsible for authentication redirect. This is how it was implemented with OpenSAML 2:
private void doAuthenticationRedirect(HttpServletRequest request, HttpServletResponse response) throws Exception {
AuthnRequest authnRequest = buildAuthnRequestObject();
HttpServletResponseAdapter responseAdapter = new HttpServletResponseAdapter(response, true);
responseAdapter.setStatusCode(HttpServletResponse.SC_MOVED_TEMPORARILY);
SAMLMessageContext<?, AuthnRequest, ?> context = makeSamlMessageContext();
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
Endpoint samlEndpoint = endpointBuilder.buildObject();
samlEndpoint.setLocation(dao.loadString((this.getClass().getName() + "_IDPRedirectURL")));
String uuid = UUIDBuilder.createUUID().toString();
context.setRelayState(uuid);
context.setPeerEntityEndpoint(samlEndpoint);
context.setOutboundSAMLMessage(authnRequest);
context.setOutboundMessageTransport(responseAdapter);
HTTPRedirectDeflateEncoder httpRedirectDeflateEncoder = new HTTPRedirectDeflateEncoder();
httpRedirectDeflateEncoder.encode((MessageContext) context);
}
I am having a hard time migrating this because this part of the library seems to be refactored a lot, however, there is not much documentation about it out there. Message API Refactoring gives me some abstract information I cannot really apply in my particular case and I also cannot find any suitable examples. Can anybody give me any support on this task?