第四十一章 创建安全对话 - 使用 SecurityContextToken

文章目录

  • [第四十一章 创建安全对话 - 使用 <SecurityContextToken>](#第四十一章 创建安全对话 - 使用 <SecurityContextToken>)
  • 结束安全对话

第四十一章 创建安全对话 - 使用

Web 服务使用 <SecurityContextToken>, 做出响应后,客户端实例和服务实例可以访问相同的对称密钥。有关此密钥的信息包含在两个实例的 SecurityContextToken 属性中。建议的程序如下:

  1. 在客户端中,将 SecurityOut 属性设置为 null,以删除请求消息中使用的安全标头。

Web 服务中不需要这样做,因为 Web 服务会在每次调用后自动清除安全标头。

  1. (可选)将 <SecurityContextToken> 添加到 WS-Security 标头元素。为此,请调用 Web 客户端或 Web 服务的 SecurityOut 属性的 AddSecurityElement() 方法。例如:
java 复制代码
 set SCT=..SecurityContextToken
 do ..SecurityOut.AddSecurityElement(SCT)

如果在下一步创建派生密钥令牌时使用 $$$SOAPWSReferenceSCT 引用选项,则此步骤是必需的。否则,此步骤不是必需的。

  1. 根据 <SecurityContextToken>创建一个新的 <DerivedKeyToken> 。为此,调用 %SOAP.WSSC.DerivedKeyTokenCreate() 方法,如下所示:
java 复制代码
 set dkenc=##class(%SOAP.WSSC.DerivedKeyToken).Create(SCT,refOpt)

在这种情况下,必须指定 Create() 的第一个参数,并且 refOpt 必须是以下参考值之一:

  • $$$SOAPWSReferenceSCT(本地引用)--- 引用的 URI 属性以 # 开头,指向 <SecurityContextToken>元素的 wsu:Id 值,该值必须包含在消息中。
  • $$$SOAPWSReferenceSCTIdentifier(远程引用)------引用的 URI 属性包含 <SecurityContextToken> 元素的 <Identifier> 值,该值不必包含在消息中。
java 复制代码
 set dkenc=##class(%SOAP.WSSC.DerivedKeyToken).Create(SCT,$$$SOAPWSReferenceSCT)
  1. 使用新的 <DerivedKeyToken> 来指定安全标头。请参阅使用派生密钥令牌进行加密和签名。
  2. 发送 SOAP 消息。请参阅添加安全标头元素中的一般注释。
java 复制代码
  //initiate conversation -- not shown here
  //clear SecurityOut so that we can respecify the security header elements for
  //the secure conversation
  set client.SecurityOut=""

  //get SecurityContextToken
  set SCT=client.SecurityContextToken
  do client.SecurityOut.AddSecurityElement(SCT) 

  // get derived keys
  set dksig=##class(%SOAP.WSSC.DerivedKeyToken).Create(SCT,$$$SOAPWSReferenceSCT)
  do client.SecurityOut.AddSecurityElement(dksig)

  // create and add signature
  set sig=##class(%XML.Security.Signature).Create(dksig,,$$$SOAPWSReferenceDerivedKey)
  do client.SecurityOut.AddSecurityElement(sig) 

  
  //invoke web methods

结束安全对话

一旦 <SecurityContextToken> 过期,安全对话就会结束,但 Web 客户端也可以通过取消未过期的 <SecurityContextToken>来结束它。

要结束安全对话,请调用 Web 客户端的 CancelSecureConversation() 方法。例如:

java 复制代码
 set status=client.CancelSecureConversation()

该方法返回一个状态值。

请注意,此方法将客户端的 SecurityOut 属性设置为空字符串。

相关推荐
Web极客码6 小时前
如何轻松、安全地管理密码(新手指南)
计算机网络·安全·web安全·网络安全
安全系统学习7 小时前
【网络安全】Qt免杀样本分析
java·网络·安全·web安全·系统安全
Bruce_Liuxiaowei7 小时前
文件上传漏洞深度解析:检测与绕过技术矩阵
安全·矩阵·文件上传漏洞
CYRUS STUDIO8 小时前
FART 脱壳某大厂 App + CodeItem 修复 dex + 反编译还原源码
android·安全·逆向·app加固·fart·脱壳
SilentCodeY9 小时前
Ubuntu 系统通过防火墙管控 Docker 容器
linux·安全·ubuntu·系统防火墙
海天胜景11 小时前
Delphi SetFileSecurity 设置安全描述符
安全
阿部多瑞 ABU11 小时前
# 从底层架构到应用实践:为何部分大模型在越狱攻击下失守?
gpt·安全·ai·自然语言处理
KKKlucifer11 小时前
从边界防护到内生安全:企业网络安全进化路线图
安全·web安全
Kjjia11 小时前
将内容明文存储在indexDB后,被指着鼻子骂道赶紧把数据隐藏...
前端·安全
WhoisXMLAPI13 小时前
利用 DNS 情报缓解报税季的网络威胁
运维·网络·安全·web安全