惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - Benny Ng

微软企业库Enterprise Library 5连接AS/400 UDB DB2的连接方法. (成功) 我可以在ASP.NET MVC的真正發展為免費的嗎?[转贴] SQL-记录表历史[转] 转自:http://www.cnblogs.com/codelove/archive/2011/07/02/2096296.html (自用,备份) WINXP下安装IIS+PHP5+MySQL5 64位Windows 7 sp1使用MyEclipse 9.0注册机无法获取System ID 配置JDK环境变量 vs2010 sp1 安装假死的问题解决,先把ISO文件内的可以安装的EXE文件都安装一次,特别是SILVERLIGHT那些,然后再安装ISO的SETUP就可以了。 SQL Server 2008支持将数据导出为脚本 [转] CD %systemroot%\system32\Inetsrv\ appcmd list wp - Benny Ng SQL SERVER – Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database ‘yourdatabasename’. CREATE DATA Server 2005 专用管理员连接 (DAC) 使用技巧 只有MDF文件如何恢复数据库 在win7的操作系统下安装Oracle11R2 Comparing escape(), encodeURI(), and encodeURIComponent() <a href='#' => <a href='javascript:void(-1) 页面不跳转到最高处。 “页面跳转”。 sql 条件处理 SSRS (Reporting Services) 2008 当导出PDF看不到中文字的时候,是没有安装SQL2008 SP1的原因。(可能会显示框,或者字符显示不完整) Visual Studio 2010 Extension Manager: Online Gallery Behind Internet Proxy 配置windows 2008 作为远程访问SSL-VPN服务器系列之一 - Benny Ng
Web Service 安全性解决方案(SOAP篇)
Benny Ng · 2010-11-24 · via 博客园 - Benny Ng

文/flyingfox  出处/博客园

闲着没事,研究了一下Web Service的安全性解决方法. 通过SOAP的头信息,通过使用帐号与PIN实现访问Web Method的安全校验.这是一个简便的好方法. 
解决方法:配置SOAP头信息,并将Token的ID和PIN写入头信息作为访问Web服务的钥匙。

    步骤如下:

1)      建立类Credentials,用来作为Token的验证

继承于System.Web.Services.Protocols.SoapHeader.

代码如下:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services.Protocols;

/**//// <summary>
/// SeviceHelper 的摘要说明
/// </summary>
public class Credentials:System.Web.Services.Protocols.SoapHeader 
{
    public string AccountID;
    public string PIN;
}

  
2)      建立带有SOAP头信息的Web服务

并定义public Credentials token;

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
/**//// <summary>
/// myWebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/";)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class myWebService : System.Web.Services.WebService {

    public myWebService () {}
    public Credentials token;
    [WebMethod(Description = "建立带有SOAP头信息的Web服务")]
    [SoapHeader("token",Direction =SoapHeaderDirection.In)]
    public string GetAccount(string yourname) 
    {
        string myname = yourname;
        if (token.AccountID == "12345" && token.PIN == "abcde")
        {
            return "myname is " + myname + ",account:abcde12345";
        }
        else
            throw new ApplicationException("Authentication Failed!");
            //return "nothing_string";
    }
}

  
3)      调用Web服务

代码如下:

protected void btnGet_Click(object sender, EventArgs e)
{
localhost.myWebService mws;
        mws=new localhost.myWebService();
        localhost.Credentials token = new localhost.Credentials();
        token.AccountID = this.txtAccount.Text;
        token.PIN = this.txtPIN.Text;
        mws.CredentialsValue = token;
        try
        {
            this.txtResult.Text= mws.GetAccount(txtName.Text);
        }
        catch (System.Exception ex)
        {
            this.txtResult.Text = ex.Message;
        }
    }