Class Credentials

java.lang.Object
ch.bztf.m226blb1.Auth.Credentials

public class Credentials extends Object
The class for validating parameters and creating API-Keys.
  • Method Details

    • generateApiKey

      public static String generateApiKey(@NonNull @NonNull AuthAccount account)
      Creates an API-key for the given account.
      Parameters:
      account - the account to create the API key for.
      Returns:
      an API-Key generated with the given email, password and the current time
      See Also:
      • SHA-512 hasher
    • validateApiKey

      public static void validateApiKey(String apiKey) throws javax.validation.ValidationException
      Validates if the api key is valid.
      Parameters:
      apiKey - the api key to validate
      Throws:
      javax.validation.ValidationException - if the api key is not valid
    • validateCredentials

      public static void validateCredentials(@NonNull @NonNull AuthAccount auth) throws javax.validation.ValidationException
      Validates an Auth-Account for the given email and password.
      Parameters:
      auth - the account to validate
      Throws:
      javax.validation.ValidationException - if the email or the password is not valid
    • extractLimit

      public static int extractLimit(Optional<Integer> limit)
      Extracts and validates the limit to a integer.
      Parameters:
      limit - the limit to extract and validate
      Returns:
      the extracted limit
      API Note:
      The default limit is 10.
    • containsNumber

      public static boolean containsNumber(@Nullable String value)
      Checks if the string contains a digit.
      Parameters:
      value - the string to be checked
      Returns:
      true if the string contains a digit
    • isValidUsername

      public static boolean isValidUsername(@Nullable String username)
      Checks if the username is valid.
      Parameters:
      username - the username to be checked
      Returns:
      true if the username is valid