Giter VIP home page Giter VIP logo

akamaiopen-edgegrid-java's Introduction

edgegrid-auth-java

Java library for EdgeGrid Client Authentication

CHANGES

May 29th 2014

Summary

edgegrid-auth-java is a Java library for signing requests to APIs that are carried on the Akamai EdgeGrid network. It builds on the Google HTTP Client Library for Java and adds the EdgeGrid signature to a normal HttpRequest.

Usage

Use the library is pretty simple.

First, create a RequestSigner object. EdgeGridV1Signer is one (the only currently provided) implementation of the RequestSigner interface.

The constructor of EdgeGridV1Signer takes two parameters:

  • headers: for specifying the ordered list of request headers to be included in the request signature. This is provided by the API service provider.
  • maxBodySize: for specifying the maximum allowed size in bytes of the request body, for POST and PUT requests. This value is also provided by the API service provider.

This RequestSigner object can then be used to sign the requests.

To sign an HttpRequest:

  1. first, add the Host header with the hostname of the request;

  2. then, sign the request with a ClientCredential that encapsulates the following:

  • clientToken: for specifying the client token obtained from the client provisioning process
  • accessToken: for specifying the access token obtained from the client authorization process
  • clientSecret: for specifying the client secret that is associated with the client token

Example

Here is an example code snippet:

RequestSigner signer = new EdgeGridV1Signer(Collections.EMPTY_LIST, 1024 * 2);
URI uri = new URI("https", "akaa-u5x3btzf44hplb4q-6jrzwnvo7llch3po.luna.akamaiapis.net",			 
	"/billing-usage/v1/reportSources", null, null);
HttpTransport HTTP_TRANSPORT = new ApacheHttpTransport();
HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory();
HttpRequest request = requestFactory.buildGetRequest(new GenericUrl(uri));
HttpHeaders headers = request.getHeaders();
headers.set("Host", "akaa-u5x3btzf44hplb4q-6jrzwnvo7llch3po.luna.akamaiapis.net");
ClientCredential credential = new DefaultCredential("akaa-nev5k66unzize2gx-5uz4svbszp4ko5wq",
	"akaa-ublu6mqdcqkjw5lz-542a56pcogddddow", "SOMESECRET");
HttpRequest signedRequest = signer.sign(request, credential);

akamaiopen-edgegrid-java's People

Contributors

tongchen avatar tochen avatar derekprior avatar shreyasdube avatar

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.