From 3aff798a0ee0f1426b857462531eed8cea858579 Mon Sep 17 00:00:00 2001 From: Juergen Steinhilber Date: Tue, 24 Dec 2013 10:14:44 +0000 Subject: [PATCH] *** empty log message *** --- Reha/src/abrechnung/AbrechnungGKV.java | 4 +- Reha/src/dta301/RVMeldung301.java | 3 +- Reha/src/emailHandling/EmailSendenExtern.java | 154 +++++++++++++-------- Reha/src/errorMail/ErrorMail.java | 6 +- Reha/src/hauptFenster/Reha.java | 4 +- .../org/therapi/reha/patient/AktuelleRezepte.java | 2 + Reha/src/org/therapi/reha/patient/LadeProg.java | 1 + .../systemEinstellungen/SysUtilEmailparameter.java | 134 ++++++++++++++---- Reha/src/systemEinstellungen/SystemConfig.java | 23 ++- Reha/src/systemEinstellungen/SystemInit.java | 4 +- Reha/src/terminKalender/DruckFenster.java | 3 +- 11 files changed, 240 insertions(+), 98 deletions(-) diff --git a/Reha/src/abrechnung/AbrechnungGKV.java b/Reha/src/abrechnung/AbrechnungGKV.java index 3dc369cd..cbc19abe 100644 --- a/Reha/src/abrechnung/AbrechnungGKV.java +++ b/Reha/src/abrechnung/AbrechnungGKV.java @@ -1097,7 +1097,7 @@ public class AbrechnungGKV extends JXPanel implements PatStammEventListener,Acti String benutzer = SystemConfig.hmEmailExtern.get("Username") ; String pass1 = SystemConfig.hmEmailExtern.get("Password"); String sender = SystemConfig.hmEmailExtern.get("SenderAdresse"); - + String secure = SystemConfig.hmEmailExtern.get("SmtpSecure"); //String recipient = "m.schuchmann@rta.de"+","+SystemConfig.hmEmailExtern.get("SenderAdresse"); String recipient = ik_email+","+SystemConfig.hmEmailExtern.get("SenderAdresse"); String text = ""; @@ -1112,7 +1112,7 @@ public class AbrechnungGKV extends JXPanel implements PatStammEventListener,Acti EmailSendenExtern oMail = new EmailSendenExtern(); try{ ////System.out.println("Starte Emailversand....."); - oMail.sendMail(smtphost, benutzer, pass1, sender, recipient, Reha.aktIK, text,attachments,authx,bestaetigen); + oMail.sendMail(smtphost, benutzer, pass1, sender, recipient, Reha.aktIK, text,attachments,authx,bestaetigen,secure); oMail = null; ////System.out.println("Emailversand beendet....."); diff --git a/Reha/src/dta301/RVMeldung301.java b/Reha/src/dta301/RVMeldung301.java index 97e09afa..4da8336e 100644 --- a/Reha/src/dta301/RVMeldung301.java +++ b/Reha/src/dta301/RVMeldung301.java @@ -1192,6 +1192,7 @@ public class RVMeldung301 { } String smtphost = SystemConfig.hmEmailExtern.get("SmtpHost"); String authent = SystemConfig.hmEmailExtern.get("SmtpAuth"); + String secure = SystemConfig.hmEmailExtern.get("SmtpSecure"); //String benutzer = SystemConfig.hmEmailExtern.get("Username") ; //String pass1 = SystemConfig.hmEmailExtern.get("Password"); String benutzer = "dta301@rta.de"; @@ -1225,7 +1226,7 @@ public class RVMeldung301 { //System.out.println("Sender-IK = "+vecdta.get(0).get(4).toString()); EmailSendenExtern oMail = new EmailSendenExtern(); try{ - oMail.sendMail(smtphost, benutzer, pass1, benutzer, recipient, vecdta.get(0).get(4).toString(), text,attachments,authx,bestaetigen); + oMail.sendMail(smtphost, benutzer, pass1, benutzer, recipient, vecdta.get(0).get(4).toString(), text,attachments,authx,bestaetigen,secure); oMail = null; return true; }catch(Exception e){ diff --git a/Reha/src/emailHandling/EmailSendenExtern.java b/Reha/src/emailHandling/EmailSendenExtern.java index 3d9ad06f..5ad33b30 100644 --- a/Reha/src/emailHandling/EmailSendenExtern.java +++ b/Reha/src/emailHandling/EmailSendenExtern.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.security.Security; import java.util.ArrayList; import java.util.Date; import java.util.Properties; @@ -31,54 +32,103 @@ import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import javax.swing.JOptionPane; +import com.sun.mail.util.MailSSLSocketFactory; + @SuppressWarnings("unused") public class EmailSendenExtern { - public void sendMail(String smtpHost,String username,String password,String senderAddress,String recipientsAddress,String subject,String text,ArrayListattachments,boolean authx,boolean bestaetigen ) throws AddressException, MessagingException{ + public boolean sendMail(String smtpHost,String username,String password,String senderAddress,String recipientsAddress,String subject,String text,ArrayListattachments,boolean authx,boolean bestaetigen,String secure ) throws AddressException, MessagingException, Exception{ + + Session session = null; + Properties properties = null; + Transport tran = null; + Message msg = null; + MailAuthenticator auth = null; + if(secure.equals("keine")){ + auth = new MailAuthenticator(username, password); + + properties = new Properties(); + if(properties.get("mail.smtp.host") != null){ + //System.out.println("Bereits belegt mit "+properties.get("mail.smtp.host")); + } + properties.clear(); + + + properties.put("mail.smtp.host", smtpHost); + properties.put("mail.smtp.socketFactory.fallback", "false"); + if(authx){ + properties.put("mail.smtp.auth", "true"); + } else { + properties.put("mail.smtp.auth", "false"); + } + session = Session.getInstance(properties, auth); + + }else if(secure.equals("TLS/STARTTLS")){ + properties = new Properties(); + properties.put("mail.smtp.host", smtpHost); + properties.put("mail.smtp.ssl.trust", smtpHost); + properties.put("mail.smtp.starttls.enable", "true"); + properties.put("mail.smtp.port", "587"); - MailAuthenticator auth = new MailAuthenticator(username, password); - - Properties properties = new Properties(); - // Den Properties wird die ServerAdresse hinzugef�gt - if(properties.get("mail.smtp.host") != null){ - //System.out.println("Bereits belegt mit "+properties.get("mail.smtp.host")); - } - properties.clear(); - properties.put("mail.smtp.host", smtpHost); - properties.put("mail.smtp.socketFactory.fallback", "false"); - // !!Wichtig!! Falls der SMTP-Server eine Authentifizierung - // verlangt - // muss an dieser Stelle die Property auf "true" gesetzt - // werden - if(authx){ - properties.put("mail.smtp.auth", "true"); - } else { - properties.put("mail.smtp.auth", "false"); + if(authx){ + properties.put("mail.smtp.auth", "true"); + } else { + properties.put("mail.smtp.auth", "false"); + } + + final String xusername = username; + final String xpassword = password; + session = Session.getInstance(properties, + new javax.mail.Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(xusername, xpassword); + } + }); + + }else if(secure.equals("SSL")){ + //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + properties = new Properties(); + properties.put("mail.smtp.host", smtpHost); + + MailSSLSocketFactory sf = new MailSSLSocketFactory(); + sf.setTrustAllHosts(true); + properties.put("mail.smtp.ssl.enable", "true"); + properties.put("mail.smtp.ssl.socketFactory", sf); + + + properties.put("mail.smtp.socketFactory.port", "465"); + properties.put("mail.smtp.socketFactory.class", + "javax.net.ssl.SSLSocketFactory"); + properties.put("mail.smtp.ssl.trust", smtpHost); + if(authx){ + properties.put("mail.smtp.auth", "true"); + } else { + properties.put("mail.smtp.auth", "false"); + } + properties.put("mail.smtp.port", "465"); + final String xusername = username; + final String xpassword = password; + session = Session.getDefaultInstance(properties, + new javax.mail.Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(xusername,xpassword); + } + }); + + }else{ + JOptionPane.showMessageDialog(null,"Fehler in der Emailkonfiguration, Item Sicherheitsstufe!"); + return false; } - /* - if(SystemConfig.hmEmailExtern.get("SmtpAuth").equals("1")){ - properties.put("mail.smtp.auth", "true"); - } else { - properties.put("mail.smtp.auth", "false"); - } - */ - // Hier wird mit den Properties und dem implements Contructor - // erzeugten - // MailAuthenticator eine Session erzeugt - Session session = null; - Transport tran = null; - Message msg = null; - try{ - session = Session.getInstance(properties, auth); + + //try{ + // Eine neue Message erzeugen - msg = new MimeMessage(session); - - - // Hier werden die Absender- und Empfängeradressen gesetzt - msg.setFrom(new InternetAddress(senderAddress)); - msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientsAddress, false)); + msg = new MimeMessage(session); + // Hier werden die Absender- und Empfängeradressen gesetzt + msg.setFrom(new InternetAddress(senderAddress)); + msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientsAddress, false)); // Der Betreff und Body der Message werden gesetzt @@ -138,24 +188,13 @@ public class EmailSendenExtern { Transport.send(msg); + /* }catch(Exception ex){ JOptionPane.showMessageDialog(null,"Fehler beim Versand der Email, evtl kein Kontakt zum Internet"); } - /* - JOptionPane.showMessageDialog(null,"Der Email-Account wurde korrekt konfiguriert!\n\n"+ - "Sie erhalten in K�rze eine Erfolgsmeldung per Email"); - */ - //Transport.send(msg); - - - /* - javax.swing.JOptionPane.showMessageDialog(null, "Emailversand fehlgeschlagen\n\n"+ - "Mögliche Ursachen:\n"+ - "- falsche Angaben zu Ihrem Emailpostfach und/oder dem Provider\n"+ - "- Sie haben kein Kontakt zum Internet"); - //e.printStackTrace( ); - */ + */ + if(session != null){ session = null; @@ -169,11 +208,8 @@ public class EmailSendenExtern { if(tran != null){ tran = null; } - /* - Runtime r = Runtime.getRuntime(); - r.gc(); - long freeMem = r.freeMemory(); - */ + + return true; } diff --git a/Reha/src/errorMail/ErrorMail.java b/Reha/src/errorMail/ErrorMail.java index 1254552e..27c2000d 100644 --- a/Reha/src/errorMail/ErrorMail.java +++ b/Reha/src/errorMail/ErrorMail.java @@ -7,9 +7,7 @@ import javax.mail.internet.AddressException; import CommonTools.INIFile; import CommonTools.INITool; - import emailHandling.EmailSendenExtern; - import systemEinstellungen.SystemConfig; import hauptFenster.Reha; @@ -47,11 +45,13 @@ public class ErrorMail extends Thread{ "eingeloggter Benutzer: "+this.benutzer+"\n"+ "Absenderadresse: "+this.sender; try { - oMail.sendMail(smtphost, benutzer, pass1, sender, recipient, titel, emailtext,attachments,authx,bestaetigen); + oMail.sendMail(smtphost, benutzer, pass1, sender, recipient, titel, emailtext,attachments,authx,bestaetigen,SystemConfig.hmEmailIntern.get("SmtpSecure")); } catch (AddressException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } diff --git a/Reha/src/hauptFenster/Reha.java b/Reha/src/hauptFenster/Reha.java index dba51299..c7c4693a 100644 --- a/Reha/src/hauptFenster/Reha.java +++ b/Reha/src/hauptFenster/Reha.java @@ -313,7 +313,7 @@ public class Reha implements FocusListener,ComponentListener,ContainerListener,M public static boolean demoversion = false; public static boolean vollbetrieb = true; - public static String aktuelleVersion = "2013-11-05-DB="; + public static String aktuelleVersion = "2013-12-24-DB="; public static Vector> timerVec = new Vector>(); public static Timer fangoTimer = null; @@ -419,7 +419,7 @@ public class Reha implements FocusListener,ComponentListener,ContainerListener,M Process process; try { System.out.println("Starte RehaxSwing.jar"); - process = new ProcessBuilder("java", "-jar",proghome+"RehaxSwing.jar").start(); + process = new ProcessBuilder("java","-Djava.net.preferIPv4Stack=true", "-jar",proghome+"RehaxSwing.jar").start(); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); diff --git a/Reha/src/org/therapi/reha/patient/AktuelleRezepte.java b/Reha/src/org/therapi/reha/patient/AktuelleRezepte.java index a2f47b18..42556bb8 100644 --- a/Reha/src/org/therapi/reha/patient/AktuelleRezepte.java +++ b/Reha/src/org/therapi/reha/patient/AktuelleRezepte.java @@ -1864,6 +1864,7 @@ public class AktuelleRezepte extends JXPanel implements ListSelectionListener,T dtblm.setValueAt(Reha.thisClass.patpanel.imgzuzahl[0],currow,1); tabaktrez.validate(); doVectorAktualisieren(new int[]{12,14,39},new String[] {"T","F","0"}); + SqlInfo.sqlAusfuehren("delete from kasse where rez_nr='"+xreznr+"' LIMIT 1"); } } @@ -2674,6 +2675,7 @@ public class AktuelleRezepte extends JXPanel implements ListSelectionListener,T SystemConfig.hmAdrRDaten.get(""), " ", true, 6)); SystemConfig.hmAdrRDaten.put("",SystemConfig.hmAdrRDaten.get("")); SystemConfig.hmAdrRDaten.put("", Reha.aktUser); + SystemConfig.hmAdrRDaten.put("", Reha.thisClass.patpanel.vecaktrez.get(0)); //System.out.println("Es wird folgender Bacrode genommen "+url); OOTools.starteBacrodeFormular(Reha.proghome+"vorlagen/"+Reha.aktIK+"/"+url,SystemConfig.rezBarcodeDrucker); diff --git a/Reha/src/org/therapi/reha/patient/LadeProg.java b/Reha/src/org/therapi/reha/patient/LadeProg.java index a9c968d9..b027d5f6 100644 --- a/Reha/src/org/therapi/reha/patient/LadeProg.java +++ b/Reha/src/org/therapi/reha/patient/LadeProg.java @@ -51,6 +51,7 @@ public class LadeProg { Listlist = Arrays.asList(xprog.split(" ")); ArrayList alist = new ArrayList(list); alist.add(0,"-jar"); + alist.add(0,"-Djava.net.preferIPv4Stack=true"); alist.add(0,"java"); Process process = new ProcessBuilder(alist).start(); diff --git a/Reha/src/systemEinstellungen/SysUtilEmailparameter.java b/Reha/src/systemEinstellungen/SysUtilEmailparameter.java index 6d397b7a..87b869e8 100644 --- a/Reha/src/systemEinstellungen/SysUtilEmailparameter.java +++ b/Reha/src/systemEinstellungen/SysUtilEmailparameter.java @@ -15,16 +15,17 @@ import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JScrollPane; import org.jdesktop.swingx.JXPanel; +import org.thera_pi.nebraska.gui.utils.JCompTools; import CommonTools.JRtaTextField; import systemTools.Verschluesseln; - import CommonTools.INIFile; import CommonTools.INITool; @@ -58,6 +59,7 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio JRtaTextField SMTPhost = null; JRtaTextField POPhost = null; JCheckBox Authent = null; + JComboBox Secure = null; HashMap hmEmail = new HashMap(); public SysUtilEmailparameter(){ super(new GridLayout(1,1)); @@ -115,6 +117,12 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio POPhost.setText(SystemConfig.hmEmailExtern.get("Pop3Host")); Authent = new JCheckBox(); Authent.setSelected((SystemConfig.hmEmailExtern.get("SmtpAuth").equals("0") ? false : true)); + + Secure = new JComboBox(new String[] {"keine","TLS/STARTTLS","SSL"}); + if(SystemConfig.hmEmailExtern.get("SmtpSecure")==null){ + SystemConfig.hmEmailExtern.put("SmtpSecure","keine"); + } + Secure.setSelectedItem(SystemConfig.hmEmailExtern.get("SmtpSecure")); /* hmEmailExtern = new HashMap(); hmEmailExtern.put("SmtpHost",String.valueOf(ini.getStringProperty("EmailExtern","SmtpHost"))); @@ -134,13 +142,15 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio // 1. 2. 3. 4. 5. 6. 7. 8. 9. - FormLayout lay = new FormLayout("right:max(60dlu;p), 10dlu, 90dlu, right:p", + FormLayout lay = new FormLayout("right:max(60dlu;p), 10dlu, 140dlu, right:p", //, 4dlu, 40dlu, 4dlu, 40dlu, 4dlu, 40dlu", - //1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25 26 27 28 29 30 31 32 33 34 35 36 37 - "p, 5dlu, p, 10dlu, p, 2dlu, p, 10dlu, p, 10dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 10dlu, p, 10dlu, p, 10dlu, p, 10dlu, p"); - + //1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25 26 27 28 29 30 31 32 33 34 35 36 37 + "p, 5dlu, p, 10dlu, p, 2dlu, p, 10dlu, p, 10dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 5dlu"); + // "p, 5dlu, p, 10dlu, p, 2dlu, p, 10dlu, p, 10dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 10dlu, p, 10dlu, p, 10dlu, p, 10dlu, p"); + + PanelBuilder builder = new PanelBuilder(lay); - builder.setDefaultDialogBorder(); + //builder.setDefaultDialogBorder(); builder.getPanel().setOpaque(false); CellConstraints cc = new CellConstraints(); @@ -152,7 +162,7 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio //builder.addLabel("Postfach w�hlen", cc.xy(3, 2)); builder.add(Postfach, cc.xy(4, 1)); - builder.addSeparator("optionale Angaben", cc.xyw(1,3,4)); + builder.addSeparator("Emailadresse / Empfangsquittung", cc.xyw(1,3,4)); builder.addLabel("Absender-Mailadresse", cc.xy(1, 5)); builder.add(Mailadresse, cc.xyw(3,5,2)); @@ -167,26 +177,58 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio builder.add(Pass1, cc.xyw(3, 13, 2)); builder.addLabel("Passwort wiederholen", cc.xy(1,15)); builder.add(Pass2, cc.xyw(3, 15, 2)); - builder.addLabel("SMTP-Host", cc.xy(1,17)); + builder.addLabel("SMTP-Host (Mailausgang)", cc.xy(1,17)); builder.add(SMTPhost, cc.xyw(3, 17, 2)); builder.addLabel("Authentifizierung erforderlich", cc.xy(1, 19)); builder.add(Authent, cc.xy(4, 19)); - builder.addLabel("POP3-Host", cc.xy(1,21)); + builder.addLabel("POP3-Host (Maileingang)", cc.xy(1,21)); builder.add(POPhost, cc.xyw(3, 21, 2)); - builder.addSeparator("", cc.xyw(1, 23, 4)); + + /*******Hier die Verschlüsselung rein*******/ + builder.addLabel("Sicherheitsstufe", cc.xy(1,23)); + builder.add(Secure, cc.xyw(3, 23, 2)); + /*******************************************/ + //builder.addSeparator("", cc.xyw(1, 23, 4)); - builder.add(knopf1, cc.xy(1, 25)); + /***********nachfolgendes in eigenes Panel*****************/ + FormLayout lay1 = new FormLayout("right:max(60dlu;p), 10dlu, 140dlu,70px, right:p","5dlu,p,5dlu,p,5dlu,p,2dlu,p,5dlu"); + PanelBuilder builder1 = new PanelBuilder(lay1); + CellConstraints cc1 = new CellConstraints(); + builder1.getPanel().setOpaque(false); - builder.add(knopf2, cc.xy(4, 25)); + //builder.add(new JLabel(""), cc.xyw(3, 1, 3,CellConstraints.FILL,CellConstraints.DEFAULT)); - builder.addSeparator("Testmail", cc.xyw(1,27,4)); - builder.addLabel("Wenn Sie eine Testmail erhalten, war die Einrichtung erfolgreich.", cc.xyw(1, 29, 3)); - builder.add(knopf3, cc.xy(4, 29)); + builder1.addSeparator("Konfiguration testen / speichern / abbrechen", cc1.xyw(1,2,5)); + + builder1.add(knopf1, cc1.xy(1, 4)); + builder1.add(knopf2, cc1.xy(5, 4)); + builder1.addLabel("Achtung: nur(!) wenn Sie nach dem Test eine Re-Email erhalten war die Einrichtung erfolgreich.", cc1.xyw(1, 6 , 5)); + builder1.add(knopf3, cc1.xy(5, 8)); - return builder.getPanel(); + + /*************Ende builder1******************************/ + + builder.getPanel().validate(); + builder1.getPanel().validate(); + + JScrollPane scr = JCompTools.getTransparentScrollPane(builder.getPanel()); + scr.validate(); + //JScrollPane scr0 = JCompTools.getTransparent2ScrollPane(scr); + //scr0.validate(); + + FormLayout lay0 = new FormLayout("fill:0:grow(1.0)","fill:0:grow(1.0),p"); + PanelBuilder builder0 = new PanelBuilder(lay0); + builder0.getPanel().setOpaque(false); + CellConstraints cc0 = new CellConstraints(); + + builder0.add(scr,cc0.xy(1,1,CellConstraints.FILL,CellConstraints.FILL)); + builder0.add(builder1.getPanel(),cc0.xy(1,2,CellConstraints.FILL,CellConstraints.FILL)); + builder0.getPanel().validate(); + + return builder0.getPanel(); } @Override @@ -254,6 +296,7 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio mailmap.put("SmtpHost", smtphost); mailmap.put("Pop3Host", pophost); mailmap.put("SmtpAuth", authent); + mailmap.put("SmtpSecure", Secure.getSelectedItem().toString()); INIFile ini = INITool.openIni(Reha.proghome+"ini/"+Reha.aktIK+"/", "email.ini"); ini.setStringProperty(postfach, "SenderAdresse", sender, null); ini.setStringProperty(postfach, "EmpfangBestaetigen", bestaetigung, null); @@ -261,7 +304,8 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio ini.setStringProperty(postfach, "Password",encrypted , null); ini.setStringProperty(postfach, "SmtpHost",smtphost , null); ini.setStringProperty(postfach, "Pop3Host",pophost , null); - ini.setStringProperty(postfach, "SmtpAuth",authent , null); + ini.setStringProperty(postfach, "SmtpAuth",authent , null); + ini.setStringProperty(postfach, "SmtpSecure",Secure.getSelectedItem().toString(),null); INITool.saveIni(ini); JOptionPane.showMessageDialog(null, "Emailparameter für --> "+Postfach.getSelectedItem().toString()+" <-- wurden erfolgreich gespeichert"); }catch(Exception ex){ @@ -273,8 +317,14 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio @SuppressWarnings("unchecked") private void wechsleEmail(){ if(Postfach.getSelectedIndex()==0){ + if(SystemConfig.hmEmailExtern.get("SmtpSecure")==null){ + SystemConfig.hmEmailExtern.put("SmtpSecure","keine"); + } hmEmail = (HashMap)SystemConfig.hmEmailExtern.clone(); }else{ + if(SystemConfig.hmEmailIntern.get("SmtpSecure")==null){ + SystemConfig.hmEmailIntern.put("SmtpSecure","keine"); + } hmEmail = (HashMap)SystemConfig.hmEmailIntern.clone(); } Mailadresse.setText(hmEmail.get("SenderAdresse")); @@ -285,7 +335,7 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio SMTPhost.setText(hmEmail.get("SmtpHost")); POPhost.setText(hmEmail.get("Pop3Host")); Authent.setSelected((hmEmail.get("SmtpAuth").equals("0") ? false : true)); - + Secure.setSelectedItem(hmEmail.get("SmtpSecure")); } private void testeEmail(){ @@ -301,23 +351,53 @@ public class SysUtilEmailparameter extends JXPanel implements KeyListener, Actio String smtphost = SMTPhost.getText().trim(); //String pophost = POPhost.getText().trim(); String authent = ( Authent.isSelected() ? "1" : "0"); - String text = "Herzlichen Glückwunsch Ihr Postfach ist perfekt konfiguriert\n\n"+ - "Sie können diese Konfiguration nun abspeichern"; + String text = "Herzlichen Glückwunsch Ihr Postfach (Emailausgang) ist perfekt konfiguriert\n\n"+ + "Sie können diese Konfiguration nun abspeichern!\n(getestet wurde lediglich der Mailausgang)\n\n"; boolean authx = (authent.equals("0") ? false : true); boolean bestaetigen = (bestaetigung.equals("0") ? false : true); - - ArrayList attachments = new ArrayList(); + String smtpport=null,popport=null; + if(Secure.getSelectedItem().toString().equals("keine")){ + smtpport = "25"; + popport = "110"; + }else if(Secure.getSelectedItem().toString().equals("TLS/STARTTLS")){ + smtpport = "587"; + popport = "995"; + }else if(Secure.getSelectedItem().toString().equals("SSL")){ + smtpport = "465"; + popport = "995"; + }else{ + smtpport = "keine oder falsche Werte"; + popport = "keine oder falsche Werte"; + } + ArrayList attachments = new ArrayList(); + String meldung = "Hostname (Mailausgang) = "+smtphost+"\n"+ + "SMTP-Port = "+smtpport+"\n"+ + "Hostname (Maileingang) = "+POPhost.getText()+"\n"+ + "Pop(3)-Port = "+popport+"\n"+ + "Benutzername = "+benutzer+"\n"+ + "Emailadresse = "+sender+"\n"+ + "PasswortAuthent. = "+(authx ? "JA" : "NEIN")+"\n"+ + "Sicherheitsstufe = "+Secure.getSelectedItem().toString(); + JOptionPane.showMessageDialog(null,"Gestestet wird mit folgenden Einstellungen:\n\n"+meldung+"\n"); EmailSendenExtern oMail = new EmailSendenExtern(); try{ - oMail.sendMail(smtphost, benutzer, pass1, sender, sender, "Test der Emailkonfiguration", text,attachments,authx,bestaetigen); - oMail = null; - JOptionPane.showMessageDialog(null,"Der Email-Account wurde korrekt konfiguriert!\n\n"+ - "Sie erhalten in Kürze eine Erfolgsmeldung per Email"); + boolean success = oMail.sendMail(smtphost, benutzer, pass1, sender, sender, "Test der Emailkonfiguration", text+"\n\n"+meldung,attachments,authx,bestaetigen,Secure.getSelectedItem().toString()); + + if(success){ + JOptionPane.showMessageDialog(null,"Der Email-Account wurde korrekt konfiguriert!\n\n"+ + "Sie erhalten in Kürze eine Erfolgsmeldung per Email"); + }else{ + JOptionPane.showMessageDialog(null, "Emailversand fehlgeschlagen\n\n"+ + "Mögliche Ursachen:\n"+ + "- falsche Angaben zu Ihrem Emailpostfach und/oder dem Provider\n"+ + "- Sie haben kein Kontakt zum Internet"); + } + oMail = null; }catch(Exception e){ JOptionPane.showMessageDialog(null, "Emailversand fehlgeschlagen\n\n"+ "Mögliche Ursachen:\n"+ "- falsche Angaben zu Ihrem Emailpostfach und/oder dem Provider\n"+ - "- Sie haben kein Kontakt zum Internet"); + "- Sie haben kein Kontakt zum Internet\n\nException="+(e.getMessage()==null ? "keine Angaben" : e.getMessage().toString())); e.printStackTrace( ); } /*message.addHeader("Return-Receipt-To", "toMe@home.com");*/ diff --git a/Reha/src/systemEinstellungen/SystemConfig.java b/Reha/src/systemEinstellungen/SystemConfig.java index 2e210ed8..0e5a0aaa 100644 --- a/Reha/src/systemEinstellungen/SystemConfig.java +++ b/Reha/src/systemEinstellungen/SystemConfig.java @@ -541,6 +541,7 @@ public class SystemConfig { } private void EmailParameter(){ + boolean mustsave = false; INIFile emailini = INITool.openIni(Reha.proghome+"ini/"+Reha.aktIK+"/", "email.ini"); hmEmailExtern = new HashMap(); hmEmailExtern.put("SmtpHost",emailini.getStringProperty("EmailExtern","SmtpHost")); @@ -553,7 +554,14 @@ public class SystemConfig { String decrypted = man.decrypt (pw); hmEmailExtern.put("Password",decrypted); hmEmailExtern.put("SenderAdresse",emailini.getStringProperty("EmailExtern","SenderAdresse")); - hmEmailExtern.put("Bestaetigen",emailini.getStringProperty("EmailExtern","EmpfangBestaetigen")); + hmEmailExtern.put("Bestaetigen",emailini.getStringProperty("EmailExtern","EmpfangBestaetigen")); + if(emailini.getStringProperty("EmailExtern","SmtpSecure")==null){ + hmEmailExtern.put("SmtpSecure", "keine"); + emailini.setStringProperty("EmailExtern","SmtpSecure","keine",null); + mustsave = true; + }else{ + hmEmailExtern.put("SmtpSecure", emailini.getStringProperty("EmailExtern","SmtpSecure")); + } /********************/ hmEmailIntern = new HashMap(); hmEmailIntern.put("SmtpHost",emailini.getStringProperty("EmailIntern","SmtpHost")); @@ -567,6 +575,19 @@ public class SystemConfig { hmEmailIntern.put("Password",decrypted); hmEmailIntern.put("SenderAdresse",emailini.getStringProperty("EmailIntern","SenderAdresse")); hmEmailIntern.put("Bestaetigen",emailini.getStringProperty("EmailIntern","EmpfangBestaetigen")); + + if(emailini.getStringProperty("EmailIntern","SmtpSecure")==null){ + hmEmailIntern.put("SmtpSecure", "keine"); + emailini.setStringProperty("EmailIntern","SmtpSecure","keine",null); + mustsave = true; + }else{ + hmEmailIntern.put("SmtpSecure", emailini.getStringProperty("EmailIntern","SmtpSecure")); + } + + if(mustsave){ + INITool.saveIni(emailini); + } + if(new File(Reha.proghome+"ini/"+Reha.aktIK+"/dta301.ini").exists()){ INIFile dtaini = INITool.openIni(Reha.proghome+"ini/"+Reha.aktIK+"/", "dta301.ini"); dta301InBox = dtaini.getStringProperty("DatenPfade301", "inbox"); diff --git a/Reha/src/systemEinstellungen/SystemInit.java b/Reha/src/systemEinstellungen/SystemInit.java index 18b6783f..5232d4ba 100644 --- a/Reha/src/systemEinstellungen/SystemInit.java +++ b/Reha/src/systemEinstellungen/SystemInit.java @@ -699,7 +699,7 @@ private void auswertenSysUtil(String util){ "Achtung: Wichtige Benuterzanfrage",JOptionPane.YES_NO_OPTION); if(anfrage == JOptionPane.YES_OPTION){ try { - Runtime.getRuntime().exec("java -jar "+Reha.proghome+"TheraPiUpdates.jar TheraPiStarten"); + Runtime.getRuntime().exec("java -Djava.net.preferIPv4Stack=true -jar "+Reha.proghome+"TheraPiUpdates.jar TheraPiStarten"); Reha.thisClass.beendeSofort(); } catch (IOException e) { e.printStackTrace(); @@ -711,7 +711,7 @@ private void auswertenSysUtil(String util){ "Achtung: Wichtige Benuterzanfrage",JOptionPane.YES_NO_OPTION); if(anfrage == JOptionPane.YES_OPTION){ try { - Runtime.getRuntime().exec("java -jar "+Reha.proghome+"TheraPiUpdates.jar TheraPiStarten"); + Runtime.getRuntime().exec("java -Djava.net.preferIPv4Stack=true -jar "+Reha.proghome+"TheraPiUpdates.jar TheraPiStarten"); Reha.thisClass.beendeSofort(); } catch (IOException e) { e.printStackTrace(); diff --git a/Reha/src/terminKalender/DruckFenster.java b/Reha/src/terminKalender/DruckFenster.java index aeb89ba7..d7f943b6 100644 --- a/Reha/src/terminKalender/DruckFenster.java +++ b/Reha/src/terminKalender/DruckFenster.java @@ -916,6 +916,7 @@ final class sendeTermine extends Thread implements Runnable{ String username = SystemConfig.hmEmailExtern.get("Username"); String password = SystemConfig.hmEmailExtern.get("Password"); String senderAddress =SystemConfig.hmEmailExtern.get("SenderAdresse"); + String secure = SystemConfig.hmEmailExtern.get("SmtpSecure"); ////System.out.println("Empf�ngeradresse = "+emailaddy); String recipientsAddress = emailaddy; String subject = "Ihre Behandlungstermine"; @@ -960,7 +961,7 @@ final class sendeTermine extends Thread implements Runnable{ EmailSendenExtern oMail = new EmailSendenExtern(); try{ - oMail.sendMail(smtpHost, username, password, senderAddress, recipientsAddress, subject, text,attachments,authx,bestaetigen); + oMail.sendMail(smtpHost, username, password, senderAddress, recipientsAddress, subject, text,attachments,authx,bestaetigen,secure); DruckFenster.thisClass.cursorWait(false); JOptionPane.showMessageDialog (null, "Die Terminliste wurde aufbereitet und per Email versandt\n"); }catch(Exception e){ -- 2.11.4.GIT