Giter Club home page Giter Club logo

akamai-g2o-java's Introduction

Akamai G2O Header Validation in Java

This is a simple library to verify Akamai signed headers. This library does not do any direct interaction with Http headers or runtime configuration. It should with any Java http filtering or configuration mechanism.

Use in other applications like this:

import com.ibm.akamai.g2o.SignatureValidator;

// The validator can be created once and reused.
SignatureValidator validator =  SignatureValidator(....);

// Call validate for each request, passing:
//  path (or the signing string): /some/url
//  header: contents of the Akamai Data header.
//     Use SignatureValidator.AUTH_SIGNATURE_DATA_HEADER for default header name.
//  signature: contents of the Akamai signature header.
//     Use SignatureValidator.AUTH_SIGNATURE_SIGN_HEADER for default header name
VerificationResult result =  validator.validate(urlPath, header, signature);

// isValid should be obvious =)
result.isValid();

// the message will be null for valid signatures
if ( !result.isValid() ) {
  System.out.println(result.getMessage());
}

Specifying parameters

Specify keys using a combined string:

// authNonceSecrets -- a string that is a concatenation of nonces: "key1:value1,key2:value2"
SignatureValidator validator =  SignatureValidator(authNonceSecrets);

or a pre-created map:

Map<String, String> secretMap = new HashMap<>();
secretMap.put("key1", "value1");
secretMap.put("key2", "value2");

// authNonceSecrets -- a map of key: secret
SignatureValidator validator =  SignatureValidator(secretMap);

Validating the age of requests

Adjust the permitted age of requests by calling setTimeWindow with a new value in seconds. The default is 30 seconds.

To make any requests older than 60 seconds invalid:

SignatureValidator validator =  SignatureValidator(authSecret, authNonceSecrets).setTimeWindow(60);

To disable this check entirely:

SignatureValidator validator =  SignatureValidator(authSecret, authNonceSecrets).setTimeWindow(0);

Acknowledgements

This java library implementation was heavily inspired by the node akamai-g2o project:

https://github.com/ynohat/akamai-g2o https://www.npmjs.com/package/akamai-g2o

akamai-g2o-java's People

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.