Code Monkey home page Code Monkey logo

baba-cdn-authenticode's Introduction

baba-cdn-authenticode

Authenticode generator to support URL authentication by Alibaba Cloud CDN

The URL authentication function protects user¡¯s site resources from illegal download and misuse. Leeching issues are only partially solved by adding the referer blacklist or whitelist. Because the referer content may be forged, this method cannot protect site resources completely. Applying URL authentication is recommended to protect the security of origin site resources.

MD5Generator follows the standard guide on the URL below https://www.alibabacloud.com/help/doc-detail/27135.htm

key = "aliyuncdnexp1234";	//	key defined from CDN console
uri = "/video/standard/1K.html";	//	URL to download

//// Sample for Type A
// with 1 day expiry
System.out.println(MD5Generator.getAuthStringA(uri, key));

//// Sample for Type B
uri = "/4/44/44c0909bcfc20a01afaf256ca99a8b8b.mp3";

//	with 1800 S of expiry from now
System.out.println(MD5Generator.getAuthStringB(uri, key));	

//	expiry at given time
System.out.println(MD5Generator.getAuthStringB(uri, "201508150800", key)); 

//// Sample for Type C
uri = "/test.flv";

//	with 1 day expiry from now, type C format 1
System.out.println(MD5Generator.getAuthStringC1(uri, key));	

//	expiry at given time in UNIX format, type C format 1
System.out.println(MD5Generator.getAuthStringC1(uri, "55CE8100", key));	

//	MD5 string to pass to the URL parameter for type C format 2
System.out.println(MD5Generator.getMDStringC(uri, "55CE8100", key));	

baba-cdn-authenticode's People

Contributors

euchungmsft 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.