Package uk.ac.starlink.table.jdbc
Class TerminalAuthenticator
- java.lang.Object
-
- uk.ac.starlink.table.jdbc.TerminalAuthenticator
-
- All Implemented Interfaces:
JDBCAuthenticator
public class TerminalAuthenticator extends java.lang.Object implements JDBCAuthenticator
Provides JDBC authentication using the terminal; assumes that someone is sitting at System.in.
-
-
Constructor Summary
Constructors Constructor Description TerminalAuthenticator()Constructs a new authenticator which uses System.err for prompting.TerminalAuthenticator(java.io.PrintStream promptStrm)Constructs a new authenticator with a given stream to use for writing prompts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]authenticate()Obtains username and password.java.lang.StringreadPassword()Prompts to the prompt stream and reads the password from standard input.java.lang.StringreadUser()Prompts to the prompt stream and reads the user name from standard input.
-
-
-
Constructor Detail
-
TerminalAuthenticator
public TerminalAuthenticator(java.io.PrintStream promptStrm)
Constructs a new authenticator with a given stream to use for writing prompts.- Parameters:
promptStrm- output stream for prompting
-
TerminalAuthenticator
public TerminalAuthenticator()
Constructs a new authenticator which uses System.err for prompting.
-
-
Method Detail
-
authenticate
public java.lang.String[] authenticate() throws java.io.IOExceptionDescription copied from interface:JDBCAuthenticatorObtains username and password. The return value is a two-element array containing the username and password to be used, in that order. Either or both of these may be null.- Specified by:
authenticatein interfaceJDBCAuthenticator- Returns:
- String[]{username,password}
- Throws:
java.io.IOException- if there is some error
-
readUser
public java.lang.String readUser() throws java.io.IOExceptionPrompts to the prompt stream and reads the user name from standard input.- Returns:
- user name obtained from user
- Throws:
java.io.IOException
-
readPassword
public java.lang.String readPassword() throws java.io.IOExceptionPrompts to the prompt stream and reads the password from standard input.- Returns:
- password obtained from user
- Throws:
java.io.IOException
-
-