我有一個SOAP Web服務,其中包含一堆不同的操作。我試圖阻止所有用戶都可以訪問它們。我試圖通過編輯web.xml文件安全約束來實現這一點。防止用戶訪問每個wsdl元素
可以說我的服務有操作1,2和3.我有user1和user2。我希望user1能夠訪問1,2和3. user2應該只能訪問3.我使用不同的角色設置了兩個安全約束。
<security-constraint>
<web-resource-collection>
<web-resource-name>SOAP Service</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>user1</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>SOAP Service</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>user2</role-name>
</auth-constraint>
</security-constraint>
這工作得很好,並同時允許user1和user2訪問一切由WSDL暴露,然後我試圖進一步限制哪些用戶2可以通過改變url-pattern的事。
<security-constraint>
<web-resource-collection>
<web-resource-name>SOAP Service</web-resource-name>
<url-pattern>/3/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>user2</role-name>
</auth-constraint>
</security-constraint>
不幸的是,這是行不通的。我被告知這是因爲它是一個肥皂請求,所有請求都在同一個網址上?所以我現在卡住了。允許某些用戶只能訪問wsdl的一部分的最佳方法是什麼?