第三十三章 使用派生密钥令牌进行加密和签名 - 使用 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语言编写,少量使用汇编语言。 从…...

测序技术--组蛋白甲基化修饰、DNA亲和纯化测序,教授(优青)团队指导:从实验设计、结果分析到SCI论文辅助
组蛋白甲基化修饰工具(H3K4me3 ChIP-seq)组蛋白甲基化类型也有很多种,包括赖氨酸甲基化位点H3K4、H3K9、H3K27、H3K36、H3K79和H4K20等。组蛋白H3第4位赖氨酸的甲基化修饰(H3K4)在进化上高度保守,是被研究最多的组蛋白修饰之一。 DNA亲和纯化测序 DNA亲…...

Llama 3.2来了,多模态且开源!AR眼镜黄仁勋首批体验,Quest 3S头显价格低到离谱
如果说 OpenAI 的 ChatGPT 拉开了「百模大战」的序幕,那 Meta 的 Ray-Ban Meta 智能眼镜无疑是触发「百镜大战」的导火索。自去年 9 月在 Meta Connect 2023 开发者大会上首次亮相,短短数月,Ray-Ban Meta 就突破百万销量,不仅让马…...

软考高级:SOA 和微服务 AI 解读
概念讲解 SOA(面向服务架构)和微服务虽然都是服务架构的设计模式,但它们的侧重点和实现方式有很大区别。为了帮助你理解这两个概念,我们可以从生活中的例子、概念本身的讲解以及记忆方法三方面入手。 生活化例子 **SOA…...

【每天学个新注解】Day 6 Lombok注解简解(五)—@SneakyThrows
SneakyThrows 简化异常处理 并不建议日常开发中通过此注解解决异常捕获问题!!! 允许方法抛出检查型异常而无需显式声明或捕获这些异常。这对于那些不希望在方法签名中声明异常或不愿意编写复杂的 try-catch 块的场景非常有用。 使用 SneakyT…...

C语言 | Leetcode C语言题解之第437题路径总和III
题目: 题解: /*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* };*/ //递归遍历树节点,判断是否为有效路径 int dfs(struct TreeNode * root, int ta…...

Linux-TCP重传
问题描述: 应用系统进行切换,包含业务流量切换(即TongWeb主备切换)和MYSQL数据库主备切换。首先进行流量切换,然后进行数据库主备切换。切换后发现备机TongWeb上有两批次慢请求,第一批慢请求响应时间在133…...

Python通过Sqlalchemy框架实现增删改查
目录 简介 什么是SQLAlchemy? SQLAlchemy可以分为两个部分:Core和ORM。 一、首先安装sqlalchemy 二、在配置文件中添加数据库连接信息,我这里是Mysql 三、 创建数据库连接类,我这里是动态读取数据库的表字段,自动…...

windows C++ - 任务计划程序(并发运行时)
如果希望微调并发运行时的现有代码的性能,则任务计划程序会很有用。 无法从通用 Windows 平台 (UWP) 应用获取任务计划程序。 在 Visual Studio 2015 及更高版本中,concurrency::task 类和 ppltasks.h 中的相关类型使用 Windows 线程池作为其计划程序。…...

多米诺骨牌(模拟)
初始化数据结构: 使用一个布尔数组 arr 来表示每个位置是否被占用。初始时所有位置均为 false(未占用)。使用一个 LinkedHashMap(命名为 queue)来记录最近的 R 操作的位置。这个结构可以保持插入顺序,方便后…...

Unity DOTS系列之Struct Change核心机制分析
最近DOTS发布了正式的版本, 我们来分享一下DOTS里面Struct Change机制,方便大家上手学习掌握Unity DOTS开发。 基于ArchType与Chunk的Entity管理机制 我们回顾以下ECS的内存管理核心机制,基于ArchTypeChunk的Entity管理模式。每个Entity不直接存放数据,…...