Class ConsolePasswordFinder

  • All Implemented Interfaces:
    PasswordFinder

    public class ConsolePasswordFinder
    extends java.lang.Object
    implements PasswordFinder
    A PasswordFinder that reads a password from a console
    • Field Detail

      • console

        private final java.io.Console console
      • promptFormat

        private final java.lang.String promptFormat
      • maxTries

        private final int maxTries
      • numTries

        private int numTries
    • Constructor Detail

      • ConsolePasswordFinder

        public ConsolePasswordFinder()
      • ConsolePasswordFinder

        public ConsolePasswordFinder​(java.io.Console console)
      • ConsolePasswordFinder

        public ConsolePasswordFinder​(java.io.Console console,
                                     java.lang.String promptFormat,
                                     int maxTries)
    • Method Detail

      • reqPassword

        public char[] reqPassword​(Resource<?> resource)
        Description copied from interface: PasswordFinder
        Request password for specified resource.

        This method may return null when the request cannot be serviced, e.g. when the user cancels a password prompt.

        Specified by:
        reqPassword in interface PasswordFinder
        Parameters:
        resource - the resource for which password is being requested
        Returns:
        the password or null
      • shouldRetry

        public boolean shouldRetry​(Resource<?> resource)
        Description copied from interface: PasswordFinder
        If password turns out to be incorrect, indicates whether another call to PasswordFinder.reqPassword(Resource) should be made.

        This method is geared at interactive implementations, and stub implementations may simply return false.

        Specified by:
        shouldRetry in interface PasswordFinder
        Parameters:
        resource - the resource for which password is being requested
        Returns:
        whether to retry requesting password for a particular resource
      • checkFormatString

        private static void checkFormatString​(java.lang.String promptFormat)