use of es.gob.jmulticard.ui.passwordcallback.NoConsoleException in project jmulticard by ctt-gob-es.
the class ConsolePasswordCallback method getPassword.
/**
* {@inheritDoc}
*/
@Override
public char[] getPassword() {
Console console = System.console();
if (console == null) {
// $NON-NLS-1$
throw new NoConsoleException("No hay consola para solicitar el PIN");
}
// $NON-NLS-1$
final char[] password = console.readPassword(removeHTML(this.prompt) + ":\n");
if (password == null) {
throw new CancelledOperationException(// $NON-NLS-1$
"Se ha cancelado la introduccion de PIN en consola");
}
if (password.length < 8 || password.length > 16) {
// $NON-NLS-1$ //$NON-NLS-2$
console.printf(Messages.getString("ConsolePasswordCallback.1") + "\n");
for (int i = 0; i < password.length; i++) {
password[i] = '\0';
}
return getPassword();
}
console.flush();
console = null;
return password;
}
Aggregations