Package org.moera.lib

Class Rules

java.lang.Object
org.moera.lib.Rules

public class Rules extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Determines whether a given character is valid for use in a node name based on specific rules.
    static boolean
    Validates if the provided node name is valid based on specific rules.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NAME_MAX_LENGTH

      public static final int NAME_MAX_LENGTH
      Specifies the maximum length allowed for a node name.
      See Also:
    • NAME_PUNCTUATION_ALLOWED

      public static final String NAME_PUNCTUATION_ALLOWED
      A constant defining the set of punctuation characters that are allowed in node names during validation.
      See Also:
    • EC_CURVE

      public static final String EC_CURVE
      Represents the elliptic curve used for cryptographic operations.
      See Also:
    • PRIVATE_KEY_LENGTH

      public static final int PRIVATE_KEY_LENGTH
      Defines the length of a private key in bytes.
      See Also:
    • PUBLIC_KEY_LENGTH

      public static final int PUBLIC_KEY_LENGTH
      Defines the length of a public key in bytes.
      See Also:
    • NODE_URI_MAX_LENGTH

      public static final int NODE_URI_MAX_LENGTH
      Defines the maximum allowable length for a node URI.
      See Also:
    • VALID_FROM_IN_PAST

      public static final Duration 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

      public static final String DIGEST_ALGORITHM
      Specifies the cryptographic hash algorithm used for generating digests.
      See Also:
    • DIGEST_LENGTH

      public static final int DIGEST_LENGTH
      Defines the standard length, in bytes, of a cryptographic digest produced by the specified digest algorithm.
      See Also:
    • SIGNATURE_ALGORITHM

      public static final String SIGNATURE_ALGORITHM
      Specifies the signature algorithm used for cryptographic operations.
      See Also:
    • SIGNATURE_MAX_LENGTH

      public static final int SIGNATURE_MAX_LENGTH
      Defines the maximum length in bytes for digital signatures.
      See Also:
    • PAGE_MAX_SIZE

      public static final int PAGE_MAX_SIZE
      Defines 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

      public static boolean isNameValid(String name)
      Validates if the provided node name is valid based on specific rules. The name must not be null 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 (see NAME_PUNCTUATION_ALLOWED).
      Parameters:
      c - the character to be validated
      Returns:
      true if the character is valid for use in a name; false otherwise