In Java SE its easy to support the authentication part with such code :
Session session = session.getInstance(props,new MyAuthenticator());
But in Java EE the session instance is not created by the application, but its supplied by JNDI injection by the application server in the application.
@Resource(name = "mail/JMsession")
private Session session
How to handle the authentication part here? What about the authenticationType argument in the @Resource annotation
@Resource(name = "mail/JMsession", authenticationType = AuthenticationType.APPLICATION)