Skip to content

Commit 05f8fd3

Browse files
committed
feat: Make cryptographic algorithms configurable
1 parent df937be commit 05f8fd3

File tree

12 files changed

+981
-629
lines changed

12 files changed

+981
-629
lines changed

Diff for: pom.xml

+51-7
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

6-
<parent>
7-
<groupId>com.github.bbottema</groupId>
8-
<artifactId>standard-project-parent</artifactId>
9-
<version>1.0.24</version>
10-
</parent>
6+
<!-- <parent>-->
7+
<!-- <groupId>com.github.bbottema</groupId>-->
8+
<!-- <artifactId>standard-project-parent</artifactId>-->
9+
<!-- <version>1.0.24</version>-->
10+
<!-- </parent>-->
1111

1212
<groupId>org.simplejavamail</groupId>
1313
<artifactId>utils-mail-smime</artifactId>
1414
<packaging>jar</packaging>
1515
<name>utils-mail-smime</name>
16-
<version>2.0.1</version>
17-
<description>A S/MIME library for JavaMail</description>
16+
<version>2.1.0-SNAPSHOT</version>
17+
<description>An S/MIME library for JavaMail</description>
1818
<url>http:///github.com/bbottema/java-utils-mail-smime</url>
1919
<inceptionYear>2021</inceptionYear>
2020

2121
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2224
<automaticModuleName>com.github.bbottema.java-utils-mail-smime</automaticModuleName>
2325
<!-- license plugin, see possible types here: -->
2426
<!-- https://github.com/mathieucarbou/license-maven-plugin/tree/master/license-maven-plugin/src/main/resources/com/mycila/maven/plugin/license/templates -->
2527
<license.type>com/mycila/maven/plugin/license/templates/APACHE-2.txt</license.type>
2628
<license.owner.name>Benny Bottema</license.owner.name>
2729
<license.owner.email>[email protected]</license.owner.email>
30+
<junit.version>5.8.2</junit.version>
31+
<maven.compiler.source>17</maven.compiler.source>
32+
<maven.compiler.target>17</maven.compiler.target>
2833
</properties>
2934

3035
<scm>
@@ -72,6 +77,18 @@
7277
<url>https://github.com/bbottema/java-utils-mail-smime/issues</url>
7378
</issueManagement>
7479

80+
<dependencyManagement>
81+
<dependencies>
82+
<dependency>
83+
<groupId>org.junit</groupId>
84+
<artifactId>junit-bom</artifactId>
85+
<version>${junit.version}</version>
86+
<type>pom</type>
87+
<scope>import</scope>
88+
</dependency>
89+
</dependencies>
90+
</dependencyManagement>
91+
7592
<dependencies>
7693
<dependency><!-- Gives us @NotNull and @Nullable -->
7794
<groupId>org.jetbrains</groupId>
@@ -85,10 +102,37 @@
85102
<artifactId>bcjmail-jdk15to18</artifactId>
86103
<version>1.70</version>
87104
</dependency>
105+
<dependency>
106+
<groupId>jakarta.activation</groupId>
107+
<artifactId>jakarta.activation-api</artifactId>
108+
<version>2.0.1</version>
109+
</dependency>
110+
<dependency>
111+
<groupId>com.sun.activation</groupId>
112+
<artifactId>jakarta.activation</artifactId>
113+
<version>2.0.1</version>
114+
</dependency>
115+
<dependency>
116+
<groupId>jakarta.mail</groupId>
117+
<artifactId>jakarta.mail-api</artifactId>
118+
<version>2.0.1</version>
119+
</dependency>
88120
<dependency>
89121
<groupId>com.sun.mail</groupId>
90122
<artifactId>jakarta.mail</artifactId>
91123
<version>2.0.1</version>
92124
</dependency>
125+
126+
<dependency>
127+
<groupId>org.junit.jupiter</groupId>
128+
<artifactId>junit-jupiter-api</artifactId>
129+
<scope>test</scope>
130+
</dependency>
131+
<dependency>
132+
<groupId>org.junit.jupiter</groupId>
133+
<artifactId>junit-jupiter-engine</artifactId>
134+
<scope>test</scope>
135+
</dependency>
93136
</dependencies>
137+
94138
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2022. Ulrich Schuster, 10827 Berlin, Germany
3+
*/
4+
5+
package org.simplejavamail.utils.mail.smime;
6+
7+
public enum KeyEncapsulationAlgorithm {
8+
RSA,
9+
RSA_OAEP_SHA224,
10+
RSA_OAEP_SHA256,
11+
RSA_OAEP_SHA384,
12+
RSA_OAEP_SHA512,
13+
}

Diff for: src/main/java/org/simplejavamail/utils/mail/smime/SmimeKey.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private void extractAssociatedAddresses() {
8989
try {
9090
X509Certificate certificate = getCertificate();
9191
if (null != certificate) {
92-
Principal principal = certificate.getSubjectDN();
92+
Principal principal = certificate.getSubjectX500Principal();
9393
if (null != principal) {
9494
String name = principal.getName();
9595
StringTokenizer tokenizer = new StringTokenizer(name, ",");

Diff for: src/main/java/org/simplejavamail/utils/mail/smime/SmimeKeyStore.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* A wrapper around a {@link KeyStore} that can be initialized with a PKCS12
1616
* keystore and is used to obtain {@link SmimeKey SmimeKeys}.
17-
*
17+
*
1818
* @author Allen Petersen (akp at sourceforge dot net)
1919
* @author Torsten Krause (tk at markenwerk dot net)
2020
* @since 1.0.0
@@ -26,11 +26,11 @@ public class SmimeKeyStore {
2626
/**
2727
* Creates a new {@code SmimeKeyStore} by loading a PKCS12 keystore from
2828
* the given input stream.
29-
*
29+
*
3030
* <p>
3131
* The character array holding the password is overwritten with {@code 0s}
3232
* after it has been used.
33-
*
33+
*
3434
* @param stream
3535
* The {@link InputStream} to read the PKCS12 keystore from.
3636
* @param password
@@ -43,12 +43,12 @@ public SmimeKeyStore(InputStream stream, char[] password) {
4343
/**
4444
* Creates a new {@code SmimeKeyStore} by loading a PKCS12 keystore from
4545
* the given input stream.
46-
*
46+
*
4747
* <p>
4848
* If {@code discardPassword} is set to {@code true}, the character array
4949
* holding the password is overwritten with {@code 0s} after it has been
5050
* used.
51-
*
51+
*
5252
* @param stream
5353
* The {@link InputStream} to read the PKCS12 keystore from.
5454
* @param password
@@ -95,11 +95,11 @@ public int size() {
9595
/**
9696
* Returns the S/MIME key associated with the given alias, using the given
9797
* password to recover it.
98-
*
98+
*
9999
* <p>
100100
* The character array holding the password is overwritten with {@code 0s}
101101
* after it has been used.
102-
*
102+
*
103103
* @param alias
104104
* The alias.
105105
* @param password
@@ -115,12 +115,12 @@ public SmimeKey getPrivateKey(String alias, char[] password) {
115115
/**
116116
* Returns the S/MIME key associated with the given alias, using the given
117117
* password to recover it.
118-
*
118+
*
119119
* <p>
120120
* If {@code discardPassword} is set to {@code true}, the character array
121121
* holding the password is overwritten with {@code 0s} after it has been
122122
* used.
123-
*
123+
*
124124
* @param alias
125125
* The alias.
126126
* @param password

0 commit comments

Comments
 (0)