Code Monkey home page Code Monkey logo

jdcloud-sdk-java-signer's Introduction

简介

欢迎使用京东云开发者Java签名工具。

环境准备

  1. 京东云Java SDK适用于jdk7及以上版本。
  2. 在开始调用京东云open API之前,需提前在京东云用户中心账户管理下的AccessKey管理页面申请accesskey和secretKey密钥对(简称AK/SK)。AK/SK信息请妥善保管,如果遗失可能会造成非法用户使用此信息操作您在云上的资源,给你造成数据和财产损失。

SDK使用方法

编译代码并引用

调用SDK

Java SDK的调用主要分为4步:

  1. 设置accessKey和secretKey
  2. 创建Client
  3. 设置请求参数
  4. 执行请求得到响应

以下是查询单个云主机实例详情的调用示例

        String secretKey = "secret key";
        String host = "192.168.182.82:5888";
        String uri = "/test/httpCode";
        String method = "GET";
        String queryString = "code=200";
        String body = "this is body";
        Map<String, String> headers = new HashMap<>();
        headers.put("x-jdcloud-nonce", "1263de8a-9adf-4626-ade0-f25b608d3a55");
        headers.put("x-jdcloud-date", "20181114T085919Z");
        headers.put("authorization", "JDCLOUD2-HMAC-SHA256 Credential=636B856DCF14D467D313CCB0C0E2B21C/20181114/cn-north-1/xapw9ul97y4p/jdcloud2_request, SignedHeaders=content-type;x-jdcloud-date;x-jdcloud-nonce, Signature=9b085f63d7fd1583f4fe20356c5770da9dffb51ea66fcdbd45e8a0c8b0a7dbfa");
        headers.put("content-type", "application/json");
        Signer signer = new Signer(ApiGatewayAlgorithm.SHA256);
        String signature = signer.sign(secretKey, host, uri, method, headers, queryString, body);
        System.out.println(signature);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.