-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [issue/#7] Omit keycloak import run if checksum is same * [issue/#7] Provide opt-in mechanism to force imports
- Loading branch information
1 parent
418334e
commit eb69e19
Showing
9 changed files
with
227 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
35 changes: 35 additions & 0 deletions
35
config-cli/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java
This file contains 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,35 @@ | ||
package de.adorsys.keycloak.config.service.checksum; | ||
|
||
import org.bouncycastle.jcajce.provider.digest.SHA3; | ||
import org.bouncycastle.util.encoders.Hex; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.security.MessageDigest; | ||
|
||
@Service | ||
public class ChecksumService { | ||
|
||
private MessageDigest digest = new SHA3.Digest512(); | ||
|
||
public String checksum(String text) { | ||
if (text == null) { | ||
throw new IllegalArgumentException("Cannot calculate checksum of null"); | ||
} | ||
|
||
byte[] textInBytes = text.getBytes(); | ||
return calculateSha3Checksum(textInBytes); | ||
} | ||
|
||
public String checksum(byte[] textInBytes) { | ||
if (textInBytes == null) { | ||
throw new IllegalArgumentException("Cannot calculate checksum of null"); | ||
} | ||
|
||
return calculateSha3Checksum(textInBytes); | ||
} | ||
|
||
private String calculateSha3Checksum(byte[] textInBytes) { | ||
byte[] shaInBytes = this.digest.digest(textInBytes); | ||
return Hex.toHexString(shaInBytes); | ||
} | ||
} |
This file contains 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.