public class RandomIdentifierGenerationStrategy extends Object implements IdentifierGenerationStrategy
Random source and encodes them into a string using a
BinaryEncoder (Hex by default).| Modifier and Type | Field and Description |
|---|---|
private org.apache.commons.codec.BinaryEncoder |
encoder
Encoder used to convert the random bytes in to a string.
|
private Random |
random
Random number generator.
|
private int |
sizeOfIdentifier
Number of random bytes in the identifier.
|
| Constructor and Description |
|---|
RandomIdentifierGenerationStrategy()
Constructor.
|
RandomIdentifierGenerationStrategy(int identifierSize)
Constructor.
|
RandomIdentifierGenerationStrategy(Random source,
int identifierSize,
org.apache.commons.codec.BinaryEncoder identifierEncoder)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
generateIdentifier()
Generates an identifier guaranteed to be XML ID safe.
|
String |
generateIdentifier(boolean xmlSafe)
Generates an identifier.
|
private final Random random
private final int sizeOfIdentifier
private final org.apache.commons.codec.BinaryEncoder encoder
public RandomIdentifierGenerationStrategy()
SecureRandom, size of identifier is set to 16
bytes, and the encoder is set to a Hex.public RandomIdentifierGenerationStrategy(int identifierSize)
SecureRandom and the encoder is set to a
Hex.identifierSize - number of random bytes in identifierpublic RandomIdentifierGenerationStrategy(@Nonnull Random source, int identifierSize, @Nonnull org.apache.commons.codec.BinaryEncoder identifierEncoder)
source - source of random bytesidentifierSize - number of random bytes in the identifieridentifierEncoder - encoder used to convert random bytes to string identifier@Nonnull public String generateIdentifier()
generateIdentifier in interface IdentifierGenerationStrategypublic String generateIdentifier(boolean xmlSafe)
generateIdentifier in interface IdentifierGenerationStrategyxmlSafe - true iff the result must be XML ID safeCopyright © 1999–2016 Shibboleth Consortium. All rights reserved.