com.actigence:api-access-tracker-java-client

A simple Java client for tracking api requests using API Access Tracker backend (https://github.com/Actigence/api-access-tracker-backend)

License

License

Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

com.actigence
ArtifactId

ArtifactId

api-access-tracker-java-client
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

com.actigence:api-access-tracker-java-client
A simple Java client for tracking api requests using API Access Tracker backend (https://github.com/Actigence/api-access-tracker-backend)
Project URL

Project URL

https://github.com/Actigence/api-access-tracker-java-client
Source Code Management

Source Code Management

https://github.com/Actigence/api-access-tracker-java-client

Download api-access-tracker-java-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.actigence/api-access-tracker-java-client/ -->
<dependency>
    <groupId>com.actigence</groupId>
    <artifactId>api-access-tracker-java-client</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.actigence/api-access-tracker-java-client/
implementation 'com.actigence:api-access-tracker-java-client:0.0.1'
// https://jarcasting.com/artifacts/com.actigence/api-access-tracker-java-client/
implementation ("com.actigence:api-access-tracker-java-client:0.0.1")
'com.actigence:api-access-tracker-java-client:jar:0.0.1'
<dependency org="com.actigence" name="api-access-tracker-java-client" rev="0.0.1">
  <artifact name="api-access-tracker-java-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.actigence', module='api-access-tracker-java-client', version='0.0.1')
)
libraryDependencies += "com.actigence" % "api-access-tracker-java-client" % "0.0.1"
[com.actigence/api-access-tracker-java-client "0.0.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.logging.log4j : log4j-api jar 2.13.2
org.apache.logging.log4j : log4j-core jar 2.13.2
org.apache.logging.log4j : log4j-slf4j-impl jar 2.13.2
com.google.code.gson : gson jar 2.8.6
com.amazonaws : aws-java-sdk-sqs jar

provided (2)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.12
javax.servlet : javax.servlet-api jar 4.0.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

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.
com.actigence

Actigence Solutions

Versions

Version
0.0.1