Skip to content

Feature: Make cryptographic algorithms configurable #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.bbottema</groupId>
<artifactId>standard-project-parent</artifactId>
<version>1.0.24</version>
</parent>
<!-- <parent>-->
<!-- <groupId>com.github.bbottema</groupId>-->
<!-- <artifactId>standard-project-parent</artifactId>-->
<!-- <version>1.0.24</version>-->
<!-- </parent>-->

<groupId>org.simplejavamail</groupId>
<artifactId>utils-mail-smime</artifactId>
<packaging>jar</packaging>
<name>utils-mail-smime</name>
<version>2.0.1</version>
<description>A S/MIME library for JavaMail</description>
<version>2.1.0-SNAPSHOT</version>
<description>An S/MIME library for JavaMail</description>
<url>http:///github.com/bbottema/java-utils-mail-smime</url>
<inceptionYear>2021</inceptionYear>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<automaticModuleName>com.github.bbottema.java-utils-mail-smime</automaticModuleName>
<!-- license plugin, see possible types here: -->
<!-- https://github.com/mathieucarbou/license-maven-plugin/tree/master/license-maven-plugin/src/main/resources/com/mycila/maven/plugin/license/templates -->
<license.type>com/mycila/maven/plugin/license/templates/APACHE-2.txt</license.type>
<license.owner.name>Benny Bottema</license.owner.name>
<license.owner.email>[email protected]</license.owner.email>
<junit.version>5.8.2</junit.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<scm>
Expand Down Expand Up @@ -72,6 +77,18 @@
<url>https://github.com/bbottema/java-utils-mail-smime/issues</url>
</issueManagement>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency><!-- Gives us @NotNull and @Nullable -->
<groupId>org.jetbrains</groupId>
Expand All @@ -85,10 +102,37 @@
<artifactId>bcjmail-jdk15to18</artifactId>
<version>1.70</version>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>2.0.1</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2022. Ulrich Schuster, 10827 Berlin, Germany
*/

package org.simplejavamail.utils.mail.smime;

public enum KeyEncapsulationAlgorithm {
RSA,
RSA_OAEP_SHA224,
RSA_OAEP_SHA256,
RSA_OAEP_SHA384,
RSA_OAEP_SHA512,
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void extractAssociatedAddresses() {
try {
X509Certificate certificate = getCertificate();
if (null != certificate) {
Principal principal = certificate.getSubjectDN();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on this change please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to its JavaDocs, getSubjectDN() is deprecated:

Deprecated
Use getSubjectX500Principal instead. This method returns the subject as an implementation specific Principal object, which should not be relied upon by portable code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear Benny
Any news on my PR? We would like to update our dependencies and are, therefore, hoping on a new release. Thanks very much!

Principal principal = certificate.getSubjectX500Principal();
if (null != principal) {
String name = principal.getName();
StringTokenizer tokenizer = new StringTokenizer(name, ",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* A wrapper around a {@link KeyStore} that can be initialized with a PKCS12
* keystore and is used to obtain {@link SmimeKey SmimeKeys}.
*
*
* @author Allen Petersen (akp at sourceforge dot net)
* @author Torsten Krause (tk at markenwerk dot net)
* @since 1.0.0
Expand All @@ -26,11 +26,11 @@ public class SmimeKeyStore {
/**
* Creates a new {@code SmimeKeyStore} by loading a PKCS12 keystore from
* the given input stream.
*
*
* <p>
* The character array holding the password is overwritten with {@code 0s}
* after it has been used.
*
*
* @param stream
* The {@link InputStream} to read the PKCS12 keystore from.
* @param password
Expand All @@ -43,12 +43,12 @@ public SmimeKeyStore(InputStream stream, char[] password) {
/**
* Creates a new {@code SmimeKeyStore} by loading a PKCS12 keystore from
* the given input stream.
*
*
* <p>
* If {@code discardPassword} is set to {@code true}, the character array
* holding the password is overwritten with {@code 0s} after it has been
* used.
*
*
* @param stream
* The {@link InputStream} to read the PKCS12 keystore from.
* @param password
Expand Down Expand Up @@ -95,11 +95,11 @@ public int size() {
/**
* Returns the S/MIME key associated with the given alias, using the given
* password to recover it.
*
*
* <p>
* The character array holding the password is overwritten with {@code 0s}
* after it has been used.
*
*
* @param alias
* The alias.
* @param password
Expand All @@ -115,12 +115,12 @@ public SmimeKey getPrivateKey(String alias, char[] password) {
/**
* Returns the S/MIME key associated with the given alias, using the given
* password to recover it.
*
*
* <p>
* If {@code discardPassword} is set to {@code true}, the character array
* holding the password is overwritten with {@code 0s} after it has been
* used.
*
*
* @param alias
* The alias.
* @param password
Expand Down
Loading