Skip to content

Commit 5f22421

Browse files
Feature2.6.0 (#293)
* always keep default pipeline * added a simple caller address filter * caller Black/white list reset on reload * reset config on reload * fix cfgdemo issue * call addr filter supports regex * call addr filter supports regex precheck * gRPC server supports caller addr filter with regex precheck * gRPC refactoring * gRPC refactoring * gRPC refactoring * gRPC refactoring * gRPC refactoring * gRPC refactoring * Netty 4.2 Migration * enable ssl.Provider option in gRPC client config in case the default option (OPENSSL) is not available * refactoring * enhanced RAS encryption/decryption for config file, etc. * enhanced security * enhanced security * enhanced security * enhanced security * enhanced security * updated README * refactor RTO error code * refactor RTO error code * default master password is no longer hardcoded, it will be loaded from etc/master.password file (auto create if no exists) when -authfile <path to master.password> is not provided to launch the app; added @UniqueIgnore to mute @unique check alert for expected duplicated values * default master password is no longer hardcoded, it will be loaded from etc/master.password file (auto create if no exists) when -authfile <path to master.password> is not provided to launch the app; added @UniqueIgnore to mute @unique check alert for expected duplicated values * refactoring * refactoring * refactoring * refactoring * make BootErrorCode not hardcoded * refactoring * refactoring * added @Log.hideJsonFields * added @Log.hideJsonFields * refactoring: @Log.protectDataFieldsFromLogging and its FormatterUtil.replaceDataField to protect JSON, XML, Form data * refactoring: @Log.protectDataFieldsFromLogging and its FormatterUtil.replaceDataField to protect JSON, XML, Form data * wip * refactoring API rename: org.summerboot.jexpress.nio.server.domain.ServiceContext renamed to org.summerboot.jexpress.nio.server.SessionContext * update README.md * API rename: @ImportResource.checkImplTagUsed and loadWhenImplTagUsed * API rename: @ImportResource.checkImplTagUsed and loadWhenImplTagUsed * Config removed: etc/boot.ini/default.interval.ConfigChangeMonitor;Config add: etc/boot.ini/default.ConfigChangeMonitor.Throttle.Milliseconds * Config add: cfg_nio.properties/nio.WebSocket.Compress.maxAllocation * refactoring DB config: use jakarta to replace hibernate * Config new in cfg_nio.properties: ping.sync.HealthStatus, ping.sync.PauseStatus and ping.sync.showRootCause * protect header * protect header * added sample service file for production Java 21 + Netty 4.2.x + ZGC + OpenSSL on Linux * added sample service file for production Java 21 + Netty 4.2.x + ZGC + OpenSSL on Linux * wip * refactoring * refactoring * API new: added @Inspector.name and @Deamon.requiredHealthChecks (value is array of @Inspector.name), this is to set Controller and/or its methods on deamon mode (accessable when pause/health failed but not for specified @Inspector.name * API new: added @Inspector.name and @Deamon.requiredHealthChecks (array of @Inspector.names, empty/null means ignore all HealthChecks); Config new: cfg_nio.properties.ping.sync.HealthStatus.requiredHealthChecks (@Inspector.names in CSV format, empty/null means require ALL HealthChecks) * API new: added @Inspector.name and @Deamon.requiredHealthChecks (array of @Inspector.names, empty/null means ignore all HealthChecks); Config new: cfg_nio.properties.ping.sync.HealthStatus.requiredHealthChecks (@Inspector.names in CSV format, empty/null means require ALL HealthChecks) * replace space with _ in log file name * refactoring * update dependencies * refactoring SessionContext.txt(.) and file(.) * added app arg -debug for debug mode * add LooseRequestTracker for NioServer and gRPCServer * add BootRequestTracker for NioServer and gRPCServer * add BootRequestTracker for NioServer and gRPCServer * add BootRequestTracker for NioServer and gRPCServer * add BootRequestTracker for NioServer and gRPCServer * add errorDesc * refactoring error code * add @LimitNonNullGroup - Validation annotation to ensure that exactly a specified number of fields are non-null. * add @LimitNonNullGroup - Validation annotation to ensure that exactly a specified number of fields are non-null. * refactoring log * add ProxyAuthStrategy to HttpClientConfig * add ProxyAuthStrategy to HttpClientConfig * add ProxyAuthStrategy to HttpClientConfig * add ProxyAuthStrategy to HttpClientConfig * refactoring * enhancement: refactoring RPCResult by supporting multiple error response types * enhancement: Err with args * dependencies update * add nio.JAX-RS.toJson.showRefInServiceError in cfg_nio.properties, default false to not show ref field in JSON/XML response * make ServiceError Deserializable * add IdleEventMonitor and IdleEventMonitor.IdleEventListener to enable app to handle gRPC/RESTFul idel event * add IdleEventMonitor and IdleEventMonitor.IdleEventListener to enable app to handle gRPC/RESTFul idel event * add IdleEventMonitor and IdleEventMonitor.IdleEventListener to enable app to handle gRPC/RESTFul idel event * dependencies update * upgrade codeql to v3 * verify Bearer Token if provided in request header for regardless of a @controller method is role-based or not * verify Bearer Token if provided in request header for regardless of a @controller method is role-based or not * replace JKS with PKCS12 * added GrpcTestBase for gRPC test; Config new: etc/boot.ini section 5. Security Settings * added GrpcTestBase for gRPC test; Config new: etc/boot.ini section 5. Security Settings * Config new: etc/boot.ini section 5. Security Settings; added cfg_nio.properties nio.JAX-RS.fromJson.autoBeanValidation * refactoring * refactoring * refactoring * refactoring * release 2.6.0
1 parent c361246 commit 5f22421

File tree

104 files changed

+4184
-1911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4184
-1911
lines changed

.github/workflows/codacy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ jobs:
5555

5656
# Upload the SARIF file generated in the previous step
5757
- name: Upload SARIF results file
58-
uses: github/codeql-action/upload-sarif@v2
58+
uses: github/codeql-action/upload-sarif@v3
5959
with:
6060
sarif_file: results.sarif

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v2
46+
uses: github/codeql-action/init@v3
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v2
57+
uses: github/codeql-action/autobuild@v3
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v2
71+
uses: github/codeql-action/analyze@v3

CHANGES

Lines changed: 314 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ import jakarta.ws.rs.core.MediaType;
162162
import java.util.List;
163163
import org.summerboot.jexpress.boot.annotation.Controller;
164164
import org.summerboot.jexpress.boot.annotation.Log;
165-
import org.summerboot.jexpress.nio.server.domain.ServiceContext;
165+
import org.summerboot.jexpress.nio.server.SessionContext;
166166
167167
@Singleton
168168
@Controller
@@ -188,7 +188,7 @@ public class MyController {
188188
* Three features:
189189
* <p> 1. auto validate JSON request by @Valid and @NotNull annotation
190190
* <p> 2. protected user credit card and privacy information from being logged by @Log annotation
191-
* <p> 3. mark performance POI (point of interest) by using ServiceContext.poi(key), see section#8.3
191+
* <p> 3. mark performance POI (point of interest) by using SessionContext.poi(key), see section#8.3
192192
*
193193
* @param myName
194194
* @param request
@@ -199,8 +199,8 @@ public class MyController {
199199
@Path("/hello/{name}")
200200
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})// require request header Content-Type: application/json or Content-Type: application/xml
201201
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})// require request header Accept: application/json or Accept: application/xml
202-
@Log(hideJsonStringFields = {"creditCardNumber", "clientPrivacy"}, hideJsonArrayFields = "secretList")
203-
public ResponseDto hello_auto_validation_protected_logging_markWithPOI(@NotNull @PathParam("name") String myName, @NotNull @Valid RequestDto request, final ServiceContext context) {
202+
@Log(maskDataFields = {"creditCardNumber", "clientPrivacy", "secretList"})
203+
public ResponseDto hello_auto_validation_protected_logging_markWithPOI(@NotNull @PathParam("name") String myName, @NotNull @Valid RequestDto request, final SessionContext context) {
204204
context.poi("DB begin");// about POI, see section8.3
205205
// DB access and it takes time ...
206206
context.poi("DB end");
@@ -251,8 +251,7 @@ public class MyController {
251251
**}
252252
> Memo: n/a
253253
254-
**Below is the log of with @Log(hideJsonStringFields = {"creditCardNumber", "clientPrivacy"}, hideJsonArrayFields = "
255-
secretList")**
254+
**Below is the log of with @Log(maskDataFields = {"creditCardNumber", "clientPrivacy", "secretList"})**
256255

257256
> 2023-04-20T19:53:47,167 INFO org.summerboot.jexpress.nio.server.BootHttpRequestHandler.() [pool-4-thread-2]
258257
> request_2.caller=null
@@ -274,13 +273,13 @@ secretList")**
274273
275274

276275

277-
**1.4 Sample Code: -use \<implTag\>**
276+
**1.4 Sample Code: -use \<AlternativeName\>**
278277

279-
Use @Controller.**implTag** field as below, this controller class will only be available with -**use RoleBased**
278+
Use @Controller.**AlternativeName** field as below, this controller class will only be available with -**use RoleBased**
280279
parameter to launch the application, see *<u>section#9</u>*
281280

282281
```
283-
@Controller(implTag="RoleBased")
282+
@Controller(AlternativeName="RoleBased")
284283
```
285284

286285
**1.5 Sample Code: PING** see *section#5*
@@ -375,7 +374,7 @@ import io.netty.handler.codec.http.HttpHeaders;
375374
import javax.naming.NamingException;
376375
import org.summerboot.jexpress.boot.annotation.Service;
377376
import org.summerboot.jexpress.nio.server.RequestProcessor;
378-
import org.summerboot.jexpress.nio.server.domain.ServiceContext;
377+
import org.summerboot.jexpress.nio.server.SessionContext;
379378
import org.summerboot.jexpress.security.auth.Authenticator;
380379
import org.summerboot.jexpress.security.auth.AuthenticatorListener;
381380
import org.summerboot.jexpress.security.auth.BootAuthenticator;
@@ -387,7 +386,7 @@ import org.summerboot.jexpress.security.auth.User;
387386
public class MyAuthenticator extends BootAuthenticator<Long> {
388387
389388
@Override
390-
protected Caller authenticate(String usename, String password, Long metaData, AuthenticatorListener listener, ServiceContext context) throws NamingException {
389+
protected Caller authenticate(String usename, String password, Long metaData, AuthenticatorListener listener, SessionContext context) throws NamingException {
391390
// verify username and password against LDAP
392391
if ("wrongpwd".equals(password)) {
393392
return null;
@@ -403,7 +402,7 @@ public class MyAuthenticator extends BootAuthenticator<Long> {
403402
}
404403
405404
@Override
406-
public boolean customizedAuthorizationCheck(RequestProcessor processor, HttpHeaders httpRequestHeaders, String httpRequestPath, ServiceContext context) throws Exception {
405+
public boolean customizedAuthorizationCheck(RequestProcessor processor, HttpHeaders httpRequestHeaders, String httpRequestPath, SessionContext context) throws Exception {
407406
return true;
408407
}
409408
@@ -592,10 +591,10 @@ my.key.name=DEC(plain password)
592591

593592
Your application launched as system service controlled by root admin, and runs with
594593

595-
> “-cfgdir <path to config folder> -authfile <path to root password file>”
594+
> “-authfile <path to root password file>”
596595
597596
```
598-
java -jar my-service.jar -cfgdir dev/configuration -authfile /etc/security/my-service.root_pwd
597+
java -jar jExpressApp.jar -authfile /etc/security/my-service-name.root_pwd
599598
```
600599
601600
Your root password is stored in file /etc/security/my-service.root_pwd, and has the following format:
@@ -876,10 +875,10 @@ configuration change event, TPS, etc.), below is a sample:
876875

877876
**9.3 Sample Code**
878877

879-
Use @Service annotation with implTag attribute
878+
Use @Service annotation with AlternativeName attribute
880879

881880
```
882-
@Service(implTag="myTag")
881+
@Service(AlternativeName="myImpl")
883882
```
884883

885884
Full version:
@@ -890,12 +889,12 @@ public class MyServiceImpl implements MyServcie {
890889
...
891890
}
892891

893-
@Service(implTag="impl1")
892+
@Service(AlternativeName="impl1")
894893
public class MyServiceImpl_1 implements MyServcie {
895894
...
896895
}
897896

898-
@Service(implTag="impl2")
897+
@Service(AlternativeName="impl2")
899898
public class MyServiceImpl_2 implements MyServcie {
900899
...
901900
}
@@ -991,20 +990,31 @@ java -jar my-service.jar -unique POI
991990

992991
## 11. Plugin - run with external jar files in plugin foler
993992

994-
**10.1 Intent**
993+
**11.1 Intent**
995994

996995
- Once the application is on production, need a way to add new features or override existing logic without changing the
997996
exiting code
998997

999-
**10.2 Motivation**
998+
**11.2 Motivation**
1000999

10011000
- Make the application focus on interface, and its implements could be developed as external jar files
10021001
- Make the visitor pattern available at the application level
10031002
- You can even put all your logic in one or multiple external jar files developed by different teams as plugins
10041003

1005-
**10.3 Supported types**
1004+
**11.3 Supported types**
10061005

10071006
- Web Controllers @Controller
10081007
- Service implementations with @service
10091008
- JExpressConfig configurations implementations with @ImportResource
10101009
- Classes with @Unique
1010+
1011+
## 12. White/Black list protected HTTP and gRPC server
1012+
1013+
**12.1 Intent**
1014+
1015+
- Have the ability to not to open the dorr to everyone from outside to your service
1016+
1017+
**12.2 Motivation**
1018+
1019+
- Some testing processes require the service only availbe to limited caller and tell others not to send request to this service to make it easy for trouble shooting
1020+
- In production, it may requires to mmake service (HTTP or gRPC) availb to caller from centain IP range

0 commit comments

Comments
 (0)