-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support cookies Signed-off-by: Joshua Castle <[email protected]> * Address existing GH reviews - Add RAK_SEND_COOKIE to DefaultRakServerConfig#getOptions() - Consolidate RakClientOfflineHandler#sendOpenConnectionRequest2 to single method - Combine pendingConnections ExpiringMap Signed-off-by: GitHub <[email protected]> * Remove unused packages Signed-off-by: Joshua Castle <[email protected]> * Create provider for preferred SecureRandom algorithm Signed-off-by: Joshua Castle <[email protected]> * preferredAlgorithms in block * Why we should not do web edits Signed-off-by: Joshua Castle <[email protected]> --------- Signed-off-by: Joshua Castle <[email protected]> Signed-off-by: GitHub <[email protected]>
- Loading branch information
Showing
10 changed files
with
192 additions
and
41 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
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
37 changes: 37 additions & 0 deletions
37
transport-raknet/src/main/java/org/cloudburstmc/netty/util/SecureAlgorithmProvider.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,37 @@ | ||
package org.cloudburstmc.netty.util; | ||
|
||
import java.security.Provider; | ||
import java.security.SecureRandom; | ||
import java.security.Security; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
public class SecureAlgorithmProvider { | ||
private static final String SECURITY_ALGORITHM; | ||
|
||
static { | ||
// SecureRandom algorithms in order of most preferred to least preferred. | ||
final List<String> preferredAlgorithms = Arrays.asList( | ||
"SHA1PRNG", | ||
"NativePRNGNonBlocking", | ||
"Windows-PRNG", | ||
"NativePRNG", | ||
"PKCS11", | ||
"DRBG", | ||
"NativePRNGBlocking" | ||
); | ||
|
||
SECURITY_ALGORITHM = Stream.of(Security.getProviders()) | ||
.flatMap(provider -> provider.getServices().stream()) | ||
.filter(service -> "SecureRandom".equals(service.getType())) | ||
.map(Provider.Service::getAlgorithm) | ||
.filter(preferredAlgorithms::contains) | ||
.min((s1, s2) -> Integer.compare(preferredAlgorithms.indexOf(s1), preferredAlgorithms.indexOf(s2))) | ||
.orElse(new SecureRandom().getAlgorithm()); | ||
} | ||
|
||
public static String getSecurityAlgorithm() { | ||
return SECURITY_ALGORITHM; | ||
} | ||
} |
Oops, something went wrong.