Class AuthorizationCodeService

java.lang.Object
io.meeds.deeds.service.AuthorizationCodeService

@Component public class AuthorizationCodeService extends Object
  • Constructor Details

  • Method Details

    • init

      @PostConstruct public void init()
    • generateCode

      public void generateCode(String key, String email, Object data) throws IllegalAccessException
      Generates a new Verification Code for a designated key and with protecting a data that will be retrieved only after providing a valid code. The generated code will be held for the designated key until 2 hours at maximum (default value of code valid time). At the period of code valid time, when the user checks more than 'meeds.authorizationCode.maxCodeVerification', then an exception is raised. Same thing, when the user attempts to generate a code more than 'meeds.authorizationCode.maxCodeSending' at the period of code validity, an exception is raised as well to limit the number of emails that a user can send.
      Parameters:
      key - A key to designate the protected data resource with code
      email - email to send to to verify access to data object
      data - data to cache and protect by email code verification mechanism
      Throws:
      IllegalAccessException - when maximum code verification sending is reached or maximum code verification has been reached
    • checkValidity

      public void checkValidity(String key, int code) throws IllegalAccessException
      Checks a code validity for a designated key and throws an exception when any verification condition hasn't been met.
      Parameters:
      key - A key to designate the protected data resource with code
      code - the verification code sent by email to protect access to data object
      Throws:
      IllegalAccessException - when the maximum verification checks has been reached or when the code isn' valid
    • validateAndGetData

      public Object validateAndGetData(String key, int code) throws IllegalAccessException
      Validate the entered code for a designated key and return its associated protected data if valid.
      Parameters:
      key - A key to designate the protected data resource with code
      code - the verification code sent by email to protect access to data object
      Returns:
      the protected data object if the provided code is valid
      Throws:
      IllegalAccessException - when the maximum verification checks has been reached or when the code isn' valid