Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(encryption): aes encryption #7

Merged
merged 8 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: ci

on:
pull_request:
types: [ opened, reopened, synchronize ]
pull_request_target:
types: [ closed ]

jobs:
lint:
if: ${{ github.event.pull_request.merged != true }}
uses: heliannuuthus/integrate-deploy/.github/workflows/call-gradle-lint.yml@master

build:
if: always()
needs: lint
uses: heliannuuthus/integrate-deploy/.github/workflows/call-gradle-build.yml@master

containerize:
if: ${{ always() && github.event.pull_request.merged == true }}
needs: build
permissions:
contents: read
packages: write
uses: heliannuuthus/integrate-deploy/.github/workflows/call-containerize.yml@master
with:
version: ${{ needs.build.outputs.version }}
target: "./build"
27 changes: 8 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@ plugins {
id "org.springframework.boot" version "3.2.3"
id "io.spring.dependency-management" version "1.1.4"
id "org.springdoc.openapi-gradle-plugin" version "1.8.0"
id "me.qoomon.git-versioning" version "6.4.2"
id "com.diffplug.spotless" version "6.25.0"
id "io.freefair.lombok" version "8.6"
}

group = "io.ghcr.heliannuuthus"
java {
sourceCompatibility = "17"
}

ext {
springOpenApiVersion = "2.3.0"
guavaVersion = "33.0.0-jre"
apacheCommonVersion = "3.14.0"
}
apply from: "./cloud.gradle"

configurations {
compileOnly {
extendsFrom annotationProcessor
}
ext {
bcVersion = "1.77"
}

repositories {
Expand All @@ -32,9 +25,8 @@ dependencies {
implementation "org.springframework.boot:spring-boot-starter-data-r2dbc"
implementation "org.springframework.boot:spring-boot-starter-webflux"

implementation "org.springdoc:springdoc-openapi-starter-webflux-ui:${springOpenApiVersion}"
implementation "com.google.guava:guava:${guavaVersion}"
implementation "org.apache.commons:commons-lang3:${apacheCommonVersion}"
implementation "org.bouncycastle:bcprov-jdk18on:${bcVersion}"
implementation "org.bouncycastle:bcpkix-jdk18on:${bcVersion}"

compileOnly "org.projectlombok:lombok"
developmentOnly "org.springframework.boot:spring-boot-devtools"
Expand All @@ -45,6 +37,3 @@ dependencies {
testImplementation "io.projectreactor:reactor-test"
}

tasks.named("test") {
useJUnitPlatform()
}
128 changes: 128 additions & 0 deletions cloud.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
buildscript {
repositories {
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
maven { url "https://repo.spring.io/plugins-snapshot" }
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:3.2.3"
classpath "io.spring.gradle:dependency-management-plugin:1.1.4"
classpath "org.springdoc:springdoc-openapi-gradle-plugin:1.8.0"
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.25.0"
classpath "me.qoomon:gradle-git-versioning-plugin:6.4.2"
classpath "io.freefair.gradle:lombok-plugin:8.6"
}
}

ext {
r2dbcConnCompVersion = "2.1.8"
r2dbcSpiVersion = "1.0.0.RELEASE"
r2dbcPoolVersion = "1.0.0.RELEASE"
joseVersion = "0.9.2"
log4j2Version = "2.19.0"
guavaVersion = "31.1-jre"
hutoolVersion = "5.8.10"
springDocVersion = "2.0.2"
bootVersion = "3.0.1"
cloudVersion = "2022.0.0"
alibabaCloudVersion = "2022.0.0.0-RC1"
guavaVersion = "33.0.0-jre"
lang3Version = "3.14.0"
rngVersion = "1.5"
spotlessVersion = "1.21.0"
helianthusCommonVersion = "0.1.0-2f44836"
}

sourceCompatibility = 17
targetCompatibility = 17

gitVersioning.apply {
version = rootProject.findProperty("version")
refs {
branch("master") {
version = '${version}-${commit.short}'
}
branch(".+") {
version = '${version}-${commit.short}-SNAPSHOT'
}
}
}

dependencies {
implementation "org.springframework.boot:spring-boot-starter-data-r2dbc"
implementation "org.springframework.boot:spring-boot-starter-validation"
implementation "org.springframework.boot:spring-boot-devtools"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "io.projectreactor:reactor-test"

//apollo
implementation "io.ghrc:helianthus-annuus-apollo-client:${helianthusCommonVersion}"

// spring cloud
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery"


// utils
implementation "com.google.guava:guava:${guavaVersion}"
implementation "org.apache.commons:commons-lang3:${lang3Version}"
implementation "org.apache.commons:commons-rng-simple:${rngVersion}"

}

allprojects {

apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"
apply plugin: "com.diffplug.spotless"
apply plugin: "io.freefair.lombok"
apply plugin: "me.qoomon.git-versioning"

group "io.ghrc"

configurations {
compileOnly {
extendsFrom annotationProcessor
}
all*.exclude module: "spring-boot-starter-logging"
}

repositories {
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url "https://maven.aliyun.com/nexus/content/repositories/jcenter" }
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/heliannuuthus/${project.name}"
credentials {
username = rootProject.findProperty("gpr.user") ?: System.getenv("GPR_USER")
password = rootProject.findProperty("gpr.token") ?: System.getenv("GPR_TOKEN")
}
}
mavenCentral()
}

tasks.named("test") {
useJUnitPlatform()
}

dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${bootVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${cloudVersion}"
mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:${alibabaCloudVersion}"
}
}

spotless {
java {
importOrder()
removeUnusedImports()
googleJavaFormat("${spotlessVersion}").groupArtifact("com.google.googlejavaformat:google-java-format")
formatAnnotations()
}
}
}

bootJar {
archiveFileName = "app.${archiveExtension.get()}"
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = 'helianthus-annuus-blog'
version = "0.0.1-SNAPSHOT"
group=io.ghrc
version=0.1.0
Empty file modified gradlew
100644 → 100755
Empty file.
92 changes: 92 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
15 changes: 0 additions & 15 deletions src/main/java/io/ghcr/heliannuuthus/blog/BlogApplication.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.ghcr.heliannuuthus.devtools;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@EnableApolloConfig
@SpringBootApplication
public class RuntimeApplication {

public static void main(String[] args) {
// https://docs.spring.io/spring-boot/docs/2.1.5.RELEASE/reference/html/using-boot-devtools.html#using-boot-devtools-restart-disable
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuntimeApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.ghcr.heliannuuthus.devtools.config;

import io.ghcr.heliannuuthus.devtools.properties.KeyProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

@EnableConfigurationProperties(KeyProperties.class)
public class PropertiesConfiguration {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.ghcr.heliannuuthus.devtools.config;

import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SecuredConfiguration {
static {
Security.addProvider(new BouncyCastleProvider());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.ghcr.heliannuuthus.devtools.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@Slf4j
@RestController
@RequestMapping("/keys")
public class KeysController {

@GetMapping("/asymmetric")
public Mono<String> asymmetricKey() {
return Mono.just("");
}

@GetMapping("/symmetric")
public Mono<String> symmetricKey() {
return Mono.just("");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.ghcr.heliannuuthus.devtools.crypto.algorithms;

public interface OamAlgorithm {

String AES_ALGORITHM = "AES";
String RSA_ALGORITHM = "RSA";

String getAlgorithm();
}
Loading
Loading