Skip to content

Commit cac88e4

Browse files
committed
Merge branch 'smtps'
2 parents 4507f21 + 579c6ab commit cac88e4

18 files changed

+347
-90
lines changed

Diff for: build/checkstyle-import.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<allow pkg="javax.net"/>
8787
<allow pkg="javax.crypto"/>
8888
<allow pkg="javax.mail"/>
89-
<allow class="com.sun.mail.smtp.SMTPSendFailedException"/>
89+
<allow pkg="com.sun.mail"/>
9090
<allow pkg="org.xeustechnologies"/>
9191
<allow pkg="net.glxn"/>
9292
<allow pkg="org.webjars"/>

Diff for: data-service/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
</dependency>
137137
<dependency>
138138
<groupId>com.sun.mail</groupId>
139-
<artifactId>javax.mail</artifactId>
140-
<version>1.6.2</version>
139+
<artifactId>jakarta.mail</artifactId>
140+
<version>1.6.3</version>
141141
</dependency>
142142
<dependency>
143143
<groupId>org.apache.httpcomponents</groupId>

Diff for: pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@
264264
<excludeFilterFile>${project.root.basedir}/build/spotbugs-exclude.xml</excludeFilterFile>
265265
<includeTests>false</includeTests>
266266
<skip>${skipSpotbugs}</skip>
267+
<effort>max</effort>
267268
</configuration>
268269
<executions>
269270
<execution>

Diff for: server/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@
226226
</dependency>
227227
<dependency>
228228
<groupId>com.sun.mail</groupId>
229-
<artifactId>javax.mail</artifactId>
230-
<version>1.6.2</version>
229+
<artifactId>jakarta.mail</artifactId>
230+
<version>1.6.3</version>
231231
</dependency>
232232
<dependency>
233233
<groupId>org.apache.httpcomponents</groupId>

Diff for: server/src/main/java/password/pwm/AppProperty.java

+2
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ public enum AppProperty
329329
SECURITY_DEFAULT_EPHEMERAL_BLOCK_ALG ( "security.defaultEphemeralBlockAlg" ),
330330
SECURITY_DEFAULT_EPHEMERAL_HASH_ALG ( "security.defaultEphemeralHashAlg" ),
331331
SEEDLIST_BUILTIN_PATH ( "seedlist.builtin.path" ),
332+
SMTP_IO_CONNECT_TIMEOUT ( "smtp.io.connectTimeoutMs" ),
333+
SMTP_IO_READ_TIMEOUT ( "smtp.io.readTimeoutMs" ),
332334
SMTP_SUBJECT_ENCODING_CHARSET ( "smtp.subjectEncodingCharset" ),
333335
SMTP_RETRYABLE_SEND_RESPONSE_STATUSES ( "smtp.retryableSendResponseStatus" ),
334336
TOKEN_CLEANER_INTERVAL_SECONDS ( "token.cleaner.intervalSeconds" ),

Diff for: server/src/main/java/password/pwm/config/PwmSetting.java

+4
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ public enum PwmSetting
310310
"email.profile.list", PwmSettingSyntax.PROFILE, PwmSettingCategory.INTERNAL ),
311311
EMAIL_SERVER_ADDRESS(
312312
"email.smtp.address", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_SERVERS ),
313+
EMAIL_SERVER_TYPE(
314+
"email.smtp.type", PwmSettingSyntax.SELECT, PwmSettingCategory.EMAIL_SERVERS ),
313315
EMAIL_SERVER_PORT(
314316
"email.smtp.port", PwmSettingSyntax.NUMERIC, PwmSettingCategory.EMAIL_SERVERS ),
317+
EMAIL_SERVER_CERTS(
318+
"email.smtp.serverCerts", PwmSettingSyntax.X509CERT, PwmSettingCategory.EMAIL_SERVERS ),
315319
EMAIL_USERNAME(
316320
"email.smtp.username", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_SERVERS ),
317321
EMAIL_PASSWORD(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Password Management Servlets (PWM)
3+
* http://www.pwm-project.org
4+
*
5+
* Copyright (c) 2006-2009 Novell, Inc.
6+
* Copyright (c) 2009-2019 The PWM Project
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package password.pwm.config.function;
22+
23+
import password.pwm.bean.UserIdentity;
24+
import password.pwm.config.Configuration;
25+
import password.pwm.config.PwmSetting;
26+
import password.pwm.config.SettingUIFunction;
27+
import password.pwm.config.stored.StoredConfigurationImpl;
28+
import password.pwm.config.value.X509CertificateValue;
29+
import password.pwm.error.PwmUnrecoverableException;
30+
import password.pwm.http.PwmRequest;
31+
import password.pwm.http.PwmSession;
32+
import password.pwm.i18n.Message;
33+
import password.pwm.svc.email.EmailServerUtil;
34+
import password.pwm.util.java.JavaHelper;
35+
36+
import java.security.cert.X509Certificate;
37+
import java.util.List;
38+
39+
public class SmtpCertImportFunction implements SettingUIFunction
40+
{
41+
@Override
42+
public String provideFunction(
43+
final PwmRequest pwmRequest,
44+
final StoredConfigurationImpl storedConfiguration,
45+
final PwmSetting setting,
46+
final String profile,
47+
final String extraData
48+
)
49+
throws PwmUnrecoverableException
50+
{
51+
final PwmSession pwmSession = pwmRequest.getPwmSession();
52+
53+
final Configuration configuration = new Configuration( storedConfiguration );
54+
final List<X509Certificate> certs = EmailServerUtil.readCertificates( configuration, profile );
55+
if ( !JavaHelper.isEmpty( certs ) )
56+
{
57+
final UserIdentity userIdentity = pwmSession.isAuthenticated() ? pwmSession.getUserInfo().getUserIdentity() : null;
58+
storedConfiguration.writeSetting( PwmSetting.EMAIL_SERVER_CERTS, profile, new X509CertificateValue( certs ), userIdentity );
59+
}
60+
61+
return Message.getLocalizedMessage( pwmSession.getSessionStateBean().getLocale(), Message.Success_Unknown, pwmRequest.getConfig() );
62+
}
63+
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Password Management Servlets (PWM)
3+
* http://www.pwm-project.org
4+
*
5+
* Copyright (c) 2006-2009 Novell, Inc.
6+
* Copyright (c) 2009-2019 The PWM Project
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package password.pwm.config.option;
22+
23+
public enum SmtpServerType
24+
{
25+
SMTP,
26+
START_TLS,
27+
SMTPS,
28+
}

Diff for: server/src/main/java/password/pwm/http/filter/SessionFilter.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private ProcessStatus handleStandardRequestOperations(
157157
// debug the http session headers
158158
if ( !pwmSession.getSessionStateBean().isDebugInitialized() )
159159
{
160-
LOGGER.trace( pwmSession, () -> pwmRequest.debugHttpHeaders() );
160+
LOGGER.trace( pwmSession, pwmRequest::debugHttpHeaders );
161161
pwmSession.getSessionStateBean().setDebugInitialized( true );
162162
}
163163

@@ -309,6 +309,13 @@ private static ProcessStatus verifySession(
309309

310310
if ( pwmRequest.getURL().isCommandServletURL() )
311311
{
312+
LOGGER.debug( pwmRequest, () -> "session is unvalidated but can not be validated during a command servlet request, will allow" );
313+
return ProcessStatus.Continue;
314+
}
315+
316+
if ( pwmRequest.getURL().isResourceURL() )
317+
{
318+
LOGGER.debug( pwmRequest, () -> "session is unvalidated but can not be validated during a resource request, will allow" );
312319
return ProcessStatus.Continue;
313320
}
314321

Diff for: server/src/main/java/password/pwm/svc/email/EmailServer.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import lombok.Builder;
2424
import lombok.Value;
25+
import password.pwm.config.option.SmtpServerType;
2526
import password.pwm.util.PasswordData;
2627
import password.pwm.util.java.StringUtil;
2728

@@ -33,19 +34,21 @@
3334
@Builder
3435
public class EmailServer
3536
{
36-
private final String id;
37-
private final String host;
38-
private final int port;
39-
private final String username;
40-
private final PasswordData password;
41-
private final Properties javaMailProps;
42-
private final javax.mail.Session session;
37+
private String id;
38+
private String host;
39+
private int port;
40+
private String username;
41+
private PasswordData password;
42+
private Properties javaMailProps;
43+
private javax.mail.Session session;
44+
private SmtpServerType type;
4345

4446
public String toDebugString()
4547
{
4648
final Map<String, String> debugProps = new LinkedHashMap<>( );
4749
debugProps.put( "id", id );
4850
debugProps.put( "host", host );
51+
debugProps.put( "type", type.name() );
4952
debugProps.put( "port", String.valueOf( port ) );
5053
if ( !StringUtil.isEmpty( username ) )
5154
{

0 commit comments

Comments
 (0)