Skip to content

Commit

Permalink
#185690008 : update dependencies, support for governance rules, some …
Browse files Browse the repository at this point in the history
…performnace improvement. (#113)

* update dependency

* little bit safer to use unmasked event instead

* governance rule blocking, remove AppConfigManager

* add governance rule blocking

* Add governance rule blocking

* Add BlockedResponse

* Add governance rule route
  • Loading branch information
Sean Huo authored Oct 21, 2023
1 parent 0db016e commit df57685
Show file tree
Hide file tree
Showing 23 changed files with 301 additions and 376 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Add the Moesif dependency to your project's pom.xml file:
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.7.8</version>
<version>1.7.9</version>
</dependency>

<!-- OR for newer Jakarta-->
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet-jakarta</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
</dependency>
```

Expand All @@ -44,12 +44,12 @@ Add the Moesif dependency to your project's build.gradle file:

```gradle
dependencies {
compile 'com.moesif.servlet:moesif-servlet:1.7.8'
compile 'com.moesif.servlet:moesif-servlet:1.7.9'
}
// OR for newer Jakarta
dependencies {
compile 'com.moesif.servlet:moesif-servlet-jakarta:2.0.2'
compile 'com.moesif.servlet:moesif-servlet-jakarta:2.0.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/spring-boot-starter-example-jakarta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet-jakarta</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ public Greeting greeting(@RequestParam(value="name", defaultValue="") String nam
return new Greeting(counter.incrementAndGet(), "Hello There!");
}

@GetMapping("gov/no_italy")
public String noItaly() {
return "{\"success\" : true}";
}

@GetMapping("gov/company1")
public String company1() {
return "{\"success\" : true}";
}

@GetMapping("gov/canada")
public String canada() {
return "{\"success\" : true}";
}

@GetMapping("gov/cairo")
public String cairo() {
return "{\"success\" : true}";
}

@GetMapping("gov/for_companies_in_japan_only")
public String forCompaniesInJapanOnly() {
return "{\"success\" : true}";
}

@GetMapping("gov/random")
public String random() {
return "{\"success\" : true}";
}

@RequestMapping("/api/text")
@ResponseBody
public String simpleString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,23 @@ public Filter moesifFilter() {

@Override
public String identifyUser(HttpServletRequest request, HttpServletResponse response) {
if (request.getUserPrincipal() == null) {
return null;
}
return request.getUserPrincipal().getName();
return request.getHeader("X-User-Id");
// if (request.getUserPrincipal() == null) {
// return null;
// }
// return request.getUserPrincipal().getName();
}

@Override
public String getSessionToken(HttpServletRequest request, HttpServletResponse response) {
return request.getHeader("Authorization");
}

@Override
public String identifyCompany(HttpServletRequest request, HttpServletResponse response) {
return request.getHeader("X-Company-Id");
}

@Override
public String getApiVersion(HttpServletRequest request, HttpServletResponse response) {
return request.getHeader("X-Api-Version");
Expand Down
2 changes: 1 addition & 1 deletion jersey-servlet-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.7.8</version>
<version>1.7.9</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion moesif-servlet-jakarta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Add the Moesif dependency to your project's pom.xml file:
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet-jakarta</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions moesif-servlet-jakarta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet-jakarta</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
<packaging>jar</packaging>
<name>moesif-servlet-jakarta</name>
<description>Moesif SDK for Java Servlet to log and analyze API calls using Jakarta</description>
Expand Down Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>com.moesif.api</groupId>
<artifactId>moesifapi</artifactId>
<version>1.7.0</version>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,7 @@ public void onSuccess(HttpContext httpContext, HttpResponse httpResponse) {
final int status = httpContext.getResponse().getStatusCode();
// No need to retry. Mark call done.
done[0] = true;
if (status == 201) {
// Fetch the response ETag to check if we need to update appConfig.
String responseConfigEtag = httpResponse.getHeaders().get("x-moesif-config-etag");
if (responseConfigEtag != null) {
AppConfigManager.getInstance().updateIfStale(responseConfigEtag);
}
} else if (debug) {
logger.warning("Status is " + status);
}

}

public void onFailure(HttpContext httpContext, Throwable error) {
Expand Down
Loading

0 comments on commit df57685

Please sign in to comment.