Skip to content

Commit

Permalink
Merge branch '2.2.X' of https://gitbox.apache.org/repos/asf/mina.git
Browse files Browse the repository at this point in the history
…into 2.2.X
  • Loading branch information
garydgregory committed Dec 14, 2023
2 parents 6f12a2c + e9d4fae commit 33ffc7d
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 54 deletions.
2 changes: 1 addition & 1 deletion LICENSE.jzlib.txt
Expand Up @@ -2,7 +2,7 @@ JZlib 0.0.* were released under the GNU LGPL license. Later, we have switched
over to a BSD-style license.

------------------------------------------------------------------------------
Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
10 changes: 0 additions & 10 deletions LICENSE.ognl.txt

This file was deleted.

41 changes: 18 additions & 23 deletions LICENSE.slf4j.txt
@@ -1,28 +1,23 @@
Copyright (c) 2004-2007 QOS.ch
Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland)
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.

28 changes: 26 additions & 2 deletions mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
Expand Up @@ -75,6 +75,12 @@ public class SslFilter extends IoFilterAdapter {

protected final SSLContext sslContext;

/** A flag used to tell the filter to start the handshake immediately (in onPostAdd method)
* alternatively handshake will be started after session is connected (in sessionOpened method)
* default value is true
**/
private final boolean autoStart;

/** A flag set if client authentication is required */
protected boolean needClientAuth = false;

Expand Down Expand Up @@ -110,9 +116,23 @@ public class SslFilter extends IoFilterAdapter {
* @param sslContext The SSLContext to use
*/
public SslFilter(SSLContext sslContext) {
this(sslContext, true);
}

/**
* Creates a new SSL filter using the specified {@link SSLContext}.
* If the <code>autostart</code> flag is set to <code>true</code>, the
* handshake will start immediately after the filter has been added
* to the chain.
*
* @param sslContext The SSLContext to use
* @param autoStart The flag used to tell the filter to start the handshake immediately
*/
public SslFilter(SSLContext sslContext, boolean autoStart) {
Objects.requireNonNull(sslContext, "ssl must not be null");

this.sslContext = sslContext;
this.autoStart = autoStart;
}

/**
Expand Down Expand Up @@ -245,8 +265,11 @@ public void onPreAdd(IoFilterChain parent, String name, NextFilter next) throws
@Override
public void onPostAdd(IoFilterChain parent, String name, NextFilter next) throws Exception {
IoSession session = parent.getSession();

if (session.isConnected()) {

// The SslFilter has been added *after* the session has been created and opened.
// We need to initiate the HandShake, this is done here, unless the user wants
// to differ the HandShake to later (and in this case autoStart is set to false)
if (session.isConnected() && autoStart) {

This comment has been minimized.

Copy link
@jon-valliere

jon-valliere Feb 9, 2024

Doesn't this potentially break the existing contract? Before the handshake would start automatically if the Connection is!isServer().

onConnected(next, session);
}

Expand Down Expand Up @@ -359,6 +382,7 @@ public void sessionOpened(NextFilter next, IoSession session) throws Exception {
}
}

// Used to initiate the HandShake if differed
onConnected(next, session);
super.sessionOpened(next, session);
}
Expand Down
Expand Up @@ -34,6 +34,7 @@
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderMalfunctionError;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -1104,7 +1105,10 @@ public void testReadOnlyBuffer() throws Exception {
duplicate.putString("A very very very very looooooong string", Charset.forName("ISO-8859-1").newEncoder());
fail("ReadOnly buffer's can't be expanded");
} catch (ReadOnlyBufferException e) {
// Expected an Exception, signifies test success
// In Java 8 or 11, it expects an Exception, signifies test success
assertTrue(true);
} catch (CoderMalfunctionError cme) {
// In Java 17, it expects an Error, signifies test success
assertTrue(true);
}
}
Expand Down
7 changes: 1 addition & 6 deletions mina-legal/pom.xml
Expand Up @@ -34,12 +34,6 @@
</properties>

<dependencies>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
Expand Down Expand Up @@ -81,3 +75,4 @@
</dependency>
</dependencies>
</project>

1 change: 1 addition & 0 deletions mina-legal/src/main/resources/notices.xml
Expand Up @@ -104,3 +104,4 @@
</project>
</supplement>
</supplementalDataModels>

15 changes: 4 additions & 11 deletions pom.xml
Expand Up @@ -75,7 +75,7 @@
<licenses>
<license>
<name>Apache 2.0 License</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
Expand Down Expand Up @@ -140,7 +140,6 @@
<!-- Jars -->
<version.easymock>2.5.2</version.easymock>
<version.jboss.javassist>3.8.0.GA</version.jboss.javassist>
<version.jdom>1.0</version.jdom>
<version.jmock>1.2.0</version.jmock>
<version.junit>4.13.2</version.junit>
<version.jzlib>1.1.3</version.jzlib>
Expand All @@ -163,7 +162,6 @@
</properties>

<modules>
<module>mina-legal</module>
<module>mina-core</module>
<module>mina-transport-apr</module>
<module>mina-filter-compression</module>
Expand All @@ -174,6 +172,7 @@
<module>mina-integration-jmx</module>
<module>mina-example</module>
<module>mina-http</module>
<module>mina-legal</module>
<!--module>mina-benchmarks</module-->
</modules>

Expand Down Expand Up @@ -247,7 +246,6 @@
</dependency>

<!-- Integration -->

<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
Expand Down Expand Up @@ -284,20 +282,15 @@
<groupId>jboss</groupId>
<artifactId>javassist</artifactId>
<version>${version.jboss.javassist}</version>
</dependency>

<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>${version.jdom}</version>
<optional>true</optional>
<scope>test</scope>
</dependency>

<dependency>
<groupId>jmock</groupId>
<artifactId>jmock</artifactId>
<version>${version.jmock}</version>
<optional>true</optional>
<scope>test</scope>
</dependency>

<dependency>
Expand Down

0 comments on commit 33ffc7d

Please sign in to comment.