Package javax.mail

Examples of javax.mail.Authenticator


   *
     * @return The {@link javax.mail.Session}.
   * @throws IOException
     */
    private Session initMailServerSession(final String host, final int port, final String username, final String password, final boolean auth) throws IOException {
        Authenticator authenticator = null;
       
        if (!Util.isNullString(username)) {
            String pw = password ;
            if (PasswordUtil.isPasswordFile(password))
            {
View Full Code Here


  /**
   * Initialise an authenticated {@link javax.mail.Session} with the mail server.
   * @return The {@link javax.mail.Session}.
   */
  private Session initMailServerSession() {
    Authenticator oAuth = null;
    String sSmtpUser = Configuration.getSmtpUsername();
   
    if (! Util.isNullString(sSmtpUser)) {
      oAuth = new MyAuth(sSmtpUser, Configuration.getSmtpPassword());     
    }
View Full Code Here

            // Aside, the JDK is clearly unaware of the Scottish
            // 'session', which involves excessive quantities of
            // alcohol :-)
            Session sesh;
            Authenticator auth = null;
            if (SSL) {
                try {
                    Provider p = (Provider) Class.forName(
                        "com.sun.net.ssl.internal.ssl.Provider").newInstance();
                    Security.addProvider(p);
View Full Code Here

   
    try {
      if (getInit() != null)
        getInit().configure(this);

      Authenticator auth = _auth;

      if (auth == null && _user != null && _password != null)
        auth = new StandardAuthenticator(_user, _password);

      if (auth != null)
View Full Code Here

        // create some properties and get the default Session
        Properties props = new Properties();

        props.put(MAIL_SMTP_HOST, smtpHost);
        props.put(MAIL_SMTP_PORT, smtpPort); // property values are strings
        Authenticator authenticator = null;
        if(mailAuthType != MailAuthType.NONE) {
            props.put(MAIL_SMTP_AUTH, "true");
            switch (mailAuthType) {
                case SSL:
                    props.put(MAIL_SMTP_SOCKETFACTORY_CLASS,
View Full Code Here

                if (smtpUsername != null) {
                    smtpProps.put("mail.smtps.user", smtpUsername);
                }

                if ((smtpUsername != null) && (smtpPassword != null)) {
                    _smtpSession = Session.getInstance(smtpProps, new Authenticator() {
                        @Override
                        protected PasswordAuthentication getPasswordAuthentication() {
                            return new PasswordAuthentication(smtpUsername, smtpPassword);
                        }
                    });
View Full Code Here

                if (smtpUsername != null) {
                    smtpProps.put("mail.smtps.user", smtpUsername);
                }

                if ((smtpUsername != null) && (smtpPassword != null)) {
                    _smtpSession = Session.getInstance(smtpProps, new Authenticator() {
                        @Override
                        protected PasswordAuthentication getPasswordAuthentication() {
                            return new PasswordAuthentication(smtpUsername, smtpPassword);
                        }
                    });
View Full Code Here

                final String[] addresses = _to.split(";");
                this.addAddresses(addresses);
            }

            // Create a mail session
            final Authenticator auth;
            final Properties props = new java.util.Properties();
            props.put("mail.smtp.host", _smtpHost);
            props.put("mail.smtp.port", "" + _smtpPort);
            if (null != _user && _user.length() > 0) {
                props.put("mail.smtp.auth", "true");
View Full Code Here

        try {
            final Properties props = new Properties();
            props.put("mail.smtp.host", config.getSmtpHost());
            props.put("mail.smtp.port", Integer.toString(config.getSmtpPort()));
            final Session session = Session.getDefaultInstance(props,
                new Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(
                            config.getSmtpUserName(), config.getSmtpPassword());
                    }
                });
View Full Code Here

    /**
     * Returns an authenticator object for use in sessions
     */
    public Authenticator getAuthenticator() {
        return new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(getUsername(), getPassword());
            }
        };
    }
View Full Code Here

TOP

Related Classes of javax.mail.Authenticator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.