├── .github
├── FUNDING.yml
├── workflows
│ └── maven.yml
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── trust-me
├── images
│ └── demo.gif
├── src
│ └── main
│ │ ├── java
│ │ └── nl
│ │ │ └── altindag
│ │ │ └── ssl
│ │ │ └── trustme
│ │ │ ├── AppStarter.java
│ │ │ ├── exception
│ │ │ ├── PingException.java
│ │ │ └── TrustMeException.java
│ │ │ ├── util
│ │ │ └── Logger.java
│ │ │ ├── service
│ │ │ └── PingService.java
│ │ │ ├── config
│ │ │ └── ClientConfig.java
│ │ │ └── App.java
│ │ └── resources
│ │ └── banner.txt
└── README.md
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── bypassing-overruling-ssl-configuration
├── src
│ └── main
│ │ ├── resources
│ │ └── simplelogger.properties
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── ssl
│ │ └── App.java
├── images
│ └── demo.png
└── pom.xml
├── elasticsearch-with-ssl
├── images
│ └── runner.png
├── elasticsearch-docker
│ ├── .env
│ ├── instances.yml
│ └── create-certs.yml
├── stop-es.sh
├── README.md
├── start-es.sh
└── pom.xml
├── spring-cn-validation-with-aop
├── server-with-cn-validation
│ ├── src
│ │ ├── test
│ │ │ └── resources
│ │ │ │ └── mockito-extensions
│ │ │ │ └── org.mockito.plugins.MockMaker
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── identity.jks
│ │ │ ├── truststore.jks
│ │ │ ├── application.yml
│ │ │ └── banner.txt
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── server
│ │ │ ├── App.java
│ │ │ ├── aspect
│ │ │ └── AdditionalCertificateValidations.java
│ │ │ └── controller
│ │ │ └── HelloWorldController.java
│ └── pom.xml
└── client-for-testing-server-with-cn-validation
│ ├── src
│ └── main
│ │ ├── resources
│ │ ├── identity.jks
│ │ └── truststore.jks
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── client
│ │ └── App.java
│ └── pom.xml
├── two-way-object-serialization
├── images
│ └── flow.png
├── pom.xml
├── src
│ └── main
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── server
│ │ ├── App.java
│ │ ├── controller
│ │ └── EmployeeController.java
│ │ ├── model
│ │ └── Employee.java
│ │ ├── service
│ │ └── EmployeeService.java
│ │ └── config
│ │ └── JacksonConfiguration.java
└── README.md
├── .gitignore
├── instant-server-ssl-reloading
├── images
│ ├── after-reloading.png
│ └── before-reloading.png
├── server
│ └── src
│ │ ├── main
│ │ ├── resources
│ │ │ ├── identity.jks
│ │ │ ├── truststore.jks
│ │ │ └── application.yml
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── server
│ │ │ ├── model
│ │ │ └── SSLUpdateRequest.java
│ │ │ ├── App.java
│ │ │ ├── controller
│ │ │ ├── HelloWorldController.java
│ │ │ └── AdminController.java
│ │ │ └── config
│ │ │ ├── ServerConfig.java
│ │ │ └── SSLConfig.java
│ │ └── test
│ │ └── resources
│ │ └── keystores
│ │ ├── admin
│ │ ├── identity.jks
│ │ └── truststore.jks
│ │ └── server
│ │ ├── identity.jks
│ │ └── truststore.jks
└── admin
│ ├── src
│ └── main
│ │ ├── resources
│ │ └── keystores
│ │ │ ├── admin
│ │ │ ├── identity.jks
│ │ │ └── truststore.jks
│ │ │ └── server
│ │ │ ├── identity.jks
│ │ │ └── truststore.jks
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── admin
│ │ └── model
│ │ └── SSLUpdateRequest.java
│ └── pom.xml
├── instant-server-ssl-reloading-with-quarkus
├── images
│ ├── after-reloading.png
│ └── before-reloading.png
├── src
│ └── main
│ │ ├── resources
│ │ ├── identity.jks
│ │ └── truststore.jks
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── server
│ │ └── resource
│ │ └── GreetingResource.java
└── pom.xml
├── instant-ssl-reloading-with-spring-grpc
├── src
│ └── main
│ │ ├── resources
│ │ ├── identity.jks
│ │ ├── truststore.jks
│ │ └── application.yml
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── server
│ │ ├── App.java
│ │ ├── service
│ │ └── GrpcServerService.java
│ │ └── config
│ │ └── SSLConfig.java
└── pom.xml
├── instant-ssl-reloading-with-spring-tomcat
├── src
│ └── main
│ │ ├── resources
│ │ ├── identity.jks
│ │ ├── truststore.jks
│ │ └── application.yml
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── server
│ │ ├── App.java
│ │ ├── controller
│ │ └── HelloWorldController.java
│ │ └── config
│ │ ├── ServerConfig.java
│ │ └── SSLConfig.java
└── pom.xml
├── log-captor-examples
├── log-captor-with-quarkus-jboss-lombok
│ └── src
│ │ ├── test
│ │ ├── resources
│ │ │ └── logback-test.xml
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── quarkus
│ │ │ └── resource
│ │ │ ├── GreetingsResourceWithoutQuarkusTestShould.java
│ │ │ └── GreetingsResourceWithQuarkusTestShould.java
│ │ └── main
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── quarkus
│ │ └── resource
│ │ └── GreetingResource.java
├── log-captor-with-java-util-logging
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── jul
│ │ │ └── FooService.java
│ │ └── test
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── jul
│ │ └── FooServiceShould.java
├── log-captor-with-jboss-and-lombok
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ │ │ └── nl.altindag.jboss
│ │ │ │ └── FooService.java
│ │ └── test
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── jboss
│ │ │ └── FooServiceShould.java
│ └── pom.xml
├── log-captor-with-log4j-api
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── log4j
│ │ │ └── FooService.java
│ │ └── test
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── log4j
│ │ └── FooServiceShould.java
├── log-captor-with-log4j-core
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── log4j
│ │ │ └── FooService.java
│ │ └── test
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── log4j
│ │ └── FooServiceShould.java
├── log-captor-with-slf4j-logback-classic
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── logback
│ │ │ └── FooService.java
│ │ └── test
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── logback
│ │ └── FooServiceShould.java
├── log-captor-with-flogger
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ │ │ └── nl
│ │ │ │ └── altindag
│ │ │ │ └── flogger
│ │ │ │ └── FooService.java
│ │ └── test
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── flogger
│ │ │ └── FooServiceShould.java
│ └── pom.xml
├── log-captor-with-slf4j-log4j
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ │ │ └── nl
│ │ │ │ └── altindag
│ │ │ │ └── log4j
│ │ │ │ └── FooService.java
│ │ └── test
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── log4j
│ │ │ └── FooServiceShould.java
│ └── pom.xml
├── log-captor-with-spring-boot-starter-log4j2
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ │ │ └── nl
│ │ │ │ └── altindag
│ │ │ │ └── spring
│ │ │ │ └── log4j2
│ │ │ │ └── FooService.java
│ │ └── test
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── spring
│ │ │ └── log4j2
│ │ │ └── FooServiceShould.java
│ └── pom.xml
└── pom.xml
├── grpc-client-server-with-ssl
├── grpc-client
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── client
│ │ │ │ ├── identity.jks
│ │ │ │ └── truststore.jks
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── grpc
│ │ │ └── client
│ │ │ └── App.java
│ └── pom.xml
├── grpc-server
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── server
│ │ │ │ ├── identity.jks
│ │ │ │ └── truststore.jks
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── grpc
│ │ │ └── server
│ │ │ └── service
│ │ │ └── HelloServiceImpl.java
│ └── pom.xml
├── instant-server-ssl-reloading-with-grpc
│ ├── images
│ │ ├── after-reloading.png
│ │ └── before-reloading.png
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── server
│ │ │ │ ├── identity.jks
│ │ │ │ └── truststore.jks
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── grpc
│ │ │ └── server
│ │ │ └── service
│ │ │ └── HelloServiceImpl.java
│ └── pom.xml
├── common-proto
│ └── src
│ │ └── main
│ │ └── resources
│ │ └── proto
│ │ └── hello-service.proto
└── pom.xml
├── instant-server-ssl-reloading-with-vertx
├── vertx-server
│ ├── images
│ │ ├── after-reloading.png
│ │ └── before-reloading.png
│ └── src
│ │ └── main
│ │ └── resources
│ │ ├── identity.jks
│ │ └── truststore.jks
└── pom.xml
├── instant-server-ssl-reloading-with-netty
├── netty-server
│ └── src
│ │ └── main
│ │ ├── resources
│ │ ├── identity.jks
│ │ └── truststore.jks
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── server
│ │ └── config
│ │ └── ServerInitializer.java
└── pom.xml
├── instant-ssl-reloading-with-spring-jetty-database
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.yml
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── server
│ │ │ ├── repository
│ │ │ └── SSLMaterialRepository.java
│ │ │ ├── App.java
│ │ │ ├── controller
│ │ │ └── HelloWorldController.java
│ │ │ ├── config
│ │ │ ├── SSLConfig.java
│ │ │ └── ServerConfig.java
│ │ │ └── model
│ │ │ └── SSLMaterial.java
│ └── test
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── server
│ │ └── LocalDB.java
└── README.md
├── spring-security-cn-validation-for-reactive-server
├── client
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── identity.jks
│ │ │ └── truststore.jks
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── client
│ │ │ └── App.java
│ └── pom.xml
├── spring-reactive-server
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── identity.jks
│ │ │ ├── truststore.jks
│ │ │ ├── application.yml
│ │ │ └── banner.txt
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── server
│ │ │ ├── App.java
│ │ │ ├── controller
│ │ │ └── HelloWorldController.java
│ │ │ └── config
│ │ │ └── SecurityConfig.java
│ └── pom.xml
└── pom.xml
├── console-captor-examples
├── console-captor-with-quarkus-jboss-lombok
│ └── src
│ │ ├── test
│ │ ├── resources
│ │ │ └── logback-test.xml
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── quarkus
│ │ │ └── resource
│ │ │ └── GreetingsResourceShould.java
│ │ └── main
│ │ └── java
│ │ └── nl.altindag.quarkus.resource
│ │ └── GreetingResource.java
├── console-captor-with-log4j-slf4j18
│ ├── src
│ │ ├── test
│ │ │ ├── resources
│ │ │ │ └── log4j2.xml
│ │ │ └── java
│ │ │ │ └── nl
│ │ │ │ └── altindag
│ │ │ │ └── console
│ │ │ │ └── log4j
│ │ │ │ └── FooServiceShould.java
│ │ └── main
│ │ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── console
│ │ │ └── log4j
│ │ │ └── FooService.java
│ └── pom.xml
└── pom.xml
├── mock-statics-with-mockito
├── src
│ ├── main
│ │ └── java
│ │ │ └── nl
│ │ │ └── altindag
│ │ │ └── mockstatics
│ │ │ ├── Animal.java
│ │ │ ├── Dog.java
│ │ │ └── AnimalUtils.java
│ └── test
│ │ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── mockstatics
│ │ └── AnimalUtilsShould.java
└── pom.xml
├── jvm-rainbow
└── src
│ ├── main
│ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── jvm
│ │ └── rainbow
│ │ ├── GreetingsService.java
│ │ ├── KotlinService.kt
│ │ ├── ScalaService.scala
│ │ ├── GroovyService.groovy
│ │ └── JavaService.java
│ └── test
│ └── java
│ └── nl
│ └── altindag
│ └── jvm
│ └── rainbow
│ ├── ScalaServiceShould.scala
│ ├── KotlinServiceShould.kt
│ ├── JavaServiceShould.java
│ └── GroovyServiceShould.groovy
├── websocket-client-with-ssl
└── pom.xml
└── streaming-json-validation
├── src
├── test
│ └── java
│ │ └── nl
│ │ └── altindag
│ │ └── validation
│ │ └── service
│ │ └── ValidationServiceShould.java
└── main
│ └── java
│ └── nl
│ └── altindag
│ └── validation
│ └── model
│ └── CustomProperties.java
└── pom.xml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [Hakky54]
2 | open_collective: hakky54
3 | ko_fi: hakky54
4 |
--------------------------------------------------------------------------------
/trust-me/images/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/trust-me/images/demo.gif
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/bypassing-overruling-ssl-configuration/src/main/resources/simplelogger.properties:
--------------------------------------------------------------------------------
1 | org.slf4j.simpleLogger.defaultLogLevel=debug
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/images/runner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/elasticsearch-with-ssl/images/runner.png
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker:
--------------------------------------------------------------------------------
1 | mock-maker-inline
2 |
--------------------------------------------------------------------------------
/two-way-object-serialization/images/flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/two-way-object-serialization/images/flow.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea
3 | *.project
4 | *.theia
5 | *.classpath
6 | *.DS_Store
7 |
8 | .settings/
9 | target/
10 | **/dependency-reduced-pom.xml
11 |
--------------------------------------------------------------------------------
/bypassing-overruling-ssl-configuration/images/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/bypassing-overruling-ssl-configuration/images/demo.png
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/elasticsearch-docker/.env:
--------------------------------------------------------------------------------
1 | COMPOSE_PROJECT_NAME=es
2 | CERTS_DIR=/usr/share/elasticsearch/config/certificates
3 | ELASTIC_PASSWORD=PleaseChangeMe
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/images/after-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/images/after-reloading.png
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/images/before-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/images/before-reloading.png
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/server/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-quarkus/images/after-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-quarkus/images/after-reloading.png
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-quarkus/images/before-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-quarkus/images/before-reloading.png
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/server/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-grpc/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-ssl-reloading-with-spring-grpc/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-grpc/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-ssl-reloading-with-spring-grpc/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-ssl-reloading-with-spring-tomcat/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-quarkus/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-quarkus/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-quarkus/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-quarkus/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-ssl-reloading-with-spring-tomcat/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-quarkus-jboss-lombok/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-client/src/main/resources/client/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/grpc-client/src/main/resources/client/identity.jks
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-client/src/main/resources/client/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/grpc-client/src/main/resources/client/truststore.jks
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-server/src/main/resources/server/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/grpc-server/src/main/resources/server/identity.jks
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-server/src/main/resources/server/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/grpc-server/src/main/resources/server/truststore.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-vertx/vertx-server/images/after-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-vertx/vertx-server/images/after-reloading.png
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-vertx/vertx-server/images/before-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-vertx/vertx-server/images/before-reloading.png
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/admin/src/main/resources/keystores/admin/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/admin/src/main/resources/keystores/admin/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-netty/netty-server/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-netty/netty-server/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-vertx/vertx-server/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-vertx/vertx-server/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/admin/src/main/resources/keystores/admin/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/admin/src/main/resources/keystores/admin/truststore.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/admin/src/main/resources/keystores/server/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/admin/src/main/resources/keystores/server/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/admin/src/main/resources/keystores/server/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/admin/src/main/resources/keystores/server/truststore.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/test/resources/keystores/admin/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/server/src/test/resources/keystores/admin/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/test/resources/keystores/admin/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/server/src/test/resources/keystores/admin/truststore.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/test/resources/keystores/server/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/server/src/test/resources/keystores/server/identity.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-netty/netty-server/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-netty/netty-server/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-vertx/vertx-server/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading-with-vertx/vertx-server/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/test/resources/keystores/server/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/instant-server-ssl-reloading/server/src/test/resources/keystores/server/truststore.jks
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | url: jdbc:postgresql://localhost:5432/integration-tests-db?loggerLevel=OFF
4 | username: sa
5 | password: sa
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-cn-validation-with-aop/server-with-cn-validation/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-cn-validation-with-aop/server-with-cn-validation/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/client/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-security-cn-validation-for-reactive-server/client/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/client/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-security-cn-validation-for-reactive-server/client/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/images/after-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/images/after-reloading.png
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/images/before-reloading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/images/before-reloading.png
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/src/main/resources/server/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/src/main/resources/server/identity.jks
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/src/main/resources/server/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/src/main/resources/server/truststore.jks
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/client-for-testing-server-with-cn-validation/src/main/resources/identity.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-cn-validation-with-aop/client-for-testing-server-with-cn-validation/src/main/resources/identity.jks
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/stop-es.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | stopExistingInstances() {
4 | docker-compose down -v
5 | }
6 |
7 | forceCleanUpInstances() {
8 | docker rm -f $(docker ps -a -q)
9 | }
10 |
11 | cd elasticsearch-docker
12 | stopExistingInstances
13 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/client-for-testing-server-with-cn-validation/src/main/resources/truststore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hakky54/java-tutorials/HEAD/spring-cn-validation-with-aop/client-for-testing-server-with-cn-validation/src/main/resources/truststore.jks
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8443
3 |
4 | ssl:
5 | client-auth: true
6 | keystore-path: identity.jks
7 | keystore-password: secret
8 | truststore-path: truststore.jks
9 | truststore-password: secret
10 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8443
3 |
4 | ssl:
5 | client-auth: true
6 | keystore-path: identity.jks
7 | keystore-password: secret
8 | truststore-path: truststore.jks
9 | truststore-password: secret
10 |
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/elasticsearch-docker/instances.yml:
--------------------------------------------------------------------------------
1 | instances:
2 | - name: es01
3 | dns:
4 | - es01
5 | - localhost
6 | ip:
7 | - 127.0.0.1
8 |
9 | - name: es02
10 | dns:
11 | - es02
12 | - localhost
13 | ip:
14 | - 127.0.0.1
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | banner:
3 | location: classpath:banner.txt
4 |
5 | server:
6 | port: 443
7 | ssl:
8 | enabled: true
9 | key-store: classpath:identity.jks
10 | key-password: secret
11 | key-store-password: secret
12 | trust-store: classpath:truststore.jks
13 | trust-store-password: secret
14 | client-auth: need
15 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-grpc/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | ssl:
2 | client-auth: true
3 | keystore-path: identity.jks
4 | keystore-password: secret
5 | truststore-path: truststore.jks
6 | truststore-password: secret
7 |
8 | spring:
9 | grpc:
10 | server:
11 | port: 8443
12 | ssl:
13 | enabled: true
14 | client-auth: require
15 | secure: true
16 | bundle: "reloadable-ssl-bundle"
--------------------------------------------------------------------------------
/console-captor-examples/console-captor-with-quarkus-jboss-lombok/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/common-proto/src/main/resources/proto/hello-service.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | option java_multiple_files = true;
4 | option java_outer_classname = "HelloServiceProto";
5 |
6 | package nl.altindag.grpc;
7 |
8 | service HelloService {
9 | rpc hello(HelloRequest) returns (HelloResponse);
10 | }
11 |
12 | message HelloResponse {
13 | string message = 1;
14 | }
15 |
16 | message HelloRequest {
17 | string name = 1;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | banner:
3 | location: classpath:banner.txt
4 | main:
5 | web-application-type: reactive
6 |
7 | server:
8 | port: 443
9 | ssl:
10 | enabled: true
11 | key-store: classpath:identity.jks
12 | key-password: secret
13 | key-store-password: secret
14 | trust-store: classpath:truststore.jks
15 | trust-store-password: secret
16 | client-auth: need
17 |
--------------------------------------------------------------------------------
/console-captor-examples/console-captor-with-log4j-slf4j18/src/test/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 |
9 | jobs:
10 | build-on-linux-with-jdk-21:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v4
14 |
15 | - name: Set up JDK
16 | uses: actions/setup-java@v4
17 | with:
18 | distribution: 'zulu'
19 | java-version: '21'
20 | cache: 'maven'
21 |
22 | - name: Build and test
23 | run: mvn clean verify --no-transfer-progress
24 |
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/README.md:
--------------------------------------------------------------------------------
1 | # ElasticSearch with SSL 🔐
2 |
3 | #### Requirements
4 | - Java 21
5 | - Terminal
6 | - Docker
7 | - Eclipse or Intellij IDEA
8 |
9 | #### Start ElasticSearch
10 | ```bash
11 | ./start-es.sh
12 | ```
13 |
14 | #### Run the RestHighLevelClient with SSL
15 | Run the main method within [App.class](src/main/java/nl/altindag/ssl/es/App.java)
16 |
17 | 
18 |
19 |
20 | #### Stop ElasticSearch
21 | ```bash
22 | ./stop-es.sh
23 | ```
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/start-es.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | createSslMaterial() {
4 | echo 'Creating ssl material...'
5 | docker-compose -f create-certs.yml run --rm create_certs
6 | }
7 |
8 | startElasticSearchInstances() {
9 | echo 'Booting up ElasticSearch...'
10 | docker-compose up -d
11 | }
12 |
13 | exportCaCertificateOfElasticSearch() {
14 | echo 'Exporting ElasticSearch CA certificate to current directory...'
15 | docker run -v es_certs:/certs --network=es_default docker.elastic.co/elasticsearch/elasticsearch:7.16.3 cat /certs/ca/ca.crt > ca.crt
16 | }
17 |
18 | cd elasticsearch-docker/
19 | createSslMaterial
20 | startElasticSearchInstances
21 | exportCaCertificateOfElasticSearch
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/elasticsearch-docker/create-certs.yml:
--------------------------------------------------------------------------------
1 | version: '2.2'
2 |
3 | services:
4 | create_certs:
5 | container_name: create_certs
6 | image: docker.elastic.co/elasticsearch/elasticsearch:7.16.3
7 | command: >
8 | bash -c '
9 | if [[ ! -f /certs/bundle.zip ]]; then
10 | bin/elasticsearch-certutil cert --silent --pem --in config/certificates/instances.yml -out /certs/bundle.zip;
11 | unzip /certs/bundle.zip -d /certs;
12 | fi;
13 | chown -R 1000:0 /certs
14 | '
15 | user: "0"
16 | working_dir: /usr/share/elasticsearch
17 | volumes: ['certs:/certs', '.:/usr/share/elasticsearch/config/certificates']
18 |
19 | volumes: {"certs"}
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-java-util-logging/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | log-captor-examples-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | log-captor-with-java-util-logging
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | 1. Provide as much of a code sample as possible.
15 | 2. provide full stack traces if possible
16 |
17 | **Expected behavior**
18 | A clear and concise description of what you expected to happen.
19 |
20 | **Screenshots**
21 | If applicable, add screenshots to help explain your problem.
22 |
23 | **Environmental Data:**
24 | - Java Version
25 | - Maven Version
26 | - OS (Windows/Linux/MacOS)
27 |
28 | **Additional context**
29 | Add any other context about the problem here.
30 |
--------------------------------------------------------------------------------
/mock-statics-with-mockito/src/main/java/nl/altindag/mockstatics/Animal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.mockstatics;
17 |
18 | public interface Animal {
19 |
20 | String getName();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/jvm-rainbow/src/main/java/nl/altindag/jvm/rainbow/GreetingsService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow;
17 |
18 | public interface GreetingsService {
19 |
20 | String hello();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/jvm-rainbow/src/main/java/nl/altindag/jvm/rainbow/KotlinService.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow
17 |
18 | class KotlinService : GreetingsService {
19 |
20 | override fun hello(): String = "Greetings from Kotlin!"
21 |
22 | }
--------------------------------------------------------------------------------
/jvm-rainbow/src/main/java/nl/altindag/jvm/rainbow/ScalaService.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow
17 |
18 | class ScalaService extends GreetingsService {
19 |
20 | override def hello(): String = "Greetings from Scala!"
21 |
22 | }
--------------------------------------------------------------------------------
/trust-me/src/main/java/nl/altindag/ssl/trustme/AppStarter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl.trustme;
17 |
18 | public class AppStarter {
19 |
20 | public static void main(String[] args) {
21 | App.main(args);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/jvm-rainbow/src/main/java/nl/altindag/jvm/rainbow/GroovyService.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow;
17 |
18 | class GroovyService implements GreetingsService {
19 |
20 | @Override
21 | String hello() {
22 | "Greetings from Groovy!"
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/jvm-rainbow/src/main/java/nl/altindag/jvm/rainbow/JavaService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow;
17 |
18 | public class JavaService implements GreetingsService {
19 |
20 | @Override
21 | public String hello() {
22 | return "Greetings from Java!";
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/trust-me/src/main/java/nl/altindag/ssl/trustme/exception/PingException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl.trustme.exception;
17 |
18 | public class PingException extends TrustMeException {
19 |
20 | public PingException(Throwable cause) {
21 | super(cause);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/trust-me/src/main/java/nl/altindag/ssl/trustme/exception/TrustMeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl.trustme.exception;
17 |
18 | public class TrustMeException extends RuntimeException {
19 |
20 | public TrustMeException(Throwable cause) {
21 | super(cause);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/two-way-object-serialization/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | java-tutorials
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | two-way-object-serialization
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-web
21 | ${version.spring}
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-jboss-and-lombok/src/main/java/nl.altindag.jboss/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jboss;
17 |
18 | import lombok.extern.jbosslog.JBossLog;
19 |
20 | @JBossLog
21 | public class FooService {
22 |
23 | public void hello() {
24 | log.info("Hello there friend!");
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-log4j-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | log-captor-examples-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | log-captor-with-log4j-api
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.apache.logging.log4j
20 | log4j-api
21 | ${version.log4j}
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-log4j-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | log-captor-examples-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | log-captor-with-log4j-core
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.apache.logging.log4j
20 | log4j-core
21 | ${version.log4j}
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/java/nl/altindag/server/model/SSLUpdateRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.model;
17 |
18 | public record SSLUpdateRequest(
19 |
20 | byte[] keyStore,
21 | char[] keyStorePassword,
22 | byte[] trustStore,
23 | char[] trustStorePassword
24 |
25 | ) {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/admin/src/main/java/nl/altindag/admin/model/SSLUpdateRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.admin.model;
17 |
18 | public record SSLUpdateRequest(
19 |
20 | byte[] keyStore,
21 | char[] keyStorePassword,
22 | byte[] trustStore,
23 | char[] trustStorePassword
24 |
25 | ) {
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-slf4j-logback-classic/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | log-captor-examples-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | log-captor-with-slf4j-logback-classic
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | ch.qos.logback
20 | logback-classic
21 | ${version.logback-classic}
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/mock-statics-with-mockito/src/main/java/nl/altindag/mockstatics/Dog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.mockstatics;
17 |
18 | public class Dog implements Animal {
19 |
20 | private final String name;
21 |
22 | public Dog(String name) {
23 | this.name = name;
24 | }
25 |
26 | @Override
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/console-captor-examples/console-captor-with-log4j-slf4j18/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | console-captor-examples-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | console-captor-with-log4j-slf4j18
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.apache.logging.log4j
20 | log4j-slf4j18-impl
21 | ${version.log4j-log4j-slf4j18}
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/jvm-rainbow/src/test/java/nl/altindag/jvm/rainbow/ScalaServiceShould.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow
17 |
18 | import org.scalatest.funspec.AnyFunSpec
19 |
20 | class ScalaServiceShould extends AnyFunSpec {
21 |
22 | describe("say hello") {
23 | val service = new ScalaService()
24 | val message = service.hello()
25 | assert(message == "Greetings from Scala!")
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-java-util-logging/src/main/java/nl/altindag/jul/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jul;
17 |
18 | import java.util.logging.Logger;
19 |
20 | public class FooService {
21 |
22 | private static final Logger LOGGER = Logger.getLogger(FooService.class.getName());
23 |
24 | public void hello() {
25 | LOGGER.info("Hello there friend!");
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-flogger/src/main/java/nl/altindag/flogger/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.flogger;
17 |
18 | import com.google.common.flogger.FluentLogger;
19 |
20 | public class FooService {
21 |
22 | private static final FluentLogger logger = FluentLogger.forEnclosingClass();
23 | public void hello() {
24 | logger.atInfo().log("Hello there friend!");
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/two-way-object-serialization/src/main/java/nl/altindag/server/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 |
21 | @SpringBootApplication
22 | public class App {
23 |
24 | public static void main(String[] args) {
25 | SpringApplication.run(App.class, args);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-slf4j-log4j/src/main/java/nl/altindag/log4j/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.log4j;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 |
21 | public class FooService {
22 |
23 | private static final Logger LOGGER = LoggerFactory.getLogger(FooService.class);
24 |
25 | public void hello() {
26 | LOGGER.info("Hello there friend!");
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/main/java/nl/altindag/server/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 |
21 | @SpringBootApplication
22 | public class App {
23 |
24 | public static void main(String[] args) {
25 | SpringApplication.run(App.class);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-slf4j-logback-classic/src/main/java/nl/altindag/logback/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.logback;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 |
21 | public class FooService {
22 |
23 | private static final Logger LOGGER = LoggerFactory.getLogger(FooService.class);
24 |
25 | public void hello() {
26 | LOGGER.info("Hello there friend!");
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | spring-security-cn-validation-for-reactive-server-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | client
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | io.github.hakky54
20 | ayza
21 |
22 |
23 | org.slf4j
24 | slf4j-simple
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/main/java/nl/altindag/server/repository/SSLMaterialRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.repository;
17 |
18 | import nl.altindag.server.model.SSLMaterial;
19 | import org.springframework.data.jpa.repository.JpaRepository;
20 | import org.springframework.stereotype.Repository;
21 |
22 | @Repository
23 | public interface SSLMaterialRepository extends JpaRepository {
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/jvm-rainbow/src/test/java/nl/altindag/jvm/rainbow/KotlinServiceShould.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow
17 |
18 | import org.assertj.core.api.Assertions.assertThat
19 | import org.junit.jupiter.api.Test
20 |
21 | class KotlinServiceShould {
22 |
23 | @Test
24 | fun sayHello() {
25 | val service = KotlinService()
26 | val message = service.hello()
27 | assertThat(message).isEqualTo("Greetings from Kotlin!")
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-log4j-api/src/main/java/nl/altindag/log4j/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.log4j;
17 |
18 | import org.apache.logging.log4j.LogManager;
19 | import org.apache.logging.log4j.Logger;
20 |
21 | public class FooService {
22 |
23 | private static final Logger LOGGER = LogManager.getLogger(FooService.class);
24 |
25 | public void hello() {
26 | LOGGER.info("Hello there friend!");
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-log4j-core/src/main/java/nl/altindag/log4j/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.log4j;
17 |
18 | import org.apache.logging.log4j.LogManager;
19 | import org.apache.logging.log4j.Logger;
20 |
21 | public class FooService {
22 |
23 | private static final Logger LOGGER = LogManager.getLogger(FooService.class);
24 |
25 | public void hello() {
26 | LOGGER.info("Hello there friend!");
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/client-for-testing-server-with-cn-validation/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-cn-validation-with-aop
7 | io.github.hakky54
8 | 1.0.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | client-for-testing-server-with-cn-validation
13 | 1.0.0-SNAPSHOT
14 | jar
15 |
16 |
17 |
18 | io.github.hakky54
19 | ayza
20 |
21 |
22 | org.slf4j
23 | slf4j-simple
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/jvm-rainbow/src/test/java/nl/altindag/jvm/rainbow/JavaServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow;
17 |
18 | import org.junit.jupiter.api.Test;
19 |
20 | import static org.assertj.core.api.Assertions.assertThat;
21 |
22 | class JavaServiceShould {
23 |
24 | @Test
25 | void sayHello() {
26 | var service = new JavaService();
27 | String message = service.hello();
28 | assertThat(message).isEqualTo("Greetings from Java!");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-spring-boot-starter-log4j2/src/main/java/nl/altindag/spring/log4j2/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.spring.log4j2;
17 |
18 | import org.apache.logging.log4j.LogManager;
19 | import org.apache.logging.log4j.Logger;
20 |
21 | public class FooService {
22 |
23 | private static final Logger LOGGER = LogManager.getLogger(FooService.class);
24 |
25 | public void hello() {
26 | LOGGER.info("Hello there friend!");
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/jvm-rainbow/src/test/java/nl/altindag/jvm/rainbow/GroovyServiceShould.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jvm.rainbow
17 |
18 | import groovy.test.GroovyTestCase
19 |
20 | import static org.assertj.core.api.Assertions.assertThat
21 |
22 | class GroovyServiceShould extends GroovyTestCase {
23 |
24 | void testSayHello() {
25 | def service = new GroovyService()
26 | def message = service.hello()
27 | assertThat(message).isEqualTo("Greetings from Groovy!")
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-quarkus/src/main/java/nl/altindag/server/resource/GreetingResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.resource;
17 |
18 | import jakarta.ws.rs.GET;
19 | import jakarta.ws.rs.Path;
20 | import jakarta.ws.rs.Produces;
21 | import jakarta.ws.rs.core.MediaType;
22 |
23 | @Path("/hello")
24 | public class GreetingResource {
25 |
26 | @GET
27 | @Produces(MediaType.TEXT_PLAIN)
28 | public String hello() {
29 | return "Hello World!";
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/java/nl/altindag/server/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 | import org.springframework.scheduling.annotation.EnableScheduling;
21 |
22 | @EnableScheduling
23 | @SpringBootApplication
24 | public class App {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(App.class, args);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/mock-statics-with-mockito/src/main/java/nl/altindag/mockstatics/AnimalUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.mockstatics;
17 |
18 | public class AnimalUtils {
19 |
20 | private AnimalUtils() {
21 | }
22 |
23 | public static Dog getGermanShepherd() {
24 | return new Dog("german shepherd");
25 | }
26 |
27 | public static Dog getKangal() {
28 | return new Dog("kangal");
29 | }
30 |
31 | public static Animal getAnimal() {
32 | return getGermanShepherd();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-grpc/src/main/java/nl/altindag/server/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 | import org.springframework.scheduling.annotation.EnableScheduling;
21 |
22 | @EnableScheduling
23 | @SpringBootApplication
24 | public class App {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(App.class, args);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/src/main/java/nl/altindag/server/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 | import org.springframework.scheduling.annotation.EnableScheduling;
21 |
22 | @EnableScheduling
23 | @SpringBootApplication
24 | public class App {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(App.class, args);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/main/java/nl/altindag/server/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 | import org.springframework.scheduling.annotation.EnableScheduling;
21 |
22 | @EnableScheduling
23 | @SpringBootApplication
24 | public class App {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(App.class, args);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/console-captor-examples/console-captor-with-log4j-slf4j18/src/main/java/nl/altindag/console/log4j/FooService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.console.log4j;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 |
21 | public class FooService {
22 |
23 | private static final Logger LOGGER = LoggerFactory.getLogger(FooService.class);
24 |
25 | public void hello() {
26 | LOGGER.info("Hello there friend!");
27 | }
28 |
29 | public static void main(String[] args) {
30 | new FooService().hello();
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-jboss-and-lombok/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | io.github.hakky54
9 | log-captor-examples-parent
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | log-captor-with-jboss-and-lombok
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.projectlombok
20 | lombok
21 | ${version.lombok}
22 |
23 |
24 | org.jboss.logging
25 | jboss-logging
26 | ${version.jboss-logging}
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/java/nl/altindag/server/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import org.springframework.boot.SpringApplication;
19 | import org.springframework.boot.autoconfigure.SpringBootApplication;
20 | import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
21 |
22 | @EnableWebFluxSecurity
23 | @SpringBootApplication
24 | public class App {
25 |
26 | public static void main(String[] args) {
27 | SpringApplication.run(App.class);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-flogger/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.github.hakky54
8 | log-captor-examples-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | log-captor-with-flogger
13 | 1.0.0-SNAPSHOT
14 | jar
15 |
16 |
17 |
18 | com.google.flogger
19 | flogger
20 | ${version.flogger}
21 |
22 |
23 |
24 | com.google.flogger
25 | flogger-slf4j-backend
26 | ${version.flogger}
27 | test
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/main/java/nl/altindag/server/aspect/AdditionalCertificateValidations.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.aspect;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target(ElementType.METHOD)
25 | public @interface AdditionalCertificateValidations {
26 |
27 | String[] allowedCommonNames() default {};
28 | String[] notAllowedCommonNames() default {};
29 |
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/java/nl/altindag/server/controller/HelloWorldController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.controller;
17 |
18 | import org.springframework.http.MediaType;
19 | import org.springframework.http.ResponseEntity;
20 | import org.springframework.stereotype.Controller;
21 | import org.springframework.web.bind.annotation.GetMapping;
22 |
23 | @Controller
24 | public class HelloWorldController {
25 |
26 | @GetMapping(value = "/api/hello", produces = MediaType.TEXT_PLAIN_VALUE)
27 | public ResponseEntity hello() {
28 | return ResponseEntity.ok("Hello");
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/src/main/java/nl/altindag/server/controller/HelloWorldController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.controller;
17 |
18 | import org.springframework.http.MediaType;
19 | import org.springframework.http.ResponseEntity;
20 | import org.springframework.stereotype.Controller;
21 | import org.springframework.web.bind.annotation.GetMapping;
22 |
23 | @Controller
24 | public class HelloWorldController {
25 |
26 | @GetMapping(value = "/api/hello", produces = MediaType.TEXT_PLAIN_VALUE)
27 | public ResponseEntity hello() {
28 | return ResponseEntity.ok("Hello");
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/main/java/nl/altindag/server/controller/HelloWorldController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.controller;
17 |
18 | import org.springframework.http.MediaType;
19 | import org.springframework.http.ResponseEntity;
20 | import org.springframework.stereotype.Controller;
21 | import org.springframework.web.bind.annotation.GetMapping;
22 |
23 | @Controller
24 | public class HelloWorldController {
25 |
26 | @GetMapping(value = "/api/hello", produces = MediaType.TEXT_PLAIN_VALUE)
27 | public ResponseEntity hello() {
28 | return ResponseEntity.ok("Hello");
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-quarkus-jboss-lombok/src/main/java/nl/altindag/quarkus/resource/GreetingResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.quarkus.resource;
17 |
18 | import lombok.extern.jbosslog.JBossLog;
19 |
20 | import jakarta.ws.rs.GET;
21 | import jakarta.ws.rs.Path;
22 | import jakarta.ws.rs.Produces;
23 | import jakarta.ws.rs.core.MediaType;
24 |
25 | @JBossLog
26 | @Path("/hello")
27 | public class GreetingResource {
28 |
29 | @GET
30 | @Produces(MediaType.TEXT_PLAIN)
31 | public String hello() {
32 | log.info("Saying hello from the logger!");
33 | return "Hello from RESTEasy Reactive";
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/console-captor-examples/console-captor-with-quarkus-jboss-lombok/src/main/java/nl.altindag.quarkus.resource/GreetingResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.quarkus.resource;
17 |
18 | import lombok.extern.jbosslog.JBossLog;
19 |
20 | import jakarta.ws.rs.GET;
21 | import jakarta.ws.rs.Path;
22 | import jakarta.ws.rs.Produces;
23 | import jakarta.ws.rs.core.MediaType;
24 |
25 | @JBossLog
26 | @Path("/hello")
27 | public class GreetingResource {
28 |
29 | @GET
30 | @Produces(MediaType.TEXT_PLAIN)
31 | public String hello() {
32 | log.info("Saying hello from the logger!");
33 | return "Hello from RESTEasy Reactive";
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/java/nl/altindag/server/controller/HelloWorldController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.controller;
17 |
18 | import org.springframework.http.MediaType;
19 | import org.springframework.web.bind.annotation.GetMapping;
20 | import org.springframework.web.bind.annotation.RestController;
21 | import reactor.core.publisher.Flux;
22 |
23 | @RestController
24 | public class HelloWorldController {
25 |
26 | @GetMapping(value = "/hello", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
27 | public Flux hello() {
28 | return Flux.just("Hello");
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/trust-me/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | # ________ __ __ __
2 | # | | \ | \ | \
3 | # \$$$$$$$| $$____ __ __ _______ ____| $$ ______ ______ | $$____ ______ ______ ______ __ __
4 | # | $$ | $$ \| \ | | \ / $$/ \ / \| $$ \ / \ / \ / \| \ | \
5 | # | $$ | $$$$$$$| $$ | $| $$$$$$$| $$$$$$| $$$$$$| $$$$$$| $$$$$$$| $$$$$$| $$$$$$| $$$$$$| $$ | $$
6 | # | $$ | $$ | $| $$ | $| $$ | $| $$ | $| $$ $| $$ \$| $$ | $| $$ $| $$ \$| $$ \$| $$ | $$
7 | # | $$ | $$ | $| $$__/ $| $$ | $| $$__| $| $$$$$$$| $$ | $$__/ $| $$$$$$$| $$ | $$ | $$__/ $$
8 | # | $$ | $$ | $$\$$ $| $$ | $$\$$ $$\$$ | $$ | $$ $$\$$ | $$ | $$ \$$ $$
9 | # \$$ \$$ \$$ \$$$$$$ \$$ \$$ \$$$$$$$ \$$$$$$$\$$ \$$$$$$$ \$$$$$$$\$$ \$$ _\$$$$$$$
10 | # | \__| $$
11 | # \$$ $$
12 | # http://thunderberry.nl/ \$$$$$$
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-quarkus-jboss-lombok/src/test/java/nl/altindag/quarkus/resource/GreetingsResourceWithoutQuarkusTestShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.quarkus.resource;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.assertj.core.api.Assertions;
20 | import org.junit.jupiter.api.Test;
21 |
22 | public class GreetingsResourceWithoutQuarkusTestShould {
23 |
24 | @Test
25 | void sayHello() {
26 | LogCaptor logCaptor = LogCaptor.forClass(GreetingResource.class);
27 |
28 | new GreetingResource().hello();
29 |
30 | Assertions.assertThat(logCaptor.getLogs()).contains("Saying hello from the logger!");
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-flogger/src/test/java/nl/altindag/flogger/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.flogger;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-java-util-logging/src/test/java/nl/altindag/jul/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jul;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-log4j-api/src/test/java/nl/altindag/log4j/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.log4j;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-log4j-core/src/test/java/nl/altindag/log4j/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.log4j;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-slf4j-log4j/src/test/java/nl/altindag/log4j/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.log4j;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-jboss-and-lombok/src/test/java/nl/altindag/jboss/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.jboss;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-slf4j-logback-classic/src/test/java/nl/altindag/logback/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.logback;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-spring-boot-starter-log4j2/src/test/java/nl/altindag/spring/log4j2/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.spring.log4j2;
17 |
18 | import nl.altindag.log.LogCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(logCaptor.getLogs())
33 | .hasSize(1)
34 | .contains("Hello there friend!");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | spring-security-cn-validation-for-reactive-server-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | spring-reactive-server
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-web
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-security
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-webflux
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | # ________ __ __ __
2 | # | | \ | \ | \
3 | # \$$$$$$$| $$____ __ __ _______ ____| $$ ______ ______ | $$____ ______ ______ ______ __ __
4 | # | $$ | $$ \| \ | | \ / $$/ \ / \| $$ \ / \ / \ / \| \ | \
5 | # | $$ | $$$$$$$| $$ | $| $$$$$$$| $$$$$$| $$$$$$| $$$$$$| $$$$$$$| $$$$$$| $$$$$$| $$$$$$| $$ | $$
6 | # | $$ | $$ | $| $$ | $| $$ | $| $$ | $| $$ $| $$ \$| $$ | $| $$ $| $$ \$| $$ \$| $$ | $$
7 | # | $$ | $$ | $| $$__/ $| $$ | $| $$__| $| $$$$$$$| $$ | $$__/ $| $$$$$$$| $$ | $$ | $$__/ $$
8 | # | $$ | $$ | $$\$$ $| $$ | $$\$$ $$\$$ | $$ | $$ $$\$$ | $$ | $$ \$$ $$
9 | # \$$ \$$ \$$ \$$$$$$ \$$ \$$ \$$$$$$$ \$$$$$$$\$$ \$$$$$$$ \$$$$$$$\$$ \$$ _\$$$$$$$
10 | # | \__| $$
11 | # \$$ $$
12 | # http://thunderberry.nl/ \$$$$$$
13 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | # ________ __ __ __
2 | # | | \ | \ | \
3 | # \$$$$$$$| $$____ __ __ _______ ____| $$ ______ ______ | $$____ ______ ______ ______ __ __
4 | # | $$ | $$ \| \ | | \ / $$/ \ / \| $$ \ / \ / \ / \| \ | \
5 | # | $$ | $$$$$$$| $$ | $| $$$$$$$| $$$$$$| $$$$$$| $$$$$$| $$$$$$$| $$$$$$| $$$$$$| $$$$$$| $$ | $$
6 | # | $$ | $$ | $| $$ | $| $$ | $| $$ | $| $$ $| $$ \$| $$ | $| $$ $| $$ \$| $$ \$| $$ | $$
7 | # | $$ | $$ | $| $$__/ $| $$ | $| $$__| $| $$$$$$$| $$ | $$__/ $| $$$$$$$| $$ | $$ | $$__/ $$
8 | # | $$ | $$ | $$\$$ $| $$ | $$\$$ $$\$$ | $$ | $$ $$\$$ | $$ | $$ \$$ $$
9 | # \$$ \$$ \$$ \$$$$$$ \$$ \$$ \$$$$$$$ \$$$$$$$\$$ \$$$$$$$ \$$$$$$$\$$ \$$ _\$$$$$$$
10 | # | \__| $$
11 | # \$$ $$
12 | # http://thunderberry.nl/ \$$$$$$
13 |
--------------------------------------------------------------------------------
/websocket-client-with-ssl/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | java-tutorials
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | websocket-client-with-ssl
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.eclipse.jetty.websocket
20 | websocket-client
21 | ${version.websocket-client}
22 |
23 |
24 | io.github.hakky54
25 | ayza-for-jetty
26 | ${version.ayza}
27 |
28 |
29 | org.slf4j
30 | slf4j-simple
31 | ${version.slf4j}
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/console-captor-examples/console-captor-with-log4j-slf4j18/src/test/java/nl/altindag/console/log4j/FooServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.console.log4j;
17 |
18 | import nl.altindag.console.ConsoleCaptor;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | class FooServiceShould {
24 |
25 | @Test
26 | void sayHello() {
27 | ConsoleCaptor consoleCaptor = new ConsoleCaptor();
28 |
29 | FooService fooService = new FooService();
30 | fooService.hello();
31 |
32 | assertThat(consoleCaptor.getStandardOutput()).hasSize(1);
33 | assertThat(consoleCaptor.getStandardOutput().get(0)).contains("Hello there friend!");
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/trust-me/README.md:
--------------------------------------------------------------------------------
1 | # Trust Me 🔐
2 | A proof-of-concept GUI for prompting an user when a certificate is not trusted yet. The ssl configuration will be reloaded during runtime.
3 |
4 | This GUI app demonstrates the feature of [Trusting additional new certificates at runtime](https://github.com/Hakky54/ayza?tab=readme-ov-file#trust-additional-new-certificates-at-runtime) from the library [ayza](https://github.com/Hakky54/ayza)
5 | It might occur that your truststore has outdated certificates and is not easy to maintain or it just calls servers which has recently updated their certificates.
6 | This option demonstrates how to integrate it in your GUI app, and it will prompt when the certificate is not trusted yet, which gives the option to the end-user to either trust or reject it.
7 |
8 | ## Demo
9 | 
10 |
11 | ## Running locally
12 |
13 | ### Minimum requirements
14 | - JDK 21
15 | - Maven
16 | - Terminal
17 |
18 | Although this project requires JDK 21, the [library](https://github.com/Hakky54/ayza) itself is compatible with JDK 8 and therefor will work with that version.
19 |
20 | Run the following commands in your terminal:
21 |
22 | ```bash
23 | mvn clean package
24 | mvn spring-boot:run
25 | ```
26 |
27 | ## Contributing
28 |
29 | There are plenty of ways to contribute to this project:
30 |
31 | * Give it a star
32 | * Submit a PR
33 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | grpc-client-server-with-ssl-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | grpc-server
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | io.grpc
20 | grpc-netty
21 |
22 |
23 |
24 | io.github.hakky54
25 | common-proto
26 | 1.0.0-SNAPSHOT
27 |
28 |
29 |
30 | io.github.hakky54
31 | ayza-for-netty
32 |
33 |
34 |
35 | org.slf4j
36 | slf4j-simple
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/src/main/java/nl/altindag/server/config/ServerConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
19 | import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
20 | import org.springframework.context.annotation.Bean;
21 | import org.springframework.context.annotation.Configuration;
22 |
23 | @Configuration
24 | public class ServerConfig {
25 |
26 | @Bean
27 | public ServletWebServerFactory servletContainer(SSLConnectorCustomizer sslConnectorCustomizer) {
28 | TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
29 | tomcat.addConnectorCustomizers(sslConnectorCustomizer);
30 | return tomcat;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-server/src/main/java/nl/altindag/grpc/server/service/HelloServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.grpc.server.service;
17 |
18 | import io.grpc.stub.StreamObserver;
19 | import nl.altindag.grpc.HelloRequest;
20 | import nl.altindag.grpc.HelloResponse;
21 | import nl.altindag.grpc.HelloServiceGrpc;
22 |
23 | public class HelloServiceImpl extends HelloServiceGrpc.HelloServiceImplBase {
24 |
25 | @Override
26 | public void hello(HelloRequest request, StreamObserver responseObserver) {
27 | HelloResponse response = HelloResponse.newBuilder()
28 | .setMessage(String.format("Hello %s, nice to meet you!", request.getName()))
29 | .build();
30 |
31 | responseObserver.onNext(response);
32 | responseObserver.onCompleted();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/src/main/java/nl/altindag/server/controller/HelloWorldController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.controller;
17 |
18 | import nl.altindag.server.aspect.AdditionalCertificateValidations;
19 | import org.springframework.http.MediaType;
20 | import org.springframework.http.ResponseEntity;
21 | import org.springframework.web.bind.annotation.GetMapping;
22 | import org.springframework.web.bind.annotation.RestController;
23 |
24 | @RestController
25 | public class HelloWorldController {
26 |
27 | @AdditionalCertificateValidations(allowedCommonNames = {"black-hole"}, notAllowedCommonNames = {})
28 | @GetMapping(value = "/hello", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
29 | public ResponseEntity hello() {
30 | return ResponseEntity.ok("Hello");
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/src/main/java/nl/altindag/grpc/server/service/HelloServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.grpc.server.service;
17 |
18 | import io.grpc.stub.StreamObserver;
19 | import nl.altindag.grpc.HelloRequest;
20 | import nl.altindag.grpc.HelloResponse;
21 | import nl.altindag.grpc.HelloServiceGrpc;
22 |
23 | public class HelloServiceImpl extends HelloServiceGrpc.HelloServiceImplBase {
24 |
25 | @Override
26 | public void hello(HelloRequest request, StreamObserver responseObserver) {
27 | HelloResponse response = HelloResponse.newBuilder()
28 | .setMessage(String.format("Hello %s, nice to meet you!", request.getName()))
29 | .build();
30 |
31 | responseObserver.onNext(response);
32 | responseObserver.onCompleted();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-vertx/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.github.hakky54
8 | java-tutorials
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | instant-server-ssl-reloading-with-vertx
13 | pom
14 |
15 |
16 | vertx-server
17 |
18 |
19 |
20 |
21 |
22 | io.vertx
23 | vertx-web
24 | ${version.vertx}
25 |
26 |
27 | io.github.hakky54
28 | ayza
29 | ${version.ayza}
30 |
31 |
32 | org.slf4j
33 | slf4j-simple
34 | ${version.slf4j}
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-netty/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | netty-server
8 |
9 |
10 |
11 | java-tutorials
12 | io.github.hakky54
13 | 1.0.0-SNAPSHOT
14 |
15 |
16 | instant-server-ssl-reloading-with-netty
17 | pom
18 |
19 |
20 |
21 |
22 | io.netty
23 | netty-all
24 | ${version.netty}
25 |
26 |
27 | io.github.hakky54
28 | ayza-for-netty
29 | ${version.ayza}
30 |
31 |
32 | org.slf4j
33 | slf4j-simple
34 | ${version.slf4j}
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-grpc/src/main/java/nl/altindag/server/service/GrpcServerService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.service;
17 |
18 | import io.grpc.stub.StreamObserver;
19 | import nl.altindag.grpc.HelloRequest;
20 | import nl.altindag.grpc.HelloResponse;
21 | import nl.altindag.grpc.HelloServiceGrpc;
22 | import org.springframework.stereotype.Service;
23 |
24 | @Service
25 | public class GrpcServerService extends HelloServiceGrpc.HelloServiceImplBase {
26 |
27 | @Override
28 | public void hello(HelloRequest request, StreamObserver responseObserver) {
29 | HelloResponse response = HelloResponse.newBuilder()
30 | .setMessage(String.format("Hello %s, nice to meet you!", request.getName()))
31 | .build();
32 |
33 | responseObserver.onNext(response);
34 | responseObserver.onCompleted();
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-grpc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | io.github.hakky54
9 | java-tutorials
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | instant-ssl-reloading-with-spring-grpc
14 | 1.0.0-SNAPSHOT
15 |
16 |
17 |
18 | io.github.hakky54
19 | ayza-for-netty
20 | ${version.ayza}
21 |
22 |
23 | io.grpc
24 | grpc-services
25 | ${version.grpc}
26 |
27 |
28 | org.springframework.grpc
29 | spring-grpc-spring-boot-starter
30 | ${version.spring-grpc-spring-boot-starter}
31 |
32 |
33 | io.github.hakky54
34 | common-proto
35 | 1.0.0-SNAPSHOT
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/main/java/nl/altindag/server/config/SSLConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import nl.altindag.ssl.SSLFactory;
19 | import nl.altindag.ssl.jetty.util.JettySslUtils;
20 | import org.eclipse.jetty.util.ssl.SslContextFactory;
21 | import org.springframework.context.annotation.Bean;
22 | import org.springframework.context.annotation.Configuration;
23 |
24 | @Configuration
25 | public class SSLConfig {
26 |
27 | @Bean
28 | public SSLFactory sslFactory() {
29 | return SSLFactory.builder()
30 | .withDummyIdentityMaterial()
31 | .withDummyTrustMaterial()
32 | .withSwappableIdentityMaterial()
33 | .withSwappableTrustMaterial()
34 | .build();
35 | }
36 |
37 | @Bean
38 | public SslContextFactory.Server sslContextFactory(SSLFactory sslFactory) {
39 | return JettySslUtils.forServer(sslFactory);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-slf4j-log4j/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | log-captor-examples-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | log-captor-with-slf4j-log4j
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.apache.logging.log4j
20 | log4j-slf4j2-impl
21 | ${version.log4j-slf4j}
22 |
23 |
24 |
25 |
26 |
27 |
28 | org.apache.maven.plugins
29 | maven-surefire-plugin
30 | ${version.maven-surefire-plugin}
31 |
32 |
33 | org.apache.logging.log4j:log4j-slf4j2-impl
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-netty/netty-server/src/main/java/nl/altindag/server/config/ServerInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import io.netty.channel.Channel;
19 | import io.netty.channel.ChannelInitializer;
20 | import io.netty.handler.codec.http.HttpServerCodec;
21 | import io.netty.handler.ssl.SslContext;
22 | import io.netty.handler.ssl.SslHandler;
23 | import nl.altindag.server.handler.ServerHandler;
24 |
25 |
26 | public class ServerInitializer extends ChannelInitializer {
27 |
28 | private final SslContext sslContext;
29 |
30 | public ServerInitializer(SslContext sslContext) {
31 | this.sslContext = sslContext;
32 | }
33 |
34 | @Override
35 | protected void initChannel(Channel channel) {
36 | channel.pipeline()
37 | .addFirst("ssl", new SslHandler(sslContext.newEngine(channel.alloc())))
38 | .addLast(new HttpServerCodec())
39 | .addLast(new ServerHandler());
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-spring-boot-starter-log4j2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | log-captor-examples-parent
7 | io.github.hakky54
8 | 1.0.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | log-captor-with-spring-boot-starter-log4j2
13 | 1.0.0-SNAPSHOT
14 | jar
15 |
16 |
17 |
18 | org.springframework.boot
19 | spring-boot-starter-log4j2
20 | ${version.spring}
21 |
22 |
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-surefire-plugin
29 | ${version.maven-surefire-plugin}
30 |
31 |
32 | org.apache.logging.log4j:log4j-slf4j2-impl
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/trust-me/src/main/java/nl/altindag/ssl/trustme/util/Logger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl.trustme.util;
17 |
18 | import javafx.application.Platform;
19 | import javafx.beans.property.SimpleStringProperty;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 |
24 | public class Logger {
25 |
26 | private static final String LINE_BREAK = "\n";
27 |
28 | private Logger() {}
29 |
30 | private static List logMessages = new ArrayList<>();
31 | private static SimpleStringProperty logContainer = new SimpleStringProperty("");
32 |
33 | public static synchronized void log(String logMessage) {
34 | Platform.runLater(() -> {
35 | if (!logMessages.isEmpty() && logMessages.get(logMessages.size() - 1).contains(logMessage)) {
36 | return;
37 | }
38 |
39 | logMessages.add(logMessage);
40 | logContainer.setValue(logContainer.getValue() + logMessage + LINE_BREAK);
41 | });
42 | }
43 |
44 | public static SimpleStringProperty logContainerProperty() {
45 | return logContainer;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/mock-statics-with-mockito/src/test/java/nl/altindag/mockstatics/AnimalUtilsShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.mockstatics;
17 |
18 | import org.junit.jupiter.api.Test;
19 | import org.mockito.MockedStatic;
20 | import org.mockito.Mockito;
21 |
22 | import java.lang.reflect.Method;
23 |
24 | import static org.assertj.core.api.Assertions.assertThat;
25 |
26 | class AnimalUtilsShould {
27 |
28 | @Test
29 | void animalUtilsTest() {
30 | Animal kangal = AnimalUtils.getKangal();
31 | try (MockedStatic mockedAnimalUtils = Mockito.mockStatic(AnimalUtils.class, invocation -> {
32 | Method method = invocation.getMethod();
33 | if ("getAnimal".equals(method.getName())) {
34 | return invocation.callRealMethod();
35 | } else if ("getGermanShepherd".equals(method.getName())) {
36 | return kangal;
37 | } else {
38 | return invocation.getMock();
39 | }
40 | })) {
41 | Animal animal = AnimalUtils.getAnimal();
42 | assertThat(animal.getName()).isEqualTo("kangal");
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/trust-me/src/main/java/nl/altindag/ssl/trustme/service/PingService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl.trustme.service;
17 |
18 | import nl.altindag.ssl.trustme.exception.PingException;
19 | import org.springframework.stereotype.Service;
20 |
21 | import java.io.IOException;
22 | import java.net.URI;
23 | import java.net.http.HttpClient;
24 | import java.net.http.HttpRequest;
25 | import java.net.http.HttpResponse;
26 | import java.time.Duration;
27 |
28 | @Service
29 | public class PingService {
30 |
31 | private final HttpClient httpClient;
32 |
33 | public PingService(HttpClient httpClient) {
34 | this.httpClient = httpClient;
35 | }
36 |
37 | public void ping(String url) {
38 | HttpRequest request = HttpRequest.newBuilder()
39 | .GET()
40 | .timeout(Duration.ofMinutes(1))
41 | .uri(URI.create(url))
42 | .build();
43 |
44 | try {
45 | httpClient.send(request, HttpResponse.BodyHandlers.discarding());
46 | } catch (IOException | InterruptedException e) {
47 | throw new PingException(e);
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/elasticsearch-with-ssl/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | java-tutorials
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | elasticsearch-with-ssl
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | co.elastic.clients
20 | elasticsearch-java
21 | ${version.elasticsearch}
22 |
23 |
24 | com.fasterxml.jackson.core
25 | jackson-databind
26 | ${version.jackson}
27 |
28 |
29 |
30 | io.github.hakky54
31 | ayza
32 | ${version.ayza}
33 |
34 |
35 |
36 | org.slf4j
37 | slf4j-simple
38 | ${version.slf4j}
39 |
40 |
41 | org.apache.logging.log4j
42 | log4j-to-slf4j
43 | ${version.log4j-slf4j}
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/two-way-object-serialization/src/main/java/nl/altindag/server/controller/EmployeeController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.controller;
17 |
18 | import com.fasterxml.jackson.core.JsonProcessingException;
19 | import nl.altindag.server.model.Employee;
20 | import nl.altindag.server.service.EmployeeService;
21 | import org.springframework.web.bind.annotation.GetMapping;
22 | import org.springframework.web.bind.annotation.PostMapping;
23 | import org.springframework.web.bind.annotation.RequestBody;
24 | import org.springframework.web.bind.annotation.RestController;
25 |
26 | import java.util.List;
27 |
28 | @RestController
29 | public class EmployeeController {
30 |
31 | private final EmployeeService service;
32 |
33 | public EmployeeController(EmployeeService service) {
34 | this.service = service;
35 | }
36 |
37 | @GetMapping(value = "/api/employee")
38 | public List getEmployees() {
39 | return service.getAll();
40 | }
41 |
42 | @PostMapping(value = "/api/employee")
43 | public void saveEmployee(@RequestBody Employee employee) throws JsonProcessingException {
44 | service.save(employee);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/README.md:
--------------------------------------------------------------------------------
1 | # Instant SSL Reloading 🔐
2 | A server configured with ssl has a key material and trust material. These materials are generated from a keypair and certificate which always have an expiration date.
3 | In a traditional server configuration a reboot of the server is required to apply the latest key material and trust material changes when the keystore and truststore are changed.
4 | A downtime is therefore unavoidable. This project demonstrates with a basic setup how update the server certificate from an external source without the need of restarting your server. In this way you can achieve zero downtime.
5 |
6 | The repository contains:
7 | - Server, based on Spring Boot with Jetty as a server engine
8 | - PostgreSQL DB
9 |
10 | The server will be initially configured with dummy ssl material. The dummy ssl material will be replaced during the startup.
11 | It will be calling the database every 10 seconds to get the ssl material. The ssl material are in pem format.
12 |
13 | ### SSL Updating entrypoint for the server:
14 | - [DatabaseBasedSslUpdateService](src/main/java/nl/altindag/server/service/DatabaseBasedSslUpdateService.java)
15 |
16 | #### Requirements
17 | - Java 21
18 | - Terminal
19 | - Docker
20 |
21 | #### Start the database
22 | 1. run `mvn clean install` on the [root directory of this repository](https://github.com/Hakky54/java-tutorials/)
23 | 2. run `mvn exec:java` on the [instant-server-ssl-reloading-with-spring-jetty-database](.)
24 |
25 | #### Start the server
26 | ```
27 | mvn spring-boot:run
28 | ```
29 | Visit the server with the following url on your browser: https://localhost:8443/api/hello to view the certificate. It will be updated every 10 seconds, but this logic can be enhanced by validating if the content has been updated on the database before updating the server ssl configuration.
30 |
--------------------------------------------------------------------------------
/bypassing-overruling-ssl-configuration/src/main/java/nl/altindag/ssl/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl;
17 |
18 | import nl.altindag.ssl.util.ProviderUtils;
19 |
20 | import java.security.Provider;
21 | import java.security.Security;
22 | import java.sql.Connection;
23 | import java.sql.DriverManager;
24 | import java.sql.SQLException;
25 |
26 | public class App {
27 |
28 | public static void main(String[] args) {
29 | SSLFactory sslFactory = SSLFactory.builder()
30 | .withLoggingTrustMaterial()
31 | .withUnsafeTrustMaterial()
32 | .build();
33 |
34 | Provider provider = ProviderUtils.create(sslFactory);
35 | Security.insertProviderAt(provider, 1);
36 |
37 | String url = "jdbc:mysql://localhost:33060/mysql?verifyServerCertificate=true&useSSL=true&requireSSL=true";
38 | try (Connection connection = DriverManager.getConnection(url, "root", "secret")) {
39 | System.out.println("Database connected!");
40 | } catch (SQLException e) {
41 | throw new IllegalStateException("Cannot connect the database!", e);
42 | } finally {
43 | Security.removeProvider("Fenix");
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | grpc-client-server-with-ssl-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | grpc-client
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | io.github.hakky54
20 | ayza-for-netty
21 |
22 |
23 |
24 | io.github.hakky54
25 | common-proto
26 | 1.0.0-SNAPSHOT
27 |
28 |
29 |
30 | org.slf4j
31 | slf4j-simple
32 |
33 |
34 |
35 | io.grpc
36 | grpc-netty
37 |
38 |
39 | io.grpc
40 | grpc-protobuf
41 |
42 |
43 | io.grpc
44 | grpc-stub
45 |
46 |
47 | com.google.protobuf
48 | protobuf-java
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/streaming-json-validation/src/test/java/nl/altindag/validation/service/ValidationServiceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.validation.service;
17 |
18 | import com.fasterxml.jackson.databind.ObjectMapper;
19 | import jakarta.validation.Validation;
20 | import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator;
21 | import org.junit.jupiter.api.Test;
22 |
23 | import java.net.URL;
24 |
25 | import static org.assertj.core.api.Assertions.assertThat;
26 | import static org.assertj.core.api.Assertions.assertThatCode;
27 |
28 | class ValidationServiceShould {
29 |
30 | @Test
31 | void validate() {
32 | var validator = Validation.byDefaultProvider()
33 | .configure()
34 | .messageInterpolator(new ParameterMessageInterpolator())
35 | .buildValidatorFactory()
36 | .getValidator();
37 |
38 | var objectMapper = new ObjectMapper();
39 | var validationService = new ValidationService(validator, objectMapper);
40 |
41 | URL url = Thread.currentThread().getContextClassLoader().getResource("example.json");
42 | assertThat(url).isNotNull();
43 | assertThatCode(() -> validationService.validate(url)).doesNotThrowAnyException();
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/two-way-object-serialization/README.md:
--------------------------------------------------------------------------------
1 | # Two-way object serialization while using one model with Jackson and Spring Boot
2 | Some projects may have requirements for different types of serialization. A server needs to accept and respond with camel case objects and needs to send a different cased objects to a downstream API.
3 | A straight forward approach would be having objects defined for every casing, in this case Employee for the RestController and EmployeeDao for the downstream api, but that would lead to more maintenance.
4 | Having duplicate code in the code base is bad and maintaining the changes is error-prone.
5 | It would be better to have a single object called Employee which can be used to serialize as camel-case and upper-snake-case or any other casing strategy. In this way the developer just only needs to maintain one model.
6 |
7 | The flow would be like the diagram below:
8 |
9 | 
10 |
11 | #### Requirements
12 | - Java 21
13 | - Terminal
14 |
15 | #### Start the server
16 | ```
17 | mvn spring-boot:run
18 | ```
19 |
20 | #### Save an object
21 | Send a POST request to http://localhost:8080/api/employee with the following body:
22 | ```json
23 | {
24 | "id": 1,
25 | "name": "Peter",
26 | "surname": "Jackson",
27 | "startDate": "2021-16-12T15:34:31"
28 | }
29 | ```
30 | Analyse the server logs, it will print the serialized object for the downstream api like the example below:
31 | ```json
32 | {
33 | "ID": 1,
34 | "NAME": "Peter",
35 | "SURNAME": "Jackson",
36 | "START_DATE": "2021-16-12T15:34:31"
37 | }
38 | ```
39 |
40 | #### Get the object
41 | Send a GET request to http://localhost:8080/api/employee It will return the following response:
42 | ```json
43 | {
44 | "id": 1,
45 | "name": "Peter",
46 | "surname": "Jackson",
47 | "startDate": "2021-16-12T15:34:31"
48 | }
49 | ```
50 |
--------------------------------------------------------------------------------
/two-way-object-serialization/src/main/java/nl/altindag/server/model/Employee.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.model;
17 |
18 | import com.fasterxml.jackson.annotation.JsonInclude;
19 | import com.fasterxml.jackson.databind.PropertyNamingStrategies;
20 | import com.fasterxml.jackson.databind.annotation.JsonNaming;
21 |
22 | @JsonInclude(JsonInclude.Include.NON_EMPTY)
23 | @JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
24 | public final class Employee {
25 |
26 | private int id;
27 | private String name;
28 | private String surname;
29 | private String startDate;
30 |
31 | public int getId() {
32 | return id;
33 | }
34 |
35 | public void setId(int id) {
36 | this.id = id;
37 | }
38 |
39 | public String getName() {
40 | return name;
41 | }
42 |
43 | public void setName(String name) {
44 | this.name = name;
45 | }
46 |
47 | public String getSurname() {
48 | return surname;
49 | }
50 |
51 | public void setSurname(String surname) {
52 | this.surname = surname;
53 | }
54 |
55 | public String getStartDate() {
56 | return startDate;
57 | }
58 |
59 | public void setStartDate(String startDate) {
60 | this.startDate = startDate;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/two-way-object-serialization/src/main/java/nl/altindag/server/service/EmployeeService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.service;
17 |
18 | import com.fasterxml.jackson.core.JsonProcessingException;
19 | import com.fasterxml.jackson.databind.ObjectMapper;
20 | import nl.altindag.server.model.Employee;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 | import org.springframework.stereotype.Service;
24 |
25 | import java.util.ArrayList;
26 | import java.util.Collections;
27 | import java.util.List;
28 |
29 | @Service
30 | public class EmployeeService {
31 |
32 | private static final Logger LOGGER = LoggerFactory.getLogger(EmployeeService.class);
33 |
34 | private final ObjectMapper objectMapper;
35 | private final List employees = new ArrayList<>();
36 |
37 | public EmployeeService(ObjectMapper objectMapper) {
38 | this.objectMapper = objectMapper;
39 | }
40 |
41 | public List getAll() {
42 | return Collections.unmodifiableList(employees);
43 | }
44 |
45 | public void save(Employee employee) throws JsonProcessingException {
46 | LOGGER.info("saving employee to the database...\n" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(employee));
47 | employees.add(employee);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/admin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | io.github.hakky54
9 | instant-ssl-reloading-parent
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | instant-ssl-reloading-admin
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | io.github.hakky54
20 | ayza
21 |
22 |
23 | org.slf4j
24 | slf4j-simple
25 |
26 |
27 | com.fasterxml.jackson.core
28 | jackson-databind
29 |
30 |
31 |
32 |
33 |
34 |
35 | org.codehaus.mojo
36 | exec-maven-plugin
37 | ${version.exec-maven-plugin}
38 |
39 |
40 |
41 | java
42 |
43 |
44 |
45 |
46 | nl.altindag.admin.App
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/src/main/java/nl/altindag/server/config/SSLConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import nl.altindag.ssl.SSLFactory;
19 | import org.springframework.beans.factory.annotation.Value;
20 | import org.springframework.context.annotation.Bean;
21 | import org.springframework.context.annotation.Configuration;
22 |
23 | @Configuration
24 | public class SSLConfig {
25 |
26 | @Bean
27 | public SSLFactory sslFactory(@Value("${ssl.keystore-path}") String keyStorePath,
28 | @Value("${ssl.keystore-password}") char[] keyStorePassword,
29 | @Value("${ssl.truststore-path}") String trustStorePath,
30 | @Value("${ssl.truststore-password}") char[] trustStorePassword,
31 | @Value("${ssl.client-auth}") boolean isClientAuthenticationRequired) {
32 |
33 | return SSLFactory.builder()
34 | .withSwappableIdentityMaterial()
35 | .withSwappableTrustMaterial()
36 | .withIdentityMaterial(keyStorePath, keyStorePassword)
37 | .withTrustMaterial(trustStorePath, trustStorePassword)
38 | .withNeedClientAuthentication(isClientAuthenticationRequired)
39 | .build();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/streaming-json-validation/src/main/java/nl/altindag/validation/model/CustomProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package nl.altindag.validation.model;
18 |
19 | import java.util.LinkedHashMap;
20 | import java.util.Map;
21 | import jakarta.annotation.Generated;
22 | import com.fasterxml.jackson.annotation.JsonAnyGetter;
23 | import com.fasterxml.jackson.annotation.JsonAnySetter;
24 | import com.fasterxml.jackson.annotation.JsonIgnore;
25 | import com.fasterxml.jackson.annotation.JsonInclude;
26 | import com.fasterxml.jackson.annotation.JsonPropertyOrder;
27 | import jakarta.validation.Valid;
28 |
29 |
30 | /**
31 | * The custom properties that were defined for the repository. The keys are the custom property names, and the values are the corresponding custom property values.
32 | *
33 | */
34 | @JsonInclude(JsonInclude.Include.NON_NULL)
35 | @JsonPropertyOrder({
36 |
37 | })
38 | @Generated("jsonschema2pojo")
39 | public class CustomProperties {
40 |
41 | @JsonIgnore
42 | @Valid
43 | private Map additionalProperties = new LinkedHashMap();
44 |
45 | @JsonAnyGetter
46 | public Map getAdditionalProperties() {
47 | return this.additionalProperties;
48 | }
49 |
50 | @JsonAnySetter
51 | public void setAdditionalProperty(String name, Object value) {
52 | this.additionalProperties.put(name, value);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/log-captor-examples/log-captor-with-quarkus-jboss-lombok/src/test/java/nl/altindag/quarkus/resource/GreetingsResourceWithQuarkusTestShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.quarkus.resource;
17 |
18 | import io.quarkus.test.junit.QuarkusTest;
19 | import nl.altindag.log.LogCaptor;
20 | import nl.altindag.log.exception.LogCaptorException;
21 | import org.junit.jupiter.api.Test;
22 |
23 | import static io.restassured.RestAssured.given;
24 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 | import static org.hamcrest.Matchers.is;
26 |
27 | @QuarkusTest
28 | public class GreetingsResourceWithQuarkusTestShould {
29 |
30 | @Test
31 | void capturingLogFailsBecauseOfDifferentClassloadersFromQuarkusTest() {
32 | assertThatThrownBy(LogCaptor::forRoot)
33 | .isInstanceOf(LogCaptorException.class)
34 | .hasMessageContaining("Multiple classloaders are being used. " +
35 | "The Logging API is created by the following classloader: [jdk.internal.loader.ClassLoaders$AppClassLoader], " +
36 | "while it should have been created by the following classloader: [io.quarkus.bootstrap.classloading.QuarkusClassLoader].");
37 |
38 | given()
39 | .when().get("/hello")
40 | .then()
41 | .statusCode(200)
42 | .body(is("Hello from RESTEasy Reactive"));
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/main/java/nl/altindag/server/config/ServerConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import org.eclipse.jetty.server.Connector;
19 | import org.eclipse.jetty.server.ServerConnector;
20 | import org.eclipse.jetty.util.ssl.SslContextFactory;
21 | import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
22 | import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
23 | import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
24 | import org.springframework.context.annotation.Bean;
25 | import org.springframework.context.annotation.Configuration;
26 |
27 | import java.util.Collections;
28 |
29 | @Configuration
30 | public class ServerConfig {
31 |
32 | @Bean
33 | public ConfigurableServletWebServerFactory webServerFactory(SslContextFactory.Server sslContextFactory) {
34 | JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
35 |
36 | JettyServerCustomizer jettyServerCustomizer = server -> {
37 | ServerConnector serverConnector = new ServerConnector(server, sslContextFactory);
38 | serverConnector.setPort(8443);
39 | server.setConnectors(new Connector[]{serverConnector});
40 | };
41 | factory.setServerCustomizers(Collections.singletonList(jettyServerCustomizer));
42 |
43 | return factory;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/client/src/main/java/nl/altindag/client/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.client;
17 |
18 | import nl.altindag.ssl.SSLFactory;
19 |
20 | import java.io.IOException;
21 | import java.net.URI;
22 | import java.net.http.HttpClient;
23 | import java.net.http.HttpRequest;
24 | import java.net.http.HttpResponse;
25 | import java.net.http.HttpResponse.BodyHandlers;
26 |
27 | public class App {
28 |
29 | public static void main(String[] args) throws IOException, InterruptedException {
30 | SSLFactory sslFactory = SSLFactory.builder()
31 | .withIdentityMaterial("identity.jks", "secret".toCharArray())
32 | .withTrustMaterial("truststore.jks", "secret".toCharArray())
33 | .withProtocols("TLSv1.3")
34 | .build();
35 |
36 | HttpClient httpClient = HttpClient.newBuilder()
37 | .sslParameters(sslFactory.getSslParameters())
38 | .sslContext(sslFactory.getSslContext())
39 | .build();
40 |
41 | HttpRequest request = HttpRequest.newBuilder()
42 | .GET()
43 | .uri(URI.create("https://localhost:443/hello"))
44 | .build();
45 |
46 | HttpResponse response = httpClient.send(request, BodyHandlers.ofString());
47 | System.out.printf("Received [%d] status code from the server%n", response.statusCode());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/server-with-cn-validation/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | spring-cn-validation-with-aop
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | server-with-cn-validation
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-web
21 |
22 |
23 | org.aspectj
24 | aspectjweaver
25 |
26 |
27 | io.github.hakky54
28 | ayza
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-test
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-logging
38 |
39 |
40 | org.mockito
41 | mockito-junit-jupiter
42 |
43 |
44 | org.junit.jupiter
45 | junit-jupiter-api
46 |
47 |
48 | io.github.hakky54
49 | logcaptor
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/bypassing-overruling-ssl-configuration/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.github.hakky54
8 | java-tutorials
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | bypassing-overruling-ssl-configuration
13 | 1.0.0-SNAPSHOT
14 | jar
15 |
16 |
17 |
18 | org.slf4j
19 | slf4j-simple
20 | ${version.slf4j}
21 |
22 |
23 | io.github.hakky54
24 | ayza
25 | ${version.ayza}
26 |
27 |
28 | com.mysql
29 | mysql-connector-j
30 | ${version.mysql-connector}
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.codehaus.mojo
38 | exec-maven-plugin
39 | ${version.exec-maven-plugin}
40 |
41 |
42 |
43 | java
44 |
45 |
46 |
47 |
48 | nl.altindag.ssl.App
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/test/java/nl/altindag/server/LocalDB.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server;
17 |
18 | import com.github.dockerjava.api.model.ExposedPort;
19 | import com.github.dockerjava.api.model.HostConfig;
20 | import com.github.dockerjava.api.model.PortBinding;
21 | import com.github.dockerjava.api.model.Ports;
22 | import org.testcontainers.containers.PostgreSQLContainer;
23 |
24 | import java.util.concurrent.TimeUnit;
25 |
26 | public class LocalDB {
27 |
28 | private static final int containerPort = 5432 ;
29 | private static final int localPort = 5432 ;
30 | private static final PostgreSQLContainer> postgreSQLContainer = new PostgreSQLContainer<>("postgres:11.1")
31 | .withDatabaseName("integration-tests-db")
32 | .withUsername("sa")
33 | .withPassword("sa")
34 | .withInitScript("db/db-init.sql")
35 | .withExposedPorts(containerPort)
36 | .withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(
37 | new HostConfig().withPortBindings(new PortBinding(Ports.Binding.bindPort(localPort), new ExposedPort(containerPort)))
38 | ));
39 |
40 | public static void main(String[] args) throws InterruptedException {
41 | postgreSQLContainer.start();
42 |
43 | System.out.println("JDBC url is: " + postgreSQLContainer.getJdbcUrl());
44 |
45 | TimeUnit.HOURS.sleep(1);
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/spring-cn-validation-with-aop/client-for-testing-server-with-cn-validation/src/main/java/nl/altindag/client/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.client;
17 |
18 | import nl.altindag.ssl.SSLFactory;
19 |
20 | import java.io.IOException;
21 | import java.net.URI;
22 | import java.net.http.HttpClient;
23 | import java.net.http.HttpRequest;
24 | import java.net.http.HttpResponse;
25 | import java.net.http.HttpResponse.BodyHandlers;
26 |
27 | public class App {
28 |
29 | public static void main(String[] args) throws IOException, InterruptedException {
30 | SSLFactory sslFactory = SSLFactory.builder()
31 | .withIdentityMaterial("identity.jks", "secret".toCharArray())
32 | .withTrustMaterial("truststore.jks", "secret".toCharArray())
33 | .withProtocols("TLSv1.3")
34 | .build();
35 |
36 | HttpClient httpClient = HttpClient.newBuilder()
37 | .sslParameters(sslFactory.getSslParameters())
38 | .sslContext(sslFactory.getSslContext())
39 | .build();
40 |
41 | HttpRequest request = HttpRequest.newBuilder()
42 | .GET()
43 | .uri(URI.create("https://localhost:443/hello"))
44 | .build();
45 |
46 | HttpResponse response = httpClient.send(request, BodyHandlers.ofString());
47 | System.out.printf("Received [%d] status code from the server%n", response.statusCode());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/streaming-json-validation/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | io.github.hakky54
9 | java-tutorials
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | streaming-json-validation
14 |
15 |
16 |
17 | com.fasterxml.jackson.core
18 | jackson-databind
19 | ${version.jackson}
20 |
21 |
22 | org.hibernate.validator
23 | hibernate-validator
24 | ${version.hibernate-validator}
25 |
26 |
27 | jakarta.annotation
28 | jakarta.annotation-api
29 | ${version.jakarta-annotation-api}
30 |
31 |
32 |
33 | org.assertj
34 | assertj-core
35 | ${version.assertj-core}
36 | test
37 |
38 |
39 | org.junit.jupiter
40 | junit-jupiter-api
41 | ${version.junit}
42 | test
43 |
44 |
45 | org.junit.jupiter
46 | junit-jupiter-engine
47 | ${version.junit}
48 | test
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading-with-quarkus/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.github.hakky54
8 | java-tutorials
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | instant-server-ssl-reloading-with-quarkus
13 |
14 |
15 |
16 | io.github.hakky54
17 | ayza
18 | ${version.ayza}
19 |
20 |
21 |
22 | io.quarkus
23 | quarkus-resteasy-reactive
24 |
25 |
26 |
27 |
28 |
29 |
30 | io.quarkus
31 | quarkus-bom
32 | ${version.quarkus}
33 | pom
34 | import
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | io.quarkus
43 | quarkus-maven-plugin
44 | ${version.quarkus}
45 | true
46 |
47 |
48 |
49 | build
50 | generate-code
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/java/nl/altindag/server/config/ServerConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import org.eclipse.jetty.server.Connector;
19 | import org.eclipse.jetty.server.ServerConnector;
20 | import org.eclipse.jetty.util.ssl.SslContextFactory;
21 | import org.springframework.beans.factory.annotation.Value;
22 | import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
23 | import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
24 | import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
25 | import org.springframework.context.annotation.Bean;
26 | import org.springframework.context.annotation.Configuration;
27 |
28 | import java.util.Collections;
29 |
30 | @Configuration
31 | public class ServerConfig {
32 |
33 | @Bean
34 | public ConfigurableServletWebServerFactory webServerFactory(SslContextFactory.Server sslContextFactory, @Value("${server.port}") int serverPort) {
35 | JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
36 |
37 | JettyServerCustomizer jettyServerCustomizer = server -> {
38 | ServerConnector serverConnector = new ServerConnector(server, sslContextFactory);
39 | serverConnector.setPort(serverPort);
40 | server.setConnectors(new Connector[]{serverConnector});
41 | };
42 | factory.setServerCustomizers(Collections.singletonList(jettyServerCustomizer));
43 |
44 | return factory;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | spring-reactive-server
8 | client
9 |
10 |
11 |
12 | java-tutorials
13 | io.github.hakky54
14 | 1.0.0-SNAPSHOT
15 |
16 |
17 | spring-security-cn-validation-for-reactive-server-parent
18 | 1.0.0-SNAPSHOT
19 | pom
20 |
21 |
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-web
26 | ${version.spring}
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-security
31 | ${version.spring}
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-webflux
36 | ${version.spring}
37 |
38 |
39 |
40 | io.github.hakky54
41 | ayza
42 | ${version.ayza}
43 |
44 |
45 | org.slf4j
46 | slf4j-simple
47 | ${version.slf4j}
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/mock-statics-with-mockito/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | io.github.hakky54
7 | java-tutorials
8 | 1.0.0-SNAPSHOT
9 |
10 |
11 | mock-statics-with-mockito
12 | 1.0.0-SNAPSHOT
13 | jar
14 |
15 |
16 |
17 | org.junit.jupiter
18 | junit-jupiter-api
19 | ${version.junit}
20 | test
21 |
22 |
23 | org.junit.jupiter
24 | junit-jupiter-engine
25 | ${version.junit}
26 | test
27 |
28 |
29 | org.mockito
30 | mockito-junit-jupiter
31 | ${version.mockito}
32 | test
33 |
34 |
35 | org.mockito
36 | mockito-inline
37 | ${version.mockito-inline}
38 | test
39 |
40 |
41 | org.assertj
42 | assertj-core
43 | ${version.assertj-core}
44 | test
45 |
46 |
47 | net.bytebuddy
48 | byte-buddy
49 | ${version.byte-buddy}
50 | test
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | grpc-client-server-with-ssl-parent
9 | io.github.hakky54
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | instant-server-ssl-reloading-with-grpc
14 | 1.0.0-SNAPSHOT
15 | jar
16 |
17 |
18 |
19 | io.grpc
20 | grpc-netty
21 |
22 |
23 |
24 | io.github.hakky54
25 | common-proto
26 | 1.0.0-SNAPSHOT
27 |
28 |
29 |
30 | io.github.hakky54
31 | ayza-for-netty
32 |
33 |
34 |
35 | org.slf4j
36 | slf4j-simple
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.codehaus.mojo
44 | exec-maven-plugin
45 | ${version.exec-maven-plugin}
46 |
47 |
48 |
49 | java
50 |
51 |
52 |
53 |
54 | nl.altindag.grpc.server.App
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/spring-security-cn-validation-for-reactive-server/spring-reactive-server/src/main/java/nl/altindag/server/config/SecurityConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import org.springframework.context.annotation.Bean;
19 | import org.springframework.context.annotation.Configuration;
20 | import org.springframework.security.config.Customizer;
21 | import org.springframework.security.config.web.server.ServerHttpSecurity;
22 | import org.springframework.security.core.authority.SimpleGrantedAuthority;
23 | import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
24 | import org.springframework.security.core.userdetails.User;
25 | import org.springframework.security.core.userdetails.UserDetails;
26 | import org.springframework.security.web.server.SecurityWebFilterChain;
27 |
28 | @Configuration
29 | public class SecurityConfig {
30 |
31 | @Bean
32 | public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
33 | return http
34 | .x509(Customizer.withDefaults())
35 | .authorizeExchange(exchanges -> exchanges.anyExchange().authenticated())
36 | .build();
37 | }
38 |
39 | @Bean
40 | public MapReactiveUserDetailsService mapReactiveUserDetailsService() {
41 | UserDetails blackHoleAsCommonName = User.withUsername("black-hole")
42 | .authorities(new SimpleGrantedAuthority("ROLE_USER"))
43 | .password("")
44 | .build();
45 |
46 | return new MapReactiveUserDetailsService(blackHoleAsCommonName);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/trust-me/src/main/java/nl/altindag/ssl/trustme/config/ClientConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl.trustme.config;
17 |
18 | import nl.altindag.ssl.SSLFactory;
19 | import nl.altindag.ssl.trustme.service.TrustMeService;
20 | import org.springframework.context.annotation.Bean;
21 | import org.springframework.context.annotation.Configuration;
22 | import org.springframework.context.annotation.Lazy;
23 |
24 | import javax.net.ssl.X509ExtendedTrustManager;
25 | import java.net.http.HttpClient;
26 | import java.nio.file.Path;
27 |
28 | @Configuration
29 | public class ClientConfig {
30 |
31 | private static final Path TRUSTSTORE_PATH = Path.of(System.getProperty("user.dir"), "truststore.jks");
32 | private static final char[] TRUSTSTORE_PASSWORD = "changeit".toCharArray();
33 | private static final String TRUSTSTORE_TYPE = "PKCS12";
34 |
35 | @Bean
36 | public HttpClient httpClient(SSLFactory sslFactory) {
37 | return HttpClient.newBuilder()
38 | .sslContext(sslFactory.getSslContext())
39 | .sslParameters(sslFactory.getSslParameters())
40 | .build();
41 | }
42 |
43 | @Bean
44 | public SSLFactory sslFactory(@Lazy TrustMeService trustMeService) {
45 | return SSLFactory.builder()
46 | .withInflatableTrustMaterial(TRUSTSTORE_PATH, TRUSTSTORE_PASSWORD, TRUSTSTORE_TYPE, trustMeService::verify)
47 | .build();
48 | }
49 |
50 | @Bean
51 | public X509ExtendedTrustManager trustManager(SSLFactory sslFactory) {
52 | return sslFactory.getTrustManager().orElseThrow();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/java/nl/altindag/server/config/SSLConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import nl.altindag.ssl.SSLFactory;
19 | import nl.altindag.ssl.jetty.util.JettySslUtils;
20 | import org.eclipse.jetty.util.ssl.SslContextFactory;
21 | import org.springframework.beans.factory.annotation.Value;
22 | import org.springframework.context.annotation.Bean;
23 | import org.springframework.context.annotation.Configuration;
24 |
25 | @Configuration
26 | public class SSLConfig {
27 |
28 | @Bean
29 | public SSLFactory sslFactory(@Value("${ssl.keystore-path}") String keyStorePath,
30 | @Value("${ssl.keystore-password}") char[] keyStorePassword,
31 | @Value("${ssl.truststore-path}") String trustStorePath,
32 | @Value("${ssl.truststore-password}") char[] trustStorePassword,
33 | @Value("${ssl.client-auth}") boolean isClientAuthenticationRequired) {
34 |
35 | return SSLFactory.builder()
36 | .withSwappableIdentityMaterial()
37 | .withSwappableTrustMaterial()
38 | .withIdentityMaterial(keyStorePath, keyStorePassword)
39 | .withTrustMaterial(trustStorePath, trustStorePassword)
40 | .withNeedClientAuthentication(isClientAuthenticationRequired)
41 | .build();
42 | }
43 |
44 | @Bean
45 | public SslContextFactory.Server sslContextFactory(SSLFactory sslFactory) {
46 | return JettySslUtils.forServer(sslFactory);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/console-captor-examples/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | console-captor-with-log4j-slf4j18
9 | console-captor-with-quarkus-jboss-lombok
10 |
11 |
12 |
13 | java-tutorials
14 | io.github.hakky54
15 | 1.0.0-SNAPSHOT
16 |
17 |
18 | console-captor-examples-parent
19 | 1.0.0-SNAPSHOT
20 | pom
21 |
22 |
23 |
24 | io.github.hakky54
25 | consolecaptor
26 | ${version.consolecaptor}
27 | test
28 |
29 |
30 |
31 | org.junit.jupiter
32 | junit-jupiter-api
33 | ${version.junit}
34 | test
35 |
36 |
37 | org.junit.jupiter
38 | junit-jupiter-engine
39 | ${version.junit}
40 | test
41 |
42 |
43 | org.assertj
44 | assertj-core
45 | ${version.assertj-core}
46 | test
47 |
48 |
49 |
50 |
51 |
52 |
53 | org.slf4j
54 | slf4j-api
55 | ${version.slf4j}
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-jetty-database/src/main/java/nl/altindag/server/model/SSLMaterial.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.model;
17 |
18 | import jakarta.persistence.Entity;
19 | import jakarta.persistence.GeneratedValue;
20 | import jakarta.persistence.GenerationType;
21 | import jakarta.persistence.Id;
22 | import jakarta.persistence.Table;
23 |
24 | import java.sql.Timestamp;
25 |
26 | @Entity
27 | @Table(name = "SSL_MATERIAL")
28 | public class SSLMaterial {
29 |
30 | @Id
31 | @GeneratedValue(strategy= GenerationType.AUTO)
32 | private Long id;
33 |
34 | private Timestamp updatedAt;
35 | private String identityContent;
36 | private String identityPassword;
37 | private String trustedCertificates;
38 |
39 | public Timestamp getUpdatedAt() {
40 | return updatedAt;
41 | }
42 |
43 | public void setUpdatedAt(Timestamp createdAt) {
44 | this.updatedAt = createdAt;
45 | }
46 |
47 | public String getIdentityContent() {
48 | return identityContent;
49 | }
50 |
51 | public void setIdentityContent(String identityContent) {
52 | this.identityContent = identityContent;
53 | }
54 |
55 | public String getIdentityPassword() {
56 | return identityPassword;
57 | }
58 |
59 | public void setIdentityPassword(String identityPassword) {
60 | this.identityPassword = identityPassword;
61 | }
62 |
63 | public String getTrustedCertificates() {
64 | return trustedCertificates;
65 | }
66 |
67 | public void setTrustedCertificates(String trustedCertificates) {
68 | this.trustedCertificates = trustedCertificates;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-grpc/src/main/java/nl/altindag/server/config/SSLConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import nl.altindag.server.model.EnhanceableSslBundle;
19 | import nl.altindag.ssl.SSLFactory;
20 | import org.springframework.beans.factory.annotation.Value;
21 | import org.springframework.boot.ssl.SslBundleRegistry;
22 | import org.springframework.context.annotation.Bean;
23 | import org.springframework.context.annotation.Configuration;
24 |
25 | @Configuration
26 | public class SSLConfig {
27 |
28 | private final SSLFactory sslFactory;
29 |
30 | public SSLConfig(@Value("${ssl.keystore-path}") String keyStorePath,
31 | @Value("${ssl.keystore-password}") char[] keyStorePassword,
32 | @Value("${ssl.truststore-path}") String trustStorePath,
33 | @Value("${ssl.truststore-password}") char[] trustStorePassword,
34 | @Value("${ssl.client-auth}") boolean isClientAuthenticationRequired,
35 | SslBundleRegistry registry) {
36 |
37 | this.sslFactory = SSLFactory.builder()
38 | .withSwappableIdentityMaterial()
39 | .withSwappableTrustMaterial()
40 | .withIdentityMaterial(keyStorePath, keyStorePassword)
41 | .withTrustMaterial(trustStorePath, trustStorePassword)
42 | .withNeedClientAuthentication(isClientAuthenticationRequired)
43 | .build();
44 |
45 | registry.registerBundle("reloadable-ssl-bundle", new EnhanceableSslBundle(sslFactory));
46 | }
47 |
48 | @Bean
49 | public SSLFactory sslFactory() {
50 | return sslFactory;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/instant-ssl-reloading-with-spring-tomcat/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.github.hakky54
8 | java-tutorials
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | instant-ssl-reloading-with-spring-tomcat
13 | 1.0.0-SNAPSHOT
14 | jar
15 |
16 |
17 |
18 | io.github.hakky54
19 | ayza
20 | ${version.ayza}
21 |
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-web
26 | ${version.spring}
27 |
28 |
29 |
30 |
31 |
32 |
33 | org.apache.tomcat.embed
34 | tomcat-embed-core
35 | ${version-tomcat}
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-maven-plugin
45 | ${version.spring}
46 |
47 | nl.altindag.server.App
48 | server
49 |
50 |
51 |
52 |
53 | repackage
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/two-way-object-serialization/src/main/java/nl/altindag/server/config/JacksonConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.config;
17 |
18 | import com.fasterxml.jackson.databind.PropertyNamingStrategies;
19 | import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
20 | import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
21 | import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
22 | import com.fasterxml.jackson.databind.util.NameTransformer;
23 | import org.springframework.context.annotation.Bean;
24 | import org.springframework.context.annotation.Configuration;
25 | import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
26 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
27 |
28 | @Configuration
29 | public class JacksonConfiguration {
30 |
31 | @Bean
32 | public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
33 | return new MappingJackson2HttpMessageConverter(Jackson2ObjectMapperBuilder.json()
34 | .propertyNamingStrategy(PropertyNamingStrategies.LOWER_CAMEL_CASE)
35 | .annotationIntrospector(ignoredAnnotationIntrospector())
36 | .build());
37 | }
38 |
39 | private static JacksonAnnotationIntrospector ignoredAnnotationIntrospector() {
40 | return new JacksonAnnotationIntrospector() {
41 | @Override
42 | public NameTransformer findUnwrappingNameTransformer(AnnotatedMember member) {
43 | return null;
44 | }
45 |
46 | @Override
47 | public Object findNamingStrategy(AnnotatedClass annotatedClass) {
48 | return null;
49 | }
50 | };
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/console-captor-examples/console-captor-with-quarkus-jboss-lombok/src/test/java/nl/altindag/quarkus/resource/GreetingsResourceShould.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.quarkus.resource;
17 |
18 | import io.quarkus.test.junit.QuarkusTest;
19 | import nl.altindag.console.ConsoleCaptor;
20 | import org.junit.jupiter.api.Test;
21 |
22 | import java.util.List;
23 |
24 | import static io.restassured.RestAssured.given;
25 | import static org.assertj.core.api.Assertions.assertThat;
26 | import static org.hamcrest.Matchers.is;
27 | import static org.junit.jupiter.api.Assertions.assertTrue;
28 |
29 | @QuarkusTest
30 | public class GreetingsResourceShould {
31 |
32 | @Test
33 | void successfullyCapturesLogs() {
34 | try(ConsoleCaptor consoleCaptor = new ConsoleCaptor()) {
35 |
36 | new GreetingResource().hello();
37 |
38 | List standardOutput = consoleCaptor.getStandardOutput();
39 | assertThat(standardOutput).isNotEmpty();
40 | assertTrue(standardOutput.stream().anyMatch(message -> message.contains("Saying hello from the logger!")));
41 | }
42 | }
43 |
44 | @Test
45 | void successfullyCapturesLogsAlternativeWhileUsingRestAssured() {
46 | try(ConsoleCaptor consoleCaptor = new ConsoleCaptor()) {
47 |
48 | given()
49 | .when().get("/hello")
50 | .then()
51 | .statusCode(200)
52 | .body(is("Hello from RESTEasy Reactive"));
53 |
54 | List standardOutput = consoleCaptor.getStandardOutput();
55 | assertThat(standardOutput).isNotEmpty();
56 | assertTrue(standardOutput.stream().anyMatch(message -> message.contains("Saying hello from the logger!")));
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/instant-server-ssl-reloading/server/src/main/java/nl/altindag/server/controller/AdminController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.server.controller;
17 |
18 | import nl.altindag.server.model.SSLUpdateRequest;
19 | import nl.altindag.ssl.SSLFactory;
20 | import nl.altindag.ssl.util.SSLFactoryUtils;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 | import org.springframework.http.MediaType;
24 | import org.springframework.web.bind.annotation.PostMapping;
25 | import org.springframework.web.bind.annotation.RequestBody;
26 | import org.springframework.web.bind.annotation.RestController;
27 |
28 | import java.io.ByteArrayInputStream;
29 | import java.io.IOException;
30 | import java.io.InputStream;
31 |
32 | @RestController
33 | public class AdminController {
34 |
35 | private static final Logger LOGGER = LoggerFactory.getLogger(AdminController.class);
36 |
37 | private final SSLFactory baseSslFactory;
38 |
39 | public AdminController(SSLFactory baseSslFactory) {
40 | this.baseSslFactory = baseSslFactory;
41 | }
42 |
43 | @PostMapping(value = "/admin/ssl", consumes = MediaType.APPLICATION_JSON_VALUE)
44 | public void updateSslMaterial(@RequestBody SSLUpdateRequest request) throws IOException {
45 | try (InputStream keyStoreStream = new ByteArrayInputStream(request.keyStore());
46 | InputStream trustStoreStream = new ByteArrayInputStream(request.trustStore())) {
47 |
48 | SSLFactory updatedSslFactory = SSLFactory.builder()
49 | .withIdentityMaterial(keyStoreStream, request.keyStorePassword())
50 | .withTrustMaterial(trustStoreStream, request.trustStorePassword())
51 | .build();
52 |
53 | SSLFactoryUtils.reload(baseSslFactory, updatedSslFactory);
54 | LOGGER.info("Updated server ssl material");
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/trust-me/src/main/java/nl/altindag/ssl/trustme/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.ssl.trustme;
17 |
18 | import javafx.application.Application;
19 | import javafx.application.Platform;
20 | import javafx.fxml.FXMLLoader;
21 | import javafx.scene.Parent;
22 | import javafx.scene.Scene;
23 | import javafx.stage.Stage;
24 | import org.springframework.boot.autoconfigure.SpringBootApplication;
25 | import org.springframework.boot.builder.SpringApplicationBuilder;
26 | import org.springframework.context.ConfigurableApplicationContext;
27 |
28 | import java.io.IOException;
29 | import java.util.function.Function;
30 |
31 | @SpringBootApplication
32 | public class App extends Application {
33 |
34 | private static final String TITLE = "Trust Me";
35 | private ConfigurableApplicationContext applicationContext;
36 | private final Function fxmlLoaderFunction = fxml -> new FXMLLoader(this.getClass().getResource(fxml));
37 |
38 | private Parent root;
39 |
40 | @Override
41 | public void init() throws IOException {
42 | applicationContext = new SpringApplicationBuilder(App.class)
43 | .headless(false)
44 | .run(getParameters().getRaw().toArray(String[]::new));
45 |
46 | FXMLLoader fxmlLoader = fxmlLoaderFunction.apply("/mainscreen.fxml");
47 | fxmlLoader.setControllerFactory(applicationContext::getBean);
48 | root = fxmlLoader.load();
49 | }
50 |
51 | @Override
52 | public void start(Stage stage) {
53 | Scene scene = new Scene(root);
54 | stage.setTitle(TITLE);
55 | stage.setScene(scene);
56 | stage.setWidth(500);
57 | stage.setHeight(400);
58 | stage.setResizable(false);
59 |
60 | stage.show();
61 | }
62 |
63 | @Override
64 | public void stop() {
65 | Platform.exit();
66 | applicationContext.stop();
67 | }
68 |
69 | public static void main(String[] args) {
70 | launch(args);
71 | }
72 |
73 | }
--------------------------------------------------------------------------------
/log-captor-examples/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | log-captor-with-java-util-logging
8 | log-captor-with-log4j-core
9 | log-captor-with-log4j-api
10 | log-captor-with-slf4j-logback-classic
11 | log-captor-with-slf4j-log4j
12 | log-captor-with-spring-boot-starter-log4j2
13 | log-captor-with-jboss-and-lombok
14 | log-captor-with-quarkus-jboss-lombok
15 | log-captor-with-flogger
16 |
17 |
18 |
19 | java-tutorials
20 | io.github.hakky54
21 | 1.0.0-SNAPSHOT
22 |
23 |
24 | log-captor-examples-parent
25 | 1.0.0-SNAPSHOT
26 | pom
27 |
28 |
29 |
30 | io.github.hakky54
31 | logcaptor
32 | ${version.logcaptor}
33 | test
34 |
35 |
36 |
37 | org.junit.jupiter
38 | junit-jupiter-api
39 | ${version.junit}
40 | test
41 |
42 |
43 | org.junit.jupiter
44 | junit-jupiter-engine
45 | ${version.junit}
46 | test
47 |
48 |
49 | org.assertj
50 | assertj-core
51 | ${version.assertj-core}
52 | test
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.slf4j
60 | slf4j-api
61 | ${version.slf4j}
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | grpc-client
8 | grpc-server
9 | instant-server-ssl-reloading-with-grpc
10 | common-proto
11 |
12 |
13 |
14 | java-tutorials
15 | io.github.hakky54
16 | 1.0.0-SNAPSHOT
17 |
18 |
19 | grpc-client-server-with-ssl-parent
20 | 1.0.0-SNAPSHOT
21 | pom
22 |
23 |
24 |
25 |
26 | io.grpc
27 | grpc-netty
28 | ${version.grpc}
29 |
30 |
31 | io.grpc
32 | grpc-protobuf
33 | ${version.grpc}
34 |
35 |
36 | io.grpc
37 | grpc-stub
38 | ${version.grpc}
39 |
40 |
41 |
42 | com.google.protobuf
43 | protobuf-java
44 | ${version.google.protobuf-java}
45 |
46 |
47 |
48 | javax.annotation
49 | javax.annotation-api
50 | ${version.javax.annotation-api}
51 |
52 |
53 |
54 | io.github.hakky54
55 | ayza-for-netty
56 | ${version.ayza}
57 |
58 |
59 |
60 | org.slf4j
61 | slf4j-simple
62 | ${version.slf4j}
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/grpc-client-server-with-ssl/grpc-client/src/main/java/nl/altindag/grpc/client/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Thunderberry.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package nl.altindag.grpc.client;
17 |
18 | import io.grpc.Channel;
19 | import io.grpc.ManagedChannel;
20 | import io.grpc.netty.GrpcSslContexts;
21 | import io.grpc.netty.NettyChannelBuilder;
22 | import io.netty.handler.ssl.SslContext;
23 | import nl.altindag.grpc.HelloRequest;
24 | import nl.altindag.grpc.HelloResponse;
25 | import nl.altindag.grpc.HelloServiceGrpc;
26 | import nl.altindag.ssl.SSLFactory;
27 | import nl.altindag.ssl.netty.util.NettySslUtils;
28 | import org.slf4j.Logger;
29 | import org.slf4j.LoggerFactory;
30 |
31 | import javax.net.ssl.SSLException;
32 |
33 | public class App {
34 |
35 | private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
36 |
37 | private final HelloServiceGrpc.HelloServiceBlockingStub stub;
38 |
39 | public App(Channel channel) {
40 | stub = HelloServiceGrpc.newBlockingStub(channel);
41 | }
42 |
43 | public void hello(String name) {
44 | LOGGER.info("Will try to greet the server as {} ...", name);
45 |
46 | HelloRequest request = HelloRequest.newBuilder().setName(name).build();
47 | HelloResponse response = stub.hello(request);
48 |
49 | LOGGER.info("Server response: {}", response.getMessage());
50 | }
51 |
52 |
53 | public static void main(String[] args) throws SSLException {
54 | SSLFactory sslFactory = SSLFactory.builder()
55 | .withIdentityMaterial("client/identity.jks", "secret".toCharArray())
56 | .withTrustMaterial("client/truststore.jks", "secret".toCharArray())
57 | .withDefaultTrustMaterial()
58 | .build();
59 |
60 | SslContext sslContext = GrpcSslContexts.configure(NettySslUtils.forClient(sslFactory)).build();
61 |
62 | ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", 8443)
63 | .sslContext(sslContext)
64 | .build();
65 |
66 | App app = new App(channel);
67 | app.hello("John");
68 |
69 | channel.shutdown();
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------