Wicket会话和Jersey REST Web服务 [英] Wicket Session and Jersey REST webservice

查看:153
本文介绍了Wicket会话和Jersey REST Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在为PACS查看器开发REST Web服务(医学图像).该Web服务需要具有加密/模糊的参数,以确保用户不能混淆参数以从其他患者那里获取数据.

Currently I'm developing an REST webservice for an PACS viewer (medical images). This webservice needs to have encrypted/obfuscated parameters to ensure users cant fuzz with the parameters to get data from other patients.

在Wicket面板中设置会话属性:

In an Wicket panel im setting an Session attribute:

wicketSession.setAttribute("study", studyInstanceUID);

我想访问Jersey网络服务中的此属性,但是会话在我的Jersey网络服务中不包含任何属性.似乎没有注入或检索?而是创建一个新的?客户端发送的具有当前会话ID的会话.

I want to access this attribute in the Jersey webservice, but the session doesn't contain any attributes in my jersey webservice. It seems like it is not injected or retrieved? Instead of that it creates a new? session with the current SessionID sent from the client.

我为jersey网络服务创建了一个过滤器和映射器:

I've created an filter and mapper for the jersey webservice:

<filter-mapping>
    <filter-name>WicketSessionFilter</filter-name>
    <url-pattern>/pacsviewer/*</url-pattern>
</filter-mapping>

但这似乎没有什么区别?我认为我在对Web服务的注入或状态做错了什么?

But this doesn't seem to make any difference? I think I'm doing something wrong with the injection or state of the webservice?

推荐答案

如果编写自己的过滤器,则可以在基础HttpSession中读取与Wicket会话相对应的对象,该对象位于"wicket:$ {filterName}:session"下将以下内容放入web.xml

If you write your own filter you can read in the underlying HttpSession the object corresponding to your Wicket Session is located under the "wicket:${filterName}:session" attribute when you put the following in your web.xml

<filter>
    <filter-name>SessionFilter</filter-name>
    <filter-class>org.apache.wicket.protocol.http.servlet.WicketSessionFilter</filter-class>
    <init-param>
        <param-name>filterName</param-name>
        <!-- expose the session of the input example app -->
        <param-value>wicket.Main</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>SessionFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

然后,您可以在自己的过滤器中获取带有以下Java代码的Wicket Session对象(例如,添加空检查和其他样板代码):

Then you can get the Wicket Session object with the following Java code in your own filter for example (add null checks and other boilerplate code):

 HttpSession session = httpRequest.getSession(false);
 WebSession wicketSession = session.getAttribute("wicket:wicket.Main:session");
 //do whatever you want with this
 //I think a wicketSession.getAttribute("study")

这篇关于Wicket会话和Jersey REST Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆