Package javax.mail

Examples of javax.mail.PasswordAuthentication


        if (login != null && pwd != null) { //authentication required?
            props.put("mail.smtp.auth", "true");
            pa = new Authenticator() {

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
        }//else: no authentication
        Session session = Session.getInstance(props, pa);
// — Tạo đối tượng message
View Full Code Here


        if (login != null && pwd != null) { //authentication required?
            props.put("mail.smtp.auth", "true");
            pa = new Authenticator() {

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
        }//else: no authentication
        Session session = Session.getInstance(props, pa);
// — Tạo đối tượng message
View Full Code Here

        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

        props.put("mail.smtp.socketFactory.fallback", "false");
      
        Session session = Session.getDefaultInstance(props,
        new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(user,password);
                }
            }
        );
      
        session.setDebug(debug);
View Full Code Here

        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() {
                        return passwordAuthentication;
                    }
View Full Code Here

  Folder folderRoot;
  boolean isAuthenticated;

  public EmailConnection(RewriteContext hr) {
    String connHandle = getConnHandle(hr);
    PasswordAuthentication pa;
    final String IMAP_PORT = "143";
    String tmpServer;
    String server;
    String port;

    /* Setup our internal values */

    user = hr.get("user");
    tmpServer = hr.get("server");

    if (tmpServer.indexOf(":") != -1) {
      server = tmpServer.substring(0,tmpServer.indexOf(":"));
      port = tmpServer.substring(tmpServer.indexOf(":")+1);
    } else {
      server = tmpServer;
      port = IMAP_PORT;
    }

    openFolders = new Hashtable();

    hr.request.log(Server.LOG_DIAGNOSTIC,connHandle,"user = " + user);
    hr.request.log(Server.LOG_DIAGNOSTIC,connHandle,"server = " + server);
    hr.request.log(Server.LOG_DIAGNOSTIC,connHandle,"port = " + port);

    /* Create our URLName for the server connection */

    serverURL = new URLName("imap://" + user + "@" + server + ":" + port);

    hr.request.log(Server.LOG_DIAGNOSTIC,connHandle,"serverURL = " + serverURL.toString());

    pa = new PasswordAuthentication(user,hr.get("password"));

    /* Register our authentication object with the mail session */

    defMailSession.setPasswordAuthentication(serverURL,pa);
  }
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

{
   private PasswordAuthentication authentication_;

   public ExoAuthenticator(String userName, String password)
   {
      authentication_ = new PasswordAuthentication(userName, password);
   }
View Full Code Here

    }

    @Override
    protected PasswordAuthentication getPasswordAuthentication() {
        if (needAuth)
            return    new PasswordAuthentication(username, password);
        else    return null;
    }
View Full Code Here

    return result;
  }
 
  private final class SMTPAuthenticator extends Authenticator {
    public PasswordAuthentication getPasswordAuthentication()   {
      PasswordAuthentication result = null;
      /** Format is pipe separated : bob|passwd. */
      String rawValue = MAIL_SERVER_CREDENTIALS.getValue();
      int delimIdx = rawValue.indexOf("|");
      if(delimIdx != -1){
        String userName = rawValue.substring(0,delimIdx);
        String password = rawValue.substring(delimIdx+1);
        result = new PasswordAuthentication(userName, password);
      }
      else {
        throw new RuntimeException("Missing pipe separator between user name and password: " + rawValue);
      }
      return result;
View Full Code Here

TOP

Related Classes of javax.mail.PasswordAuthentication

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.