From f718164df836614d879104cbfd3e53142ac4b4d3 Mon Sep 17 00:00:00 2001 From: "Yong.Teng" Date: Wed, 27 Dec 2023 14:05:56 +0800 Subject: [PATCH 1/5] Upgrade 2.3.3 --- CHANGELOG.md | 10 ++++++++++ buession-cas-audit-core/pom.xml | 2 +- buession-cas-audit-couchbase/pom.xml | 2 +- buession-cas-audit-couchdb/pom.xml | 2 +- buession-cas-audit-jdbc/pom.xml | 2 +- buession-cas-audit-mongodb/pom.xml | 2 +- buession-cas-audit-redis/pom.xml | 2 +- buession-cas-audit-rest/pom.xml | 2 +- buession-cas-audit/pom.xml | 2 +- buession-cas-authentication/pom.xml | 2 +- buession-cas-captcha/pom.xml | 2 +- buession-cas-client/pom.xml | 2 +- buession-cas-core/pom.xml | 2 +- buession-cas-logging/pom.xml | 2 +- buession-cas-metrics/pom.xml | 2 +- buession-cas-oauth/pom.xml | 2 +- buession-cas-parent/pom.xml | 14 +++++++------- buession-cas-rest/pom.xml | 2 +- buession-cas-service-cassandra/pom.xml | 2 +- buession-cas-service-core/pom.xml | 2 +- buession-cas-service-cosmosdb/pom.xml | 2 +- buession-cas-service-couchbase/pom.xml | 2 +- buession-cas-service-couchdb/pom.xml | 2 +- buession-cas-service-git/pom.xml | 2 +- buession-cas-service-jdbc/pom.xml | 2 +- buession-cas-service-json/pom.xml | 2 +- buession-cas-service-ldap/pom.xml | 2 +- buession-cas-service-mongodb/pom.xml | 2 +- buession-cas-service-redis/pom.xml | 2 +- buession-cas-service-rest/pom.xml | 2 +- buession-cas-service-yaml/pom.xml | 2 +- buession-cas-service/pom.xml | 2 +- buession-cas-session-core/pom.xml | 2 +- buession-cas-session-hazelcast/pom.xml | 2 +- buession-cas-session-jdbc/pom.xml | 2 +- buession-cas-session-mongodb/pom.xml | 2 +- buession-cas-session-redis/pom.xml | 2 +- buession-cas-session/pom.xml | 2 +- buession-cas-support-cassandra/pom.xml | 2 +- buession-cas-support-couchbase/pom.xml | 2 +- buession-cas-support-couchdb/pom.xml | 2 +- buession-cas-support-hazelcast/pom.xml | 2 +- buession-cas-support-jdbc/pom.xml | 2 +- buession-cas-support-mongodb/pom.xml | 2 +- buession-cas-support-redis/pom.xml | 2 +- buession-cas-support/pom.xml | 2 +- buession-cas-throttle-bucket4j/pom.xml | 2 +- buession-cas-throttle-core/pom.xml | 2 +- buession-cas-throttle-couchdb/pom.xml | 2 +- buession-cas-throttle-hazelcast/pom.xml | 2 +- buession-cas-throttle-jdbc/pom.xml | 2 +- buession-cas-throttle-mongodb/pom.xml | 2 +- buession-cas-throttle-redis/pom.xml | 2 +- buession-cas-throttle/pom.xml | 2 +- buession-cas-ticket-cassandra/pom.xml | 2 +- buession-cas-ticket-core/pom.xml | 2 +- buession-cas-ticket-couchbase/pom.xml | 2 +- buession-cas-ticket-couchdb/pom.xml | 2 +- buession-cas-ticket-ehcache/pom.xml | 2 +- buession-cas-ticket-hazelcast/pom.xml | 2 +- buession-cas-ticket-ignite/pom.xml | 2 +- buession-cas-ticket-infinispan/pom.xml | 2 +- buession-cas-ticket-jdbc/pom.xml | 2 +- buession-cas-ticket-jms/pom.xml | 2 +- buession-cas-ticket-memcached/pom.xml | 2 +- buession-cas-ticket-mongodb/pom.xml | 2 +- buession-cas-ticket-redis/pom.xml | 2 +- buession-cas-ticket/pom.xml | 2 +- buession-cas-token/pom.xml | 2 +- buession-cas-view/pom.xml | 2 +- buession-cas-web/pom.xml | 2 +- buession-cas-webflow/pom.xml | 2 +- 72 files changed, 87 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f620ce..fae60d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ =========================== +## [2.3.3](https://github.com/buession/buession-cas/releases/tag/v2.3.3) (2024-xx-xx) + +### 🔨依赖升级 + +- [依赖库版本升级和安全漏洞修复](https://github.com/buession/buession-parent/releases/tag/v2.3.3) + + +--- + + ## [2.3.2](https://github.com/buession/buession-cas/releases/tag/v2.3.2) (2023-12-27) ### 🔨依赖升级 diff --git a/buession-cas-audit-core/pom.xml b/buession-cas-audit-core/pom.xml index c6c0900..8f2bac1 100644 --- a/buession-cas-audit-core/pom.xml +++ b/buession-cas-audit-core/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit-core https://cas.buession.com/ diff --git a/buession-cas-audit-couchbase/pom.xml b/buession-cas-audit-couchbase/pom.xml index 4bc1977..3081687 100644 --- a/buession-cas-audit-couchbase/pom.xml +++ b/buession-cas-audit-couchbase/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit-couchbase https://cas.buession.com/ diff --git a/buession-cas-audit-couchdb/pom.xml b/buession-cas-audit-couchdb/pom.xml index be48aee..5f9f3f4 100644 --- a/buession-cas-audit-couchdb/pom.xml +++ b/buession-cas-audit-couchdb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit-couchdb https://cas.buession.com/ diff --git a/buession-cas-audit-jdbc/pom.xml b/buession-cas-audit-jdbc/pom.xml index 0e6a777..3b5bf15 100644 --- a/buession-cas-audit-jdbc/pom.xml +++ b/buession-cas-audit-jdbc/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit-jdbc https://cas.buession.com/ diff --git a/buession-cas-audit-mongodb/pom.xml b/buession-cas-audit-mongodb/pom.xml index d5f5c88..1e67da1 100644 --- a/buession-cas-audit-mongodb/pom.xml +++ b/buession-cas-audit-mongodb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit-mongodb https://cas.buession.com/ diff --git a/buession-cas-audit-redis/pom.xml b/buession-cas-audit-redis/pom.xml index d0a23aa..f14a57e 100644 --- a/buession-cas-audit-redis/pom.xml +++ b/buession-cas-audit-redis/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit-redis https://cas.buession.com/ diff --git a/buession-cas-audit-rest/pom.xml b/buession-cas-audit-rest/pom.xml index b79a583..d553631 100644 --- a/buession-cas-audit-rest/pom.xml +++ b/buession-cas-audit-rest/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit-rest https://cas.buession.com/ diff --git a/buession-cas-audit/pom.xml b/buession-cas-audit/pom.xml index 363e0ca..33dbbf8 100644 --- a/buession-cas-audit/pom.xml +++ b/buession-cas-audit/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-audit https://cas.buession.com/ diff --git a/buession-cas-authentication/pom.xml b/buession-cas-authentication/pom.xml index 2fd4a58..27e1605 100644 --- a/buession-cas-authentication/pom.xml +++ b/buession-cas-authentication/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-authentication https://cas.buession.com/ diff --git a/buession-cas-captcha/pom.xml b/buession-cas-captcha/pom.xml index 9a09a2e..a2d45a2 100644 --- a/buession-cas-captcha/pom.xml +++ b/buession-cas-captcha/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-captcha https://cas.buession.com/ diff --git a/buession-cas-client/pom.xml b/buession-cas-client/pom.xml index 80e79c9..59e411a 100644 --- a/buession-cas-client/pom.xml +++ b/buession-cas-client/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-client https://cas.buession.com/ diff --git a/buession-cas-core/pom.xml b/buession-cas-core/pom.xml index 4d2d116..eb1783a 100644 --- a/buession-cas-core/pom.xml +++ b/buession-cas-core/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-core https://cas.buession.com/ diff --git a/buession-cas-logging/pom.xml b/buession-cas-logging/pom.xml index 05ea75a..6e2be00 100644 --- a/buession-cas-logging/pom.xml +++ b/buession-cas-logging/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-logging https://cas.buession.com/ diff --git a/buession-cas-metrics/pom.xml b/buession-cas-metrics/pom.xml index 707a42e..cfd176b 100644 --- a/buession-cas-metrics/pom.xml +++ b/buession-cas-metrics/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-metrics https://cas.buession.com/ diff --git a/buession-cas-oauth/pom.xml b/buession-cas-oauth/pom.xml index 55d197b..e66aaf7 100644 --- a/buession-cas-oauth/pom.xml +++ b/buession-cas-oauth/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-oauth https://cas.buession.com/ diff --git a/buession-cas-parent/pom.xml b/buession-cas-parent/pom.xml index 9e3d8e5..1357c21 100644 --- a/buession-cas-parent/pom.xml +++ b/buession-cas-parent/pom.xml @@ -7,13 +7,13 @@ com.buession parent - 2.3.2 + 2.3.3 com.buession.cas buession-cas-parent https://cas.buession.com/ Buession Framework CAS Parent - 2.3.2 + 2.3.3 pom @@ -131,11 +131,11 @@ 11 11 11 - 2.3.2 - 2.3.2 - 0.0.3 - 2.3.2 - 2.3.2 + 2.3.3 + 2.3.3 + 0.0.4 + 2.3.3 + 2.3.3 6.3.7.4 diff --git a/buession-cas-rest/pom.xml b/buession-cas-rest/pom.xml index 2828814..02e3231 100644 --- a/buession-cas-rest/pom.xml +++ b/buession-cas-rest/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-rest https://cas.buession.com/ diff --git a/buession-cas-service-cassandra/pom.xml b/buession-cas-service-cassandra/pom.xml index f9340aa..784343a 100644 --- a/buession-cas-service-cassandra/pom.xml +++ b/buession-cas-service-cassandra/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-cassandra https://cas.buession.com/ diff --git a/buession-cas-service-core/pom.xml b/buession-cas-service-core/pom.xml index 991df19..192f470 100644 --- a/buession-cas-service-core/pom.xml +++ b/buession-cas-service-core/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-core https://cas.buession.com/ diff --git a/buession-cas-service-cosmosdb/pom.xml b/buession-cas-service-cosmosdb/pom.xml index e3dcdd6..32482c5 100644 --- a/buession-cas-service-cosmosdb/pom.xml +++ b/buession-cas-service-cosmosdb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-cosmosdb https://cas.buession.com/ diff --git a/buession-cas-service-couchbase/pom.xml b/buession-cas-service-couchbase/pom.xml index 7e708e6..5a3682d 100644 --- a/buession-cas-service-couchbase/pom.xml +++ b/buession-cas-service-couchbase/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-couchbase https://cas.buession.com/ diff --git a/buession-cas-service-couchdb/pom.xml b/buession-cas-service-couchdb/pom.xml index a645ab5..d5bf582 100644 --- a/buession-cas-service-couchdb/pom.xml +++ b/buession-cas-service-couchdb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-couchdb https://cas.buession.com/ diff --git a/buession-cas-service-git/pom.xml b/buession-cas-service-git/pom.xml index 1f3e244..a2913d1 100644 --- a/buession-cas-service-git/pom.xml +++ b/buession-cas-service-git/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-git https://cas.buession.com/ diff --git a/buession-cas-service-jdbc/pom.xml b/buession-cas-service-jdbc/pom.xml index 9e22554..b84751f 100644 --- a/buession-cas-service-jdbc/pom.xml +++ b/buession-cas-service-jdbc/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-jdbc https://cas.buession.com/ diff --git a/buession-cas-service-json/pom.xml b/buession-cas-service-json/pom.xml index f1fe8bd..ae2413c 100644 --- a/buession-cas-service-json/pom.xml +++ b/buession-cas-service-json/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-json https://cas.buession.com/ diff --git a/buession-cas-service-ldap/pom.xml b/buession-cas-service-ldap/pom.xml index 24cf108..5d537dc 100644 --- a/buession-cas-service-ldap/pom.xml +++ b/buession-cas-service-ldap/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-ldap https://cas.buession.com/ diff --git a/buession-cas-service-mongodb/pom.xml b/buession-cas-service-mongodb/pom.xml index a0f0b5c..8d836ed 100644 --- a/buession-cas-service-mongodb/pom.xml +++ b/buession-cas-service-mongodb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-mongodb https://cas.buession.com/ diff --git a/buession-cas-service-redis/pom.xml b/buession-cas-service-redis/pom.xml index c80f0f9..28ff232 100644 --- a/buession-cas-service-redis/pom.xml +++ b/buession-cas-service-redis/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-redis https://cas.buession.com/ diff --git a/buession-cas-service-rest/pom.xml b/buession-cas-service-rest/pom.xml index aa75382..2b74ce6 100644 --- a/buession-cas-service-rest/pom.xml +++ b/buession-cas-service-rest/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-rest https://cas.buession.com/ diff --git a/buession-cas-service-yaml/pom.xml b/buession-cas-service-yaml/pom.xml index 71643c7..893c6b8 100644 --- a/buession-cas-service-yaml/pom.xml +++ b/buession-cas-service-yaml/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service-yaml https://cas.buession.com/ diff --git a/buession-cas-service/pom.xml b/buession-cas-service/pom.xml index 0418900..e7792a1 100644 --- a/buession-cas-service/pom.xml +++ b/buession-cas-service/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-service https://cas.buession.com/ diff --git a/buession-cas-session-core/pom.xml b/buession-cas-session-core/pom.xml index 44be522..46f4399 100644 --- a/buession-cas-session-core/pom.xml +++ b/buession-cas-session-core/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-session-core https://cas.buession.com/ diff --git a/buession-cas-session-hazelcast/pom.xml b/buession-cas-session-hazelcast/pom.xml index d77fe7a..67f01f1 100644 --- a/buession-cas-session-hazelcast/pom.xml +++ b/buession-cas-session-hazelcast/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-session-hazelcast https://cas.buession.com/ diff --git a/buession-cas-session-jdbc/pom.xml b/buession-cas-session-jdbc/pom.xml index 37cfe58..4f719ae 100644 --- a/buession-cas-session-jdbc/pom.xml +++ b/buession-cas-session-jdbc/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-session-jdbc https://cas.buession.com/ diff --git a/buession-cas-session-mongodb/pom.xml b/buession-cas-session-mongodb/pom.xml index 6032419..b71c84f 100644 --- a/buession-cas-session-mongodb/pom.xml +++ b/buession-cas-session-mongodb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-session-mongodb https://cas.buession.com/ diff --git a/buession-cas-session-redis/pom.xml b/buession-cas-session-redis/pom.xml index b0c6b97..795155e 100644 --- a/buession-cas-session-redis/pom.xml +++ b/buession-cas-session-redis/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-session-redis https://cas.buession.com/ diff --git a/buession-cas-session/pom.xml b/buession-cas-session/pom.xml index 7eb9768..e999ad9 100644 --- a/buession-cas-session/pom.xml +++ b/buession-cas-session/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-session https://cas.buession.com/ diff --git a/buession-cas-support-cassandra/pom.xml b/buession-cas-support-cassandra/pom.xml index 5b3f798..930a78f 100644 --- a/buession-cas-support-cassandra/pom.xml +++ b/buession-cas-support-cassandra/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support-cassandra https://cas.buession.com/ diff --git a/buession-cas-support-couchbase/pom.xml b/buession-cas-support-couchbase/pom.xml index bd5f343..e514a20 100644 --- a/buession-cas-support-couchbase/pom.xml +++ b/buession-cas-support-couchbase/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support-couchbase https://cas.buession.com/ diff --git a/buession-cas-support-couchdb/pom.xml b/buession-cas-support-couchdb/pom.xml index b5f9717..5a25b21 100644 --- a/buession-cas-support-couchdb/pom.xml +++ b/buession-cas-support-couchdb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support-couchdb https://cas.buession.com/ diff --git a/buession-cas-support-hazelcast/pom.xml b/buession-cas-support-hazelcast/pom.xml index cba8a87..d0474d2 100644 --- a/buession-cas-support-hazelcast/pom.xml +++ b/buession-cas-support-hazelcast/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support-hazelcast https://cas.buession.com/ diff --git a/buession-cas-support-jdbc/pom.xml b/buession-cas-support-jdbc/pom.xml index b56c9d1..786cff3 100644 --- a/buession-cas-support-jdbc/pom.xml +++ b/buession-cas-support-jdbc/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support-jdbc https://cas.buession.com/ diff --git a/buession-cas-support-mongodb/pom.xml b/buession-cas-support-mongodb/pom.xml index 79137c3..1e868cd 100644 --- a/buession-cas-support-mongodb/pom.xml +++ b/buession-cas-support-mongodb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support-mongodb https://cas.buession.com/ diff --git a/buession-cas-support-redis/pom.xml b/buession-cas-support-redis/pom.xml index 4169bdb..407973f 100644 --- a/buession-cas-support-redis/pom.xml +++ b/buession-cas-support-redis/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support-redis https://cas.buession.com/ diff --git a/buession-cas-support/pom.xml b/buession-cas-support/pom.xml index 7a5c607..6724cbd 100644 --- a/buession-cas-support/pom.xml +++ b/buession-cas-support/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-support https://cas.buession.com/ diff --git a/buession-cas-throttle-bucket4j/pom.xml b/buession-cas-throttle-bucket4j/pom.xml index 28d7179..9cad83d 100644 --- a/buession-cas-throttle-bucket4j/pom.xml +++ b/buession-cas-throttle-bucket4j/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle-bucket4j https://cas.buession.com/ diff --git a/buession-cas-throttle-core/pom.xml b/buession-cas-throttle-core/pom.xml index 10d2da1..bb200f8 100644 --- a/buession-cas-throttle-core/pom.xml +++ b/buession-cas-throttle-core/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle-core https://cas.buession.com/ diff --git a/buession-cas-throttle-couchdb/pom.xml b/buession-cas-throttle-couchdb/pom.xml index cb64f89..45cf02d 100644 --- a/buession-cas-throttle-couchdb/pom.xml +++ b/buession-cas-throttle-couchdb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle-couchdb https://cas.buession.com/ diff --git a/buession-cas-throttle-hazelcast/pom.xml b/buession-cas-throttle-hazelcast/pom.xml index 79fab19..a92ee07 100644 --- a/buession-cas-throttle-hazelcast/pom.xml +++ b/buession-cas-throttle-hazelcast/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle-hazelcast https://cas.buession.com/ diff --git a/buession-cas-throttle-jdbc/pom.xml b/buession-cas-throttle-jdbc/pom.xml index 06f09f4..2447614 100644 --- a/buession-cas-throttle-jdbc/pom.xml +++ b/buession-cas-throttle-jdbc/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle-jdbc https://cas.buession.com/ diff --git a/buession-cas-throttle-mongodb/pom.xml b/buession-cas-throttle-mongodb/pom.xml index 85ca6e4..59e60ef 100644 --- a/buession-cas-throttle-mongodb/pom.xml +++ b/buession-cas-throttle-mongodb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle-mongodb https://cas.buession.com/ diff --git a/buession-cas-throttle-redis/pom.xml b/buession-cas-throttle-redis/pom.xml index f265107..3a141e4 100644 --- a/buession-cas-throttle-redis/pom.xml +++ b/buession-cas-throttle-redis/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle-redis https://cas.buession.com/ diff --git a/buession-cas-throttle/pom.xml b/buession-cas-throttle/pom.xml index f266f4f..e2d400d 100644 --- a/buession-cas-throttle/pom.xml +++ b/buession-cas-throttle/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-throttle https://cas.buession.com/ diff --git a/buession-cas-ticket-cassandra/pom.xml b/buession-cas-ticket-cassandra/pom.xml index 9b2b0a0..7abd79d 100644 --- a/buession-cas-ticket-cassandra/pom.xml +++ b/buession-cas-ticket-cassandra/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-cassandra https://cas.buession.com/ diff --git a/buession-cas-ticket-core/pom.xml b/buession-cas-ticket-core/pom.xml index e99a2f2..5c36943 100644 --- a/buession-cas-ticket-core/pom.xml +++ b/buession-cas-ticket-core/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-core https://cas.buession.com/ diff --git a/buession-cas-ticket-couchbase/pom.xml b/buession-cas-ticket-couchbase/pom.xml index 8ef200e..f99487f 100644 --- a/buession-cas-ticket-couchbase/pom.xml +++ b/buession-cas-ticket-couchbase/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-couchbase https://cas.buession.com/ diff --git a/buession-cas-ticket-couchdb/pom.xml b/buession-cas-ticket-couchdb/pom.xml index 8b5d8ce..3c1dd84 100644 --- a/buession-cas-ticket-couchdb/pom.xml +++ b/buession-cas-ticket-couchdb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-couchdb https://cas.buession.com/ diff --git a/buession-cas-ticket-ehcache/pom.xml b/buession-cas-ticket-ehcache/pom.xml index 2941834..0c30bc2 100644 --- a/buession-cas-ticket-ehcache/pom.xml +++ b/buession-cas-ticket-ehcache/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-ehcache https://cas.buession.com/ diff --git a/buession-cas-ticket-hazelcast/pom.xml b/buession-cas-ticket-hazelcast/pom.xml index 314a3ec..dc90ade 100644 --- a/buession-cas-ticket-hazelcast/pom.xml +++ b/buession-cas-ticket-hazelcast/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-hazelcast https://cas.buession.com/ diff --git a/buession-cas-ticket-ignite/pom.xml b/buession-cas-ticket-ignite/pom.xml index 933fe0e..832bc54 100644 --- a/buession-cas-ticket-ignite/pom.xml +++ b/buession-cas-ticket-ignite/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-ignite https://cas.buession.com/ diff --git a/buession-cas-ticket-infinispan/pom.xml b/buession-cas-ticket-infinispan/pom.xml index 96dd681..5f749fb 100644 --- a/buession-cas-ticket-infinispan/pom.xml +++ b/buession-cas-ticket-infinispan/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-infinispan https://cas.buession.com/ diff --git a/buession-cas-ticket-jdbc/pom.xml b/buession-cas-ticket-jdbc/pom.xml index 5710e23..6a6b77c 100644 --- a/buession-cas-ticket-jdbc/pom.xml +++ b/buession-cas-ticket-jdbc/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-jdbc https://cas.buession.com/ diff --git a/buession-cas-ticket-jms/pom.xml b/buession-cas-ticket-jms/pom.xml index 001bcde..f450cf8 100644 --- a/buession-cas-ticket-jms/pom.xml +++ b/buession-cas-ticket-jms/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-jms https://cas.buession.com/ diff --git a/buession-cas-ticket-memcached/pom.xml b/buession-cas-ticket-memcached/pom.xml index a64010c..b41ebe2 100644 --- a/buession-cas-ticket-memcached/pom.xml +++ b/buession-cas-ticket-memcached/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-memcached https://cas.buession.com/ diff --git a/buession-cas-ticket-mongodb/pom.xml b/buession-cas-ticket-mongodb/pom.xml index a85872c..78a1bb5 100644 --- a/buession-cas-ticket-mongodb/pom.xml +++ b/buession-cas-ticket-mongodb/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-mongodb https://cas.buession.com/ diff --git a/buession-cas-ticket-redis/pom.xml b/buession-cas-ticket-redis/pom.xml index b53256d..3ea28e3 100644 --- a/buession-cas-ticket-redis/pom.xml +++ b/buession-cas-ticket-redis/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket-redis https://cas.buession.com/ diff --git a/buession-cas-ticket/pom.xml b/buession-cas-ticket/pom.xml index 80a8888..3584ede 100644 --- a/buession-cas-ticket/pom.xml +++ b/buession-cas-ticket/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-ticket https://cas.buession.com/ diff --git a/buession-cas-token/pom.xml b/buession-cas-token/pom.xml index d0d6943..37fd3a5 100644 --- a/buession-cas-token/pom.xml +++ b/buession-cas-token/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-token https://cas.buession.com/ diff --git a/buession-cas-view/pom.xml b/buession-cas-view/pom.xml index 4eb0074..37c88d1 100644 --- a/buession-cas-view/pom.xml +++ b/buession-cas-view/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-view https://cas.buession.com/ diff --git a/buession-cas-web/pom.xml b/buession-cas-web/pom.xml index 6d072b3..d5cfd78 100644 --- a/buession-cas-web/pom.xml +++ b/buession-cas-web/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-web https://cas.buession.com/ diff --git a/buession-cas-webflow/pom.xml b/buession-cas-webflow/pom.xml index f27b850..c0fabfb 100644 --- a/buession-cas-webflow/pom.xml +++ b/buession-cas-webflow/pom.xml @@ -7,7 +7,7 @@ com.buession.cas buession-cas-parent ../buession-cas-parent - 2.3.2 + 2.3.3 buession-cas-webflow https://cas.buession.com/ From 341906ed48f2434d175293b0d5f5d8a658f1c3da Mon Sep 17 00:00:00 2001 From: "Yong.Teng" Date: Tue, 2 Apr 2024 21:50:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=A8=A1=E5=BC=8F=EF=BC=8C=E9=9B=86?= =?UTF-8?q?=E6=88=90=20com.buession.logging:buession-logging-support-conso?= =?UTF-8?q?le=20&&=20=E4=BC=98=E5=8C=96=E5=92=8C=E8=A7=84=E8=8C=83=20LogHa?= =?UTF-8?q?ndler=20bean=20=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buession-cas-logging/pom.xml | 6 + .../org/apereo/cas/logging/Constants.java | 4 + .../AbstractLogHandlerConfiguration.java | 34 +- .../BaseLoginLoggingConfiguration.java | 67 ++ .../BasicLoginLoggingConfiguration.java | 112 +--- .../HistoryLoginLoggingConfiguration.java | 55 +- .../LoginLoggingConfiguration.java | 59 ++ .../ConsoleLogHandlerConfiguration.java | 82 +++ .../autoconfigure/console/package-info.java | 29 + .../ElasticsearchLogHandlerConfiguration.java | 80 +-- .../jdbc/JdbcLogHandlerConfiguration.java | 132 +++- .../autoconfigure/jdbc/package-info.java | 2 +- .../kafka/KafkaLogHandlerConfiguration.java | 95 +-- .../mongo/MongoLogHandlerConfiguration.java | 251 ++++---- .../rabbit/RabbitLogHandlerConfiguration.java | 97 +-- .../rest/RestLogHandlerConfiguration.java | 39 +- .../logging/config/BaseJdbcLogProperties.java | 189 ++++++ .../basic/BasicConsoleLogProperties.java | 43 +- .../config/basic/BasicJdbcLogProperties.java | 604 +----------------- .../history/HistoryJdbcLogProperties.java | 207 +----- .../DefaultBasicLoginLoggingManager.java | 51 ++ .../manager/JdbcBasicLoginLoggingManager.java | 305 --------- .../CasConsoleLogDataFormatter.java} | 26 +- .../console}/package-info.java | 4 +- .../org/apereo/cas/logging/package-info.java | 2 +- .../CasLoginLoggingConfiguration.java | 6 +- .../main/resources/META-INF/spring.factories | 2 + 27 files changed, 1020 insertions(+), 1563 deletions(-) create mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BaseLoginLoggingConfiguration.java create mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/LoginLoggingConfiguration.java create mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java create mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/package-info.java create mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/config/BaseJdbcLogProperties.java create mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/DefaultBasicLoginLoggingManager.java delete mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/JdbcBasicLoginLoggingManager.java rename buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/{ConsoleBasicLoginLoggingManager.java => console/CasConsoleLogDataFormatter.java} (82%) rename buession-cas-logging/src/main/java/org/apereo/cas/logging/{utils => manager/console}/package-info.java (93%) diff --git a/buession-cas-logging/pom.xml b/buession-cas-logging/pom.xml index 6e2be00..cb49385 100644 --- a/buession-cas-logging/pom.xml +++ b/buession-cas-logging/pom.xml @@ -80,6 +80,12 @@ buession-logging-spring ${buession.logging.version} + + com.buession.logging + buession-logging-support-console + ${buession.logging.version} + provided + com.buession.logging buession-logging-support-elasticsearch diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/Constants.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/Constants.java index e6d2b1e..b342c1c 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/Constants.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/Constants.java @@ -38,8 +38,12 @@ public interface Constants { String BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_TEMPLATE_BEAN_NAME = "basicLoginLoggingJdbcTransactionTemplate"; + String BASIC_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME = "basicLoginLoggingManagerFactory"; + String BASIC_LOGIN_LOGGING_MANAGER_BEAN_NAME = "basicLoginLoggingManager"; + String HISTORY_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME = "historyLoginLoggingManagerFactory"; + String HISTORY_LOGIN_LOGGING_MANAGER_BEAN_NAME = "historyLoginLoggingManager"; } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/AbstractLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/AbstractLogHandlerConfiguration.java index 1a17931..570897c 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/AbstractLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/AbstractLogHandlerConfiguration.java @@ -32,16 +32,38 @@ * @author Yong.Teng * @since 2.3.0 */ -public abstract class AbstractLogHandlerConfiguration

{ +public abstract class AbstractLogHandlerConfiguration { - public final static String PREFIX = CasLoggingConfigurationProperties.PREFIX + ".history"; + protected final static PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull(); - protected final P handlerProperties; + public static class AbstractBasicLogHandlerConfiguration

+ extends AbstractLogHandlerConfiguration { - protected final PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull(); + public final static String PREFIX = CasLoggingConfigurationProperties.PREFIX + ".basic"; + + public final static String LOG_HANDLER_BEAN_NAME = "basicLoggingLogHandler"; + + protected final P handlerProperties; + + public AbstractBasicLogHandlerConfiguration(final P handlerProperties) { + this.handlerProperties = handlerProperties; + } + + } + + public static class AbstractHistoryLogHandlerConfiguration

+ extends AbstractLogHandlerConfiguration { + + public final static String PREFIX = CasLoggingConfigurationProperties.PREFIX + ".history"; + + public final static String LOG_HANDLER_BEAN_NAME = "historyLoggingLogHandler"; + + protected final P handlerProperties; + + public AbstractHistoryLogHandlerConfiguration(final P handlerProperties) { + this.handlerProperties = handlerProperties; + } - public AbstractLogHandlerConfiguration(final P handlerProperties) { - this.handlerProperties = handlerProperties; } } \ No newline at end of file diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BaseLoginLoggingConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BaseLoginLoggingConfiguration.java new file mode 100644 index 0000000..133e56c --- /dev/null +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BaseLoginLoggingConfiguration.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + * + * ========================================================================================================= + * + * This software consists of voluntary contributions made by many individuals on behalf of the + * Apache Software Foundation. For more information on the Apache Software Foundation, please see + * . + * + * +-------------------------------------------------------------------------------------------------------+ + * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | + * | Author: Yong.Teng | + * | Copyright @ 2013-2024 Buession.com Inc. | + * +-------------------------------------------------------------------------------------------------------+ + */ +package org.apereo.cas.logging.autoconfigure; + +import com.buession.core.validator.Validate; +import com.buession.geoip.Resolver; +import com.buession.logging.core.handler.LogHandler; +import com.buession.logging.core.handler.PrincipalHandler; +import com.buession.logging.core.request.RequestContext; +import com.buession.logging.spring.LogManagerFactoryBean; +import org.apereo.cas.core.CasCoreConfigurationProperties; +import org.springframework.beans.factory.ObjectProvider; + +/** + * @author Yong.Teng + * @since 2.3.3 + */ +public abstract class BaseLoginLoggingConfiguration { + + protected final CasCoreConfigurationProperties casCoreConfigurationProperties; + + public BaseLoginLoggingConfiguration(CasCoreConfigurationProperties casCoreConfigurationProperties) { + this.casCoreConfigurationProperties = casCoreConfigurationProperties; + } + + protected LogManagerFactoryBean createLogManagerFactoryBean( + final ObjectProvider> principalHandler, + final ObjectProvider requestContext, + final ObjectProvider logHandler, + final ObjectProvider geoResolver) { + final LogManagerFactoryBean logManagerFactoryBean = new LogManagerFactoryBean(); + + requestContext.ifAvailable(logManagerFactoryBean::setRequestContext); + geoResolver.ifAvailable(logManagerFactoryBean::setGeoResolver); + principalHandler.ifAvailable(logManagerFactoryBean::setPrincipalHandler); + logHandler.ifAvailable(logManagerFactoryBean::setLogHandler); + + if(Validate.isNotBlank(casCoreConfigurationProperties.getClientRealIpHeaderName())){ + logManagerFactoryBean.setClientIpHeaderName(casCoreConfigurationProperties.getClientRealIpHeaderName()); + } + + return logManagerFactoryBean; + } + +} diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BasicLoginLoggingConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BasicLoginLoggingConfiguration.java index 20721d1..bab6179 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BasicLoginLoggingConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/BasicLoginLoggingConfiguration.java @@ -19,117 +19,57 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure; -import org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties; -import org.apereo.cas.configuration.support.JpaBeans; +import com.buession.geoip.Resolver; +import com.buession.logging.core.handler.LogHandler; +import com.buession.logging.core.handler.PrincipalHandler; +import com.buession.logging.core.mgt.LogManager; +import com.buession.logging.core.request.RequestContext; +import com.buession.logging.spring.LogManagerFactoryBean; +import org.apereo.cas.core.CasCoreConfigurationProperties; import org.apereo.cas.logging.Constants; import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; import org.apereo.cas.logging.manager.BasicLoginLoggingManager; -import org.apereo.cas.logging.manager.ConsoleBasicLoginLoggingManager; -import org.apereo.cas.logging.manager.JdbcBasicLoginLoggingManager; +import org.apereo.cas.logging.manager.DefaultBasicLoginLoggingManager; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.support.TransactionTemplate; - -import javax.sql.DataSource; /** * @author Yong.Teng * @since 2.3.0 */ @Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties({CasLoggingConfigurationProperties.class}) +@EnableConfigurationProperties({CasCoreConfigurationProperties.class, CasLoggingConfigurationProperties.class}) @ConditionalOnProperty(prefix = CasLoggingConfigurationProperties.PREFIX, name = "enabled", havingValue = "true") -public class BasicLoginLoggingConfiguration { - - private final static String PREFIX = CasLoggingConfigurationProperties.PREFIX + ".basic"; - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties({CasLoggingConfigurationProperties.class}) - @ConditionalOnProperty(prefix = PREFIX, name = "jdbc.enabled", havingValue = "true") - @ConditionalOnMissingBean(name = Constants.BASIC_LOGIN_LOGGING_MANAGER_BEAN_NAME) - static class BasicJdbcLoginLoggingManagerConfiguration { - - protected final CasLoggingConfigurationProperties loggingConfigurationProperties; - - protected final AbstractJpaProperties jpaProperties; - - public BasicJdbcLoginLoggingManagerConfiguration( - CasLoggingConfigurationProperties loggingConfigurationProperties) { - this.loggingConfigurationProperties = loggingConfigurationProperties; - this.jpaProperties = loggingConfigurationProperties.getBasic().getJdbc(); - } - - @Bean(name = Constants.BASIC_LOGIN_LOGGING_DATASOURCE_BEAN_NAME) - @ConditionalOnMissingBean(name = Constants.BASIC_LOGIN_LOGGING_DATASOURCE_BEAN_NAME) - public DataSource basicLoginLoggingDataSource() { - return JpaBeans.newDataSource(jpaProperties); - } - - @Bean(name = Constants.BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_MANAGER_BEAN_NAME) - @ConditionalOnMissingBean(name = Constants.BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_MANAGER_BEAN_NAME) - public PlatformTransactionManager basicLoginLoggingTransactionManager( - @Qualifier(Constants.BASIC_LOGIN_LOGGING_DATASOURCE_BEAN_NAME) DataSource loginLogDataSource) { - return new DataSourceTransactionManager(loginLogDataSource); - } - - @Bean(name = Constants.BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_TEMPLATE_BEAN_NAME) - @ConditionalOnMissingBean(name = Constants.BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_TEMPLATE_BEAN_NAME) - public TransactionTemplate basicLoginLoggingTransactionTemplate( - @Qualifier(Constants.BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_MANAGER_BEAN_NAME) PlatformTransactionManager loginLogTransactionManager) { - return createTransactionTemplate(loginLogTransactionManager); - } - - @Bean(name = Constants.BASIC_LOGIN_LOGGING_MANAGER_BEAN_NAME) - @ConditionalOnBean(name = Constants.BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_TEMPLATE_BEAN_NAME) - public BasicLoginLoggingManager basicLoginLoggingManager( - @Qualifier(Constants.BASIC_LOGIN_LOGGING_DATASOURCE_BEAN_NAME) ObjectProvider dataSource, - @Qualifier(Constants.BASIC_LOGIN_LOGGING_JDBC_TRANSACTION_TEMPLATE_BEAN_NAME) ObjectProvider transactionTemplate) { - return new JdbcBasicLoginLoggingManager(dataSource.getIfAvailable(), - transactionTemplate.getIfAvailable(), loggingConfigurationProperties.getBasic().getJdbc()); - } - - protected TransactionTemplate createTransactionTemplate(final PlatformTransactionManager transactionManager) { - final TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); - - transactionTemplate.setIsolationLevelName(jpaProperties.getIsolationLevelName()); - transactionTemplate.setPropagationBehaviorName(jpaProperties.getPropagationBehaviorName()); - - return transactionTemplate; - } +public class BasicLoginLoggingConfiguration extends BaseLoginLoggingConfiguration { + public BasicLoginLoggingConfiguration(CasCoreConfigurationProperties casCoreConfigurationProperties) { + super(casCoreConfigurationProperties); } - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties({CasLoggingConfigurationProperties.class}) - @ConditionalOnMissingBean(name = Constants.BASIC_LOGIN_LOGGING_MANAGER_BEAN_NAME) - static class BasicConsoleLoginLoggingManagerConfiguration { - - protected final CasLoggingConfigurationProperties loggingConfigurationProperties; - - public BasicConsoleLoginLoggingManagerConfiguration( - CasLoggingConfigurationProperties loggingConfigurationProperties) { - this.loggingConfigurationProperties = loggingConfigurationProperties; - } - - @Bean(name = Constants.BASIC_LOGIN_LOGGING_MANAGER_BEAN_NAME) - public BasicLoginLoggingManager basicLoginLoggingManager() { - return new ConsoleBasicLoginLoggingManager( - loggingConfigurationProperties.getBasic().getConsole().getMessage()); - } + @Bean(name = Constants.BASIC_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME) + @ConditionalOnMissingBean(name = {Constants.BASIC_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME}) + public LogManagerFactoryBean logManagerFactoryBean(ObjectProvider> principalHandler, + ObjectProvider requestContext, + @Qualifier(AbstractLogHandlerConfiguration.AbstractBasicLogHandlerConfiguration.LOG_HANDLER_BEAN_NAME) ObjectProvider logHandler, + ObjectProvider geoResolver) { + return createLogManagerFactoryBean(principalHandler, requestContext, logHandler, geoResolver); + } + @Bean(name = Constants.BASIC_LOGIN_LOGGING_MANAGER_BEAN_NAME) + @ConditionalOnMissingBean(name = {Constants.BASIC_LOGIN_LOGGING_MANAGER_BEAN_NAME}) + public BasicLoginLoggingManager historyLoginLoggingManager( + @Qualifier(Constants.BASIC_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME) ObjectProvider logManager) { + return new DefaultBasicLoginLoggingManager(logManager.getIfAvailable()); } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/HistoryLoginLoggingConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/HistoryLoginLoggingConfiguration.java index 8314bce..8f0a052 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/HistoryLoginLoggingConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/HistoryLoginLoggingConfiguration.java @@ -19,19 +19,16 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure; -import com.buession.core.validator.Validate; import com.buession.geoip.Resolver; -import com.buession.logging.core.handler.DefaultLogHandler; -import com.buession.logging.core.handler.DefaultPrincipalHandler; import com.buession.logging.core.handler.LogHandler; import com.buession.logging.core.handler.PrincipalHandler; import com.buession.logging.core.mgt.LogManager; -import com.buession.logging.core.request.ServletRequestContext; +import com.buession.logging.core.request.RequestContext; import com.buession.logging.spring.LogManagerFactoryBean; import org.apereo.cas.core.CasCoreConfigurationProperties; import org.apereo.cas.logging.Constants; @@ -39,6 +36,8 @@ import org.apereo.cas.logging.manager.DefaultHistoryLoginLoggingManager; import org.apereo.cas.logging.manager.HistoryLoginLoggingManager; import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -51,49 +50,25 @@ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties({CasCoreConfigurationProperties.class, CasLoggingConfigurationProperties.class}) @ConditionalOnProperty(prefix = CasLoggingConfigurationProperties.PREFIX, name = "enabled", havingValue = "true") -public class HistoryLoginLoggingConfiguration { +public class HistoryLoginLoggingConfiguration extends BaseLoginLoggingConfiguration { - private CasCoreConfigurationProperties casCoreConfigurationProperties; - - public HistoryLoginLoggingConfiguration( - CasCoreConfigurationProperties casCoreConfigurationProperties) { - this.casCoreConfigurationProperties = casCoreConfigurationProperties; + public HistoryLoginLoggingConfiguration(CasCoreConfigurationProperties casCoreConfigurationProperties) { + super(casCoreConfigurationProperties); } - @Bean + @Bean(name = Constants.HISTORY_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME) + @ConditionalOnMissingBean(name = {Constants.HISTORY_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME}) public LogManagerFactoryBean logManagerFactoryBean(ObjectProvider> principalHandler, - ObjectProvider logHandler, + ObjectProvider requestContext, + @Qualifier(AbstractLogHandlerConfiguration.AbstractHistoryLogHandlerConfiguration.LOG_HANDLER_BEAN_NAME) ObjectProvider logHandler, ObjectProvider geoResolver) { - final LogManagerFactoryBean logManagerFactoryBean = new LogManagerFactoryBean(); - - logManagerFactoryBean.setRequestContext(new ServletRequestContext()); - - geoResolver.ifUnique(logManagerFactoryBean::setGeoResolver); - principalHandler.ifUnique(logManagerFactoryBean::setPrincipalHandler); - - PrincipalHandler principalHandlerInstance = principalHandler.getIfAvailable(); - if(principalHandlerInstance == null){ - logManagerFactoryBean.setPrincipalHandler(new DefaultPrincipalHandler()); - }else{ - logManagerFactoryBean.setPrincipalHandler(principalHandlerInstance); - } - - LogHandler logHandlerInstance = logHandler.getIfAvailable(); - if(logHandlerInstance == null){ - logManagerFactoryBean.setLogHandler(new DefaultLogHandler()); - }else{ - logManagerFactoryBean.setLogHandler(logHandlerInstance); - } - - if(Validate.isNotBlank(casCoreConfigurationProperties.getClientRealIpHeaderName())){ - logManagerFactoryBean.setClientIpHeaderName(casCoreConfigurationProperties.getClientRealIpHeaderName()); - } - - return logManagerFactoryBean; + return createLogManagerFactoryBean(principalHandler, requestContext, logHandler, geoResolver); } @Bean(name = Constants.HISTORY_LOGIN_LOGGING_MANAGER_BEAN_NAME) - public HistoryLoginLoggingManager historyLoginLoggingManager(ObjectProvider logManager) { + @ConditionalOnMissingBean(name = {Constants.HISTORY_LOGIN_LOGGING_MANAGER_BEAN_NAME}) + public HistoryLoginLoggingManager historyLoginLoggingManager( + @Qualifier(Constants.HISTORY_LOGIN_LOGGING_MANAGER_FACTORY_BEAN_NAME) ObjectProvider logManager) { return new DefaultHistoryLoginLoggingManager(logManager.getIfAvailable()); } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/LoginLoggingConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/LoginLoggingConfiguration.java new file mode 100644 index 0000000..1249bee --- /dev/null +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/LoginLoggingConfiguration.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + * + * ========================================================================================================= + * + * This software consists of voluntary contributions made by many individuals on behalf of the + * Apache Software Foundation. For more information on the Apache Software Foundation, please see + * . + * + * +-------------------------------------------------------------------------------------------------------+ + * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | + * | Author: Yong.Teng | + * | Copyright @ 2013-2024 Buession.com Inc. | + * +-------------------------------------------------------------------------------------------------------+ + */ +package org.apereo.cas.logging.autoconfigure; + +import com.buession.logging.core.handler.DefaultPrincipalHandler; +import com.buession.logging.core.handler.PrincipalHandler; +import com.buession.logging.core.request.RequestContext; +import com.buession.logging.core.request.ServletRequestContext; +import org.apereo.cas.core.CasCoreConfigurationProperties; +import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.security.Principal; + +/** + * @author Yong.Teng + * @since 2.3.3 + */ +@Configuration(proxyBeanMethods = false) +@EnableConfigurationProperties({CasCoreConfigurationProperties.class, CasLoggingConfigurationProperties.class}) +@ConditionalOnProperty(prefix = CasLoggingConfigurationProperties.PREFIX, name = "enabled", havingValue = "true") +public class LoginLoggingConfiguration { + + @Bean + public RequestContext requestContext() { + return new ServletRequestContext(); + } + + @Bean + public PrincipalHandler principalHandler() { + return new DefaultPrincipalHandler(); + } + +} diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java new file mode 100644 index 0000000..5108e74 --- /dev/null +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + * + * ========================================================================================================= + * + * This software consists of voluntary contributions made by many individuals on behalf of the + * Apache Software Foundation. For more information on the Apache Software Foundation, please see + * . + * + * +-------------------------------------------------------------------------------------------------------+ + * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | + * | Author: Yong.Teng | + * | Copyright @ 2013-2024 Buession.com Inc. | + * +-------------------------------------------------------------------------------------------------------+ + */ +package org.apereo.cas.logging.autoconfigure.console; + +import com.buession.logging.console.formatter.ConsoleLogDataFormatter; +import com.buession.logging.console.spring.ConsoleLogHandlerFactoryBean; +import org.apereo.cas.logging.autoconfigure.AbstractLogHandlerConfiguration; +import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; +import org.apereo.cas.logging.config.basic.BasicConsoleLogProperties; +import org.apereo.cas.logging.manager.console.CasConsoleLogDataFormatter; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 控制台日志处理器自动配置类 + * + * @author Yong.Teng + * @since 2.3.3 + */ +@Configuration(proxyBeanMethods = false) +@EnableConfigurationProperties(CasLoggingConfigurationProperties.class) +@ConditionalOnClass(name = {"com.buession.logging.console.spring.ConsoleLogHandlerFactoryBean"}) +public class ConsoleLogHandlerConfiguration extends AbstractLogHandlerConfiguration { + + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = Basic.PREFIX, name = "console.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = Basic.LOG_HANDLER_BEAN_NAME) + static class Basic extends AbstractBasicLogHandlerConfiguration { + + public Basic(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getBasic().getConsole()); + } + + @Bean(name = "basicLoggingConsoleLogDataFormatter") + @ConditionalOnMissingBean(name = "basicLoggingConsoleLogDataFormatter") + public ConsoleLogDataFormatter consoleLogDataFormatter() { + return new CasConsoleLogDataFormatter(); + } + + @Bean(name = Basic.LOG_HANDLER_BEAN_NAME) + public ConsoleLogHandlerFactoryBean logHandlerFactoryBean( + @Qualifier("basicLoggingConsoleLogDataFormatter") ObjectProvider> consoleLogDataFormatter) { + final ConsoleLogHandlerFactoryBean logHandlerFactoryBean = new ConsoleLogHandlerFactoryBean(); + + consoleLogDataFormatter.ifAvailable(logHandlerFactoryBean::setFormatter); + propertyMapper.from(handlerProperties.getTemplate()).to(logHandlerFactoryBean::setTemplate); + + return logHandlerFactoryBean; + } + + } + +} diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/package-info.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/package-info.java new file mode 100644 index 0000000..d5a8755 --- /dev/null +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/package-info.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + * + * ========================================================================================================= + * + * This software consists of voluntary contributions made by many individuals on behalf of the + * Apache Software Foundation. For more information on the Apache Software Foundation, please see + * . + * + * +-------------------------------------------------------------------------------------------------------+ + * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | + * | Author: Yong.Teng | + * | Copyright @ 2013-2024 Buession.com Inc. | + * +-------------------------------------------------------------------------------------------------------+ + */ +/** + * @author Yong.Teng + * @since 2.3.3 + */ +package org.apereo.cas.logging.autoconfigure.console; \ No newline at end of file diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/elasticsearch/ElasticsearchLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/elasticsearch/ElasticsearchLogHandlerConfiguration.java index afee944..2335042 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/elasticsearch/ElasticsearchLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/elasticsearch/ElasticsearchLogHandlerConfiguration.java @@ -19,12 +19,11 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure.elasticsearch; -import com.buession.logging.core.handler.LogHandler; import com.buession.logging.elasticsearch.spring.ElasticsearchLogHandlerFactoryBean; import com.buession.logging.elasticsearch.spring.ElasticsearchRestTemplateFactoryBean; import com.buession.logging.elasticsearch.spring.RestHighLevelClientFactoryBean; @@ -50,52 +49,57 @@ */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) -@ConditionalOnMissingBean(LogHandler.class) -@ConditionalOnClass({ElasticsearchLogHandlerFactoryBean.class}) -@ConditionalOnProperty(prefix = ElasticsearchLogHandlerConfiguration.PREFIX, name = "elasticsearch.enabled", havingValue = "true") -public class ElasticsearchLogHandlerConfiguration - extends AbstractLogHandlerConfiguration { +@ConditionalOnClass(name = {"com.buession.logging.elasticsearch.spring.ElasticsearchLogHandlerFactoryBean"}) +public class ElasticsearchLogHandlerConfiguration extends AbstractLogHandlerConfiguration { - public ElasticsearchLogHandlerConfiguration(CasLoggingConfigurationProperties logProperties) { - super(logProperties.getHistory().getElasticsearch()); - } + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = History.PREFIX, name = "elasticsearch.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = History.LOG_HANDLER_BEAN_NAME) + static class History extends AbstractHistoryLogHandlerConfiguration { - @Bean(name = "loggingElasticsearchRestHighLevelClient") - public RestHighLevelClientFactoryBean restHighLevelClientFactoryBean() { - final RestHighLevelClientFactoryBean restHighLevelClientFactoryBean = new RestHighLevelClientFactoryBean(); + public History(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getHistory().getElasticsearch()); + } - propertyMapper.from(handlerProperties::getUrls).to(restHighLevelClientFactoryBean::setUrls); - propertyMapper.from(handlerProperties::getHost).to(restHighLevelClientFactoryBean::setHost); - propertyMapper.from(handlerProperties::getPort).to(restHighLevelClientFactoryBean::setPort); - propertyMapper.from(handlerProperties::getUsername).to(restHighLevelClientFactoryBean::setUsername); - propertyMapper.from(handlerProperties::getPassword).to(restHighLevelClientFactoryBean::setPassword); - propertyMapper.from(handlerProperties::getConnectionTimeout) - .to(restHighLevelClientFactoryBean::setConnectionTimeout); - propertyMapper.from(handlerProperties::getReadTimeout).to(restHighLevelClientFactoryBean::setReadTimeout); + @Bean(name = "historyLoggingElasticsearchRestHighLevelClient") + public RestHighLevelClientFactoryBean restHighLevelClientFactoryBean() { + final RestHighLevelClientFactoryBean restHighLevelClientFactoryBean = new RestHighLevelClientFactoryBean(); - return restHighLevelClientFactoryBean; - } + propertyMapper.from(handlerProperties::getUrls).to(restHighLevelClientFactoryBean::setUrls); + propertyMapper.from(handlerProperties::getHost).to(restHighLevelClientFactoryBean::setHost); + propertyMapper.from(handlerProperties::getPort).to(restHighLevelClientFactoryBean::setPort); + propertyMapper.from(handlerProperties::getUsername).to(restHighLevelClientFactoryBean::setUsername); + propertyMapper.from(handlerProperties::getPassword).to(restHighLevelClientFactoryBean::setPassword); + propertyMapper.from(handlerProperties::getConnectionTimeout) + .to(restHighLevelClientFactoryBean::setConnectionTimeout); + propertyMapper.from(handlerProperties::getReadTimeout).to(restHighLevelClientFactoryBean::setReadTimeout); - @Bean(name = "loggingElasticsearchElasticsearchRestTemplate") - public ElasticsearchRestTemplateFactoryBean elasticsearchRestTemplateFactoryBean( - @Qualifier("loggingElasticsearchRestHighLevelClient") ObjectProvider restHighLevelClient) { - final ElasticsearchRestTemplateFactoryBean elasticsearchRestTemplateFactoryBean = - new ElasticsearchRestTemplateFactoryBean(); + return restHighLevelClientFactoryBean; + } - restHighLevelClient.ifUnique(elasticsearchRestTemplateFactoryBean::setClient); + @Bean(name = "historyLoggingElasticsearchRestTemplate") + public ElasticsearchRestTemplateFactoryBean elasticsearchRestTemplateFactoryBean( + @Qualifier("historyLoggingElasticsearchRestHighLevelClient") ObjectProvider restHighLevelClient) { + final ElasticsearchRestTemplateFactoryBean elasticsearchRestTemplateFactoryBean = + new ElasticsearchRestTemplateFactoryBean(); - return elasticsearchRestTemplateFactoryBean; - } + restHighLevelClient.ifAvailable(elasticsearchRestTemplateFactoryBean::setClient); + + return elasticsearchRestTemplateFactoryBean; + } + + @Bean(name = History.LOG_HANDLER_BEAN_NAME) + public ElasticsearchLogHandlerFactoryBean logHandlerFactoryBean( + @Qualifier("historyLoggingElasticsearchRestTemplate") ObjectProvider restTemplateFactory) { + final ElasticsearchLogHandlerFactoryBean logHandlerFactoryBean = new ElasticsearchLogHandlerFactoryBean(); - @Bean - public ElasticsearchLogHandlerFactoryBean logHandlerFactoryBean( - @Qualifier("loggingElasticsearchElasticsearchRestTemplate") ObjectProvider restTemplateFactory) { - final ElasticsearchLogHandlerFactoryBean logHandlerFactoryBean = new ElasticsearchLogHandlerFactoryBean(); + restTemplateFactory.ifAvailable(logHandlerFactoryBean::setRestTemplate); + propertyMapper.from(handlerProperties::getIndexName).to(logHandlerFactoryBean::setIndexName); - restTemplateFactory.ifUnique(logHandlerFactoryBean::setRestTemplate); - propertyMapper.from(handlerProperties::getIndexName).to(logHandlerFactoryBean::setIndexName); + return logHandlerFactoryBean; + } - return logHandlerFactoryBean; } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/JdbcLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/JdbcLogHandlerConfiguration.java index edc973a..ac930e9 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/JdbcLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/JdbcLogHandlerConfiguration.java @@ -19,16 +19,22 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure.jdbc; -import com.buession.logging.core.handler.LogHandler; +import com.buession.jdbc.datasource.config.HikariPoolConfiguration; +import com.buession.logging.jdbc.converter.DefaultLogDataConverter; +import com.buession.logging.jdbc.converter.LogDataConverter; import com.buession.logging.jdbc.spring.JdbcLogHandlerFactoryBean; import com.buession.logging.jdbc.spring.JdbcTemplateFactoryBean; +import org.apereo.cas.configuration.model.support.ConnectionPoolingProperties; +import org.apereo.cas.configuration.support.Beans; import org.apereo.cas.logging.autoconfigure.AbstractLogHandlerConfiguration; +import org.apereo.cas.logging.config.BaseJdbcLogProperties; import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; +import org.apereo.cas.logging.config.basic.BasicJdbcLogProperties; import org.apereo.cas.logging.config.history.HistoryJdbcLogProperties; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.ObjectProvider; @@ -41,6 +47,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; +import java.time.Duration; + /** * JDBC 日志处理器自动配置类 * @@ -49,45 +57,115 @@ */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) -@ConditionalOnMissingBean(LogHandler.class) -@ConditionalOnClass({JdbcLogHandlerFactoryBean.class}) -@ConditionalOnProperty(prefix = JdbcLogHandlerConfiguration.PREFIX, name = "jdbc.enabled", havingValue = "true") -public class JdbcLogHandlerConfiguration extends AbstractLogHandlerConfiguration { - - public JdbcLogHandlerConfiguration(CasLoggingConfigurationProperties logProperties) { - super(logProperties.getHistory().getJdbc()); - } +@ConditionalOnClass(name = {"com.buession.logging.jdbc.spring.JdbcLogHandlerFactoryBean"}) +public class JdbcLogHandlerConfiguration extends AbstractLogHandlerConfiguration { - @Bean(name = "loggingJdbcJdbcTemplate") - public JdbcTemplateFactoryBean jdbcTemplateFactoryBean() { + protected static JdbcTemplateFactoryBean jdbcTemplateFactoryBean(final BaseJdbcLogProperties jdbcLogProperties) { final JdbcTemplateFactoryBean jdbcTemplateFactoryBean = new JdbcTemplateFactoryBean(); - propertyMapper.from(handlerProperties::getDriverClassName).to(jdbcTemplateFactoryBean::setDriverClassName); - propertyMapper.from(handlerProperties::getUrl).to(jdbcTemplateFactoryBean::setUrl); - propertyMapper.from(handlerProperties::getUser).to(jdbcTemplateFactoryBean::setUsername); - propertyMapper.from(handlerProperties::getPassword).to(jdbcTemplateFactoryBean::setPassword); - propertyMapper.from(handlerProperties::getPoolConfiguration).to(jdbcTemplateFactoryBean::setPoolConfiguration); + propertyMapper.from(jdbcLogProperties::getDriverClass).to(jdbcTemplateFactoryBean::setDriverClassName); + propertyMapper.from(jdbcLogProperties::getUrl).to(jdbcTemplateFactoryBean::setUrl); + propertyMapper.from(jdbcLogProperties::getUser).to(jdbcTemplateFactoryBean::setUsername); + propertyMapper.from(jdbcLogProperties::getPassword).to(jdbcTemplateFactoryBean::setPassword); + + final ConnectionPoolingProperties pool = jdbcLogProperties.getPool(); + final HikariPoolConfiguration poolConfiguration = new HikariPoolConfiguration(); + + poolConfiguration.setIdleTimeout(Beans.newDuration(jdbcLogProperties.getIdleTimeout())); + poolConfiguration.setMinIdle(pool.getMinSize()); + poolConfiguration.setMaxPoolSize(pool.getMaxSize()); + poolConfiguration.setInitializationFailTimeout(Duration.ofMillis(jdbcLogProperties.getFailFastTimeout())); + poolConfiguration.setConnectionTestQuery(jdbcLogProperties.getHealthQuery()); + poolConfiguration.setValidationTimeout(Duration.ofMillis(pool.getTimeoutMillis())); + poolConfiguration.setAutoCommit(jdbcLogProperties.isAutocommit()); + poolConfiguration.setAllowPoolSuspension(jdbcLogProperties.getPool().isSuspension()); + poolConfiguration.setIsolateInternalQueries(jdbcLogProperties.isIsolateInternalQueries()); + poolConfiguration.setLeakDetectionThreshold((long) jdbcLogProperties.getLeakThreshold()); + + jdbcTemplateFactoryBean.setPoolConfiguration(poolConfiguration); return jdbcTemplateFactoryBean; } - @Bean - public JdbcLogHandlerFactoryBean logHandlerFactoryBean( - @Qualifier("loggingJdbcJdbcTemplate") ObjectProvider jdbcTemplate) { + protected static JdbcLogHandlerFactoryBean logHandlerFactoryBean(final BaseJdbcLogProperties jdbcLogProperties, + final LogDataConverter logDataConverter, + final JdbcTemplate jdbcTemplate) { final JdbcLogHandlerFactoryBean logHandlerFactoryBean = new JdbcLogHandlerFactoryBean(); - jdbcTemplate.ifUnique(logHandlerFactoryBean::setJdbcTemplate); - - propertyMapper.from(handlerProperties::getSql).to(logHandlerFactoryBean::setSql); - propertyMapper.from(handlerProperties::getIdGenerator).as(BeanUtils::instantiateClass) + propertyMapper.from(jdbcTemplate).to(logHandlerFactoryBean::setJdbcTemplate); + propertyMapper.from(jdbcLogProperties::getSql).to(logHandlerFactoryBean::setSql); + propertyMapper.from(jdbcLogProperties::getIdGenerator).as(BeanUtils::instantiateClass) .to(logHandlerFactoryBean::setIdGenerator); - propertyMapper.from(handlerProperties::getDateTimeFormat).to(logHandlerFactoryBean::setDateTimeFormat); - propertyMapper.from(handlerProperties::getRequestParametersFormatter).as(BeanUtils::instantiateClass) + propertyMapper.from(jdbcLogProperties::getDateTimeFormat).to(logHandlerFactoryBean::setDateTimeFormat); + propertyMapper.from(jdbcLogProperties::getRequestParametersFormatter).as(BeanUtils::instantiateClass) .to(logHandlerFactoryBean::setRequestParametersFormatter); - propertyMapper.from(handlerProperties::getExtraFormatter).as(BeanUtils::instantiateClass) + propertyMapper.from(jdbcLogProperties::getExtraFormatter).as(BeanUtils::instantiateClass) .to(logHandlerFactoryBean::setExtraFormatter); + propertyMapper.from(logDataConverter).to(logHandlerFactoryBean::setLogDataConverter); return logHandlerFactoryBean; } + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = Basic.PREFIX, name = "jdbc.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = Basic.LOG_HANDLER_BEAN_NAME) + static class Basic extends AbstractBasicLogHandlerConfiguration { + + public Basic(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getBasic().getJdbc()); + } + + @Bean(name = "basicLoggingJdbcJdbcTemplate") + public JdbcTemplateFactoryBean jdbcTemplateFactoryBean() { + return JdbcLogHandlerConfiguration.jdbcTemplateFactoryBean(handlerProperties); + } + + @Bean(name = "basicLoggingJdbcDataConverter") + @ConditionalOnMissingBean(name = "basicLoggingJdbcDataConverter") + public LogDataConverter logDataConverter() { + return new DefaultLogDataConverter(); + } + + @Bean(name = Basic.LOG_HANDLER_BEAN_NAME) + public JdbcLogHandlerFactoryBean logHandlerFactoryBean( + @Qualifier("basicLoggingJdbcJdbcTemplate") ObjectProvider jdbcTemplate, + @Qualifier("basicLoggingJdbcDataConverter") ObjectProvider logDataConverter) { + return JdbcLogHandlerConfiguration.logHandlerFactoryBean(handlerProperties, + logDataConverter.getIfAvailable(), jdbcTemplate.getIfAvailable()); + } + + } + + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = History.PREFIX, name = "jdbc.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = History.LOG_HANDLER_BEAN_NAME) + static class History extends AbstractHistoryLogHandlerConfiguration { + + public History(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getHistory().getJdbc()); + } + + @Bean(name = "historyLoggingJdbcJdbcTemplate") + public JdbcTemplateFactoryBean jdbcTemplateFactoryBean() { + return JdbcLogHandlerConfiguration.jdbcTemplateFactoryBean(handlerProperties); + } + + @Bean(name = "historyLoggingJdbcDataConverter") + @ConditionalOnMissingBean(name = "historyLoggingJdbcDataConverter") + public LogDataConverter logDataConverter() { + return new DefaultLogDataConverter(); + } + + @Bean(name = History.LOG_HANDLER_BEAN_NAME) + public JdbcLogHandlerFactoryBean logHandlerFactoryBean( + @Qualifier("historyLoggingJdbcJdbcTemplate") ObjectProvider jdbcTemplate, + @Qualifier("historyLoggingJdbcDataConverter") ObjectProvider logDataConverter) { + return JdbcLogHandlerConfiguration.logHandlerFactoryBean(handlerProperties, + logDataConverter.getIfAvailable(), jdbcTemplate.getIfAvailable()); + } + + } + } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/package-info.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/package-info.java index 4f07bca..c3d6b53 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/package-info.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/jdbc/package-info.java @@ -19,7 +19,7 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ /** diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/kafka/KafkaLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/kafka/KafkaLogHandlerConfiguration.java index 52ab625..ef045c1 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/kafka/KafkaLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/kafka/KafkaLogHandlerConfiguration.java @@ -19,12 +19,11 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure.kafka; -import com.buession.logging.core.handler.LogHandler; import com.buession.logging.kafka.spring.KafkaLogHandlerFactoryBean; import com.buession.logging.kafka.spring.KafkaTemplateFactoryBean; import com.buession.logging.kafka.spring.ProducerFactoryBean; @@ -40,6 +39,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.core.ProducerFactory; /** * Kafka 日志处理器自动配置类 @@ -49,57 +49,64 @@ */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) -@ConditionalOnMissingBean(LogHandler.class) -@ConditionalOnClass({KafkaLogHandlerFactoryBean.class}) -@ConditionalOnProperty(prefix = KafkaLogHandlerConfiguration.PREFIX, name = "kafka.enabled", havingValue = "true") -public class KafkaLogHandlerConfiguration extends AbstractLogHandlerConfiguration { +@ConditionalOnClass(name = {"com.buession.logging.kafka.spring.KafkaLogHandlerFactoryBean"}) +public class KafkaLogHandlerConfiguration extends AbstractLogHandlerConfiguration { - public KafkaLogHandlerConfiguration(CasLoggingConfigurationProperties logProperties) { - super(logProperties.getHistory().getKafka()); - } + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = History.PREFIX, name = "kafka.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = History.LOG_HANDLER_BEAN_NAME) + static class History extends AbstractHistoryLogHandlerConfiguration { - @Bean(name = "loggingKafkaProducerFactory") - public ProducerFactoryBean producerFactoryBean() { - final ProducerFactoryBean producerFactoryBean = new ProducerFactoryBean(); - - propertyMapper.from(handlerProperties::getBootstrapServers).to(producerFactoryBean::setBootstrapServers); - propertyMapper.from(handlerProperties::getClientId).to(producerFactoryBean::setClientId); - propertyMapper.from(handlerProperties::getTransactionIdPrefix) - .to(producerFactoryBean::setTransactionIdPrefix); - propertyMapper.from(handlerProperties::getAcks).to(producerFactoryBean::setAcks); - propertyMapper.from(handlerProperties::getBatchSize).to(producerFactoryBean::setBatchSize); - propertyMapper.from(handlerProperties::getBufferMemory).to(producerFactoryBean::setBufferMemory); - propertyMapper.from(handlerProperties::getCompressionType).to(producerFactoryBean::setCompressionType); - propertyMapper.from(handlerProperties::getRetries).to(producerFactoryBean::setRetries); - propertyMapper.from(handlerProperties::getSslConfiguration).to(producerFactoryBean::setSslConfiguration); - propertyMapper.from(handlerProperties::getSecurityConfiguration) - .to(producerFactoryBean::setSecurityConfiguration); - propertyMapper.from(handlerProperties::getTransactionIdPrefix).to(producerFactoryBean::setTransactionIdPrefix); - propertyMapper.from(handlerProperties::getProperties).to(producerFactoryBean::setProperties); - - return producerFactoryBean; - } + public History(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getHistory().getKafka()); + } - @Bean(name = "loggingKafkaKafkaTemplate") - public KafkaTemplateFactoryBean kafkaTemplateFactoryBean(@Qualifier("loggingKafkaProducerFactory") - ObjectProvider> producerFactory) { - final KafkaTemplateFactoryBean kafkaTemplateFactoryBean = new KafkaTemplateFactoryBean<>(); + @Bean(name = "historyLoggingKafkaProducerFactory") + public ProducerFactoryBean producerFactoryBean() { + final ProducerFactoryBean producerFactoryBean = new ProducerFactoryBean(); - producerFactory.ifUnique(kafkaTemplateFactoryBean::setProducerFactory); + propertyMapper.from(handlerProperties::getBootstrapServers).to(producerFactoryBean::setBootstrapServers); + propertyMapper.from(handlerProperties::getClientId).to(producerFactoryBean::setClientId); + propertyMapper.from(handlerProperties::getTransactionIdPrefix) + .to(producerFactoryBean::setTransactionIdPrefix); + propertyMapper.from(handlerProperties::getAcks).to(producerFactoryBean::setAcks); + propertyMapper.from(handlerProperties::getBatchSize).to(producerFactoryBean::setBatchSize); + propertyMapper.from(handlerProperties::getBufferMemory).to(producerFactoryBean::setBufferMemory); + propertyMapper.from(handlerProperties::getCompressionType).to(producerFactoryBean::setCompressionType); + propertyMapper.from(handlerProperties::getRetries).to(producerFactoryBean::setRetries); + propertyMapper.from(handlerProperties::getSslConfiguration).to(producerFactoryBean::setSslConfiguration); + propertyMapper.from(handlerProperties::getSecurityConfiguration) + .to(producerFactoryBean::setSecurityConfiguration); + propertyMapper.from(handlerProperties::getTransactionIdPrefix) + .to(producerFactoryBean::setTransactionIdPrefix); + propertyMapper.from(handlerProperties::getProperties).to(producerFactoryBean::setProperties); - return kafkaTemplateFactoryBean; - } + return producerFactoryBean; + } + + @Bean(name = "historyLoggingKafkaKafkaTemplate") + public KafkaTemplateFactoryBean kafkaTemplateFactoryBean( + @Qualifier("historyLoggingKafkaProducerFactory") ObjectProvider> producerFactory) { + final KafkaTemplateFactoryBean kafkaTemplateFactoryBean = new KafkaTemplateFactoryBean<>(); + + producerFactory.ifAvailable(kafkaTemplateFactoryBean::setProducerFactory); + + return kafkaTemplateFactoryBean; + } + + @Bean(name = History.LOG_HANDLER_BEAN_NAME) + public KafkaLogHandlerFactoryBean logHandlerFactoryBean( + @Qualifier("historyLoggingKafkaKafkaTemplate") ObjectProvider> kafkaTemplate) { + final KafkaLogHandlerFactoryBean logHandlerFactoryBean = new KafkaLogHandlerFactoryBean(); - @Bean - public KafkaLogHandlerFactoryBean logHandlerFactoryBean( - @Qualifier("loggingKafkaKafkaTemplate") ObjectProvider> kafkaTemplate) { - final KafkaLogHandlerFactoryBean logHandlerFactoryBean = new KafkaLogHandlerFactoryBean(); + kafkaTemplate.ifAvailable(logHandlerFactoryBean::setKafkaTemplate); - kafkaTemplate.ifUnique(logHandlerFactoryBean::setKafkaTemplate); + propertyMapper.from(handlerProperties::getTopic).to(logHandlerFactoryBean::setTopic); - propertyMapper.from(handlerProperties::getTopic).to(logHandlerFactoryBean::setTopic); + return logHandlerFactoryBean; + } - return logHandlerFactoryBean; } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/mongo/MongoLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/mongo/MongoLogHandlerConfiguration.java index 0e94271..74ba21a 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/mongo/MongoLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/mongo/MongoLogHandlerConfiguration.java @@ -19,7 +19,7 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure.mongo; @@ -28,10 +28,9 @@ import com.buession.dao.mongodb.core.ReadConcern; import com.buession.dao.mongodb.core.ReadPreference; import com.buession.dao.mongodb.core.WriteConcern; -import com.buession.logging.core.handler.LogHandler; import com.buession.logging.mongodb.spring.MongoClientFactoryBean; import com.buession.logging.mongodb.spring.MongoDatabaseFactoryBean; -import com.buession.logging.mongodb.spring.MongoHandlerFactoryBean; +import com.buession.logging.mongodb.spring.MongoLogHandlerFactoryBean; import com.buession.logging.mongodb.spring.MongoMappingContextFactoryBean; import com.buession.logging.mongodb.spring.MongoTemplateFactoryBean; import com.mongodb.ConnectionString; @@ -66,154 +65,168 @@ */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) -@ConditionalOnMissingBean(LogHandler.class) -@ConditionalOnClass({MongoHandlerFactoryBean.class}) -@ConditionalOnProperty(prefix = MongoLogHandlerConfiguration.PREFIX, name = "mongo.enabled", havingValue = "true") -public class MongoLogHandlerConfiguration extends AbstractLogHandlerConfiguration { +@ConditionalOnClass(name = {"com.buession.logging.mongodb.spring.MongoLogHandlerFactoryBean"}) +public class MongoLogHandlerConfiguration extends AbstractLogHandlerConfiguration { - public MongoLogHandlerConfiguration(CasLoggingConfigurationProperties logProperties) { - super(logProperties.getHistory().getMongo()); - } - - @Bean(name = "logMongoDbMongoClient") - public MongoClientFactoryBean mongoClientFactoryBean() { - final MongoClientFactoryBean mongoClientFactoryBean = new MongoClientFactoryBean(); + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = History.PREFIX, name = "mongo.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = History.LOG_HANDLER_BEAN_NAME) + static class History extends AbstractHistoryLogHandlerConfiguration { - if(Validate.hasText(handlerProperties.getUrl())){ - propertyMapper.from(handlerProperties::getUrl).as(ConnectionString::new) - .to(mongoClientFactoryBean::setConnectionString); - }else{ - propertyMapper.from(handlerProperties::getHost).to(mongoClientFactoryBean::setHost); - propertyMapper.from(handlerProperties::getPort).to(mongoClientFactoryBean::setPort); + public History(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getHistory().getMongo()); } - propertyMapper.from(handlerProperties::getReplicaSetName).to(mongoClientFactoryBean::setReplicaSet); - - if(handlerProperties.getUsername() != null && handlerProperties.getPassword() != null){ - final String database = - handlerProperties.getAuthenticationDatabase() == - null ? handlerProperties.getDatabaseName() : handlerProperties.getAuthenticationDatabase(); - final MongoCredential credential = MongoCredential.createCredential(handlerProperties.getUsername(), - database, handlerProperties.getPassword().toCharArray()); - mongoClientFactoryBean.setCredential(new MongoCredential[]{credential}); - } + @Bean(name = "historyLoggingMongoDbMongoClient") + public MongoClientFactoryBean mongoClientFactoryBean() { + final MongoClientFactoryBean mongoClientFactoryBean = new MongoClientFactoryBean(); - final MongoClientSettings.Builder mongoClientSettingsBuilder = MongoClientSettings.builder(); + if(Validate.hasText(handlerProperties.getUrl())){ + propertyMapper.from(handlerProperties::getUrl).as(ConnectionString::new) + .to(mongoClientFactoryBean::setConnectionString); + }else{ + propertyMapper.from(handlerProperties::getHost).to(mongoClientFactoryBean::setHost); + propertyMapper.from(handlerProperties::getPort).to(mongoClientFactoryBean::setPort); + } + propertyMapper.from(handlerProperties::getReplicaSetName).to(mongoClientFactoryBean::setReplicaSet); - propertyMapper.from(handlerProperties::getReadPreference).as(ReadPreference::getValue) - .to(mongoClientSettingsBuilder::readPreference); - propertyMapper.from(handlerProperties::getReadConcern).as(ReadConcern::getValue) - .to(mongoClientSettingsBuilder::readConcern); - propertyMapper.from(handlerProperties::getWriteConcern).as(WriteConcern::getValue) - .to(mongoClientSettingsBuilder::writeConcern); - propertyMapper.from(handlerProperties::getUuidRepresentation) - .to(mongoClientSettingsBuilder::uuidRepresentation); + if(handlerProperties.getUsername() != null && handlerProperties.getPassword() != null){ + mongoClientFactoryBean.setCredential(createMongoCredential()); + } - mongoClientSettingsBuilder.applyToSocketSettings(($builder)->{ - final SocketSettings.Builder socketBuilder = SocketSettings.builder(); + final MongoClientSettings.Builder mongoClientSettingsBuilder = MongoClientSettings.builder(); - if(handlerProperties.getConnectionTimeout() != null){ - socketBuilder.connectTimeout((int) handlerProperties.getConnectionTimeout().toMillis(), - TimeUnit.MILLISECONDS); - } - if(handlerProperties.getReadTimeout() != null){ - socketBuilder.readTimeout((int) handlerProperties.getReadTimeout().toMillis(), TimeUnit.MILLISECONDS); - } + propertyMapper.from(handlerProperties::getReadPreference).as(ReadPreference::getValue) + .to(mongoClientSettingsBuilder::readPreference); + propertyMapper.from(handlerProperties::getReadConcern).as(ReadConcern::getValue) + .to(mongoClientSettingsBuilder::readConcern); + propertyMapper.from(handlerProperties::getWriteConcern).as(WriteConcern::getValue) + .to(mongoClientSettingsBuilder::writeConcern); + propertyMapper.from(handlerProperties::getUuidRepresentation) + .to(mongoClientSettingsBuilder::uuidRepresentation); - $builder.applySettings(socketBuilder.build()); - }).applyToConnectionPoolSettings(($builder)->{ - if(handlerProperties.getPool() != null){ - final ConnectionPoolSettings.Builder poolBuilder = ConnectionPoolSettings.builder(); + mongoClientSettingsBuilder.applyToSocketSettings(($builder)->{ + final SocketSettings.Builder socketBuilder = SocketSettings.builder(); - if(handlerProperties.getPool().getMinSize() > 0){ - poolBuilder.minSize(handlerProperties.getPool().getMinSize()); - } - if(handlerProperties.getPool().getMaxSize() > 0){ - poolBuilder.minSize(handlerProperties.getPool().getMaxSize()); - } - if(handlerProperties.getPool().getMaxWaitTime() != null){ - poolBuilder.maxWaitTime(handlerProperties.getPool().getMaxWaitTime().toMillis(), - TimeUnit.MILLISECONDS); - } - if(handlerProperties.getPool().getMaxConnectionLifeTime() != null){ - poolBuilder.maxConnectionLifeTime(handlerProperties.getPool().getMaxConnectionLifeTime().toMillis(), - TimeUnit.MILLISECONDS); - } - if(handlerProperties.getPool().getMaxConnectionIdleTime() != null){ - poolBuilder.maxConnectionIdleTime(handlerProperties.getPool().getMaxConnectionIdleTime().toMillis(), - TimeUnit.MILLISECONDS); - } - if(handlerProperties.getPool().getMaintenanceInitialDelay() != null){ - poolBuilder.maintenanceInitialDelay( - handlerProperties.getPool().getMaintenanceInitialDelay().toMillis(), + if(handlerProperties.getConnectionTimeout() != null){ + socketBuilder.connectTimeout((int) handlerProperties.getConnectionTimeout().toMillis(), TimeUnit.MILLISECONDS); } - if(handlerProperties.getPool().getMaintenanceFrequency() != null){ - poolBuilder.maintenanceFrequency(handlerProperties.getPool().getMaintenanceFrequency().toMillis(), + if(handlerProperties.getReadTimeout() != null){ + socketBuilder.readTimeout((int) handlerProperties.getReadTimeout().toMillis(), TimeUnit.MILLISECONDS); } - if(handlerProperties.getPool().getMaxConnecting() > 0){ - poolBuilder.maxConnecting(handlerProperties.getPool().getMaxConnecting()); + + $builder.applySettings(socketBuilder.build()); + }).applyToConnectionPoolSettings(($builder)->{ + if(handlerProperties.getPool() != null){ + final ConnectionPoolSettings.Builder poolBuilder = ConnectionPoolSettings.builder(); + + if(handlerProperties.getPool().getMinSize() > 0){ + poolBuilder.minSize(handlerProperties.getPool().getMinSize()); + } + if(handlerProperties.getPool().getMaxSize() > 0){ + poolBuilder.minSize(handlerProperties.getPool().getMaxSize()); + } + if(handlerProperties.getPool().getMaxWaitTime() != null){ + poolBuilder.maxWaitTime(handlerProperties.getPool().getMaxWaitTime().toMillis(), + TimeUnit.MILLISECONDS); + } + if(handlerProperties.getPool().getMaxConnectionLifeTime() != null){ + poolBuilder.maxConnectionLifeTime( + handlerProperties.getPool().getMaxConnectionLifeTime().toMillis(), + TimeUnit.MILLISECONDS); + } + if(handlerProperties.getPool().getMaxConnectionIdleTime() != null){ + poolBuilder.maxConnectionIdleTime( + handlerProperties.getPool().getMaxConnectionIdleTime().toMillis(), + TimeUnit.MILLISECONDS); + } + if(handlerProperties.getPool().getMaintenanceInitialDelay() != null){ + poolBuilder.maintenanceInitialDelay( + handlerProperties.getPool().getMaintenanceInitialDelay().toMillis(), + TimeUnit.MILLISECONDS); + } + if(handlerProperties.getPool().getMaintenanceFrequency() != null){ + poolBuilder.maintenanceFrequency( + handlerProperties.getPool().getMaintenanceFrequency().toMillis(), + TimeUnit.MILLISECONDS); + } + if(handlerProperties.getPool().getMaxConnecting() > 0){ + poolBuilder.maxConnecting(handlerProperties.getPool().getMaxConnecting()); + } + + $builder.applySettings(poolBuilder.build()); } + }); - $builder.applySettings(poolBuilder.build()); - } - }); + return mongoClientFactoryBean; + } - return mongoClientFactoryBean; - } + @Bean(name = "historyLoggingMongoDbMongoDatabase") + public MongoDatabaseFactoryBean mongoDatabaseFactoryBean( + @Qualifier("historyLoggingMongoDbMongoClient") ObjectProvider mongoClient) { + final MongoDatabaseFactoryBean mongoDatabaseFactoryBean = new MongoDatabaseFactoryBean(); - @Bean(name = "logMongoDbMongoDatabase") - public MongoDatabaseFactoryBean mongoDatabaseFactoryBean( - @Qualifier("logMongoDbMongoClient") ObjectProvider mongoClient) { - final MongoDatabaseFactoryBean mongoDatabaseFactoryBean = new MongoDatabaseFactoryBean(); + mongoClient.ifAvailable(mongoDatabaseFactoryBean::setMongoClient); - mongoClient.ifUnique(mongoDatabaseFactoryBean::setMongoClient); + if(Validate.hasText(handlerProperties.getDatabaseName())){ + mongoDatabaseFactoryBean.setDatabaseName(handlerProperties.getDatabaseName()); + }else{ + String database = new ConnectionString(handlerProperties.getUrl()).getDatabase(); + mongoDatabaseFactoryBean.setDatabaseName(database); + } - if(Validate.hasText(handlerProperties.getDatabaseName())){ - mongoDatabaseFactoryBean.setDatabaseName(handlerProperties.getDatabaseName()); - }else{ - String database = new ConnectionString(handlerProperties.getUrl()).getDatabase(); - mongoDatabaseFactoryBean.setDatabaseName(database); + return mongoDatabaseFactoryBean; } - return mongoDatabaseFactoryBean; - } + @Bean(name = "historyLoggingMongoDbMongoMappingContext") + public MongoMappingContextFactoryBean mongoMappingContextFactoryBean() { + final MongoMappingContextFactoryBean mongoMappingContextFactoryBean = new MongoMappingContextFactoryBean(); - @Bean(name = "logMongoDbMongoMappingContext") - public MongoMappingContextFactoryBean mongoMappingContextFactoryBean() { - final MongoMappingContextFactoryBean mongoMappingContextFactoryBean = new MongoMappingContextFactoryBean(); + propertyMapper.from(handlerProperties::getAutoIndexCreation) + .to(mongoMappingContextFactoryBean::setAutoIndexCreation); + propertyMapper.from(handlerProperties::getFieldNamingStrategy).as(BeanUtils::instantiateClass) + .to(mongoMappingContextFactoryBean::setFieldNamingStrategy); - propertyMapper.from(handlerProperties::getAutoIndexCreation) - .to(mongoMappingContextFactoryBean::setAutoIndexCreation); - propertyMapper.from(handlerProperties::getFieldNamingStrategy).as(BeanUtils::instantiateClass) - .to(mongoMappingContextFactoryBean::setFieldNamingStrategy); + return mongoMappingContextFactoryBean; + } - return mongoMappingContextFactoryBean; - } + @Bean(name = "historyLoggingMongoDbMongoTemplate") + public MongoTemplateFactoryBean mongoTemplateFactoryBean( + @Qualifier("historyLoggingMongoDbMongoDatabase") ObjectProvider mongoDatabaseFactory, + @Qualifier("historyLoggingMongoDbMongoMappingContext") ObjectProvider mongoMappingContext) { + final MongoTemplateFactoryBean mongoTemplateFactoryBean = new MongoTemplateFactoryBean(); + + mongoDatabaseFactory.ifAvailable(mongoTemplateFactoryBean::setMongoDatabaseFactory); + mongoMappingContext.ifAvailable(mongoTemplateFactoryBean::setMongoMappingContext); - @Bean(name = "logMongoDbMongoTemplate") - public MongoTemplateFactoryBean mongoTemplateFactoryBean( - @Qualifier("logMongoDbMongoDatabase") ObjectProvider mongoDatabaseFactory, - @Qualifier("logMongoDbMongoMappingContext") ObjectProvider mongoMappingContext) { - final MongoTemplateFactoryBean mongoTemplateFactoryBean = new MongoTemplateFactoryBean(); + return mongoTemplateFactoryBean; + } - mongoDatabaseFactory.ifUnique(mongoTemplateFactoryBean::setMongoDatabaseFactory); - mongoMappingContext.ifUnique(mongoTemplateFactoryBean::setMongoMappingContext); + @Bean(name = History.LOG_HANDLER_BEAN_NAME) + public MongoLogHandlerFactoryBean logHandlerFactoryBean( + @Qualifier("historyLoggingMongoDbMongoTemplate") ObjectProvider mongoTemplate) { + final MongoLogHandlerFactoryBean logHandlerFactoryBean = new MongoLogHandlerFactoryBean(); - return mongoTemplateFactoryBean; - } + mongoTemplate.ifAvailable(logHandlerFactoryBean::setMongoTemplate); - @Bean - public MongoHandlerFactoryBean logHandlerFactoryBean( - @Qualifier("logMongoDbMongoTemplate") ObjectProvider mongoTemplate) { - final MongoHandlerFactoryBean logHandlerFactoryBean = new MongoHandlerFactoryBean(); + propertyMapper.from(handlerProperties::getCollectionName).to(logHandlerFactoryBean::setCollectionName); - mongoTemplate.ifUnique(logHandlerFactoryBean::setMongoTemplate); + return logHandlerFactoryBean; + } + + private MongoCredential[] createMongoCredential() { + final String database = + handlerProperties.getAuthenticationDatabase() == + null ? handlerProperties.getDatabaseName() : handlerProperties.getAuthenticationDatabase(); + final MongoCredential credential = MongoCredential.createCredential(handlerProperties.getUsername(), + database, handlerProperties.getPassword().toCharArray()); - propertyMapper.from(handlerProperties::getCollectionName).to(logHandlerFactoryBean::setCollectionName); + return new MongoCredential[]{credential}; + } - return logHandlerFactoryBean; } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rabbit/RabbitLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rabbit/RabbitLogHandlerConfiguration.java index 3157f94..385bb15 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rabbit/RabbitLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rabbit/RabbitLogHandlerConfiguration.java @@ -19,18 +19,18 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure.rabbit; -import com.buession.logging.core.handler.LogHandler; import com.buession.logging.rabbitmq.spring.ConnectionFactoryBean; import com.buession.logging.rabbitmq.spring.RabbitLogHandlerFactoryBean; import com.buession.logging.rabbitmq.spring.RabbitTemplateFactoryBean; import org.apereo.cas.logging.autoconfigure.AbstractLogHandlerConfiguration; import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; import org.apereo.cas.logging.config.history.HistoryRabbitLogProperties; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Qualifier; @@ -49,58 +49,67 @@ */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) -@ConditionalOnMissingBean(LogHandler.class) -@ConditionalOnClass({RabbitLogHandlerFactoryBean.class}) -@ConditionalOnProperty(prefix = RabbitLogHandlerConfiguration.PREFIX, name = "rabbit.enabled", havingValue = "true") -public class RabbitLogHandlerConfiguration extends AbstractLogHandlerConfiguration { +@ConditionalOnClass(name = {"com.buession.logging.rabbitmq.spring.RabbitLogHandlerFactoryBean"}) +public class RabbitLogHandlerConfiguration extends AbstractLogHandlerConfiguration { - public RabbitLogHandlerConfiguration(CasLoggingConfigurationProperties logProperties) { - super(logProperties.getHistory().getRabbit()); - } + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = History.PREFIX, name = "rabbit.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = History.LOG_HANDLER_BEAN_NAME) + static class History extends AbstractHistoryLogHandlerConfiguration { - @Bean(name = "logRabbitConnectionFactory") - public ConnectionFactoryBean connectionFactoryBean() { - final ConnectionFactoryBean connectionFactoryBean = new ConnectionFactoryBean(); + public History(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getHistory().getRabbit()); + } - propertyMapper.from(handlerProperties::getHost).to(connectionFactoryBean::setHost); - propertyMapper.from(handlerProperties::getPort).to(connectionFactoryBean::setPort); - propertyMapper.from(handlerProperties::getVirtualHost).to(connectionFactoryBean::setVirtualHost); - propertyMapper.from(handlerProperties::getUsername).to(connectionFactoryBean::setUsername); - propertyMapper.from(handlerProperties::getPassword).to(connectionFactoryBean::setPassword); - propertyMapper.from(handlerProperties::getRequestedHeartbeat).to(connectionFactoryBean::setRequestedHeartbeat); - propertyMapper.from(handlerProperties::getRequestedChannelMax) - .to(connectionFactoryBean::setRequestedChannelMax); - propertyMapper.from(handlerProperties::getPublisherConfirmType) - .to(connectionFactoryBean::setPublisherConfirmType); - propertyMapper.from(handlerProperties::getConnectionTimeout).to(connectionFactoryBean::setConnectionTimeout); - propertyMapper.from(handlerProperties::getSslConfiguration).to(connectionFactoryBean::setSslConfiguration); - propertyMapper.from(handlerProperties::getCache).to(connectionFactoryBean::setCache); + @Bean(name = "historyLoggingRabbitConnectionFactory") + public ConnectionFactoryBean connectionFactoryBean() { + final ConnectionFactoryBean connectionFactoryBean = new ConnectionFactoryBean(); - return connectionFactoryBean; - } + propertyMapper.from(handlerProperties::getHost).to(connectionFactoryBean::setHost); + propertyMapper.from(handlerProperties::getPort).to(connectionFactoryBean::setPort); + propertyMapper.from(handlerProperties::getVirtualHost).to(connectionFactoryBean::setVirtualHost); + propertyMapper.from(handlerProperties::getUsername).to(connectionFactoryBean::setUsername); + propertyMapper.from(handlerProperties::getPassword).to(connectionFactoryBean::setPassword); + propertyMapper.from(handlerProperties::getRequestedHeartbeat) + .to(connectionFactoryBean::setRequestedHeartbeat); + propertyMapper.from(handlerProperties::getRequestedChannelMax) + .to(connectionFactoryBean::setRequestedChannelMax); + propertyMapper.from(handlerProperties::getPublisherConfirmType) + .to(connectionFactoryBean::setPublisherConfirmType); + propertyMapper.from(handlerProperties::getConnectionTimeout) + .to(connectionFactoryBean::setConnectionTimeout); + propertyMapper.from(handlerProperties::getSslConfiguration).to(connectionFactoryBean::setSslConfiguration); + propertyMapper.from(handlerProperties::getCache).to(connectionFactoryBean::setCache); - @Bean(name = "logRabbitRabbitTemplate") - public RabbitTemplateFactoryBean rabbitTemplateFactoryBean( - @Qualifier("logRabbitConnectionFactory") ObjectProvider connectionFactory) { - final RabbitTemplateFactoryBean rabbitTemplateFactoryBean = new RabbitTemplateFactoryBean(); + return connectionFactoryBean; + } - connectionFactory.ifUnique(rabbitTemplateFactoryBean::setConnectionFactory); - propertyMapper.from(handlerProperties::getTemplate).to(rabbitTemplateFactoryBean::setTemplate); - propertyMapper.from(handlerProperties::isPublisherReturns).to(rabbitTemplateFactoryBean::setPublisherReturns); + @Bean(name = "historyLoggingRabbitRabbitTemplate") + public RabbitTemplateFactoryBean rabbitTemplateFactoryBean( + @Qualifier("historyLoggingRabbitConnectionFactory") ObjectProvider connectionFactory) { + final RabbitTemplateFactoryBean rabbitTemplateFactoryBean = new RabbitTemplateFactoryBean(); - return rabbitTemplateFactoryBean; - } + connectionFactory.ifAvailable(rabbitTemplateFactoryBean::setConnectionFactory); + propertyMapper.from(handlerProperties::getTemplate).to(rabbitTemplateFactoryBean::setTemplate); + propertyMapper.from(handlerProperties::isPublisherReturns) + .to(rabbitTemplateFactoryBean::setPublisherReturns); + + return rabbitTemplateFactoryBean; + } + + @Bean(name = History.LOG_HANDLER_BEAN_NAME) + public RabbitLogHandlerFactoryBean logHandlerFactoryBean(@Qualifier("historyLoggingRabbitRabbitTemplate") + ObjectProvider rabbitTemplate) { + final RabbitLogHandlerFactoryBean logHandlerFactoryBean = new RabbitLogHandlerFactoryBean(); - @Bean - public RabbitLogHandlerFactoryBean logHandlerFactoryBean(@Qualifier("logRabbitRabbitTemplate") - ObjectProvider rabbitTemplate) { - final RabbitLogHandlerFactoryBean logHandlerFactoryBean = new RabbitLogHandlerFactoryBean(); + rabbitTemplate.ifAvailable(logHandlerFactoryBean::setRabbitTemplate); + logHandlerFactoryBean.setExchange(handlerProperties.getExchange()); + logHandlerFactoryBean.setRoutingKey(handlerProperties.getRoutingKey()); - rabbitTemplate.ifUnique(logHandlerFactoryBean::setRabbitTemplate); - logHandlerFactoryBean.setExchange(handlerProperties.getExchange()); - logHandlerFactoryBean.setRoutingKey(handlerProperties.getRoutingKey()); + return logHandlerFactoryBean; + } - return logHandlerFactoryBean; } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rest/RestLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rest/RestLogHandlerConfiguration.java index dad7708..5d6ae45 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rest/RestLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/rest/RestLogHandlerConfiguration.java @@ -19,12 +19,11 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.autoconfigure.rest; -import com.buession.logging.core.handler.LogHandler; import com.buession.logging.rest.spring.RestLogHandlerFactoryBean; import org.apereo.cas.logging.autoconfigure.AbstractLogHandlerConfiguration; import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; @@ -45,25 +44,31 @@ */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) -@ConditionalOnMissingBean(LogHandler.class) -@ConditionalOnClass({RestLogHandlerFactoryBean.class}) -@ConditionalOnProperty(prefix = RestLogHandlerConfiguration.PREFIX, name = "rest.enabled", havingValue = "true") -public class RestLogHandlerConfiguration extends AbstractLogHandlerConfiguration { +@ConditionalOnClass(name = {"com.buession.logging.rest.spring.RestLogHandlerFactoryBean"}) +public class RestLogHandlerConfiguration extends AbstractLogHandlerConfiguration { - public RestLogHandlerConfiguration(CasLoggingConfigurationProperties logProperties) { - super(logProperties.getHistory().getRest()); - } + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(CasLoggingConfigurationProperties.class) + @ConditionalOnProperty(prefix = History.PREFIX, name = "rest.enabled", havingValue = "true") + @ConditionalOnMissingBean(name = History.LOG_HANDLER_BEAN_NAME) + static class History extends AbstractHistoryLogHandlerConfiguration { + + public History(CasLoggingConfigurationProperties logProperties) { + super(logProperties.getHistory().getRest()); + } + + @Bean(name = History.LOG_HANDLER_BEAN_NAME) + public RestLogHandlerFactoryBean logHandlerFactoryBean() { + final RestLogHandlerFactoryBean logHandlerFactoryBean = new RestLogHandlerFactoryBean(); - @Bean - public RestLogHandlerFactoryBean logHandlerFactoryBean() { - final RestLogHandlerFactoryBean logHandlerFactoryBean = new RestLogHandlerFactoryBean(); + propertyMapper.from(handlerProperties::getUrl).to(logHandlerFactoryBean::setUrl); + propertyMapper.from(handlerProperties::getRequestMethod).to(logHandlerFactoryBean::setRequestMethod); + propertyMapper.from(handlerProperties::getRequestBodyBuilder).as(BeanUtils::instantiateClass) + .to(logHandlerFactoryBean::setRequestBodyBuilder); - propertyMapper.from(handlerProperties::getUrl).to(logHandlerFactoryBean::setUrl); - propertyMapper.from(handlerProperties::getRequestMethod).to(logHandlerFactoryBean::setRequestMethod); - propertyMapper.from(handlerProperties::getRequestBodyBuilder).as(BeanUtils::instantiateClass) - .to(logHandlerFactoryBean::setRequestBodyBuilder); + return logHandlerFactoryBean; + } - return logHandlerFactoryBean; } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/BaseJdbcLogProperties.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/BaseJdbcLogProperties.java new file mode 100644 index 0000000..07c8dce --- /dev/null +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/BaseJdbcLogProperties.java @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + * + * ========================================================================================================= + * + * This software consists of voluntary contributions made by many individuals on behalf of the + * Apache Software Foundation. For more information on the Apache Software Foundation, please see + * . + * + * +-------------------------------------------------------------------------------------------------------+ + * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | + * | Author: Yong.Teng | + * | Copyright @ 2013-2024 Buession.com Inc. | + * +-------------------------------------------------------------------------------------------------------+ + */ +package org.apereo.cas.logging.config; + +import com.buession.core.id.IdGenerator; +import com.buession.logging.core.formatter.GeoFormatter; +import com.buession.logging.core.formatter.MapFormatter; +import com.buession.logging.jdbc.formatter.DefaultGeoFormatter; +import com.buession.logging.jdbc.formatter.JsonMapFormatter; +import com.buession.logging.support.config.HandlerProperties; +import org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties; + +import java.io.Serializable; + +/** + * @author Yong.Teng + * @since 2.3.3 + */ +public abstract class BaseJdbcLogProperties extends AbstractJpaProperties implements HandlerProperties, Serializable { + + private final static long serialVersionUID = 6396868404292124235L; + + /** + * SQL + */ + private String sql; + + /** + * ID 生成器 + */ + private Class> idGenerator; + + /** + * 日期时间格式 + */ + private String dateTimeFormat; + + /** + * 请求参数格式化为字符串 + */ + private Class> requestParametersFormatter = JsonMapFormatter.class; + + /** + * Geo 格式化 + */ + private Class geoFormatter = DefaultGeoFormatter.class; + + /** + * 附加参数格式化为字符串 + */ + private Class> extraFormatter = JsonMapFormatter.class; + + /** + * 返回 SQL + * + * @return SQL + */ + public String getSql() { + return sql; + } + + /** + * 设置 SQL + * + * @param sql + * SQL + */ + public void setSql(String sql) { + this.sql = sql; + } + + /** + * 返回 ID 生成器 + * + * @return ID 生成器 + */ + public Class> getIdGenerator() { + return idGenerator; + } + + /** + * 设置 ID 生成器 + * + * @param idGenerator + * ID 生成器 + */ + public void setIdGenerator(Class> idGenerator) { + this.idGenerator = idGenerator; + } + + /** + * 返回日期时间格式 + * + * @return 日期时间格式 + */ + public String getDateTimeFormat() { + return dateTimeFormat; + } + + /** + * 设置日期时间格式 + * + * @param dateTimeFormat + * 日期时间格式 + */ + public void setDateTimeFormat(String dateTimeFormat) { + this.dateTimeFormat = dateTimeFormat; + } + + /** + * 返回请求参数格式化为字符串 + * + * @return 请求参数格式化为字符串 + */ + public Class> getRequestParametersFormatter() { + return requestParametersFormatter; + } + + /** + * 设置请求参数格式化为字符串 + * + * @param requestParametersFormatter + * 请求参数格式化为字符串 + */ + public void setRequestParametersFormatter(Class> requestParametersFormatter) { + this.requestParametersFormatter = requestParametersFormatter; + } + + /** + * 返回 Geo 格式化 + * + * @return Geo 格式化 + */ + public Class getGeoFormatter() { + return geoFormatter; + } + + /** + * 设置 Geo 格式化 + * + * @param geoFormatter + * Geo 格式化 + */ + public void setGeoFormatter(Class geoFormatter) { + this.geoFormatter = geoFormatter; + } + + /** + * 返回附加参数格式化为字符串 + * + * @return 附加参数格式化为字符串 + */ + public Class> getExtraFormatter() { + return extraFormatter; + } + + /** + * 设置附加参数格式化为字符串 + * + * @param extraFormatter + * 附加参数格式化为字符串 + */ + public void setExtraFormatter(Class> extraFormatter) { + this.extraFormatter = extraFormatter; + } + +} diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicConsoleLogProperties.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicConsoleLogProperties.java index 59ba510..8b7b4b3 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicConsoleLogProperties.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicConsoleLogProperties.java @@ -19,11 +19,13 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.config.basic; +import com.buession.logging.support.config.HandlerProperties; + import java.io.Serializable; /** @@ -32,35 +34,56 @@ * @author Yong.Teng * @since 2.3.0 */ -public class BasicConsoleLogProperties implements Serializable { +public class BasicConsoleLogProperties implements HandlerProperties, Serializable { private final static long serialVersionUID = -6264010693592997006L; /** - * 日志消息 + * 日志模板 */ - private String message = + private String template = "${id} login success at: ${time}(IP: ${clientIp}), User-Agent: ${User-Agent}, operating system: " + "${os_name} ${os_version}, device type: ${device_type}, browser: ${browser_name} " + "${browser_version}."; /** - * 返回日志消息 + * 返回日志模板 + * + * @return 日志模板 + */ + public String getTemplate() { + return template; + } + + /** + * 设置日志模板 + * + * @param template + * 日志模板 + */ + public void setTemplate(String template) { + this.template = template; + } + + /** + * 返回日志模板 * - * @return 日志消息 + * @return 日志模板 */ + @Deprecated public String getMessage() { - return message; + return getTemplate(); } /** - * 设置日志消息 + * 设置日志模板 * * @param message - * 日志消息 + * 日志模板 */ + @Deprecated public void setMessage(String message) { - this.message = message; + setTemplate(message); } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicJdbcLogProperties.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicJdbcLogProperties.java index c729d69..310644a 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicJdbcLogProperties.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/basic/BasicJdbcLogProperties.java @@ -24,614 +24,14 @@ */ package org.apereo.cas.logging.config.basic; -import org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties; +import org.apereo.cas.logging.config.BaseJdbcLogProperties; /** * @author Yong.Teng * @since 2.3.0 */ -public class BasicJdbcLogProperties extends AbstractJpaProperties { +public class BasicJdbcLogProperties extends BaseJdbcLogProperties { private final static long serialVersionUID = -8855157645722841369L; - /** - * 数据表名称 - */ - private String tableName; - - /** - * 标识字段名称 - */ - private String idFieldName; - - /** - * 登录次数字段名称 - */ - private String loginTimesFieldName; - - /** - * 登录时间字段名称 - */ - private String loginTimeFieldName; - - /** - * 登录 IP 字段名称 - */ - private String loginIpFieldName; - - /** - * User-Agent 字段名称 - */ - private String userAgentFieldName; - - /** - * 操作系统名称字段名称 - */ - private String operatingSystemNameFieldName; - - /** - * 操作系统版本字段名称 - */ - private String operatingSystemVersionFieldName; - - /** - * 设备类型字段名称 - */ - private String deviceTypeFieldName; - - /** - * 浏览器名称字段名称 - */ - private String browserNameFieldName; - - /** - * 浏览器版本字段名称 - */ - private String browserVersionFieldName; - - /** - * 国家 Code 字段名称 - */ - private String countryCodeFieldName; - - /** - * 国家名称字段名称 - */ - private String countryNameFieldName; - - /** - * 地区名称字段名称 - */ - private String districtNameFieldName; - - /** - * 上次登录时间字段名称 - */ - private String lastLoginTimeFieldName; - - /** - * 上次登录 IP 字段名称 - */ - private String lastLoginIpFieldName; - - /** - * 上次登录 User-Agent 字段名称 - */ - private String lastUserAgentFieldName; - - /** - * 上次登录操作系统名称字段名称 - */ - private String lastOperatingSystemNameFieldName; - - /** - * 上次登录操作系统版本字段名称 - */ - private String lastOperatingSystemVersionFieldName; - - /** - * 上次登录设备类型字段名称 - */ - private String lastDeviceTypeFieldName; - - /** - * 上次登录浏览器名称字段名称 - */ - private String lastBrowserNameFieldName; - - /** - * 上次登录浏览器版本字段名称 - */ - private String lastBrowserVersionFieldName; - - /** - * 上次登录国家 Code 字段名称 - */ - private String lastCountryCodeFieldName; - - /** - * 上次登录国家名称字段名称 - */ - private String lastCountryNameFieldName; - - /** - * 上次登录地区名称字段名称 - */ - private String lastDistrictNameFieldName; - - /** - * 返回数据表名称 - * - * @return 数据表名称 - */ - public String getTableName(){ - return tableName; - } - - /** - * 设置数据表名称 - * - * @param tableName - * 数据表名称 - */ - public void setTableName(String tableName){ - this.tableName = tableName; - } - - /** - * 返回标识字段名称 - * - * @return 标识字段名称 - */ - public String getIdFieldName(){ - return idFieldName; - } - - /** - * 设置标识字段名称 - * - * @param idFieldName - * 标识字段名称 - */ - public void setIdFieldName(String idFieldName){ - this.idFieldName = idFieldName; - } - - /** - * 返回登录次数字段名称 - * - * @return 登录次数字段名称 - */ - public String getLoginTimesFieldName(){ - return loginTimesFieldName; - } - - /** - * 设置登录次数字段名称 - * - * @param loginTimesFieldName - * 登录次数字段名称 - */ - public void setLoginTimesFieldName(String loginTimesFieldName){ - this.loginTimesFieldName = loginTimesFieldName; - } - - /** - * 返回登录时间字段名称 - * - * @return 登录时间字段名称 - */ - public String getLoginTimeFieldName(){ - return loginTimeFieldName; - } - - /** - * 设置登录时间字段名称 - * - * @param loginTimeFieldName - * 登录时间字段名称 - */ - public void setLoginTimeFieldName(String loginTimeFieldName){ - this.loginTimeFieldName = loginTimeFieldName; - } - - /** - * 返回登录 IP 字段名称 - * - * @return 登录 IP 字段名称 - */ - public String getLoginIpFieldName(){ - return loginIpFieldName; - } - - /** - * 设置登录 IP 字段名称 - * - * @param loginIpFieldName - * 登录 IP 字段名称 - */ - public void setLoginIpFieldName(String loginIpFieldName){ - this.loginIpFieldName = loginIpFieldName; - } - - /** - * 返回 User-Agent 字段名称 - * - * @return User-Agent 字段名称 - */ - public String getUserAgentFieldName(){ - return userAgentFieldName; - } - - /** - * 设置 User-Agent 字段名称 - * - * @param userAgentFieldName - * User-Agent 字段名称 - */ - public void setUserAgentFieldName(String userAgentFieldName){ - this.userAgentFieldName = userAgentFieldName; - } - - /** - * 返回操作系统名称字段名称 - * - * @return 操作系统名称字段名称 - */ - public String getOperatingSystemNameFieldName(){ - return operatingSystemNameFieldName; - } - - /** - * 设置操作系统名称字段名称 - * - * @param operatingSystemNameFieldName - * 操作系统名称字段名称 - */ - public void setOperatingSystemNameFieldName(String operatingSystemNameFieldName){ - this.operatingSystemNameFieldName = operatingSystemNameFieldName; - } - - /** - * 返回操作系统版本字段名称 - * - * @return 操作系统版本字段名称 - */ - public String getOperatingSystemVersionFieldName(){ - return operatingSystemVersionFieldName; - } - - /** - * 设置操作系统版本字段名称 - * - * @param operatingSystemVersionFieldName - * 操作系统版本字段名称 - */ - public void setOperatingSystemVersionFieldName(String operatingSystemVersionFieldName){ - this.operatingSystemVersionFieldName = operatingSystemVersionFieldName; - } - - /** - * 返回设备类型字段名称 - * - * @return 设备类型字段名称 - */ - public String getDeviceTypeFieldName(){ - return deviceTypeFieldName; - } - - /** - * 设置设备类型字段名称 - * - * @param deviceTypeFieldName - * 设备类型字段名称 - */ - public void setDeviceTypeFieldName(String deviceTypeFieldName){ - this.deviceTypeFieldName = deviceTypeFieldName; - } - - /** - * 返回浏览器名称字段名称 - * - * @return 浏览器名称字段名称 - */ - public String getBrowserNameFieldName(){ - return browserNameFieldName; - } - - /** - * 设置浏览器名称字段名称 - * - * @param browserNameFieldName - * 浏览器名称字段名称 - */ - public void setBrowserNameFieldName(String browserNameFieldName){ - this.browserNameFieldName = browserNameFieldName; - } - - /** - * 返回浏览器版本字段名称 - * - * @return 浏览器版本字段名称 - */ - public String getBrowserVersionFieldName(){ - return browserVersionFieldName; - } - - /** - * 设置浏览器版本字段名称 - * - * @param browserVersionFieldName - * 浏览器版本字段名称 - */ - public void setBrowserVersionFieldName(String browserVersionFieldName){ - this.browserVersionFieldName = browserVersionFieldName; - } - - /** - * 返回国家 Code 字段名称 - * - * @return 国家 Code 字段名称 - */ - public String getCountryCodeFieldName(){ - return countryCodeFieldName; - } - - /** - * 设置国家 Code 字段名称 - * - * @param countryCodeFieldName - * 国家 Code 字段名称 - */ - public void setCountryCodeFieldName(String countryCodeFieldName){ - this.countryCodeFieldName = countryCodeFieldName; - } - - /** - * 返回国家名称字段名称 - * - * @return 国家名称字段名称 - */ - public String getCountryNameFieldName(){ - return countryNameFieldName; - } - - /** - * 设置国家名称字段名称 - * - * @param countryNameFieldName - * 国家名称字段名称 - */ - public void setCountryNameFieldName(String countryNameFieldName){ - this.countryNameFieldName = countryNameFieldName; - } - - /** - * 返回地区名称字段名称 - * - * @return 地区名称字段名称 - */ - public String getDistrictNameFieldName(){ - return districtNameFieldName; - } - - /** - * 设置地区名称字段名称 - * - * @param districtNameFieldName - * 地区名称字段名称 - */ - public void setDistrictNameFieldName(String districtNameFieldName){ - this.districtNameFieldName = districtNameFieldName; - } - - /** - * 返回上次登录时间字段名称 - * - * @return 上次登录时间字段名称 - */ - public String getLastLoginTimeFieldName(){ - return lastLoginTimeFieldName; - } - - /** - * 设置上次登录时间字段名称 - * - * @param lastLoginTimeFieldName - * 上次登录时间字段名称 - */ - public void setLastLoginTimeFieldName(String lastLoginTimeFieldName){ - this.lastLoginTimeFieldName = lastLoginTimeFieldName; - } - - /** - * 返回上次登录 IP 字段名称 - * - * @return 上次登录 IP 字段名称 - */ - public String getLastLoginIpFieldName(){ - return lastLoginIpFieldName; - } - - /** - * 设置上次登录 IP 字段名称 - * - * @param lastLoginIpFieldName - * 上次登录 IP 字段名称 - */ - public void setLastLoginIpFieldName(String lastLoginIpFieldName){ - this.lastLoginIpFieldName = lastLoginIpFieldName; - } - - /** - * 返回上次登录 User-Agent 字段名称 - * - * @return 上次登录 User-Agent 字段名称 - */ - public String getLastUserAgentFieldName(){ - return lastUserAgentFieldName; - } - - /** - * 设置上次登录 User-Agent 字段名称 - * - * @param lastUserAgentFieldName - * 上次登录 User-Agent 字段名称 - */ - public void setLastUserAgentFieldName(String lastUserAgentFieldName){ - this.lastUserAgentFieldName = lastUserAgentFieldName; - } - - /** - * 返回上次登录操作系统名称字段名称 - * - * @return 上次登录操作系统名称字段名称 - */ - public String getLastOperatingSystemNameFieldName(){ - return lastOperatingSystemNameFieldName; - } - - /** - * 设置上次登录操作系统名称字段名称 - * - * @param lastOperatingSystemNameFieldName - * 上次登录操作系统名称字段名称 - */ - public void setLastOperatingSystemNameFieldName(String lastOperatingSystemNameFieldName){ - this.lastOperatingSystemNameFieldName = lastOperatingSystemNameFieldName; - } - - /** - * 返回上次登录操作系统版本字段名称 - * - * @return 上次登录操作系统版本字段名称 - */ - public String getLastOperatingSystemVersionFieldName(){ - return lastOperatingSystemVersionFieldName; - } - - /** - * 设置上次登录操作系统版本字段名称 - * - * @param lastOperatingSystemVersionFieldName - * 上次登录操作系统版本字段名称 - */ - public void setLastOperatingSystemVersionFieldName(String lastOperatingSystemVersionFieldName){ - this.lastOperatingSystemVersionFieldName = lastOperatingSystemVersionFieldName; - } - - /** - * 返回上次登录设备类型字段名称 - * - * @return 上次登录设备类型字段名称 - */ - public String getLastDeviceTypeFieldName(){ - return lastDeviceTypeFieldName; - } - - /** - * 设置上次登录设备类型字段名称 - * - * @param lastDeviceTypeFieldName - * 上次登录设备类型字段名称 - */ - public void setLastDeviceTypeFieldName(String lastDeviceTypeFieldName){ - this.lastDeviceTypeFieldName = lastDeviceTypeFieldName; - } - - /** - * 返回上次登录浏览器名称字段名称 - * - * @return 上次登录浏览器名称字段名称 - */ - public String getLastBrowserNameFieldName(){ - return lastBrowserNameFieldName; - } - - /** - * 设置上次登录浏览器名称字段名称 - * - * @param lastBrowserNameFieldName - * 上次登录浏览器名称字段名称 - */ - public void setLastBrowserNameFieldName(String lastBrowserNameFieldName){ - this.lastBrowserNameFieldName = lastBrowserNameFieldName; - } - - /** - * 返回上次登录浏览器版本字段名称 - * - * @return 上次登录浏览器版本字段名称 - */ - public String getLastBrowserVersionFieldName(){ - return lastBrowserVersionFieldName; - } - - /** - * 设置上次登录浏览器版本字段名称 - * - * @param lastBrowserVersionFieldName - * 上次登录浏览器版本字段名称 - */ - public void setLastBrowserVersionFieldName(String lastBrowserVersionFieldName){ - this.lastBrowserVersionFieldName = lastBrowserVersionFieldName; - } - - /** - * 返回上次登录国家 Code 字段名称 - * - * @return 上次登录国家 Code 字段名称 - */ - public String getLastCountryCodeFieldName(){ - return lastCountryCodeFieldName; - } - - /** - * 设置上次登录国家 Code 字段名称 - * - * @param lastCountryCodeFieldName - * 上次登录国家 Code 字段名称 - */ - public void setLastCountryCodeFieldName(String lastCountryCodeFieldName){ - this.lastCountryCodeFieldName = lastCountryCodeFieldName; - } - - /** - * 返回上次登录国家名称字段名称 - * - * @return 上次登录国家名称字段名称 - */ - public String getLastCountryNameFieldName(){ - return lastCountryNameFieldName; - } - - /** - * 设置上次登录国家名称字段名称 - * - * @param lastCountryNameFieldName - * 上次登录国家名称字段名称 - */ - public void setLastCountryNameFieldName(String lastCountryNameFieldName){ - this.lastCountryNameFieldName = lastCountryNameFieldName; - } - - /** - * 返回上次登录地区名称字段名称 - * - * @return 上次登录地区名称字段名称 - */ - public String getLastDistrictNameFieldName(){ - return lastDistrictNameFieldName; - } - - /** - * 设置上次登录地区名称字段名称 - * - * @param lastDistrictNameFieldName - * 上次登录地区名称字段名称 - */ - public void setLastDistrictNameFieldName(String lastDistrictNameFieldName){ - this.lastDistrictNameFieldName = lastDistrictNameFieldName; - } - } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/history/HistoryJdbcLogProperties.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/history/HistoryJdbcLogProperties.java index 04c9816..2d26682 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/history/HistoryJdbcLogProperties.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/config/history/HistoryJdbcLogProperties.java @@ -19,21 +19,12 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.config.history; -import com.buession.core.id.IdGenerator; -import com.buession.jdbc.datasource.config.PoolConfiguration; -import com.buession.logging.core.formatter.GeoFormatter; -import com.buession.logging.core.formatter.MapFormatter; -import com.buession.logging.jdbc.formatter.DefaultGeoFormatter; -import com.buession.logging.jdbc.formatter.JsonMapFormatter; -import com.buession.logging.support.config.HandlerProperties; -import org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties; - -import java.io.Serializable; +import org.apereo.cas.logging.config.BaseJdbcLogProperties; /** * JDBC 历史登录日志配置 @@ -41,200 +32,8 @@ * @author Yong.Teng * @since 2.3.0 */ -public class HistoryJdbcLogProperties extends AbstractJpaProperties implements HandlerProperties, Serializable { +public class HistoryJdbcLogProperties extends BaseJdbcLogProperties { private final static long serialVersionUID = 6396868404292124235L; - /** - * 数据库驱动类名 - */ - private String driverClassName; - - /** - * 连接池配置 - */ - private PoolConfiguration poolConfiguration; - - /** - * SQL - */ - private String sql; - - /** - * ID 生成器 - */ - private Class> idGenerator; - - /** - * 日期时间格式 - */ - private String dateTimeFormat; - - /** - * 请求参数格式化为字符串 - */ - private Class> requestParametersFormatter = JsonMapFormatter.class; - - /** - * Geo 格式化 - */ - private Class geoFormatter = DefaultGeoFormatter.class; - - /** - * 附加参数格式化为字符串 - */ - private Class> extraFormatter = JsonMapFormatter.class; - - /** - * 返回数据库驱动类名 - * - * @return 数据库驱动类名 - */ - public String getDriverClassName() { - return driverClassName; - } - - /** - * 设置数据库驱动类名 - * - * @param driverClassName - * 数据库驱动类名 - */ - public void setDriverClassName(String driverClassName) { - this.driverClassName = driverClassName; - } - - /** - * 返回连接池配置 - * - * @return 连接池配置 - */ - public PoolConfiguration getPoolConfiguration() { - return poolConfiguration; - } - - /** - * 设置连接池配置 - * - * @param poolConfiguration - * 连接池配置 - */ - public void setPoolConfiguration(PoolConfiguration poolConfiguration) { - this.poolConfiguration = poolConfiguration; - } - - /** - * 返回 SQL - * - * @return SQL - */ - public String getSql() { - return sql; - } - - /** - * 设置 SQL - * - * @param sql - * SQL - */ - public void setSql(String sql) { - this.sql = sql; - } - - /** - * 返回 ID 生成器 - * - * @return ID 生成器 - */ - public Class> getIdGenerator() { - return idGenerator; - } - - /** - * 设置 ID 生成器 - * - * @param idGenerator - * ID 生成器 - */ - public void setIdGenerator(Class> idGenerator) { - this.idGenerator = idGenerator; - } - - /** - * 返回日期时间格式 - * - * @return 日期时间格式 - */ - public String getDateTimeFormat() { - return dateTimeFormat; - } - - /** - * 设置日期时间格式 - * - * @param dateTimeFormat - * 日期时间格式 - */ - public void setDateTimeFormat(String dateTimeFormat) { - this.dateTimeFormat = dateTimeFormat; - } - - /** - * 返回请求参数格式化为字符串 - * - * @return 请求参数格式化为字符串 - */ - public Class> getRequestParametersFormatter() { - return requestParametersFormatter; - } - - /** - * 设置请求参数格式化为字符串 - * - * @param requestParametersFormatter - * 请求参数格式化为字符串 - */ - public void setRequestParametersFormatter(Class> requestParametersFormatter) { - this.requestParametersFormatter = requestParametersFormatter; - } - - /** - * 返回 Geo 格式化 - * - * @return Geo 格式化 - */ - public Class getGeoFormatter() { - return geoFormatter; - } - - /** - * 设置 Geo 格式化 - * - * @param geoFormatter - * Geo 格式化 - */ - public void setGeoFormatter(Class geoFormatter) { - this.geoFormatter = geoFormatter; - } - - /** - * 返回附加参数格式化为字符串 - * - * @return 附加参数格式化为字符串 - */ - public Class> getExtraFormatter() { - return extraFormatter; - } - - /** - * 设置附加参数格式化为字符串 - * - * @param extraFormatter - * 附加参数格式化为字符串 - */ - public void setExtraFormatter(Class> extraFormatter) { - this.extraFormatter = extraFormatter; - } - } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/DefaultBasicLoginLoggingManager.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/DefaultBasicLoginLoggingManager.java new file mode 100644 index 0000000..5977726 --- /dev/null +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/DefaultBasicLoginLoggingManager.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + * + * ========================================================================================================= + * + * This software consists of voluntary contributions made by many individuals on behalf of the + * Apache Software Foundation. For more information on the Apache Software Foundation, please see + * . + * + * +-------------------------------------------------------------------------------------------------------+ + * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | + * | Author: Yong.Teng | + * | Copyright @ 2013-2024 Buession.com Inc. | + * +-------------------------------------------------------------------------------------------------------+ + */ +package org.apereo.cas.logging.manager; + +import com.buession.core.utils.Assert; +import com.buession.logging.core.LogData; +import com.buession.logging.core.mgt.LogManager; + +/** + * 默认基本登录日志管理器 + * + * @author Yong.Teng + * @since 2.3.3 + */ +public class DefaultBasicLoginLoggingManager extends AbstractLoginLoggingManager implements BasicLoginLoggingManager { + + private final LogManager logManager; + + public DefaultBasicLoginLoggingManager(final LogManager logManager) { + Assert.isNull(logManager, "LogManager cloud not be null."); + this.logManager = logManager; + } + + @Override + public void execute(final LogData logData) { + logManager.save(logData); + } + +} diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/JdbcBasicLoginLoggingManager.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/JdbcBasicLoginLoggingManager.java deleted file mode 100644 index 7d2f67c..0000000 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/JdbcBasicLoginLoggingManager.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. - * See the NOTICE file distributed with this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - * - * ========================================================================================================= - * - * This software consists of voluntary contributions made by many individuals on behalf of the - * Apache Software Foundation. For more information on the Apache Software Foundation, please see - * . - * - * +-------------------------------------------------------------------------------------------------------+ - * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | - * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | - * +-------------------------------------------------------------------------------------------------------+ - */ -package org.apereo.cas.logging.manager; - -import com.buession.core.utils.Assert; -import com.buession.core.validator.Validate; -import com.buession.logging.core.LogData; -import org.apereo.cas.logging.config.basic.BasicJdbcLogProperties; -import org.jetbrains.annotations.NotNull; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -import javax.sql.DataSource; -import java.util.ArrayList; -import java.util.List; -import java.util.StringJoiner; - -/** - * JDBC 基本登录日志管理器 - * - * @author Yong.Teng - * @since 2.3.0 - */ -public class JdbcBasicLoginLoggingManager extends AbstractLoginLoggingManager implements BasicLoginLoggingManager { - - private final JdbcBasicLoginLoggingJdbcDaoSupport daoSupport; - - public JdbcBasicLoginLoggingManager(final DataSource dataSource, final TransactionTemplate transactionTemplate, - final BasicJdbcLogProperties properties) { - super(); - Assert.isNull(transactionTemplate, "TransactionTemplate cloud not be null."); - this.daoSupport = new JdbcBasicLoginLoggingJdbcDaoSupport(dataSource, transactionTemplate, properties); - } - - @Override - public void execute(final LogData logData) { - daoSupport.execute(logData); - } - - private final static class JdbcBasicLoginLoggingJdbcDaoSupport extends NamedParameterJdbcDaoSupport { - - private final TransactionTemplate transactionTemplate; - - private final BasicJdbcLogProperties properties; - - private final String sql; - - public JdbcBasicLoginLoggingJdbcDaoSupport(final DataSource dataSource, - final TransactionTemplate transactionTemplate, - final BasicJdbcLogProperties properties) { - this.transactionTemplate = transactionTemplate; - this.properties = properties; - this.sql = buildLogSql(); - setDataSource(dataSource); - } - - public void execute(final LogData logData) { - List arguments = new ArrayList<>(12); - - // 登录时间 - if(Validate.isNotEmpty(properties.getLoginTimeFieldName())){ - arguments.add(logData.getDateTime()); - } - - // 登录 IP 地址 - if(Validate.isNotEmpty(properties.getLoginIpFieldName())){ - arguments.add(logData.getClientIp()); - } - - // 登录 User-Agent - if(Validate.isNotEmpty(properties.getUserAgentFieldName())){ - arguments.add(logData.getUserAgent()); - } - - // 登录操作系统名称 - if(Validate.isNotEmpty(properties.getOperatingSystemNameFieldName())){ - arguments.add(logData.getOperatingSystem().getName()); - } - - // 登录操作系统版本 - if(Validate.isNotEmpty(properties.getOperatingSystemVersionFieldName())){ - arguments.add(logData.getOperatingSystem().getVersion()); - } - - // 登录设备 - if(Validate.isNotEmpty(properties.getDeviceTypeFieldName())){ - arguments.add(logData.getDeviceType().name()); - } - - // 登录浏览器名称 - if(Validate.isNotEmpty(properties.getBrowserNameFieldName())){ - arguments.add(logData.getBrowser().getName()); - } - - // 登录浏览器版本 - if(Validate.isNotEmpty(properties.getBrowserVersionFieldName())){ - arguments.add(logData.getBrowser().getVersion()); - } - - // 登录国家 code - if(Validate.isNotEmpty(properties.getCountryCodeFieldName())){ - arguments.add(logData.getLocation().getCountry().getCode()); - } - - // 登录国家名称 - if(Validate.isNotEmpty(properties.getCountryNameFieldName())){ - arguments.add(logData.getLocation().getCountry().getName()); - } - - // 登录地区名称 - if(Validate.isNotEmpty(properties.getDistrictNameFieldName())){ - arguments.add(logData.getLocation().getDistrict().getFullName()); - } - - arguments.add(logData.getPrincipal().getUserName()); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - - @Override - protected void doInTransactionWithoutResult(@NotNull TransactionStatus transactionStatus) { - getJdbcTemplate().update(sql, arguments.toArray(new Object[]{})); - } - - }); - } - - private String buildLogSql() { - final StringBuilder sql = new StringBuilder(); - final StringJoiner updateFields = new StringJoiner(", "); - - sql.append("UPDATE `").append(properties.getTableName()).append("` SET "); - - // 登录次数 - if(Validate.isNotEmpty(properties.getLoginTimesFieldName())){ - updateFields.add("`" + properties.getLoginTimesFieldName() + "` = `" + - properties.getLoginTimesFieldName() + "` + 1"); - } - - // 上次登录时间 - if(Validate.isNotEmpty(properties.getLastLoginTimeFieldName()) && - Validate.isNotEmpty(properties.getLoginTimeFieldName())){ - updateFields.add("`" + properties.getLastLoginTimeFieldName() + "` = `" + - properties.getLoginTimeFieldName() + "`"); - } - - // 登录时间 - if(Validate.isNotEmpty(properties.getLoginTimeFieldName())){ - updateFields.add("`" + properties.getLoginTimeFieldName() + "` = ?"); - } - - // 上次登录 IP 地址 - if(Validate.isNotEmpty(properties.getLastLoginIpFieldName()) && - Validate.isNotEmpty(properties.getLoginIpFieldName())){ - updateFields.add("`" + properties.getLastLoginIpFieldName() + "` = `" + - properties.getLoginIpFieldName() + "`"); - } - - // 登录 IP 地址 - if(Validate.isNotEmpty(properties.getLoginIpFieldName())){ - updateFields.add("`" + properties.getLoginIpFieldName() + "` = ?"); - } - - // 上次登录 User-Agent - if(Validate.isNotEmpty(properties.getLastUserAgentFieldName()) && - Validate.isNotEmpty(properties.getUserAgentFieldName())){ - updateFields.add("`" + properties.getLastUserAgentFieldName() + "` = `" + - properties.getUserAgentFieldName() + "`"); - } - - // 登录 User-Agent - if(Validate.isNotEmpty(properties.getUserAgentFieldName())){ - updateFields.add("`" + properties.getUserAgentFieldName() + "` = ?"); - } - - // 上次登录操作系统名称 - if(Validate.isNotEmpty(properties.getLastOperatingSystemNameFieldName()) && - Validate.isNotEmpty(properties.getOperatingSystemNameFieldName())){ - updateFields.add("`" + properties.getLastOperatingSystemNameFieldName() + "` = `" + - properties.getOperatingSystemNameFieldName() + "`"); - } - - // 登录操作系统名称 - if(Validate.isNotEmpty(properties.getOperatingSystemNameFieldName())){ - updateFields.add("`" + properties.getOperatingSystemNameFieldName() + "` = ?"); - } - - // 上次登录操作系统版本 - if(Validate.isNotEmpty(properties.getLastOperatingSystemVersionFieldName()) && - Validate.isNotEmpty(properties.getOperatingSystemVersionFieldName())){ - updateFields.add("`" + properties.getLastOperatingSystemVersionFieldName() + "` = `" + - properties.getOperatingSystemVersionFieldName() + "`"); - } - - // 登录操作系统版本 - if(Validate.isNotEmpty(properties.getOperatingSystemVersionFieldName())){ - updateFields.add("`" + properties.getOperatingSystemVersionFieldName() + "` = ?"); - } - - // 上次登录设备 - if(Validate.isNotEmpty(properties.getLastDeviceTypeFieldName()) && - Validate.isNotEmpty(properties.getDeviceTypeFieldName())){ - updateFields.add("`" + properties.getLastDeviceTypeFieldName() + "` = `" + - properties.getDeviceTypeFieldName() + "`"); - } - - // 登录设备 - if(Validate.isNotEmpty(properties.getDeviceTypeFieldName())){ - updateFields.add("`" + properties.getDeviceTypeFieldName() + "` = ?"); - } - - // 上次登录浏览器名称 - if(Validate.isNotEmpty(properties.getLastBrowserNameFieldName()) && - Validate.isNotEmpty(properties.getBrowserNameFieldName())){ - updateFields.add("`" + properties.getLastBrowserNameFieldName() + "` = `" + - properties.getBrowserNameFieldName() + "`"); - } - - // 登录浏览器名称 - if(Validate.isNotEmpty(properties.getBrowserNameFieldName())){ - updateFields.add("`" + properties.getBrowserNameFieldName() + "` = ?"); - } - - // 上次登录浏览器版本 - if(Validate.isNotEmpty(properties.getLastBrowserVersionFieldName()) && - Validate.isNotEmpty(properties.getBrowserVersionFieldName())){ - updateFields.add("`" + properties.getLastBrowserVersionFieldName() + "` = `" + - properties.getBrowserVersionFieldName() + "`"); - } - - // 登录浏览器版本 - if(Validate.isNotEmpty(properties.getBrowserVersionFieldName())){ - updateFields.add("`" + properties.getBrowserVersionFieldName() + "` = ?"); - } - - // 上次登录国家 code - if(Validate.isNotEmpty(properties.getLastCountryCodeFieldName()) && - Validate.isNotEmpty(properties.getCountryCodeFieldName())){ - updateFields.add("`" + properties.getLastCountryCodeFieldName() + "` = `" + - properties.getCountryCodeFieldName() + "`"); - } - - // 登录国家 code - if(Validate.isNotEmpty(properties.getCountryCodeFieldName())){ - updateFields.add("`" + properties.getCountryCodeFieldName() + "` = ?"); - } - - // 上次登录国家名称 - if(Validate.isNotEmpty(properties.getLastCountryNameFieldName()) && - Validate.isNotEmpty(properties.getCountryNameFieldName())){ - updateFields.add("`" + properties.getLastCountryNameFieldName() + "` = `" + - properties.getCountryNameFieldName() + "`"); - } - - // 登录国家名称 - if(Validate.isNotEmpty(properties.getCountryNameFieldName())){ - updateFields.add("`" + properties.getCountryNameFieldName() + "` = ?"); - } - - // 上次登录地区名称 - if(Validate.isNotEmpty(properties.getLastDistrictNameFieldName()) && - Validate.isNotEmpty(properties.getDistrictNameFieldName())){ - updateFields.add("`" + properties.getLastDistrictNameFieldName() + "` = `" + - properties.getDistrictNameFieldName() + "`"); - } - - // 登录地区名称 - if(Validate.isNotEmpty(properties.getDistrictNameFieldName())){ - updateFields.add("`" + properties.getDistrictNameFieldName() + "` = ?"); - } - - sql.append(updateFields) - .append(" WHERE `") - .append(properties.getIdFieldName()) - .append("` = ?"); - - return sql.toString(); - } - - } - -} diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/ConsoleBasicLoginLoggingManager.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/CasConsoleLogDataFormatter.java similarity index 82% rename from buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/ConsoleBasicLoginLoggingManager.java rename to buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/CasConsoleLogDataFormatter.java index f75499f..066bf62 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/ConsoleBasicLoginLoggingManager.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/CasConsoleLogDataFormatter.java @@ -19,30 +19,32 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ -package org.apereo.cas.logging.manager; +package org.apereo.cas.logging.manager.console; import com.buession.core.utils.StringUtils; +import com.buession.logging.console.formatter.ConsoleLogDataFormatter; import com.buession.logging.core.LogData; /** - * 控制台基本登录日志管理器 - * * @author Yong.Teng - * @since 2.3.0 + * @since 2.3.3 */ -public class ConsoleBasicLoginLoggingManager extends AbstractLoginLoggingManager implements BasicLoginLoggingManager { - - private final String template; +public class CasConsoleLogDataFormatter implements ConsoleLogDataFormatter { - public ConsoleBasicLoginLoggingManager(final String template) { - this.template = template; + @Override + public String format(final LogData logData) { + return logData == null ? null : logData.toString(); } @Override - public void execute(final LogData logData) { + public String format(final String template, final LogData logData) { + if(logData == null){ + return null; + } + String message = template; message = StringUtils.replace(message, "${id}", logData.getPrincipal().toString()); @@ -55,7 +57,7 @@ public void execute(final LogData logData) { message = StringUtils.replace(message, "${browser_name}", logData.getBrowser().getName()); message = StringUtils.replace(message, "${browser_version}", logData.getBrowser().getVersion()); - System.out.println(message); + return message; } } diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/utils/package-info.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/package-info.java similarity index 93% rename from buession-cas-logging/src/main/java/org/apereo/cas/logging/utils/package-info.java rename to buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/package-info.java index 3f24867..78af439 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/utils/package-info.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/package-info.java @@ -19,11 +19,11 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ /** * @author Yong.Teng * @since 2.3.0 */ -package org.apereo.cas.logging.utils; \ No newline at end of file +package org.apereo.cas.logging.manager.console; \ No newline at end of file diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/package-info.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/package-info.java index c3c16eb..5fb1940 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/package-info.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/package-info.java @@ -19,7 +19,7 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ /** diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/autoconfigure/CasLoginLoggingConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/autoconfigure/CasLoginLoggingConfiguration.java index 4948ddb..c69ba03 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/autoconfigure/CasLoginLoggingConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/autoconfigure/CasLoginLoggingConfiguration.java @@ -19,7 +19,7 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.web.flow.autoconfigure; @@ -64,18 +64,14 @@ HistoryLoginLoggingConfiguration.class}) public class CasLoginLoggingConfiguration extends AbstractWebflowConfiguration { - private final CasCoreConfigurationProperties casCoreConfigurationProperties; - private final CasLoggingConfigurationProperties casLoggingConfigurationProperties; public CasLoginLoggingConfiguration(CasConfigurationProperties casProperties, - CasCoreConfigurationProperties casCoreConfigurationProperties, CasLoggingConfigurationProperties casLoggingConfigurationProperties, ObjectProvider applicationContext, @Qualifier("loginFlowRegistry") ObjectProvider loginFlowDefinitionRegistry, ObjectProvider flowBuilderServices) { super(casProperties, applicationContext, loginFlowDefinitionRegistry, flowBuilderServices); - this.casCoreConfigurationProperties = casCoreConfigurationProperties; this.casLoggingConfigurationProperties = casLoggingConfigurationProperties; } diff --git a/buession-cas-logging/src/main/resources/META-INF/spring.factories b/buession-cas-logging/src/main/resources/META-INF/spring.factories index 84a3a6a..915034d 100644 --- a/buession-cas-logging/src/main/resources/META-INF/spring.factories +++ b/buession-cas-logging/src/main/resources/META-INF/spring.factories @@ -1,4 +1,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + org.apereo.cas.logging.autoconfigure.LoginLoggingConfiguration, \ + org.apereo.cas.logging.autoconfigure.console.ConsoleLogHandlerConfiguration, \ org.apereo.cas.logging.autoconfigure.elasticsearch.ElasticsearchLogHandlerConfiguration, \ org.apereo.cas.logging.autoconfigure.jdbc.JdbcLogHandlerConfiguration, \ org.apereo.cas.logging.autoconfigure.kafka.KafkaLogHandlerConfiguration, \ From 6d57c8525ca6b7727a4dca0284892574042ce997 Mon Sep 17 00:00:00 2001 From: "Yong.Teng" Date: Wed, 3 Apr 2024 14:03:45 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/flow/action/LoginLoggingAction.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/action/LoginLoggingAction.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/action/LoginLoggingAction.java index c4c95d4..a928a18 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/action/LoginLoggingAction.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/web/flow/action/LoginLoggingAction.java @@ -19,7 +19,7 @@ * +-------------------------------------------------------------------------------------------------------+ * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | * | Author: Yong.Teng | - * | Copyright @ 2013-2023 Buession.com Inc. | + * | Copyright @ 2013-2024 Buession.com Inc. | * +-------------------------------------------------------------------------------------------------------+ */ package org.apereo.cas.logging.web.flow.action; @@ -27,14 +27,21 @@ import com.buession.lang.Constants; import com.buession.logging.core.LogData; import com.buession.logging.core.Principal; +import org.apereo.cas.authentication.Authentication; +import org.apereo.cas.authentication.AuthenticationResult; +import org.apereo.cas.authentication.Credential; import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; import org.apereo.cas.logging.manager.BasicLoginLoggingManager; import org.apereo.cas.logging.manager.HistoryLoginLoggingManager; +import org.apereo.cas.web.support.WebUtils; import org.springframework.webflow.action.AbstractAction; import org.springframework.webflow.execution.Action; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Optional; /** @@ -90,16 +97,27 @@ public LoginLoggingAction(final CasLoggingConfigurationProperties casLoggingConf @Override protected Event doExecute(final RequestContext requestContext) { + final AuthenticationResult authenticationResult = WebUtils.getAuthenticationResult(requestContext); + final Authentication authentication = authenticationResult.getAuthentication(); + final org.apereo.cas.authentication.principal.Principal principal = authentication.getPrincipal(); + final String uid = principal.getId(); + final Map> uAttributes = principal.getAttributes(); + final Credential credential = WebUtils.getCredential(requestContext); + final LogData loginData = new LogData(); - final String username = requestContext.getRequestParameters().get("username"); - final Principal principal = new Principal(); - principal.setUserName(username); + final Principal logPrincipal = new Principal(); + + logPrincipal.setId(uid); + logPrincipal.setUserName(credential.getId()); + + final Map extra = new HashMap<>(uAttributes); loginData.setBusinessType(casLoggingConfigurationProperties.getBusinessType()); loginData.setEvent(casLoggingConfigurationProperties.getEvent()); - loginData.setPrincipal(principal); + loginData.setPrincipal(logPrincipal); loginData.setDescription(description); + loginData.setExtra(extra); historyLoginLoggingManager.execute(loginData); basicLoginLoggingManager.execute(loginData); From 5faa7c4560ab05d7b5ecf5ba135f2b5fd65ca45f Mon Sep 17 00:00:00 2001 From: "Yong.Teng" Date: Wed, 3 Apr 2024 16:56:04 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 ++++ .../ConsoleLogHandlerConfiguration.java | 4 +- .../console/CasConsoleLogDataFormatter.java | 63 ------------------- .../logging/manager/console/package-info.java | 29 --------- 4 files changed, 13 insertions(+), 94 deletions(-) delete mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/CasConsoleLogDataFormatter.java delete mode 100644 buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/package-info.java diff --git a/CHANGELOG.md b/CHANGELOG.md index fae60d4..7d597a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,17 @@ - [依赖库版本升级和安全漏洞修复](https://github.com/buession/buession-parent/releases/tag/v2.3.3) +### 🔔 变化 + +- **buession-cas-logging:** 基本日志控制台模式,集成 com.buession.logging:buession-logging-support-console + + +### ⏪ 优化 + +- **buession-cas-logging:** 优化和规范 LogHandler bean 初始化 +- **buession-cas-logging:** 优化日志数据参数 + + --- diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java index 5108e74..85d8990 100644 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java +++ b/buession-cas-logging/src/main/java/org/apereo/cas/logging/autoconfigure/console/ConsoleLogHandlerConfiguration.java @@ -25,11 +25,11 @@ package org.apereo.cas.logging.autoconfigure.console; import com.buession.logging.console.formatter.ConsoleLogDataFormatter; +import com.buession.logging.console.formatter.DefaultConsoleLogDataFormatter; import com.buession.logging.console.spring.ConsoleLogHandlerFactoryBean; import org.apereo.cas.logging.autoconfigure.AbstractLogHandlerConfiguration; import org.apereo.cas.logging.config.CasLoggingConfigurationProperties; import org.apereo.cas.logging.config.basic.BasicConsoleLogProperties; -import org.apereo.cas.logging.manager.console.CasConsoleLogDataFormatter; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -63,7 +63,7 @@ public Basic(CasLoggingConfigurationProperties logProperties) { @Bean(name = "basicLoggingConsoleLogDataFormatter") @ConditionalOnMissingBean(name = "basicLoggingConsoleLogDataFormatter") public ConsoleLogDataFormatter consoleLogDataFormatter() { - return new CasConsoleLogDataFormatter(); + return new DefaultConsoleLogDataFormatter(); } @Bean(name = Basic.LOG_HANDLER_BEAN_NAME) diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/CasConsoleLogDataFormatter.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/CasConsoleLogDataFormatter.java deleted file mode 100644 index 066bf62..0000000 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/CasConsoleLogDataFormatter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. - * See the NOTICE file distributed with this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - * - * ========================================================================================================= - * - * This software consists of voluntary contributions made by many individuals on behalf of the - * Apache Software Foundation. For more information on the Apache Software Foundation, please see - * . - * - * +-------------------------------------------------------------------------------------------------------+ - * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | - * | Author: Yong.Teng | - * | Copyright @ 2013-2024 Buession.com Inc. | - * +-------------------------------------------------------------------------------------------------------+ - */ -package org.apereo.cas.logging.manager.console; - -import com.buession.core.utils.StringUtils; -import com.buession.logging.console.formatter.ConsoleLogDataFormatter; -import com.buession.logging.core.LogData; - -/** - * @author Yong.Teng - * @since 2.3.3 - */ -public class CasConsoleLogDataFormatter implements ConsoleLogDataFormatter { - - @Override - public String format(final LogData logData) { - return logData == null ? null : logData.toString(); - } - - @Override - public String format(final String template, final LogData logData) { - if(logData == null){ - return null; - } - - String message = template; - - message = StringUtils.replace(message, "${id}", logData.getPrincipal().toString()); - message = StringUtils.replace(message, "${time}", logData.getDateTime().toString()); - message = StringUtils.replace(message, "${clientIp}", logData.getClientIp()); - message = StringUtils.replace(message, "${User-Agent}", logData.getUserAgent()); - message = StringUtils.replace(message, "${os_name}", logData.getOperatingSystem().getName()); - message = StringUtils.replace(message, "${os_version}", logData.getOperatingSystem().getVersion()); - message = StringUtils.replace(message, "${device_type}", logData.getDeviceType().getName()); - message = StringUtils.replace(message, "${browser_name}", logData.getBrowser().getName()); - message = StringUtils.replace(message, "${browser_version}", logData.getBrowser().getVersion()); - - return message; - } - -} diff --git a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/package-info.java b/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/package-info.java deleted file mode 100644 index 78af439..0000000 --- a/buession-cas-logging/src/main/java/org/apereo/cas/logging/manager/console/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. - * See the NOTICE file distributed with this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - * - * ========================================================================================================= - * - * This software consists of voluntary contributions made by many individuals on behalf of the - * Apache Software Foundation. For more information on the Apache Software Foundation, please see - * . - * - * +-------------------------------------------------------------------------------------------------------+ - * | License: http://www.apache.org/licenses/LICENSE-2.0.txt | - * | Author: Yong.Teng | - * | Copyright @ 2013-2024 Buession.com Inc. | - * +-------------------------------------------------------------------------------------------------------+ - */ -/** - * @author Yong.Teng - * @since 2.3.0 - */ -package org.apereo.cas.logging.manager.console; \ No newline at end of file From 8e61f96be1f0870b0726de6b09b6edda9b23feba Mon Sep 17 00:00:00 2001 From: "Yong.Teng" Date: Tue, 7 May 2024 00:00:23 +0800 Subject: [PATCH 5/5] Release 2.3.3 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d597a1..edc6944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ =========================== -## [2.3.3](https://github.com/buession/buession-cas/releases/tag/v2.3.3) (2024-xx-xx) +## [2.3.3](https://github.com/buession/buession-cas/releases/tag/v2.3.3) (2024-05-06) ### 🔨依赖升级