Examples of InternetAddress


Examples of com.google.code.javax.mail.internet.InternetAddress

     * @param   a   The comparison is applied to this Address object.
     * @return          true if the match succeeds, otherwise false.
     */
    protected boolean match(Address a) {
  if (a instanceof InternetAddress) {
      InternetAddress ia = (InternetAddress)a;
      // We dont use toString() to get "a"'s String representation,
      // because InternetAddress.toString() returns a RFC 2047
      // encoded string, which isn't what we need here.

      return super.match(ia.toUnicodeString());
  } else
      return super.match(a.toString());
    }
View Full Code Here

Examples of com.intel.mtwilson.datatypes.InternetAddress

     * @param host
     * @return
     */
    public HashMap<String, ? extends IManifest> getManifest(TblHosts host) {
        try {
            InternetAddress hostAddress = new InternetAddress(host.getName());
            String connectionString = getConnectionString(host);
            String tlsPolicyName = host.getTlsPolicyName() == null ? "TRUST_FIRST_CERTIFICATE" : host.getTlsPolicyName(); // txtHost.getTlsPolicy();  // XXX TODO TxtHost doesn't have this field yet
//            ByteArrayResource resource = new ByteArrayResource(host.getTlsKeystore() == null ? new byte[0] : host.getTlsKeystore()); // XXX TODO it's the responsibility of the caller to save the TblHosts record after calling this method if the policy is trust first certificate ; we need to get tie the keystore to the database, especially for TRUST_FIRST_CERTIFICATE, so if it's the first connection we can save the certificate back to the database after connecting
            String password = "password"; // XXX TODO uh oh... opening a keystore requires a password, so we can verify its signed contents, which is important. putting the password in the txthost record won't be secure.  password needs to  come from attestation service configuration - or from the user.  this isn't an issue for the factory because the factory is supposed to get the keystore AFTER it has been opened with the password.  but when this code moves to the JPA/DAO/Repository layer, we'll need to have a password from somewhere.        
            SimpleKeystore tlsKeystore = new SimpleKeystore(host.getTlsKeystoreResource(), password); // XXX TODO see above commment about password;  the per-host trusted certificates keystore has to either be protected by a password known to all mt wilson instances (stored in database or sync'd across each server's configuration files) or it has to be protected by a group secret known to all authorized clients (and then we need a mechanism for the api client to send us the secret in the request, and a way get secrets in and out of api client's keystore so it can be sync'd across the authorized group of clients) or we can just not store it encrypted and use a pem-format keystore instead of a java KeyStore
View Full Code Here

Examples of javax.mail.internet.InternetAddress

        if(mailc > 1)
          timeToSleep = 0;
        if(mails.size()>0){
          for(;i<mails.size();i++){
            MimeMessage mail = (MimeMessage)mails.get(i);
            mail.setFrom(new InternetAddress(sender,"DLOG4J Messenger"));
            if(userDNSQuery){
              //�ؿ�ר��
              String email = mail.getRecipients(RecipientType.TO)[0].toString();
              String domain_name = parseDomain(email);
              //TODO: ʵ�������Ļ���,�ӿ�����ٶ�
              Lookup lookup = new Lookup(domain_name, Type.MX);
                  lookup.run();
              if (lookup.getResult() != Lookup.SUCCESSFUL){
                log("ERROR: " + lookup.getErrorString() + " when lookup MX record of " + email);
                continue;
              }
              Record[] answers = lookup.getAnswers();
              for(int ai=0;ai<answers.length;ai++){
                Transport transport = null;
                    log("Using " + answers[i].getAdditionalName()+" to send mail to " + email);
                    String mx_host = answers[i].getAdditionalName().toString();
                    mailSession.getProperties().put("mail.smtp.host", mx_host);
                    InternetAddress smtp_host = new InternetAddress(mx_host);
                    try {
                        transport = mailSession.getTransport(smtp_host);
                        try {
                            transport.connect();
                            log("INFO: connected to "+mx_host);
                        } catch (MessagingException me) {
                            // Any error on connect should cause the mailet to attempt
                            // to connect to the next SMTP server associated with this
                            // MX record.  Just log the exception.  We'll worry about
                            // failing the message at the end of the loop.
                            me.printStackTrace();
                            log("ERROR: Connecto to " + mx_host + " failed." , me);
                            continue;
                        }
                        InternetAddress mailToAddress = new InternetAddress(email);           
                        transport.sendMessage(mail, new InternetAddress[]{mailToAddress});
                        log("INFO: mail sent to " + email);
                        break;
                    } finally {
                        if (transport != null) {
View Full Code Here

Examples of javax.mail.internet.InternetAddress

          Multipart multipart = new MimeMultipart("related");
      MimeBodyPart messageBodyPart = new MimeBodyPart();
          messageBodyPart.setText("Welcome to JavaMail.");
          multipart.addBodyPart(messageBodyPart);
          mailMessage.setContent(multipart);
          mailMessage.setFrom(new InternetAddress("javayou@gmail.com","Winter Lau"));
         
          String mail_postfix = mailaddr.substring(mailaddr.indexOf('@')+1);
          //System.out.println("mail postfix is " + mail_postfix);
          Lookup lookup = new Lookup(mail_postfix, Type.MX);
          lookup.run();
      if (lookup.getResult() != Lookup.SUCCESSFUL){
        System.out.println(" " + lookup.getErrorString());
        return;
      }
      Record[] answers = lookup.getAnswers();
      for(int i=0;i<answers.length;i++){
            Transport transport = null;
            //System.out.println("Using " + answers[i].getAdditionalName()+" to send...");
            ssn.getProperties().put("mail.smtp.host", answers[i].getAdditionalName().toString());
            InternetAddress smtp_host = new InternetAddress(answers[i].getAdditionalName().toString());
            try {
                transport = ssn.getTransport(smtp_host);
                  transport.connect();
                  System.out.println("connect to "+smtp_host+" ok.");
                InternetAddress mailToAddress = new InternetAddress(mailaddr);           
                transport.sendMessage(mailMessage, new InternetAddress[]{mailToAddress});
                System.out.println("mail sent to " + mailaddr + " via " + smtp_host);
                break;
              } catch (MessagingException me) {
                  // Any error on connect should cause the mailet to attempt
View Full Code Here

Examples of javax.mail.internet.InternetAddress

                throw new AddressException();
            }

            Address[] replyTo = new Address[1];

            replyTo[0] = new InternetAddress(addstr);
            message.setReplyTo(replyTo);
        } catch (Exception mx) {
            System.err.println("Error in MailObject.setReplyTo(): "+mx);
            setStatus(REPLYTO);
        }
View Full Code Here

Examples of javax.mail.internet.InternetAddress

            }

            Address address = null;

            if (name != null && name != Undefined.instance) {
                address = new InternetAddress(addstr,
                                          MimeUtility.encodeWord(name.toString()));
            } else {
                address = new InternetAddress(addstr);
            }

            message.setFrom(address);
        } catch (Exception mx) {
            System.err.println("Error in MailObject.setFrom(): "+mx);
View Full Code Here

Examples of javax.mail.internet.InternetAddress

        }

        Address address = null;

        if (name != null && name != Undefined.instance) {
            address = new InternetAddress(addstr,
                                          MimeUtility.encodeWord(name.toString()));
        } else {
            address = new InternetAddress(addstr);
        }

        message.addRecipient(type, address);
    }
View Full Code Here

Examples of javax.mail.internet.InternetAddress

  private String appendAddresses(ArrayList addressList)
  {
    StringBuffer addresses = new StringBuffer();
    Iterator iter = addressList.iterator();
    while (iter.hasNext()) {
      InternetAddress address = (InternetAddress)iter.next();
      addresses.append(address.toString());
      if (iter.hasNext()) {
        addresses.append(", ");
      }
    }
    return(addresses.toString());
View Full Code Here

Examples of javax.mail.internet.InternetAddress

  private String appendCcAddresses(ArrayList addressList)
  {
    StringBuffer addresses = new StringBuffer();
    Iterator iter = addressList.iterator();
    while (iter.hasNext()) {
      InternetAddress address = (InternetAddress) iter.next();
      addresses.append(address.toString());
      if (iter.hasNext()) {
        addresses.append(", ");
      }
    }
    return (addresses.toString());
View Full Code Here

Examples of javax.mail.internet.InternetAddress

            String address = "";
            try {
              if (mergeType.equals("EMAIL")) {
                address = printTemplate.getEmail();
                name = printTemplate.getFirstName() + " " + printTemplate.getLastName();
                InternetAddress internetAddress = new InternetAddress(address, name);
                emailList.add(internetAddress.toString());
              }
              // templateList is sample template with update information of the
              // Individual.
              templateList.add(tempData);
            } catch (UnsupportedEncodingException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.