User authentication in Java using the IMAP or SMTP protocols

Recently, a couple of students have asked me the same question:

“I need to authenticate users (other students) in my diploma thesis application with their faculty credentials. Is there a way to do this?”

The faculty student server (i.e. www.scs.ubbcluj.ro) offers two public services: IMAP (on TCP port 993) and SMTP (on TCP port 465). You can use either of these two services to authenticate a user. Just be sure you have the JavaMail jar in your classpath. Since April 2017 the JavaMail API is available as an open source project on GitHub.

Here is a sample piece of code, just pass the username and the password as command line parameters.

Darius Bufnea