Package org.moera.lib
Class Rules
java.lang.Object
org.moera.lib.Rules
The Rules class provides constants and utility methods for validating specific constraints used within the library.
It defines limits, algorithms, and validation logic for various properties and ensures compliance with
predetermined rules.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Specifies the cryptographic hash algorithm used for generating digests.static final int
Defines the standard length, in bytes, of a cryptographic digest produced by the specified digest algorithm.static final String
Represents the elliptic curve used for cryptographic operations.static final int
Specifies the maximum length allowed for a node name.static final String
A constant defining the set of punctuation characters that are allowed in node names during validation.static final int
Defines the maximum allowable length for a node URI.static final int
Defines the maximum number of items allowed in a single page for pagination or listing operations.static final int
Defines the length of a private key in bytes.static final int
Defines the length of a public key in bytes.static final String
Specifies the signature algorithm used for cryptographic operations.static final int
Defines the maximum length in bytes for digital signatures.static final Duration
Defines the maximum age of a cryptographic signature that can be revoked by changing the signing key with its retroactive activation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isNameCharacterValid
(char c) Determines whether a given character is valid for use in a node name based on specific rules.static boolean
isNameValid
(String name) Validates if the provided node name is valid based on specific rules.
-
Field Details
-
NAME_MAX_LENGTH
public static final int NAME_MAX_LENGTHSpecifies the maximum length allowed for a node name.- See Also:
-
NAME_PUNCTUATION_ALLOWED
A constant defining the set of punctuation characters that are allowed in node names during validation.- See Also:
-
EC_CURVE
Represents the elliptic curve used for cryptographic operations.- See Also:
-
PRIVATE_KEY_LENGTH
public static final int PRIVATE_KEY_LENGTHDefines the length of a private key in bytes.- See Also:
-
PUBLIC_KEY_LENGTH
public static final int PUBLIC_KEY_LENGTHDefines the length of a public key in bytes.- See Also:
-
NODE_URI_MAX_LENGTH
public static final int NODE_URI_MAX_LENGTHDefines the maximum allowable length for a node URI.- See Also:
-
VALID_FROM_IN_PAST
Defines the maximum age of a cryptographic signature that can be revoked by changing the signing key with its retroactive activation. -
DIGEST_ALGORITHM
Specifies the cryptographic hash algorithm used for generating digests.- See Also:
-
DIGEST_LENGTH
public static final int DIGEST_LENGTHDefines the standard length, in bytes, of a cryptographic digest produced by the specified digest algorithm.- See Also:
-
SIGNATURE_ALGORITHM
Specifies the signature algorithm used for cryptographic operations.- See Also:
-
SIGNATURE_MAX_LENGTH
public static final int SIGNATURE_MAX_LENGTHDefines the maximum length in bytes for digital signatures.- See Also:
-
PAGE_MAX_SIZE
public static final int PAGE_MAX_SIZEDefines the maximum number of items allowed in a single page for pagination or listing operations. This constant helps enforce limits when retrieving or displaying data in chunks, ensuring consistent and efficient handling of large datasets.- See Also:
-
-
Constructor Details
-
Rules
public Rules()
-
-
Method Details
-
isNameValid
Validates if the provided node name is valid based on specific rules. The name must not benull
or empty. It must also meet conditions such as a minimum length and absence of prohibited characters.- Parameters:
name
- the name to be validated- Returns:
true
if the name is valid, according to the rules;false
otherwise
-
isNameCharacterValid
public static boolean isNameCharacterValid(char c) Determines whether a given character is valid for use in a node name based on specific rules. The validation allows only certain types of characters, including letters, numbers, currency symbols, and a subset of punctuation (seeNAME_PUNCTUATION_ALLOWED
).- Parameters:
c
- the character to be validated- Returns:
true
if the character is valid for use in a name;false
otherwise
-