Class ValueTypeValidator

java.lang.Object
io.getlime.security.powerauth.http.validator.ValueTypeValidator

public class ValueTypeValidator extends Object
Utility class to validate various value types, such as UUID, base64 encoded data, etc.
Author:
Petr Dvorak, petr@wultra.com
  • Constructor Details

    • ValueTypeValidator

      public ValueTypeValidator()
  • Method Details

    • isValidUuid

      public static boolean isValidUuid(String uuidCandidate)
      Check if provided string is a valid UUID.
      Parameters:
      uuidCandidate - UUID candidate.
      Returns:
      True in case provided string is a valid UUID, false otherwise.
    • isValidBase64OfLength

      public static boolean isValidBase64OfLength(String base64candidate, int expectedLength)
      Validate provided string that is expected to be in Base64 encoding. If the string is in Base64 encoding, validate for expected length of decoded bytes.
      Parameters:
      base64candidate - Base64 string candidate.
      expectedLength - Expected length od decoded bytes.
      Returns:
      True in case the provided string are Base64 encoded data of expected byte length, false otherwise.
    • isValidBase64OfLengthRange

      public static boolean isValidBase64OfLengthRange(String base64candidate, int from, int to)
      Validate provided string that is expected to be in Base64 encoding. If the string is in Base64 encoding, validate if expected length of decoded bytes is in range from-to.
      Parameters:
      base64candidate - Base64 string candidate.
      from - Expected minimal length od decoded bytes.
      to - Expected maximal length od decoded bytes.
      Returns:
      True in case the provided string are Base64 encoded data of expected byte length, false otherwise.
    • isValidSignatureType

      public static boolean isValidSignatureType(String signatureType)
      Check if the provided signature type value is valid.
      Parameters:
      signatureType - Signature type candidate.
      Returns:
      True if the provided signature type is valid.
    • isValidSignatureValue

      public static boolean isValidSignatureValue(String signature)
      Validate if the provided signature is of a correct format.
      Parameters:
      signature - Signature candidate.
      Returns:
      True if signature candidate has correct format, false otherwise.
    • isDecimalString

      public static boolean isDecimalString(String decimalString, int from, int to)
      Check if the string is a decimal string of provided length range.
      Parameters:
      decimalString - Decimal string candidate.
      from - Minimal length.
      to - Maximal length.
      Returns:
      True if provided string is decimal and has expected length range.
    • isValidProtocolVersion

      public static boolean isValidProtocolVersion(String version)
      Check if the provided version is a valid one.
      Parameters:
      version - Version to check.
      Returns:
      True if provided version is valid, false otherwise.