加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java WSDL修改或隐藏Web View上的某些属性

发布时间:2020-12-15 02:20:13 所属栏目:Java 来源:网络整理
导读:TLDR是否有可能在有人阅读时为IP地址(例如0.0.0.0:8080/services as SERVER_1)或WSDL内容上的任何其他属性创建“别名”?相近: entry key="org.apache.cxf.endpoint.private" value="true"/ 对于服务列表,它保持功能完整但隐藏服务列表. 如果有,怎么样?如
TLDR是否有可能在有人阅读时为IP地址(例如0.0.0.0:8080/services as SERVER_1)或WSDL内容上的任何其他属性创建“别名”?相近:

<entry key="org.apache.cxf.endpoint.private" value="true"/>

对于服务列表,它保持功能完整但隐藏服务列表.

如果有,怎么样?如果没有,有没有办法隐藏它而不使用@XmlTransient,因为如果我们使用它,并且从我的理解,程序甚至不会映射这个元素,因此不再工作.

我正在使用Spring和JAX-RS处理SOAP服务.

在进行道德黑客测试后,我们正在保护我们的应用程序,结果是我们在URL上公开了服务和生产IP地址.

我们能够从Web视图中隐藏服务列表,例如,如果我们访问http:// localhost:8080 / foo / services,我们会收到以下文本:

No services have been found.

这很好,我们通过遵循this answer来完成它,但它不是在cxf-servlet.xml文件上,而是在applicationContext- {moduleName} .xml文件中.

现在,如果我们知道或有权访问任何WSDL路径,我们仍然可以看到WSDL内容(包括生产IP地址),如果我们输入:

http://localhost:8080/foo/services/bar?_wsdl

我们有类似的定义如下(出于安全原因我编辑了它):

<application
    xmlns="http://wsdl.dev.java.net/2009/02"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <grammars/>
    <resources base="http://localhost:8080/foo/services/bar">
        <resource path="/VX">
            <resource path="/anotherPath">
                <method name="POST">
                    <request>
                        <representation mediaType="application/x-www-form-urlencoded">
                            <param name="someParam" style="query" type="xs:string"/>
                        </representation>
                    </request>
                    <response>
                        <representation mediaType="application/json">
                            <param name="anotherParam" style="plain" type="xs:string"/>
                        </representation>
                    </response>
                </method>
            </resource>
        </resource>
    </resources>
</application>

我怎么能,例如在运行时编辑属性

<resources base="http://localhost:8080/foo/services/bar">

喜欢的东西

<resources base="SERVER_1">

那么,我们内部知道SERVER_1有什么IP地址,但是那些设法到达那里的人没有,换句话说,我怎么能为IP地址创建一个别名并使用它而不是真正的IP地址呢?

这是因为我们有大约10台服务器,每台服务器都有不同的IP地址,如果我们需要进行一些生产调试,我们需要知道我们所在的服务器,所以我们希望避免隐藏整个WSDL内容(因为我知道它可以完成,因为模块具有这种配置).

我知道我可以使用@XmlTransient注释,但是根据docs:

Prevents the mapping of a JavaBean property/type to XML representation.

所以,根据我的理解,如果我在包含IP地址的属性上使用此注释,那么它将不再有效.

如果这是不可能的,那么为了解决这个特殊情况你会有哪些其他的建议?

我们使用自上而下的方法创建服务(即我们获得了WSDL,我们使用wsdl2java从中创建Java Objects服务接口)

解决方法

TLDR:使用DNS为您的IP地址分配名称.

We’re securing our apps,after an ethical hacking test,the results
thrown that we were exposing services and production IP addresses on
our URLs

你有一个SOAP服务.要使用它,需要知道端点的地址.因此无论如何你都会“暴露”它.不建议使用Security through obscurity.

So,we internally know what IP address does SERVER_1 has,but people
outside that manage to get there doesn’t,in other words how could I
create an alias for the IP address and use it instead of the real ip
address on it?

这就是DNS的发明之处. IP地址的“别名”.将IP地址用于服务是不好的做法.因此,设置DNS(或使用主机文件)为每个IP地址分配一个名称.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读