|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.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 Authenticator
settings
- 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 Authenticator
AuthenticationInformation
,
Authenticator.authenticate(String,String)
public AuthenticationInformation authenticate(String login, String password) throws UnknownLoginException, InvalidPasswordException, AuthenticationException
authenticate
in interface Authenticator
login
- 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 failsprivate 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
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |