summaryrefslogtreecommitdiffstats
path: root/auth/auth-batch/src/main/java
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-09-19 06:59:20 -0500
committerInstrumental <jonathan.gathman@att.com>2018-09-19 06:59:31 -0500
commit413480483ae4dbbeb34b454ffc164f81867b4a9c (patch)
tree798b3febd13d8bfcc8a46fe61e588ca0499881b7 /auth/auth-batch/src/main/java
parente66b95f220bbef1efeaee337749f91e7b15b1fd7 (diff)
Update to new Oparent
Issue-ID: AAF-509 Change-Id: Ic9235812d4a396fdc86a4938b626805c22773c00 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-batch/src/main/java')
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/javax/JavaxMailer.java160
1 files changed, 0 insertions, 160 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/javax/JavaxMailer.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/javax/JavaxMailer.java
deleted file mode 100644
index f4a0f37c..00000000
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/javax/JavaxMailer.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-package org.onap.aaf.auth.javax;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.mail.Address;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.org.Mailer;
-import org.onap.aaf.auth.org.OrganizationException;
-
-public class JavaxMailer implements Mailer {
- private Session session;
-
- public JavaxMailer() {
-
- // Get the default Session object.
- session = Session.getDefaultInstance(System.getProperties());
-
- }
-
- @Override
- public int sendEmail(AuthzTrans trans, boolean testMode, String mailFrom, List<String> to, List<String> cc, String subject, String body,
- Boolean urgent) throws OrganizationException {
-
- int status = 1;
-
-
- try {
- // Create a default MimeMessage object.
- MimeMessage message = new MimeMessage(session);
-
- // Set From: header field of the header.
- message.setFrom(new InternetAddress(mailFrom));
-
- if (!testMode) {
- // Set To: header field of the header. This is a required field
- // and calling module should make sure that it is not null or
- // blank
- message.addRecipients(Message.RecipientType.TO,getAddresses(to));
-
- // Set CC: header field of the header.
- if ((cc != null) && (cc.size() > 0)) {
- message.addRecipients(Message.RecipientType.CC,getAddresses(cc));
- }
-
- // Set Subject: header field
- message.setSubject(subject);
-
- if (urgent) {
- message.addHeader("X-Priority", "1");
- }
-
- // Now set the actual message
- message.setText(body);
- } else {
-
- // override recipients
- message.addRecipients(Message.RecipientType.TO,
- InternetAddress.parse(mailFrom));
-
- // Set Subject: header field
- message.setSubject("[TESTMODE] " + subject);
-
- if (urgent) {
- message.addHeader("X-Priority", "1");
- }
-
- ArrayList<String> newBody = new ArrayList<>();
-
- Address temp[] = getAddresses(to);
- String headerString = "TO:\t" + InternetAddress.toString(temp) + "\n";
-
- temp = getAddresses(cc);
- headerString += "CC:\t" + InternetAddress.toString(temp) + "\n";
-
- newBody.add(headerString);
-
- newBody.add("Text: \n");
-
- newBody.add(body);
- String outString = "";
- for (String s : newBody) {
- outString += s + "\n";
- }
-
- message.setText(outString);
- }
- // Send message
- Transport.send(message);
- status = 0;
-
- } catch (MessagingException mex) {
- System.out.println("Error messaging: "+ mex.getMessage());
- System.out.println("Error messaging: "+ mex.toString());
- throw new OrganizationException("Exception send email message "
- + mex.getMessage());
- }
-
- return status;
- }
-
- /**
- * Convert the delimiter String into Internet addresses with the default
- * delimiter of ";"
- * @param strAddress
- * @return
- */
- private Address[] getAddresses(List<String> strAddress) throws OrganizationException {
- return this.getAddresses(strAddress,";");
- }
- /**
- * Convert the delimiter String into Internet addresses with the
- * delimiter of provided
- * @param strAddresses
- * @param delimiter
- * @return
- */
- private Address[] getAddresses(List<String> strAddresses, String delimiter) throws OrganizationException {
- Address[] addressArray = new Address[strAddresses.size()];
- int count = 0;
- for (String addr : strAddresses)
- {
- try{
- addressArray[count] = new InternetAddress(addr);
- count++;
- } catch (Exception e){
- throw new OrganizationException("Failed to parse the email address "+ addr +": "+e.getMessage());
- }
- }
- return addressArray;
- }
-
-}