-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provider/kafka): add new resource KafkaUser (#391)
Fix: #391
- Loading branch information
1 parent
2e8db24
commit 015af5b
Showing
35 changed files
with
1,575 additions
and
89 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
68 changes: 68 additions & 0 deletions
68
core/src/main/java/io/streamthoughts/jikkou/common/utils/SecurePasswordGenerator.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,68 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) The original authors | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.streamthoughts.jikkou.common.utils; | ||
|
||
import java.security.SecureRandom; | ||
|
||
/** | ||
* Service interface for generating secure passwords. | ||
*/ | ||
public interface SecurePasswordGenerator { | ||
|
||
/** | ||
* Generates a random secure password of the given length. | ||
* | ||
* @param length The length of the password to generate. | ||
* @return a secure random generated password. | ||
*/ | ||
String generate(int length); | ||
|
||
static SecurePasswordGenerator getDefault() { | ||
return new DefaultSecurePasswordGenerator(); | ||
} | ||
|
||
/** | ||
* Default implementation for {@link SecurePasswordGenerator}. | ||
*/ | ||
class DefaultSecurePasswordGenerator implements SecurePasswordGenerator { | ||
// Character sets to use in generated passwords | ||
private static final String LOWERCASE_LETTERS = "abcdefghijklmnopqrstuvwxyz"; | ||
private static final String UPPERCASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
private static final String DIGITS = "0123456789"; | ||
private static final String SPECIAL_CHARACTERS = "!@#$%^&*()-_=+?/~"; | ||
private static final String ALL_CHARACTERS = LOWERCASE_LETTERS + UPPERCASE_LETTERS + DIGITS + SPECIAL_CHARACTERS; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String generate(int length) { | ||
SecureRandom random = new SecureRandom(); | ||
StringBuilder password = new StringBuilder(length); | ||
|
||
// Ensure the password has at least one character from each character set | ||
password.append(LOWERCASE_LETTERS.charAt(random.nextInt(LOWERCASE_LETTERS.length()))); | ||
password.append(UPPERCASE_LETTERS.charAt(random.nextInt(UPPERCASE_LETTERS.length()))); | ||
password.append(DIGITS.charAt(random.nextInt(DIGITS.length()))); | ||
password.append(SPECIAL_CHARACTERS.charAt(random.nextInt(SPECIAL_CHARACTERS.length()))); | ||
|
||
// Fill the rest of the password length with random characters from all character sets | ||
for (int i = 4; i < length; i++) { | ||
password.append(ALL_CHARACTERS.charAt(random.nextInt(ALL_CHARACTERS.length()))); | ||
} | ||
|
||
// Shuffle the characters to ensure randomness | ||
for (int i = password.length() - 1; i > 0; i--) { | ||
int index = random.nextInt(i + 1); | ||
char temp = password.charAt(index); | ||
password.setCharAt(index, password.charAt(i)); | ||
password.setCharAt(i, temp); | ||
} | ||
return password.toString(); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/main/java/io/streamthoughts/jikkou/core/exceptions/InterruptedException.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,18 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) The original authors | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.streamthoughts.jikkou.core.exceptions; | ||
|
||
/** | ||
* An unchecked wrapper for {@link java.lang.InterruptedException} | ||
*/ | ||
public class InterruptedException extends JikkouRuntimeException { | ||
|
||
public InterruptedException(java.lang.InterruptedException cause) { | ||
super(cause); | ||
Thread.currentThread().interrupt(); | ||
} | ||
} |
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
45 changes: 0 additions & 45 deletions
45
core/src/main/java/io/streamthoughts/jikkou/core/models/AbstractHasMetadata.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.