Class RandomIdentifierGenerationStrategy
java.lang.Object
net.shibboleth.shared.security.impl.RandomIdentifierGenerationStrategy
- All Implemented Interfaces:
IdentifierGenerationStrategy
- Direct Known Subclasses:
SecureRandomIdentifierGenerationStrategy
@ThreadSafe
public class RandomIdentifierGenerationStrategy
extends Object
implements IdentifierGenerationStrategy
Generates a random number of bytes via a
Random source and encodes them into a string using a
BinaryEncoder (Hex by default).-
Nested Class Summary
Nested classes/interfaces inherited from interface net.shibboleth.shared.security.IdentifierGenerationStrategy
IdentifierGenerationStrategy.ParameterSpec, IdentifierGenerationStrategy.ProviderType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.commons.codec.BinaryEncoderEncoder used to convert the random bytes in to a string.private final RandomGeneratorRandom number generator.private final intNumber of random bytes in the identifier. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGenerates an identifier guaranteed to be XML ID safe.generateIdentifier(boolean xmlSafe) Generates an identifier.
-
Field Details
-
random
Random number generator. -
sizeOfIdentifier
private final int sizeOfIdentifierNumber of random bytes in the identifier. -
encoder
@Nonnull private final org.apache.commons.codec.BinaryEncoder encoderEncoder used to convert the random bytes in to a string.
-
-
Constructor Details
-
RandomIdentifierGenerationStrategy
public RandomIdentifierGenerationStrategy()Default constructor.Initializes the random number source to a new
SecureRandom, size of identifier is set to 16 bytes, and the encoder is set to aHex.
-
-
Method Details
-
generateIdentifier
Generates an identifier guaranteed to be XML ID safe.- Specified by:
generateIdentifierin interfaceIdentifierGenerationStrategy- Returns:
- the identifier
-
generateIdentifier
Generates an identifier.- Specified by:
generateIdentifierin interfaceIdentifierGenerationStrategy- Parameters:
xmlSafe- true iff the result must be XML ID safe- Returns:
- the identifier
-