第三十三章 使用派生密钥令牌进行加密和签名 - 使用 DerivedKeyToken _进行加密(一)
文章目录
- 第三十三章 使用派生密钥令牌进行加密和签名 - 使用 <DerivedKeyToken>
第三十三章 使用派生密钥令牌进行加密和签名 - 使用
进行加密(一)
- 如果加密了任何安全标头元素,请将它们添加到
WS-Security标头元素中。为此,请调用Web客户端或Web服务的SecurityOut属性的AddSecurityElement()方法。在这种情况下,需要两个参数:
a. 安全标头元素(而不是从中生成的的 %XML.Security.EncryptedData)。
b. 引用列表实例。第二个参数指定将第一个参数指定的项目放在何处。如果参数是 A、B,则 IRIS 确保 A 在 B 之后。指定此项以便收件人首先处理引用列表,然后再处理依赖于它的加密安全标头元素。
do client.SecurityOut.AddSecurityElement(userToken,reflist)
如果仅加密了 SOAP 主体,系统会自动将 <EncryptedData> 元素作为 <Body>的子元素。
- 发送
SOAP消息。请参阅添加安全标头元素中的一般注释。
例如,以下客户端代码对 SOAP 主体和 <UsernameToken>进行加密:
// Create UsernameTokenset userToken=##class(%SOAP.Security.UsernameToken).Create("_SYSTEM","SYS")// get credentials for encryptionset cred = ##class(%SYS.X509Credentials).GetByAlias("servercred") // get EncryptedKey element to encrypt <UsernameToken)// $$$SOAPWSEncryptNone means that this key does not encrypt the bodyset enckey=##class(%XML.Security.EncryptedKey).CreateX509(cred,$$$SOAPWSEncryptNone)//add to WS-Security Headerdo client.SecurityOut.AddSecurityElement(enckey)// get derived key to use for encryption// second argument specifies how the derived key // refers to the key on which it is basedset dkenc=##class(%SOAP.WSSC.DerivedKeyToken).Create(enckey,$$$SOAPWSReferenceEncryptedKey)//add to WS-Security Headerdo client.SecurityOut.AddSecurityElement(dkenc)// create <EncryptedData> element to contain <UserToken>set encdata=##class(%XML.Security.EncryptedData).Create(dkenc,userToken,$$$SOAPWSReferenceDerivedKey)// create <EncryptedData> element to contain SOAP bodyset encdata2=##class(%XML.Security.EncryptedData).Create(dkenc,"",$$$SOAPWSReferenceDerivedKey)// create <ReferenceList> with <DataReference> elements that// point to these two <EncryptedData> elementsset reflist=##class(%XML.Security.ReferenceList).%New()set dataref=##class(%XML.Security.DataReference).Create(encdata)do reflist.AddReference(dataref)set dataref2=##class(%XML.Security.DataReference).Create(encdata2)do reflist.AddReference(dataref2)// add <ReferenceList> to WS-Security headerdo client.SecurityOut.AddSecurityElement(reflist)// add encrypted <UserName> to security header;// 2nd argument specifies positiondo client.SecurityOut.AddSecurityElement(userToken,reflist)// encrypted SOAP body is handled automatically
客户端发送如下消息:
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope [parts omitted]><SOAP-ENV:Header><Security xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd"><EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#" Id="Id-658202BF-239A-4A8C-A100-BB25579F366B"><EncryptionMethod Algorithm="[parts omitted]#rsa-oaep-mgf1p"><DigestMethod xmlns="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod></EncryptionMethod><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><SecurityTokenReference xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd"><KeyIdentifier EncodingType="[parts omitted]#Base64Binary" ValueType="[parts omitted]#ThumbprintSHA1">5afOHv1w7WSXwDyz6F3WdM1r6cM=</KeyIdentifier></SecurityTokenReference></KeyInfo><CipherData><CipherValue>tFeKrZKw[parts omitted]r+bx7KQ==</CipherValue></CipherData></EncryptedKey><DerivedKeyToken xmlns="[parts omitted]ws-secureconversation/200512" xmlns:wsc="[parts omitted]ws-secureconversation/200512" wsu:Id="Enc-943C6673-E3F3-48E4-AA24-A7F82CCF6511"><SecurityTokenReference xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd"><Reference URI="#Id-658202BF-239A-4A8C-A100-BB25579F366B"></Reference></SecurityTokenReference><Nonce>GbjRvVNrPtHs0zo/w9Ne0w==</Nonce></DerivedKeyToken><ReferenceList xmlns="http://www.w3.org/2001/04/xmlenc#"><DataReference URI="#Enc-358FB189-81B3-465D-AFEC-BC28A92B179C"></DataReference><DataReference URI="#Enc-9EF5CCE4-CF43-407F-921D-931B5159672D"></DataReference></ReferenceList><EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Id="Enc-358FB189-81B3-465D-AFEC-BC28A92B179C" Type="http://www.w3.org/2001/04/xmlenc#Element"><EncryptionMethod Algorithm="[parts omitted]#aes256-cbc"></EncryptionMethod><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><SecurityTokenReference xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd"><Reference URI="#Enc-943C6673-E3F3-48E4-AA24-A7F82CCF6511"></Reference></SecurityTokenReference></KeyInfo><CipherData><CipherValue>e4//6aWGqo1dIQ7ZAF[parts omitted]KZcj99N78A==</CipherValue></CipherData></EncryptedData></Security></SOAP-ENV:Header><SOAP-ENV:Body><EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Id="Enc-9EF5CCE4-CF43-407F-921D-931B5159672D" Type="http://www.w3.org/2001/04/xmlenc#Content"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></EncryptionMethod><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><SecurityTokenReference xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd"><Reference URI="#Enc-943C6673-E3F3-48E4-AA24-A7F82CCF6511"></Reference></SecurityTokenReference></KeyInfo><CipherData><CipherValue>Q3XxuNjSan[parts omitted]x9AD7brM4</CipherValue></CipherData></EncryptedData></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
再举一个例子,以下 Web 服务在入站消息中接收 <EncryptedKey> ,并使用它来生成 <DerivedKeyToken> ,用于加密响应的各个部分:
// create <DerivedKeyToken> based on first <EncryptedKey> in inbound message;// refer to it with SHA1 thumbprintset refopt=$$$SOAPWSReferenceEncryptedKeySHA1set dkenc=##class(%SOAP.WSSC.DerivedKeyToken).Create(,refopt)do ..SecurityOut.AddSecurityElement(dkenc)// create <EncryptedData> element to contain SOAP bodyset encdata=##class(%XML.Security.EncryptedData).Create(dkenc,"",$$$SOAPWSReferenceDerivedKey)// create <ReferenceList> with <DataReference> elements that// point to the <EncryptedData> elementsset reflist=##class(%XML.Security.ReferenceList).%New()set dataref=##class(%XML.Security.DataReference).Create(encdata)do reflist.AddReference(dataref)// add <ReferenceList> to WS-Security headerdo ..SecurityOut.AddSecurityElement(reflist)
该 Web 服务发送如下消息:
<SOAP-ENV:Envelope [parts omitted]> <SOAP-ENV:Header><Security xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd"><DerivedKeyToken xmlns="[parts omitted]ws-secureconversation/200512" xmlns:wsc="[parts omitted]ws-secureconversation/200512" wsu:Id="Enc-D69085A9-9608-472D-85F3-44031586AB35"><SecurityTokenReference xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd" s01:TokenType="[parts omitted]#EncryptedKey" xmlns:s01="h[parts omitted]oasis-wss-wssecurity-secext-1.1.xsd"><KeyIdentifier EncodingType="[parts omitted]#Base64Binary" [parts omitted]#EncryptedKeySHA1">U8CEWXdUPsIk/r8JT+2KdwU/gSw=</KeyIdentifier></SecurityTokenReference><Nonce>nJWyIJUcXXLd4k1tbNg10w==</Nonce></DerivedKeyToken><ReferenceList xmlns="http://www.w3.org/2001/04/xmlenc#"><DataReference URI="#Enc-0FF09175-B594-4198-9850-57D40EB66DC3"></DataReference></ReferenceList></Security> </SOAP-ENV:Header> <SOAP-ENV:Body><EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Id="Enc-0FF09175-B594-4198-9850-57D40EB66DC3" Type="http://www.w3.org/2001/04/xmlenc#Content"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></EncryptionMethod><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><SecurityTokenReference xmlns="[parts omitted]oasis-200401-wss-wssecurity-secext-1.0.xsd"><Reference URI="#Enc-D69085A9-9608-472D-85F3-44031586AB35"></Reference></SecurityTokenReference></KeyInfo><CipherData><CipherValue>NzI94WnuQU4uBO[parts omitted]xHZpJSA==</CipherValue></CipherData></EncryptedData></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
相关文章:
第三十三章 使用派生密钥令牌进行加密和签名 - 使用 DerivedKeyToken _进行加密(一)
文章目录 第三十三章 使用派生密钥令牌进行加密和签名 - 使用 <DerivedKeyToken> 第三十三章 使用派生密钥令牌进行加密和签名 - 使用 进行加密(一) 如果加密了任何安全标头元素,请将它们添加到 WS-Security 标头元素中。为此&#…...
Structure-Aware Transformer for Graph Representation Learning
Structure-Aware Transformer for Graph Representation Learning(ICML22) 摘要 Transformer 架构最近在图表示学习中受到越来越多的关注,因为它通过避免严格的结构归纳偏差而仅通过位置编码对图结构进行编码,自然地克服了图神经…...
滚动页面,el-table表头始终置顶
效果如下: 起始状态: 滚动后: 代码地址:代码地址-面包多...
Mac使用gradle编译springboot-2.7.x源码
1 开发环境: JDK8 ideaIU-2024.2.2 gradle-7.6.3 代理网络 2 下载springboot源码 代码仓库网址 git clone -b 2.7.x https://github.com/spring-projects/spring-boot.git3 安装gradle gradle下载网址 https://services.gradle.org/distributions/ 安装此文件指…...
MySQL --索引(下)
文章目录 6.索引操作6.1 创建主键索引6.2 创建唯一索引6.3 创建普通索引6.4 创建全文索引6.5 查询索引6.6 删除索引6.7 索引创建原则6.8 复合索引6.9 索引最左匹配原则6.10 索引覆盖 6.索引操作 6.1 创建主键索引 第一种方式: – 在创建表的时候,直接…...
选择寄宿学校,给自闭症孩子一个温暖的第二家
在寻找适合自闭症孩子成长的道路上,每一个家庭都充满了艰辛与希望。而广州市星贝育园康复中心,以其独特的全托寄宿制教育模式,为这些特殊的孩子提供了一个充满爱与关怀的“第二家”。在这里,孩子们不仅能够得到专业的康复训练&…...
大模型训练:K8s 环境中数千节点存储最佳实践
今天这篇博客来自全栈工程师朱唯唯,她在前不久举办的 KubeCon 中国大会上进行了该主题分享。 Kubernetes 已经成为事实的应用编排标准,越来越多的应用在不断的向云原生靠拢。与此同时,人工智能技术的迅速发展,尤其是大型语言模型&…...
【Linux学习】1-2 新建虚拟机ubuntu环境
1.双击打开VMware软件,点击“创建新的虚拟机”,在弹出的中选择“自定义(高级)” 2.点击下一步,自动识别ubuntu光盘映像文件,也可以点击“浏览”手动选择,点击下一步 3.设置名称及密码后…...
ftdi_sio驱动学习笔记 3 - 端口操作
目录 1. ftdi_port_probe 1.1 私有数据结构ftdi_private 1.2 特殊probe处理 1.3 确定FTDI设备类型 1.4 确定最大数据包大小 1.5 设置读取延迟时间 1.6 初始化GPIO 1.6.1 使能GPIO 1.6.2 添加到系统 1.6.2.1 设置GPIO控制器的基本信息 1.6.2.2 设置GPIO控制器的元信息…...
[leetcode]39_组合总和_给定数组且数组可重复
给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的数字可以无限制重复被选取。说明: 所有数字(包括 target)都是正整数。 解集不能包含重复的组合…...
【笔记】第三节 组织与性能
3.1 基本成分 3.2 微观组织特征 0.6-0.8C%碳素钢的组织为珠光体和少量的铁素体。 如何把组织和性能联系起来?德国克虏伯公司的研究——珠光体片间距与渗碳体片层厚度成比例: t s 0 ( ρ 15 ( C % ) − 1 ) ts_0(\frac{\rho}{15(C\%)}-1) ts0(15(C%)…...
数据库——sql语言学习 查找语句
一、什么是sql SQL是结构化查询语言(Structured Query Language)的缩写,它是一种专门为数据库设计的操作命令集,用于管理关系数据库管理系统(RDBMS)。 二、查找相关语句 首先,我们已经设…...
【计算机网络 - 基础问题】每日 3 题(二十三)
✍个人博客:Pandaconda-CSDN博客 📣专栏地址:http://t.csdnimg.cn/fYaBd 📚专栏简介:在这个专栏中,我将会分享 C 面试中常见的面试题给大家~ ❤️如果有收获的话,欢迎点赞👍收藏&…...
JPA + Thymeleaf 增删改查
一、 什么是 Thymeleaf JPA(Java Persistence API):是一种用于对象关系映射(ORM)的 Java 规范,它简化了数据库操作,使开发者可以以面向对象的方式处理数据存储。通过定义实体类和数据访问接口&a…...
Android常用C++特性之std::this_thread
声明:本文内容生成自ChatGPT,目的是为方便大家了解学习作为引用到作者的其他文章中。 std::this_thread 是 C11 标准库中的一个命名空间,提供了一组与当前线程(即调用这些函数的线程)相关的操作。通过 std::this_threa…...
成语700词(31~45组)
目录 31.对待错误的态度(12 个)32.改变与不变(19 个)33.顺势造势(6 个)34.自然会发生(6 个)35.提早准备和补救(11 个)36.办公、管理相关(8 个)37.空谈与虚幻(8 个)38.来者众多(11 个)39.人多热闹(6)40.好坏掺杂(7 个)41.流行与名声(14 个)42.与传播、传闻…...
vue3组件通信(组合式API)
vue3组件通信(组合式API) vue3组件通信,采用组合式API。选项式API,参看官网 Vue3组件通信和Vue2的区别: 移出事件总线,使用mitt代替。 vuex换成了pinia。把.sync优化到了v-model里面了。把$listeners所…...
从预测性维护到智能物流:ARM边缘计算控制器的工业实践
工业4.0时代的到来,边缘计算技术成为连接物理世界与数字世界的桥梁。ARM架构的边缘计算控制器凭借其低功耗、高能效和灵活性等特点,在工业自动化领域展现出巨大潜力。本文将通过几个实际应用案例来探讨ARM边缘计算控制器是如何提升生产线效率和安全性的&…...
2024年汉字小达人区级自由报名备考冲刺:最新问题和官模题练一练
今天是2024年第十一届汉字小达人的区级自由报名活动的第二天。 我们继续回答几个关于汉字小达人的最新问题,做几道2024年官方模拟题,帮助孩子们少走弯路,再冲刺一般,更精准地备考2024年汉字小达人。 【温馨提示】本专题在比赛期…...
Linux相关概念和重要知识点(8)(操作系统、进程的概念)
1.操作系统(OS) (1)基本结构的认识 任何计算机系统都包含一个基本的程序集合,用于实现计算机最基本最底层的操作,这个软件称为操作系统。操作系统大部分使用C语言编写,少量使用汇编语言。 从…...
如何3步搭建AI驱动的多智能体股票分析平台?TradingAgents-CN全指南
如何3步搭建AI驱动的多智能体股票分析平台?TradingAgents-CN全指南 【免费下载链接】TradingAgents-CN 基于多智能体LLM的中文金融交易框架 - TradingAgents中文增强版 项目地址: https://gitcode.com/GitHub_Trending/tr/TradingAgents-CN 面对复杂多变的金…...
音频处理避坑指南:二进制编码转换中的常见问题与解决方案
音频处理避坑指南:二进制编码转换中的常见问题与解决方案 音频处理在现代多媒体应用中扮演着重要角色,从语音识别到音乐制作,从流媒体传输到嵌入式设备音频播放,二进制编码转换都是核心技术环节。对于有一定经验的开发者而言&…...
GLM-5.1 全面支持与 Gemini CLI 集成:HagiCode 的多模型进化之路
GLM-5.1 全面支持与 Gemini CLI 集成:HagiCode 的多模型进化之路 本文介绍了 HagiCode 平台近期的重要更新——智谱 AI GLM-5.1 模型的全面支持,以及 Gemini CLI 作为第十个 Agent CLI 的成功集成。这两项更新进一步强化了平台的多模型能力和多 CLI 生态…...
收藏!小白程序员必看:Agent和工作流是最佳拍档,教你如何协同它们(附案例)
文章探讨了AI智能体(Agent)和工作流工具的关系,指出它们并非竞争对手,而是最佳拍档。Agent擅长自主决策和动态规划,适用于探索性和不确定性任务;工作流则负责流程编排和确定性执行,适用于重复性…...
3个关键步骤:如何用Bilibili-Evolved打造60fps流畅播放体验
3个关键步骤:如何用Bilibili-Evolved打造60fps流畅播放体验 【免费下载链接】Bilibili-Evolved 强大的哔哩哔哩增强脚本 项目地址: https://gitcode.com/gh_mirrors/bi/Bilibili-Evolved Bilibili-Evolved作为一款强大的哔哩哔哩增强脚本,为追求极…...
2026年实测10款降AI工具:毕业论文降AIGC哪款最靠谱?
2026年毕业季临近,降低论文AI生成痕迹、通过学校AIGC检测已经成为所有毕业生的必过关卡。但当前降AI工具市场鱼龙混杂:不少用户花了高价处理,AI率却纹丝不动;还有的工具改完的论文语句生硬、逻辑混乱,反而过不了答辩。…...
智能抢票系统:从技术实现到场景落地
智能抢票系统:从技术实现到场景落地 【免费下载链接】Automatic_ticket_purchase 大麦网抢票脚本 项目地址: https://gitcode.com/GitHub_Trending/au/Automatic_ticket_purchase 你是否曾遇到这样的场景:苦等数月的演唱会门票在开票瞬间售罄&…...
郭老师-我们为什么要爱国?
我们为什么要爱国? ——因为家在,根在,魂在“你可以不爱你的管家, 但必须爱你家的房子。”🌿 国家如屋,人民为主, 执政者不过管家—— 而这屋,是我们的命脉所系。🏠 一、…...
5步释放游戏潜能:面向玩家的原神帧率解锁完全指南
5步释放游戏潜能:面向玩家的原神帧率解锁完全指南 【免费下载链接】genshin-fps-unlock unlocks the 60 fps cap 项目地址: https://gitcode.com/gh_mirrors/ge/genshin-fps-unlock 一、问题发现:为什么你的高端显卡在原神中无法全力奔跑…...
效率倍增:基于快马平台集成最新openclaw构建自动化采集工具
最近在做一个数据采集项目时,发现手动写爬虫实在太费时间了。每次都要重复处理请求头、代理设置、数据清洗这些基础工作,效率特别低。后来发现了openclaw这个工具包的新版本,正好结合InsCode(快马)平台快速搭建了一个自动化采集工具ÿ…...
