LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Customized Decryptor

Some organizations that don’t want to use the default implementation can use their customized encryptor and decryptor. To demo how to use a customized decryptor, we have provided a test implementation DummyDecryptor. Because it doesn’t do any encryption but just adds the prefix CRYPT in front of the clear text, please don’t use it in any official environment.

If you implement your decryptor in a common module, you can release it internally to the organization’s Artifactory and include it in your service dependency.

config.yml

Once you have the decryptor implemented, you should externalize config.yml into your application src/main/resources/config folder. Here is the modified config.yml from the light-4j repository.

#----------------------------------------------------------------------------------------------------------------
# Scalable Config file
#
# This file serves as a configuration extension platform. Functions are list below:
#
# [1]   exclusionConfigFileList: this configuration will be used by the light-4j/config module, when reading
#       config files. it allows the listing of files which will be excluded from parameterized values set at
#       the command-line or in a values.yml file
#       Notes:
#       File name included in the list will be excluded
#       If the file is not provided, the config module will safely ignore it
#       Simply list the config file names without extensions(.json, .yaml, .yml)
#----------------------------------------------------------------------------------------------------------------
exclusionConfigFileList:
  - openapi
  - values

# The AutoAESSaltDecryptor is the most secure one we have implemented, and it can be used by
# everyone with a master key set up as an environment variable on the deployment environment.
# To encrypt your sensitive secret with a command line tool, please visit the following URL.
# https://github.com/networknt/light-encryptor
# To learn how the decryptor works, please visit the document URL.
# https://doc.networknt.com/concern/decryptor/
decryptorClass: com.networknt.decrypt.DummyDecryptor
# decryptorClass: com.networknt.decrypt.AESSaltDecryptor
# decryptorClass: com.networknt.decrypt.ManualAESSaltDecryptor

# For some configuration files, we have left some properties without default values as there
# would be negative impact on the application security. The following config will ensure that
# null will be used when the default value is empty without stopping the server during the start.
allowDefaultValueEmpty: true

Copy the above config.yml and change the decryptorClass to your implementation class from the DummyDecryptor.

Test

To test it with the petstore API, we need to update the values.yml to the following.


#--------------------------------------------------------------------------------
# values.yml : Set of values commonly overridden in microservices
# 			   The file can be extended with other elements, as necessary 
#--------------------------------------------------------------------------------

# client.yml
# https://github.com/networknt/light-4j/blob/master/client/src/main/resources/config/client.yml
client.timeout: 3000
client.verifyHostname: true

# server.yml
# https://github.com/networknt/light-4j/blob/master/server/src/main/resources/config/server.yml
server.httpPort: 8080
server.enableHttp: false
server.httpsPort: 9443
server.enableHttps: true
server.enableHttp2: true
server.enableRegistry: false
server.serviceId: com.networknt.petstore-3.0.1
server.buildNumber: 3.0.1
server.keystorePass: CRYPT:password

# openapi-security.yml
# https://github.com/networknt/light-rest-4j/blob/master/openapi-security/src/main/resources/config/openapi-security.yml
openapi-security.enableVerifyJwt: false

# metrics.yml
metrics.enabled: false

# service.yml
service.singletons:
- com.networknt.registry.URL:
  - com.networknt.registry.URLImpl:
      protocol: light
      host: localhost
      port: 8080
      path: portal
      parameters:
        registryRetryPeriod: '30000'
- com.networknt.portal.registry.client.PortalRegistryClient:
  - com.networknt.portal.registry.client.PortalRegistryClientImpl
- com.networknt.registry.Registry:
  - com.networknt.portal.registry.PortalRegistry
- com.networknt.balance.LoadBalance:
  - com.networknt.balance.RoundRobinLoadBalance
- com.networknt.cluster.Cluster:
  - com.networknt.cluster.LightCluster
# StartupHookProvider implementations, there are one to many and they are called in the same sequence defined.
- com.networknt.server.StartupHookProvider:
  
  
# ShutdownHookProvider implementations, there are one to many and they are called in the same sequence defined.
- com.networknt.server.ShutdownHookProvider:
  

In the above values.yml, we have added the following line and it needs the DummyDecryptor to decrypt during the server startup.

server.keystorePass: CRYPT:password

If you can start the server without any error, then it approves the decryptor works.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Customized Decryptor” was last updated: October 23, 2023: fix a typo (163f2af)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute