MCPcopy Create free account
hub / github.com/M66B/FairEmail / login

Method login

app/src/main/java/com/sun/mail/pop3/Protocol.java:343–392  ·  view source on GitHub ↗

Login to the server, using the USER and PASS commands.

(String user, String password)

Source from the content-addressed store, hash-verified

341 * Login to the server, using the USER and PASS commands.
342 */
343 synchronized String login(String user, String password)
344 throws IOException {
345 Response r;
346 // only pipeline password if connection is secure
347 boolean batch = pipelining && socket instanceof SSLSocket;
348
349 try {
350
351 if (noauthdebug && isTracing()) {
352 logger.fine("authentication command trace suppressed");
353 suspendTracing();
354 }
355 String dpw = null;
356 if (apopChallenge != null)
357 dpw = getDigest(password);
358 if (apopChallenge != null && dpw != null) {
359 r = simpleCommand("APOP " + user + " " + dpw);
360 } else if (batch) {
361 String cmd = "USER " + user;
362 batchCommandStart(cmd);
363 issueCommand(cmd);
364 cmd = "PASS " + password;
365 batchCommandContinue(cmd);
366 issueCommand(cmd);
367 r = readResponse();
368 if (!r.ok) {
369 String err = r.data != null ? r.data : "USER command failed";
370 readResponse(); // read and ignore PASS response
371 batchCommandEnd();
372 return err;
373 }
374 r = readResponse();
375 batchCommandEnd();
376 } else {
377 r = simpleCommand("USER " + user);
378 if (!r.ok)
379 return r.data != null ? r.data : "USER command failed";
380 r = simpleCommand("PASS " + password);
381 }
382 if (noauthdebug && isTracing())
383 logger.log(Level.FINE, "authentication command {0}",
384 (r.ok ? "succeeded" : "failed"));
385 if (!r.ok)
386 return r.data != null ? r.data : "login failed";
387 return null;
388
389 } finally {
390 resumeTracing();
391 }
392 }
393
394 /**
395 * Gets the APOP message digest.

Callers 1

authenticateMethod · 0.45

Calls 12

isTracingMethod · 0.95
suspendTracingMethod · 0.95
getDigestMethod · 0.95
simpleCommandMethod · 0.95
batchCommandStartMethod · 0.95
issueCommandMethod · 0.95
batchCommandContinueMethod · 0.95
readResponseMethod · 0.95
batchCommandEndMethod · 0.95
resumeTracingMethod · 0.95
fineMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected