[英]How to secure a sun-jaxws java web service inside the webapp xml config files
我有一個sun-jaxws xml Web服務:
package com.myWebservices.ws;
import java.*;
import javax.*;
@WebService
public class GetSomeInfo{
//allow IP to consume web service
private static final String IP = "192.168.0.1";
@Resource
WebServiceContext wsContext;
@WebMethod(operationName="getSomeInfo")
public String getSomeInfo(String data) {
MessageContext mc = wsContext.getMessageContext();
HttpServletRequest req = (HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST);
//control access by IP inside the web service code
if (!(req.getRemoteAddr().equals(IP)))
result = "ACCESS DENIED";
else
String result = bean.executeSomeProcess(data);
return result
}
}
如您所見,Web服務受IP訪問保護。 但是,Web服務具有公共訪問權限,即使您不僅僅通過“訪問拒絕”獲得信息,也可以使用它。
我想知道是否可以在自己的webapp xml文件配置(WEB-INF / sun-jaxws.xml,web.xml,META-IN / context.xml或其他任何內容)中配置Web服務。保護IP訪問,它將自動拒絕對不是同一授權IP的Web服務的任何訪問,甚至沒有人可以使用該Web服務。
編輯:添加信息:
我真正需要知道的是是否可以為JAX-RS過濾器配置web.xml文件並獲得IP保護訪問。
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.