|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.basedb.core.authentication.POP3Authenticator
public class POP3Authenticator
This class is an example implementation of the Authenticator
interface that authenticates a user against a POP3 server. This means
that all users having an email account on a specified mail server are
able to log in to base using the same username and password as they use
to read their mails.
Example
String host = "mail.thep.lu.se";
String login = "nicklas";
String password = "secret";
Authenticator a = new POP3Authenticator();
a.init(host);
if (a.authenticate(login, password))
{
// Do some stuff that only nicklas is allowed to do!
}
| Field Summary | |
|---|---|
private String |
host
The address or IP-number to the POP3 host. |
private int |
port
The POP3 port to use. |
| Constructor Summary | |
|---|---|
POP3Authenticator()
Create a new POP3Authenticator object. |
|
| Method Summary | |
|---|---|
AuthenticationInformation |
authenticate(String login,
String password)
Authenticates a user against the POP3 server. |
void |
init(String settings)
Initialises the object. |
private String |
send(String cmd,
BufferedWriter out,
BufferedReader in)
Send cmd to the out buffer. |
boolean |
supportsExtraInformation()
Always return FALSE. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private String host
private int port
| Constructor Detail |
|---|
public POP3Authenticator()
POP3Authenticator object.
| Method Detail |
|---|
public void init(String settings)
throws AuthenticationException
settings string should be the address or
IP-number to the POP3 server. Optionally, the name/number may be followed by
a colon (:) and a port number. For example: pop.yourdomain.com
or pop.yourdomain.com:110
init in interface Authenticatorsettings - The host name with an optional port number
AuthenticationException - This exception is thrown if the format
of the settings string is invalid. No check is made that
the host actually exists and answers at the specified port.public boolean supportsExtraInformation()
supportsExtraInformation in interface AuthenticatorAuthenticationInformation,
Authenticator.authenticate(String,String)
public AuthenticationInformation authenticate(String login,
String password)
throws UnknownLoginException,
InvalidPasswordException,
AuthenticationException
authenticate in interface Authenticatorlogin - The login name of the userpassword - The password for the user
AuthenticationInformation
object. The id is the same as
the login. No extra information
is returned.
UnknownLoginException - This exception may be thrown if the
server doesn't know about the user. It is also possible for an
implmentation to throw an AuthenticationException
InvalidPasswordException - This exception may be thrown if the
password is invalid. It is also possible for an implementation to throw
an AuthenticationException
AuthenticationException - This exception is thrown if the
authentication fails
private String send(String cmd,
BufferedWriter out,
BufferedReader in)
throws Exception
cmd to the out buffer. Read a single line
of response from the in buffer.
Exception
|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||