如何使用 Java 重定向到 Pentaho 用户控制台?
我在服务器上运行 Pentaho。在另一台服务器上,我正在运行一个 Struts 1 应用程序。
我想要做的是提供 Pentaho 用户控制台的链接 (http://myserver/pentaho/Home
)。然而,这需要身份验证。
我可以在 URL 字符串中传递用户名/密码,它工作得很好。但显然,这会暴露 URL 中的密码。
有关如何执行此操作的任何线索?以下代码显示了我如何做到这一点并转储输出(通过 PrintWriter),但它要求 pentaho 源位于本地。
感谢您的任何帮助。
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HttpClient client = new HttpClient();
PostMethod method = new PostMethod("http://myserver/pentaho/Home");
method.addParameter("userid", "moe.howard");
method.addParameter("password", "password");
int status = client.executeMethod(method);
PrintWriter out = response.getWriter();
out.print(method.getResponseBodyAsString());
out.flush();
out.close();
return mapping.findForward(SUCCESS);
}
I have Pentaho running on a server. On a different server, I have a Struts 1 app running.
What I want to do is provide a link to the User Console of Pentaho (http://myserver/pentaho/Home
). However, this requires authentication.
I can pass the user/pass in the URL string and it works just fine. But obviously, this exposes the password in the URL.
Any clues on how to do this? The following code show how I was able to do it and dump the output (via an PrintWriter) but it requires the pentaho source to be local.
Thanks for any help.
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HttpClient client = new HttpClient();
PostMethod method = new PostMethod("http://myserver/pentaho/Home");
method.addParameter("userid", "moe.howard");
method.addParameter("password", "password");
int status = client.executeMethod(method);
PrintWriter out = response.getWriter();
out.print(method.getResponseBodyAsString());
out.flush();
out.close();
return mapping.findForward(SUCCESS);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于找到解决办法了。我最终在 Pentaho 服务器上创建了一个 redirect.jsp 文件。然后,我将加密的 http 身份验证令牌传递给它,解密它,然后重定向到登录。效果很好。
编辑
确实是老问题,但我被要求提供有关我的解决方案的更多信息。所以就这样吧。
首先,Pentaho 的默认安装使用
HTTP 基本身份验证 (BA)
。如果您使用单点登录或 LDAP 解决方案,这可能不适合您。所以我所做的就是在
..tomcat\webapps\ROOT
下的ROOT
文件夹中放置一个JSP
文件。该 JSP 获取传入的登录信息并对其进行解密。该登录信息只是一个经过 BASE64 身份验证的请求。无论如何,这都不是超级安全的。但它允许我做的是从一台服务器发送加密的用户/密码并将其传递到另一台服务器。当然,如果您一直使用 SSL,那么这可能不需要,但我们遇到的情况是信息在内部以明文形式传递。因此,它从未暴露于外部,但我仍然想确保我们的内部服务器尽可能安全。
JSP:
因此,我的登录服务器根据 Pentaho 使用的相同 MySQL 数据库对用户进行身份验证,创建经过身份验证的 (BA) 请求(BASE64),使用相同的 MY-SECRET-PASSWORD 对其进行加密并发送该请求到 JSP。然后 JSP 对其进行解密并读取 BA 标头并将其传递给 Pentaho。
对我们来说效果很好。
希望它能帮助别人。
Finally found a solution. I ended up creating a redirect.jsp file on the Pentaho server. Then, I passed an encrypted http auth token to it, decrypted it, and then redirected to the login. Works great.
EDIT
Really old question but I was asked to provide more information on my solution. So here goes.
First, the default install of Pentaho used
HTTP Basic Authentication (BA)
. If you're using a single sign-on or LDAP solution this might not work for you.So what I did was put a
JSP
file in theROOT
folder under..tomcat\webapps\ROOT
. That JSP takes the passed in login information and de-crypts it. That login information is just aBASE64
authenticated request.This isn't super secure, by any means. But what it allowed me to do was send an encrypted user/pass from one server and pass it to another server. Of course, if you're SSL all the way then this probably isn't needed but we had a situation where the information was being passed in clear text INTERNALLY. So, it was never exposed to the outside but I still wanted to make sure our internal servers are as secure as possible.
The JSP:
So, my login server authenticates the user against the same MySQL database Pentaho uses, creates the authenticated (BA) request, BASE64's it, encrypts it using the same
MY-SECRET-PASSWORD
and sends that to the JSP. The JSP then de-crypts it and reads the BA header and passes that on to Pentaho.Works great for us.
Hope it helps someone out.