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

[DO NOT MERGE] test github actions #517

Closed
wants to merge 6 commits into from
Closed
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
23 changes: 18 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,30 @@ jobs:
- name: Check style
run: ./gradlew checkstyleMain checkstyleTest

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build jacocoTestReport sonar --info
- name: Build
id: build_jar
run: |
./gradlew build --info
echo current_version=$(echo $(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')) >> $GITHUB_OUTPUT

- name: Publish test report
if: always()
uses: mikepenz/action-junit-report@v5
with:
report_paths: '**/build/test-results/test/TEST-*.xml'

- name: Upload
uses: actions/upload-artifact@v4
with:
name: ns4kafka
path: ${{ github.workspace }}/build/libs/ns4kafka-${{ steps.build_jar.outputs.current_version }}.jar

- name: Sonar
if: github.event.pull_request.head.repo.fork == false
run: ./gradlew jacocoTestReport sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Docker
run: ./gradlew dockerBuild
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AclNonNamespacedController extends NonNamespacedResourceController
AclService aclService;

/**
* List ACLs.
* List all ACLs.
*
* @return A list of ACLs
*/
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/com/michelin/ns4kafka/util/EncryptionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.nimbusds.jose.JWEHeader;
import com.nimbusds.jose.crypto.AESDecrypter;
import com.nimbusds.jose.crypto.AESEncrypter;
import com.nimbusds.jose.crypto.impl.AAD;
import com.nimbusds.jose.util.Base64URL;
import io.micronaut.core.util.StringUtils;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -86,10 +87,13 @@ public static String encryptAes256Gcm(String clearText, String key) {
return clearText;
}

JWEHeader header = new JWEHeader(JWEAlgorithm.A256KW, EncryptionMethod.A256GCM);
AESEncrypter encrypter = new AESEncrypter(key.getBytes(StandardCharsets.UTF_8));
JWECryptoParts encryptedData =
encrypter.encrypt(new JWEHeader(JWEAlgorithm.A256KW, EncryptionMethod.A256GCM),
clearText.getBytes(StandardCharsets.UTF_8));
JWECryptoParts encryptedData = encrypter.encrypt(
header,
clearText.getBytes(StandardCharsets.UTF_8),
AAD.compute(header)
);

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.write(encryptedData.getEncryptedKey().decode());
Expand Down Expand Up @@ -126,8 +130,8 @@ public static String decryptAes256Gcm(String encryptedText, String key) {
Base64URL auth = Base64URL.encode(Arrays.copyOfRange(encryptedData, 52, 68));
Base64URL text = Base64URL.encode(Arrays.copyOfRange(encryptedData, 68, encryptedData.length));

byte[] clearTextAsBytes = decrypter.decrypt(new JWEHeader(JWEAlgorithm.A256KW, EncryptionMethod.A256GCM),
encryptedKey, iv, text, auth);
JWEHeader header = new JWEHeader(JWEAlgorithm.A256KW, EncryptionMethod.A256GCM);
byte[] clearTextAsBytes = decrypter.decrypt(header, encryptedKey, iv, text, auth, AAD.compute(header));

return new String(clearTextAsBytes);
} catch (JOSEException e) {
Expand Down
Loading