当前位置: 首页 > news >正文

第三十三章 使用派生密钥令牌进行加密和签名 - 使用 DerivedKeyToken _进行加密(一)

文章目录

  • 第三十三章 使用派生密钥令牌进行加密和签名 - 使用 <DerivedKeyToken>

第三十三章 使用派生密钥令牌进行加密和签名 - 使用

进行加密(一)

  1. 如果加密了任何安全标头元素,请将它们添加到 WS-Security 标头元素中。为此,请调用 Web 客户端或 Web 服务的 SecurityOut 属性的 AddSecurityElement() 方法。在这种情况下,需要两个参数:

a. 安全标头元素(而不是从中生成的的 %XML.Security.EncryptedData)。

b. 引用列表实例。第二个参数指定将第一个参数指定的项目放在何处。如果参数是 AB,则 IRIS 确保 AB 之后。指定此项以便收件人首先处理引用列表,然后再处理依赖于它的加密安全标头元素。

 do client.SecurityOut.AddSecurityElement(userToken,reflist)

如果仅加密了 SOAP 主体,系统会自动将 <EncryptedData> 元素作为 <Body>的子元素。

  1. 发送 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> 第三十三章 使用派生密钥令牌进行加密和签名 - 使用 进行加密&#xff08;一&#xff09; 如果加密了任何安全标头元素&#xff0c;请将它们添加到 WS-Security 标头元素中。为此&#…...

Structure-Aware Transformer for Graph Representation Learning

Structure-Aware Transformer for Graph Representation Learning&#xff08;ICML22&#xff09; 摘要 Transformer 架构最近在图表示学习中受到越来越多的关注&#xff0c;因为它通过避免严格的结构归纳偏差而仅通过位置编码对图结构进行编码&#xff0c;自然地克服了图神经…...

滚动页面,el-table表头始终置顶

效果如下&#xff1a; 起始状态&#xff1a; 滚动后&#xff1a; 代码地址&#xff1a;代码地址-面包多...

Mac使用gradle编译springboot-2.7.x源码

1 开发环境&#xff1a; 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 创建主键索引 第一种方式&#xff1a; – 在创建表的时候&#xff0c;直接…...

选择寄宿学校,给自闭症孩子一个温暖的第二家

在寻找适合自闭症孩子成长的道路上&#xff0c;每一个家庭都充满了艰辛与希望。而广州市星贝育园康复中心&#xff0c;以其独特的全托寄宿制教育模式&#xff0c;为这些特殊的孩子提供了一个充满爱与关怀的“第二家”。在这里&#xff0c;孩子们不仅能够得到专业的康复训练&…...

大模型训练:K8s 环境中数千节点存储最佳实践

今天这篇博客来自全栈工程师朱唯唯&#xff0c;她在前不久举办的 KubeCon 中国大会上进行了该主题分享。 Kubernetes 已经成为事实的应用编排标准&#xff0c;越来越多的应用在不断的向云原生靠拢。与此同时&#xff0c;人工智能技术的迅速发展&#xff0c;尤其是大型语言模型&…...

【Linux学习】1-2 新建虚拟机ubuntu环境

1.双击打开VMware软件&#xff0c;点击“创建新的虚拟机”&#xff0c;在弹出的中选择“自定义&#xff08;高级&#xff09;” 2.点击下一步&#xff0c;自动识别ubuntu光盘映像文件&#xff0c;也可以点击“浏览”手动选择&#xff0c;点击下一步 3.设置名称及密码后&#xf…...

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 &#xff0c;找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的数字可以无限制重复被选取。说明&#xff1a; 所有数字&#xff08;包括 target&#xff09;都是正整数。 解集不能包含重复的组合…...

【笔记】第三节 组织与性能

3.1 基本成分 3.2 微观组织特征 0.6-0.8C%碳素钢的组织为珠光体和少量的铁素体。 如何把组织和性能联系起来&#xff1f;德国克虏伯公司的研究——珠光体片间距与渗碳体片层厚度成比例&#xff1a; t s 0 ( ρ 15 ( C % ) − 1 ) ts_0(\frac{\rho}{15(C\%)}-1) ts0​(15(C%)…...

数据库——sql语言学习 查找语句

一、什么是sql SQL是结构化查询语言&#xff08;Structured Query Language&#xff09;的缩写&#xff0c;它是一种专门为数据库设计的操作命令集&#xff0c;用于管理关系数据库管理系统&#xff08;RDBMS&#xff09;。 二、查找相关语句 ‌‌首先&#xff0c;我们已经设…...

【计算机网络 - 基础问题】每日 3 题(二十三)

✍个人博客&#xff1a;Pandaconda-CSDN博客 &#x1f4e3;专栏地址&#xff1a;http://t.csdnimg.cn/fYaBd &#x1f4da;专栏简介&#xff1a;在这个专栏中&#xff0c;我将会分享 C 面试中常见的面试题给大家~ ❤️如果有收获的话&#xff0c;欢迎点赞&#x1f44d;收藏&…...

JPA + Thymeleaf 增删改查

一、 什么是 Thymeleaf JPA&#xff08;Java Persistence API&#xff09;&#xff1a;是一种用于对象关系映射&#xff08;ORM&#xff09;的 Java 规范&#xff0c;它简化了数据库操作&#xff0c;使开发者可以以面向对象的方式处理数据存储。通过定义实体类和数据访问接口&a…...

Android常用C++特性之std::this_thread

声明&#xff1a;本文内容生成自ChatGPT&#xff0c;目的是为方便大家了解学习作为引用到作者的其他文章中。 std::this_thread 是 C11 标准库中的一个命名空间&#xff0c;提供了一组与当前线程&#xff08;即调用这些函数的线程&#xff09;相关的操作。通过 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组件通信&#xff08;组合式API&#xff09; vue3组件通信&#xff0c;采用组合式API。选项式API&#xff0c;参看官网 Vue3组件通信和Vue2的区别&#xff1a; 移出事件总线&#xff0c;使用mitt代替。 vuex换成了pinia。把.sync优化到了v-model里面了。把$listeners所…...

从预测性维护到智能物流:ARM边缘计算控制器的工业实践

工业4.0时代的到来&#xff0c;边缘计算技术成为连接物理世界与数字世界的桥梁。ARM架构的边缘计算控制器凭借其低功耗、高能效和灵活性等特点&#xff0c;在工业自动化领域展现出巨大潜力。本文将通过几个实际应用案例来探讨ARM边缘计算控制器是如何提升生产线效率和安全性的&…...

2024年汉字小达人区级自由报名备考冲刺:最新问题和官模题练一练

今天是2024年第十一届汉字小达人的区级自由报名活动的第二天。 我们继续回答几个关于汉字小达人的最新问题&#xff0c;做几道2024年官方模拟题&#xff0c;帮助孩子们少走弯路&#xff0c;再冲刺一般&#xff0c;更精准地备考2024年汉字小达人。 【温馨提示】本专题在比赛期…...

Linux相关概念和重要知识点(8)(操作系统、进程的概念)

1.操作系统&#xff08;OS&#xff09; &#xff08;1&#xff09;基本结构的认识 任何计算机系统都包含一个基本的程序集合&#xff0c;用于实现计算机最基本最底层的操作&#xff0c;这个软件称为操作系统。操作系统大部分使用C语言编写&#xff0c;少量使用汇编语言。 从…...

DeepSeek 赋能智慧能源:微电网优化调度的智能革新路径

目录 一、智慧能源微电网优化调度概述1.1 智慧能源微电网概念1.2 优化调度的重要性1.3 目前面临的挑战 二、DeepSeek 技术探秘2.1 DeepSeek 技术原理2.2 DeepSeek 独特优势2.3 DeepSeek 在 AI 领域地位 三、DeepSeek 在微电网优化调度中的应用剖析3.1 数据处理与分析3.2 预测与…...

【Java学习笔记】Arrays类

Arrays 类 1. 导入包&#xff1a;import java.util.Arrays 2. 常用方法一览表 方法描述Arrays.toString()返回数组的字符串形式Arrays.sort()排序&#xff08;自然排序和定制排序&#xff09;Arrays.binarySearch()通过二分搜索法进行查找&#xff08;前提&#xff1a;数组是…...

解锁数据库简洁之道:FastAPI与SQLModel实战指南

在构建现代Web应用程序时&#xff0c;与数据库的交互无疑是核心环节。虽然传统的数据库操作方式&#xff08;如直接编写SQL语句与psycopg2交互&#xff09;赋予了我们精细的控制权&#xff0c;但在面对日益复杂的业务逻辑和快速迭代的需求时&#xff0c;这种方式的开发效率和可…...

在Ubuntu中设置开机自动运行(sudo)指令的指南

在Ubuntu系统中&#xff0c;有时需要在系统启动时自动执行某些命令&#xff0c;特别是需要 sudo权限的指令。为了实现这一功能&#xff0c;可以使用多种方法&#xff0c;包括编写Systemd服务、配置 rc.local文件或使用 cron任务计划。本文将详细介绍这些方法&#xff0c;并提供…...

Module Federation 和 Native Federation 的比较

前言 Module Federation 是 Webpack 5 引入的微前端架构方案&#xff0c;允许不同独立构建的应用在运行时动态共享模块。 Native Federation 是 Angular 官方基于 Module Federation 理念实现的专为 Angular 优化的微前端方案。 概念解析 Module Federation (模块联邦) Modul…...

EtherNet/IP转DeviceNet协议网关详解

一&#xff0c;设备主要功能 疆鸿智能JH-DVN-EIP本产品是自主研发的一款EtherNet/IP从站功能的通讯网关。该产品主要功能是连接DeviceNet总线和EtherNet/IP网络&#xff0c;本网关连接到EtherNet/IP总线中做为从站使用&#xff0c;连接到DeviceNet总线中做为从站使用。 在自动…...

数据库分批入库

今天在工作中&#xff0c;遇到一个问题&#xff0c;就是分批查询的时候&#xff0c;由于批次过大导致出现了一些问题&#xff0c;一下是问题描述和解决方案&#xff1a; 示例&#xff1a; // 假设已有数据列表 dataList 和 PreparedStatement pstmt int batchSize 1000; // …...

JavaScript基础-API 和 Web API

在学习JavaScript的过程中&#xff0c;理解API&#xff08;应用程序接口&#xff09;和Web API的概念及其应用是非常重要的。这些工具极大地扩展了JavaScript的功能&#xff0c;使得开发者能够创建出功能丰富、交互性强的Web应用程序。本文将深入探讨JavaScript中的API与Web AP…...

Go 并发编程基础:通道(Channel)的使用

在 Go 中&#xff0c;Channel 是 Goroutine 之间通信的核心机制。它提供了一个线程安全的通信方式&#xff0c;用于在多个 Goroutine 之间传递数据&#xff0c;从而实现高效的并发编程。 本章将介绍 Channel 的基本概念、用法、缓冲、关闭机制以及 select 的使用。 一、Channel…...

【Linux手册】探秘系统世界:从用户交互到硬件底层的全链路工作之旅

目录 前言 操作系统与驱动程序 是什么&#xff0c;为什么 怎么做 system call 用户操作接口 总结 前言 日常生活中&#xff0c;我们在使用电子设备时&#xff0c;我们所输入执行的每一条指令最终大多都会作用到硬件上&#xff0c;比如下载一款软件最终会下载到硬盘上&am…...