Package javax.mail

Examples of javax.mail.Authenticator


            props.put("mail.host", host);
            props.put("mail.store.protocol", "pop3");
            props.put("mail.transport.protocol", "smtp");
            props.put("mail.smtp.port", smtpPort);

            Session session = Session.getInstance(props, new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return authentication;
                }
            });
            MimeMessage msg = new MimeMessage(session);
View Full Code Here


            props.put("mail.host", host);
            props.put("mail.store.protocol", "pop3");
            props.put("mail.transport.protocol", "smtp");
            props.put("mail.pop3.port", popPort);

            Session session = Session.getInstance(props, new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return authentication;
                }
            });
View Full Code Here

   *
   * @return a Authenticator object.
   */
  @Nonnull
  public Authenticator getAuthenticator() {
    return new Authenticator() {
      @Override
      protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication( configuration.getSmtpUser(), configuration.getSmtpPass() );
      }
    };
View Full Code Here

    return Session.getInstance( getProperties(), getAuthenticator() );
  }

  @NotNull
  public Authenticator getAuthenticator() {
    return new Authenticator() {
      @Override
      protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication( configuration.getSmtpUser(), configuration.getSmtpPass() );
      }
    };
View Full Code Here

      Session mailSession = null;
      if( null != userName && null != userPassword ) {
        final String name = userName;
        final String pw = userPassword;
       
        Authenticator auth = new Authenticator(){
          protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(name,pw);
          }
        };
        mailSession = Session.getInstance(mailProperties, auth);
View Full Code Here

        if ((mail != null) && transmitionEnd) {
            return Constants.COMMAND_TRANSMISSION_END;
        }

        if (input.startsWith("MAIL")) {
            mail = new MimeMessage(Session.getInstance(new Properties(), new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return null;
                }
            }));
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

            // 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

                        }

                        props.put(attr.getType(), attr.getContent());
                    }

                    Authenticator auth = null;
                    if (password != null) {
                        String user = props.getProperty("mail.smtp.user");
                        if(user == null) {
                            user = props.getProperty("mail.user");
                        }
                       
                        if(user != null) {
                            final PasswordAuthentication pa = new PasswordAuthentication(user, password);
                            auth = new Authenticator() {
                                    protected PasswordAuthentication getPasswordAuthentication() {
                                        return pa;
                                    }
                                };
                        }
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.