3434import org .slf4j .Logger ;
3535import org .slf4j .LoggerFactory ;
3636
37+ import com .ecyrd .speed4j .StopWatch ;
3738import com .elasticinbox .core .account .authenticator .AuthenticationException ;
3839import com .elasticinbox .core .account .authenticator .AuthenticatorFactory ;
3940import com .elasticinbox .core .account .authenticator .IAuthenticator ;
4041import com .elasticinbox .core .account .validator .IValidator ;
4142import com .elasticinbox .core .account .validator .ValidatorFactory ;
4243import com .elasticinbox .core .account .validator .IValidator .AccountStatus ;
4344import com .elasticinbox .core .model .Mailbox ;
45+ import com .elasticinbox .pop3 .Activator ;
4446
4547/**
4648 * POP3 Authentication Handler (AUTH)
@@ -69,6 +71,8 @@ protected org.apache.james.protocols.pop3.mailbox.Mailbox auth(POP3Session sessi
6971 logger .debug ("POP3: Authenticating session {}, user {}, pass {}" ,
7072 new Object [] { session .getSessionID (), username , password });
7173
74+ StopWatch stopWatch = Activator .getDefault ().getStopWatch ();
75+
7276 try {
7377 // authenticate mailbox, if failed return null
7478 AccountStatus status = validator .getAccountStatus (username );
@@ -81,12 +85,16 @@ protected org.apache.james.protocols.pop3.mailbox.Mailbox auth(POP3Session sessi
8185 // authenticate user with password
8286 mailbox = authenticator .authenticate (username , password );
8387
88+ stopWatch .stop ("AUTH.success" );
89+
8490 // return POP3 handler for mailbox
8591 return backend .getMailboxHander (mailbox );
8692 } catch (IllegalArgumentException iae ) {
93+ stopWatch .stop ("AUTH.fail" );
8794 logger .debug ("POP3 Authentication failed. Invalid username [{}]: {}" , username , iae .getMessage ());
8895 return null ;
8996 } catch (AuthenticationException ae ) {
97+ stopWatch .stop ("AUTH.fail" );
9098 logger .debug ("POP3 Authentication failed. Invalid username [{}] or password [{}]" , username , password );
9199 return null ;
92100 }
0 commit comments