java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.PhoneDtoMapper

@Component public class PhoneDtoMapper extends Object
Maps the results of the phone use cases onto the DTOs generated from the contract. The number is never shown whole: only its last digits are.
  • Field Details

    • VISIBLE_DIGITS

      static final int VISIBLE_DIGITS
      Number of trailing digits of the number that are shown.
      See Also:
    • HIDDEN_DIGIT

      static final char HIDDEN_DIGIT
      Character that replaces a hidden digit.
      See Also:
  • Constructor Details

    • PhoneDtoMapper

      public PhoneDtoMapper()
  • Method Details

    • toResponse

      public PhoneResponse toResponse(UserPhone phone)
      Maps a verified phone.
      Parameters:
      phone - the verified phone.
      Returns:
      the phone with its number masked, such as +*******1222.
    • toResponse

      public PhoneEnrolmentResponse toResponse(PhoneEnrolmentStarted started)
      Maps a started enrolment.
      Parameters:
      started - the started enrolment.
      Returns:
      the answer, with how long the code stays valid.
    • mask

      private static String mask(String e164)
      Hides every digit of an E.164 number but the last ones, keeping the + and the length.
      Parameters:
      e164 - the number.
      Returns:
      the masked number.