没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
http://cxf.apache.org/docs/soap-12.html
实现Webservice 中Soap Header 的用户验证
SoapHeader 中结构如下
view plaincopy to clipboardprint?
<soap:header>
<authentication></authentication>
<userorgid></userorgid>UserOrgID
<userid></userid>Hubs1
<userpsw></userpsw>password
soap:header>
采用Handler 处理链 来拦截SOAP Message 进行验证
代码实现:
view plaincopy to clipboardprint?
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
实现Webservice 中Soap Header 的用户验证
SoapHeader 中结构如下
view plaincopy to clipboardprint?
<soap:header>
<authentication></authentication>
<userorgid></userorgid>UserOrgID
<userid></userid>Hubs1
<userpsw></userpsw>password
soap:header>
采用Handler 处理链 来拦截SOAP Message 进行验证
代码实现:
view plaincopy to clipboardprint?
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* AuthenticationHandler.java
*
* @author waterborn
*/
public class AuthenticationHandler implements SOAPHandler<soapmessagecontext></soapmessagecontext> {
private static final Log log = LogFactory.getLog(AuthenticationHandler.class);
private boolean checkAuthentication(String userOrgID, String userID, String userPSW) {
log.debug("checkAuthentication : userOrgID=" + userOrgID + " , userID=" + userID + " , userPSW=" + userPSW);
boolean check = false;
if ("Hubs1".equals(userID) && "password".equals(userPSW)) {
check = true;
}
return check;
}
@SuppressWarnings("unchecked")
public boolean handleMessage(SOAPMessageContext messageContext) {
log.debug("LoggingHandler : handleMessage Called....");
Boolean outboundProperty = (Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (!outboundProperty) { // InBound Message
String userOrgID = "";
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* AuthenticationHandler.java
*
* @author waterborn
*/
public class AuthenticationHandler implements SOAPHandler<soapmessagecontext></soapmessagecontext> {
private static final Log log = LogFactory.getLog(AuthenticationHandler.class);
private boolean checkAuthentication(String userOrgID, String userID, String userPSW) {
log.debug("checkAuthentication : userOrgID=" + userOrgID + " , userID=" + userID + " , userPSW=" + userPSW);
boolean check = false;
if ("Hubs1".equals(userID) && "password".equals(userPSW)) {
check = true;
}
return check;
}
@SuppressWarnings("unchecked")
public boolean handleMessage(SOAPMessageContext messageContext) {
log.debug("LoggingHandler : handleMessage Called....");
Boolean outboundProperty = (Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (!outboundProperty) { // InBound Message
String userOrgID = "";
剩余15页未读,继续阅读
codeyell-com
- 粉丝: 88
- 资源: 71
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页