请原谅我一个冗长的问题。我正在将REST服务与我们的WebSSO设置集成。这项任务似乎很复杂;因此寻求建议。虽然我提供了添加更多细节的细节,但我要求您将此视为如何与Java层中的WebSSO设置集成的一般问题。这样你就不会被我必须使用的特定技术所劝阻。
我们在AngularJS中构建了一个应用程序。使用此应用程序,可以将文件上传到Filenet。我们的Filenet平台提供REST API(我们围绕Filenet本机API的内部REST包装器)。 Filenet启用了WebSSO - 我们需要使用它。由于我无法控制的原因,我无法直接从AngularJS直接调用Filenet REST。相反,我需要创建自己的REST接口(WebLogic上的Java Jersey) - 让我们将此接口称为façadeREST。 AngularJS代码调用façadeREST,而façadeREST实现依次调用Filenet REST。当我使用应用程序帐户(或系统帐户或匿名帐户)时,一切都很顺利。但是,我需要提高标准并实施WebSSO(我们不能使用应用程序帐户或基本身份验证)。注意:
以下是我设想它将如何运作以及随后的查询。
1) The AngularJS makes a call to façade REST
2) Façade REST makes a call to Filenet REST
2.2) Filenet REST, upon finding that the WebSSO cookie is absent, redirects the caller to WebSSO login page (this is evident in the code that I have developed so far).
2.2) From façade, do I need to redirect the browser to this login page? I haven’t tried this yet. If I redirected the browser to login page, how would the browser then know that, after seamless and successful login, it should get back to my façade REST?
重复上述第2.2点:
答案 0 :(得分:0)
虽然看似复杂,但解决方案却相对简单直接。这就是我必须要做的事情:
以下是代码(删除了不相关的部分):
@POST
@Path("/upload")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response upload(@CookieParam("CTSESSION") Cookie ctSessionCookie) {
// Get the CTSESSION cookie value
String ctSession = ctSessionCookie.getValue();
// Initialize Apache HTTPClient and pass the obtained cookie as a header
HttpPost request = new HttpPost("FileNet.REST.URL");
request.addHeader("Cookie", "CTSESSION=" + ctSession);
CloseableHttpClient client = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build();
CloseableHttpResponse result = client.execute(request);
// Obtain the result, construct Jersey Response, and send it out to the original caller
Response.ok(result.toString()).build();
}