public class Sign extends Object
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
| Constructor and Description |
|---|
Sign() |
| Modifier and Type | Method and Description |
|---|---|
void |
DoSignRequest(org.apache.http.client.methods.HttpPost httpPost,
URI uri,
String action,
String ak,
String sk,
String region)
核心加签方法:为 HttpPost 请求添加火山引擎 API 签名
|
static String |
hashSHA256(byte[] content) |
static byte[] |
hmacSHA256(byte[] key,
String content) |
public static final Charset UTF_8
public void DoSignRequest(org.apache.http.client.methods.HttpPost httpPost,
URI uri,
String action,
String ak,
String sk,
String region)
throws Exception
httpPost - 待加签的 HttpPost 请求(需提前设置请求体,若有)uri - 请求的 URI(包含 host、path、query 参数)ak - 访问密钥 AKsk - 密钥 SKregion - 地域(如 cn-beijing,需与 API 所属地域一致)Exception - 加签过程中异常(如加密算法异常、请求体读取异常)Copyright © 2025. All rights reserved.