Git Product home page Git Product logo

api-access-tracker-java-client's Introduction

API Access Tracker (Java Client)

Java CI with Maven

This is the supporting Java client for API Access Tracker.

This Java client in conjunction with the API Access Tracker (Backend) can be used to log all request and response data for your webservices APIs. If you want to log all the requests coming to your webservices you can use API Access Tracker.

API Access Tracker stores all the request details of API calls made to your webservices to AWS using serverless technologies such as AWS DynamoDB, AWS Lambda, AWS SQS etc.

This README will not detail into how API Access Tracker works, but will describe setup of this Java client too allow you to start pushing data too AWS Stack created by API Access Tracker (Backend).

How this client works?

This client contains a simple Http Servlet filter, which when setup correctly, intercepts all the requests coming to your APIs, and publishes them to the AWS SQS created by API Access Tracker (Backend). Before starting to use this client, you must follow steps described in API Access Tracker (Backend) to setup your AWS Stack.

Getting Started

Follow below steps to setup API Access Tracker.

  • Setup API Access Tracker (Backend)
  • Create an AWS IAM user that has access to AWS SQS queues generated by API Access Tracker (Backend). You can use below policy for reference.
{
 "Version": "2012-10-17",
 "Statement": [
   {
     "Sid": "VisualEditor0",
     "Effect": "Allow",
     "Action": [
       "sqs:GetQueueUrl",
       "sqs:SendMessage",
       "sqs:CreateQueue"
     ],
     "Resource": "arn:aws:sqs:us-east-1:<Your-AWS-Account-ID>:aal_*"
   }
 ]
}
  • Add this API Access Tracker (Java Client) to you Java project.

For Maven Project

<dependency>
  <groupId>com.actigence</groupId>
  <artifactId>api-access-tracker-java-client</artifactId>
  <version>0.0.1</version>
</dependency>

For Gradle Project

plugins {
id 'maven'
}

dependencies {
implementation 'com.actigence:api-access-tracker-java-client:0.0.1'
}
  • Configure request filter to intercept desired URLs.

For projects build using Spring Boot add below configuration file:

@Configuration
public class FilterConfiguration
{

    @Bean
    public FilterRegistrationBean<ApiAccessLoggingFilter> loggingFilter()
    {
        FilterRegistrationBean<ApiAccessLoggingFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new ApiAccessLoggingFilter());
        registrationBean.addUrlPatterns("/test/*");
        registrationBean.addInitParameter("clientId", "MyServiceName");
        return registrationBean;
    }
}

For projects built using Java Servlets:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
        "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>

    <filter>
        <filter-name>API Access Tracking Filter</filter-name>
        <filter-class>com.actigence.aal.ApiAccessLoggingFilter</filter-class>
        <init-param>
            <param-name>clientId</param-name>
            <param-value>MyServiceName</param-value>
        </init-param>
    </filter>
    
    <filter-mapping>
        <filter-name>API Access Tracking Filter</filter-name>
        <url-pattern>/test/*</url-pattern>
    </filter-mapping>

</web-app>

That's it. Now any request made to your webservice APIs at the configured URLs will be intercepted and you will be able to see entries in AWS DynamoDB tables.

Limitations

  • Minimum Java version 8 is required.
  • AWS SQS has limit of maximum payload size of 256 KB. Hence combined data of request and response values can not be more than 256 KB.

api-access-tracker-java-client's People

Contributors

anubhavshukla avatar ashuklafispan avatar dependabot[bot] avatar

Watchers

 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.