Package javax.mail

Examples of javax.mail.Authenticator


        props.put("mail.smtp.starttls.enable", useSSL);
        this.username = _username;
        this.password = _password;
        if (username != null && password != null) {
            props.put("mail.smtp.auth", "true");
            pa = new Authenticator() {
                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password);
                }
            };
        }
View Full Code Here


            }
            if (data.port > 0) {
                properties.put(prefix + ".port", String.valueOf(data.port));
            }

            final Authenticator authenticator = buildAuthenticator(data.username, data.password);
            if (null != authenticator) {
                properties.put(prefix + ".auth", "true");
            }

            final Session session = Session.getInstance(properties, authenticator);
View Full Code Here

            return new SMTPManager(name, session, message, data);
        }

        private Authenticator buildAuthenticator(final String username, final String password) {
            if (null != password && null != username) {
                return new Authenticator() {
                    private final PasswordAuthentication passwordAuthentication =
                        new PasswordAuthentication(username, password);

                    @Override
                    protected PasswordAuthentication getPasswordAuthentication() {
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

    }
    fLogger.fine("Mail is sent.");
  }
 
  private Authenticator getAuthenticator(){
    Authenticator  result = null;
    if( areCredentialsEnabled() ){
      result = new SMTPAuthenticator();
    }
    return result;
  }
View Full Code Here

  private void enableAuth(final String username, final String password) {
    if (username == null || password == null) {
      throw new RuntimeException("[Error] Username or password is empty!");
    }
    properties.put("mail.smtp.auth", "true");
    authenticator = new Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password);
      }
    };
  }
View Full Code Here

  private void enableAuth(final String username, final String password) {
    if (username == null || password == null) {
      throw new RuntimeException("[Error] Username or password is empty!");
    }
    properties.put("mail.smtp.auth", "true");
    authenticator = new Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password);
      }
    };
  }
View Full Code Here

          props.put("mail.smtp.starttls.enable",        "true");
          props.put("mail.smtp.ssl",                    "true");
        }
  
        if (doAuth) {
          Authenticator   authenticator = new ar.com.AmberSoft.util.Authenticator(user, password);
  
          props.put("mail.user",      user);
          props.put("mail.smtp.auth", "true");
  
          session = Session.getInstance(props, authenticator);
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

            // Aside, the JDK is clearly unaware of the Scottish
            // 'session', which involves excessive quantities of
            // alcohol :-)
            Session sesh;
            Authenticator auth;
            if (SSL) {
                try {
                    Provider p = (Provider) Class.forName(
                        "com.sun.net.ssl.internal.ssl.Provider").newInstance();
                    Security.addProvider(p);
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.