jax-rs Web服务:如何隐藏某些实体字段并使用SSL [英] jax-rs web service: how to hide some entity fields and use SSL

查看:52
本文介绍了jax-rs Web服务:如何隐藏某些实体字段并使用SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我在这里问了一些有关Web服务的问题

Recently I asked some questions here about web services

如何使用Web服务保护数据库?

Glassfish:部署多个应用程序,其中一些使用SSL

,但根本找不到答案 这次我将尝试更加具体,希望能找到一些帮助...

but didn't find answers at all This time I will try to be more specific hoping to find some help...

我使用向导从Netbeans中创建了一个简单的Web服务,该向导从数据库表中创建了Web服务.该向导将创建一个持久性单元,实体类并使用JPA. 宁静的Web服务是使用jax-rs创建的,我检查了使用Jersey默认值",这导致了web.xml文件的创建. 它可以工作,但是在数据库表中我需要过滤一些字段,但是我不想报告给客户端:如何将它们隐藏在由宁静的Web服务生成的xml/json中?

I created a simple web service in Netbeans using the wizard which creates a web service from a Database table. The wizard creates a persistence unit, entity classes and uses JPA. The restful web service is created using jax-rs and I checked "Use Jersey default" which caused the creation of a web.xml file. It works but in the database table there are some fields I need for filtering but I don't want reported to the client: how can I hide them in the xml/json produced by the restful web service ?

如何强制使用SSL?

我试图放

<transport-guarantee>CONFIDENTIAL</transport-guarantee>

在web.xml中,它强制使用SSL,但响应不相同,它不是xml/json,但仅包含实体字段的值的串联.此外,某些带有路径参数的URI根本不起作用.我想念什么?

in web.xml, it forces SSL but the response is not the same, it is not xml/json but it contains only the concatenation of the values of the entities ' fields. Besides some URI with path parameters don't work at all. What am I missing ?

谢谢 菲利波

有关SSL的更新

我做了更多检查,使用Firefox时,使用SSL得到了有效的响应,而使用IE9时却得到了奇怪的结果.在那种情况下,强制使用SSL,我得到了一个包含字母数字字符的长字符串.我将尽快在另一台计算机上重复测试.

I made some more checks and using Firefox I got valid responses using SSL, while I get weird results with IE9. In that case forcing to use SSL I got a single long string with alphanumeric characters. As soon as possible I'm going to repeat the test on another computer.

推荐答案

由于您使用的是Jersey,因此您应该拥有Jackson. Jackson帮助处理实体-> JSON和JSON->实体解析.

Since you're using Jersey you should have Jackson along with that. Jackson helps working with entity -> JSON and JSON -> entity parsing.

您正在寻找一个名为

@JsonIgnore

然后您要将其放在要从输出中遮盖的成员的"getter"方法上.

And you'll want to put that on the 'getter' method of the member you wish to obscure from the output.

来源: http://jackson.codehaus.org/

这篇关于jax-rs Web服务:如何隐藏某些实体字段并使用SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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