-
Notifications
You must be signed in to change notification settings - Fork 0
Enhancement/encrypt ssn #80
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a8770ec
Add encryption configuration and service: implement TextEncryptor bea…
codebyNorthsteep 0931c4f
Enhance EncryptionService: add encrypt, decrypt, and maskLastFour met…
codebyNorthsteep 97727e2
Move key-values to .env file
codebyNorthsteep 76fd830
Integrate EncryptionService into EmploymentFormService and StaffServi…
codebyNorthsteep ee96fcb
Add encryption for SSNs in EmploymentForm and update related services…
codebyNorthsteep 3e15602
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep a4694ba
Add `@ActiveProfiles("test")` to security tests and improve HR access…
codebyNorthsteep 0b2b5c1
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep 243ebcd
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep 5f198ad
Enhance SSN handling: update staff retrieval methods to improve secur…
codebyNorthsteep 37b531d
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep b6de479
Enhance SSN handling: update staff retrieval methods to improve secur…
codebyNorthsteep 1fba67b
Enhance SSN handling: update staff retrieval methods to improve secur…
codebyNorthsteep 27722a0
Enhance SSN handling: refactor employment form creation and update me…
codebyNorthsteep 20b3179
Enhance SSN handling: refactor employment form creation and update me…
codebyNorthsteep ec2696f
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep d9ff110
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep 95fc28f
Refactor EmploymentFormController to simplify staff type checking
codebyNorthsteep b997563
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep 70d8635
Refactor EmploymentFormController and StaffService to use @Authentica…
codebyNorthsteep 6c47873
Enhance SecurityIntegrationTests to include authentication for HR rol…
codebyNorthsteep 3a3f38f
Merge branch 'main' into enhancement/encryptSSN
codebyNorthsteep 8cc701b
Refactor EmploymentFormController logging and improve SSN masking log…
codebyNorthsteep ec8d40b
Update exception message in StaffService to clarify input validation …
codebyNorthsteep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/org/example/cyberwatch/config/EncryptionConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.example.cyberwatch.config; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.security.crypto.encrypt.Encryptors; | ||
| import org.springframework.security.crypto.encrypt.TextEncryptor; | ||
|
|
||
| @Configuration | ||
| public class EncryptionConfig { | ||
|
|
||
| @Value("${app.encryption.key}") | ||
| private String encryptionKey; | ||
|
|
||
| @Value("${app.encryption.salt}") | ||
| private String salt; | ||
|
|
||
| @Bean | ||
| public TextEncryptor textEncryptor() { | ||
| return Encryptors.text(encryptionKey, salt); | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
src/main/java/org/example/cyberwatch/config/security/EncryptionService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package org.example.cyberwatch.config.security; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.security.crypto.encrypt.TextEncryptor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class EncryptionService { | ||
|
|
||
| private final TextEncryptor textEncryptor; | ||
|
|
||
| public String encrypt(String data) { | ||
| return textEncryptor.encrypt(data); | ||
| } | ||
|
|
||
| public String decrypt(String data) { | ||
| return textEncryptor.decrypt(data); | ||
| } | ||
|
|
||
| public String maskLastFour(String encrypted) { | ||
| if (encrypted == null || encrypted.isBlank()) { | ||
| return "****"; | ||
| } | ||
| String decrypted = textEncryptor.decrypt(encrypted); | ||
| if (decrypted.length() <= 4) { | ||
| return "****"; | ||
| } | ||
| return decrypted.substring(0, decrypted.length() - 4) + "****"; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.