【发布时间】:2018-07-30 14:47:18
【问题描述】:
我将项目中的 OpenSAML 依赖项从 2.6.5 更新到 3.3.0,并成功迁移了大部分代码,包括库的初始化。我无法迁移的唯一最后一种方法是负责身份验证重定向的方法。这是使用 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);
}
我很难迁移它,因为库的这一部分似乎被重构了很多,但是,那里没有太多关于它的文档。 Message API Refactoring 给了我一些抽象信息,我无法真正应用到我的特定案例中,我也找不到任何合适的例子。有人可以在这项任务上给我任何支持吗?
【问题讨论】: