From 60e36613e26539eab33707fb792673f5430f9fce Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Thu, 11 Jan 2024 07:28:59 +0530 Subject: [PATCH] bz-68460 remove references to com.sun.net.ssl.internal.ssl.Provider The Java SSLContext API notes that TLS version will be available at runtime, so we don't have to lookup an internal JDK Provider class (which no longer exists in recent Java versions) and then register it as a Security Provider. --- WHATSNEW | 5 +++++ .../tools/ant/taskdefs/email/JakartaMimeMailer.java | 11 ----------- .../apache/tools/ant/taskdefs/email/MimeMailer.java | 11 ----------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index cc4a0a622c..779c314b56 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -12,6 +12,11 @@ Other changes: Bugzilla Report 26453 + * Removes direct references to com.sun.net.ssl.internal.ssl.Provider class + from the mail task, since that internal JDK class is no longer available + in recent versions of Java. + Bugzilla Report 68460 + Fixed bugs: ----------- diff --git a/src/main/org/apache/tools/ant/taskdefs/email/JakartaMimeMailer.java b/src/main/org/apache/tools/ant/taskdefs/email/JakartaMimeMailer.java index a1ebb983c1..0055c5ffca 100644 --- a/src/main/org/apache/tools/ant/taskdefs/email/JakartaMimeMailer.java +++ b/src/main/org/apache/tools/ant/taskdefs/email/JakartaMimeMailer.java @@ -25,8 +25,6 @@ import java.io.OutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; -import java.security.Provider; -import java.security.Security; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -148,15 +146,6 @@ public void send() { Session sesh; Authenticator auth = null; if (SSL) { - try { - final Provider p = - Class.forName("com.sun.net.ssl.internal.ssl.Provider") - .asSubclass(Provider.class).getDeclaredConstructor().newInstance(); - Security.addProvider(p); - } catch (final Exception e) { - throw new BuildException( - "could not instantiate ssl security provider, check that you have JSSE in your classpath"); - } // SMTP provider props.put("mail.smtp.socketFactory.class", SSL_FACTORY); props.put("mail.smtp.socketFactory.fallback", "false"); diff --git a/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java b/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java index 387078b8a4..54514b9843 100644 --- a/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java +++ b/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java @@ -25,8 +25,6 @@ import java.io.OutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; -import java.security.Provider; -import java.security.Security; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -150,15 +148,6 @@ public void send() { Session sesh; Authenticator auth = null; if (SSL) { - try { - final Provider p = - Class.forName("com.sun.net.ssl.internal.ssl.Provider") - .asSubclass(Provider.class).getDeclaredConstructor().newInstance(); - Security.addProvider(p); - } catch (final Exception e) { - throw new BuildException( - "could not instantiate ssl security provider, check that you have JSSE in your classpath"); - } // SMTP provider props.put("mail.smtp.socketFactory.class", SSL_FACTORY); props.put("mail.smtp.socketFactory.fallback", "false");