You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by je...@apache.org on 2013/11/27 13:26:04 UTC
[1/8] git commit: Added the http module into the distribution : it
was missing
Updated Branches:
refs/heads/2.0 597221e00 -> 41811548e
Added the http module into the distribution : it was missing
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/4ae142bb
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/4ae142bb
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/4ae142bb
Branch: refs/heads/2.0
Commit: 4ae142bb0c453ef06f4a63a7c00dea1d3b1b65df
Parents: a9b6446
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Fri Feb 1 18:09:22 2013 +0100
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Fri Feb 1 18:09:22 2013 +0100
----------------------------------------------------------------------
distribution/pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/4ae142bb/distribution/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 22bede9..ba312d5 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -130,6 +130,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mina-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- We don't include distrinution as a dependency : it's not part of the release -->
</dependencies>
[7/8] git commit: Apply the DIRMINA-933 patch
Posted by je...@apache.org.
Apply the DIRMINA-933 patch
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/89605f0d
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/89605f0d
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/89605f0d
Branch: refs/heads/2.0
Commit: 89605f0db26813eaaaac450c1f61ef9bbccdc595
Parents: 885ec9f
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Thu Apr 11 00:15:31 2013 +0200
Committer: Jeff MAURY <je...@apache.org>
Committed: Wed Nov 27 13:23:06 2013 +0100
----------------------------------------------------------------------
.../java/org/apache/mina/http/HttpServerDecoder.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/89605f0d/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java
----------------------------------------------------------------------
diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java b/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java
index e9d09b8..61c1933 100644
--- a/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java
+++ b/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java
@@ -71,7 +71,7 @@ public class HttpServerDecoder implements ProtocolDecoder {
/** Regex to split cookie header following RFC6265 Section 5.4 */
public static final Pattern COOKIE_SEPARATOR_PATTERN = Pattern.compile(";");
- public void decode(final IoSession session, final IoBuffer msg, final ProtocolDecoderOutput out) {
+ public void decode(IoSession session, IoBuffer msg, ProtocolDecoderOutput out) {
DecoderState state = (DecoderState) session.getAttribute(DECODER_STATE_ATT);
if (null == state) {
session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
@@ -85,37 +85,38 @@ public class HttpServerDecoder implements ProtocolDecoder {
// concat the old buffer and the new incoming one
IoBuffer.allocate(oldBuffer.remaining() + msg.remaining()).put(oldBuffer).put(msg).flip();
// now let's decode like it was a new message
-
+ msg = IoBuffer.allocate(oldBuffer.remaining() + msg.remaining()).put(oldBuffer).put(msg).flip();
case NEW:
LOG.debug("decoding NEW");
- final HttpRequestImpl rq = parseHttpRequestHead(msg.buf());
+ HttpRequestImpl rq = parseHttpRequestHead(msg.buf());
if (rq == null) {
// we copy the incoming BB because it's going to be recycled by the inner IoProcessor for next reads
- final ByteBuffer partial = ByteBuffer.allocate(msg.remaining());
+ ByteBuffer partial = ByteBuffer.allocate(msg.remaining());
partial.put(msg.buf());
partial.flip();
// no request decoded, we accumulate
session.setAttribute(PARTIAL_HEAD_ATT, partial);
session.setAttribute(DECODER_STATE_ATT, DecoderState.HEAD);
+ break;
} else {
out.write(rq);
// is it a request with some body content ?
- final String contentLen = rq.getHeader("content-length");
+ String contentLen = rq.getHeader("content-length");
if (contentLen != null) {
LOG.debug("found content len : {}", contentLen);
session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(contentLen));
session.setAttribute(DECODER_STATE_ATT, DecoderState.BODY);
+ // fallthrough, process body immediately
} else {
LOG.debug("request without content");
session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
out.write(new HttpEndOfContent());
+ break;
}
}
- break;
-
case BODY:
LOG.debug("decoding BODY: {} bytes", msg.remaining());
final int chunkSize = msg.remaining();
[8/8] git commit: Merge branch '2.0' of
https://git-wip-us.apache.org/repos/asf/mina into 2.0
Posted by je...@apache.org.
Merge branch '2.0' of https://git-wip-us.apache.org/repos/asf/mina into 2.0
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/41811548
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/41811548
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/41811548
Branch: refs/heads/2.0
Commit: 41811548e4a2f0ec92b2fdc6880c7a3c48287f01
Parents: 89605f0 597221e
Author: Jeff MAURY <je...@apache.org>
Authored: Wed Nov 27 13:25:35 2013 +0100
Committer: Jeff MAURY <je...@apache.org>
Committed: Wed Nov 27 13:25:35 2013 +0100
----------------------------------------------------------------------
----------------------------------------------------------------------
[5/8] git commit: removed MD4 provider since it's bundled with the JRE
Posted by je...@apache.org.
removed MD4 provider since it's bundled with the JRE
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/9f9af070
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/9f9af070
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/9f9af070
Branch: refs/heads/2.0
Commit: 9f9af070c41fcba1d34afebc4f02183d7423db97
Parents: f42feed
Author: Julien Vermillard <jv...@apache.org>
Authored: Tue Feb 19 16:43:53 2013 +0100
Committer: Jeff MAURY <je...@apache.org>
Committed: Wed Nov 27 13:23:04 2013 +0100
----------------------------------------------------------------------
.../java/org/apache/mina/proxy/utils/MD4.java | 333 -------------------
.../apache/mina/proxy/utils/MD4Provider.java | 60 ----
.../java/org/apache/mina/proxy/MD4Test.java | 96 ------
.../java/org/apache/mina/proxy/NTLMTest.java | 9 +-
.../mina/example/proxy/ProxyTestClient.java | 12 +-
5 files changed, 2 insertions(+), 508 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/9f9af070/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4.java b/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4.java
deleted file mode 100644
index 5fa47bf..0000000
--- a/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.mina.proxy.utils;
-
-import java.security.DigestException;
-import java.security.MessageDigestSpi;
-
-/**
- * MD4.java - An implementation of Ron Rivest's MD4 message digest algorithm.
- * The MD4 algorithm is designed to be quite fast on 32-bit machines. In
- * addition, the MD4 algorithm does not require any large substitution
- * tables.
- *
- * @see The <a href="http://www.ietf.org/rfc/rfc1320.txt">MD4</a> Message-
- * Digest Algorithm by R. Rivest.
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- * @since MINA 2.0.0-M3
- */
-public class MD4 extends MessageDigestSpi {
-
- /**
- * The MD4 algorithm message digest length is 16 bytes wide.
- */
- public static final int BYTE_DIGEST_LENGTH = 16;
-
- /**
- * The MD4 algorithm block length is 64 bytes wide.
- */
- public static final int BYTE_BLOCK_LENGTH = 64;
-
- /**
- * The initial values of the four registers. RFC gives the values
- * in LE so we converted it as JAVA uses BE endianness.
- */
- private final static int A = 0x67452301;
-
- private final static int B = 0xefcdab89;
-
- private final static int C = 0x98badcfe;
-
- private final static int D = 0x10325476;
-
- /**
- * The four registers initialized with the above IVs.
- */
- private int a = A;
-
- private int b = B;
-
- private int c = C;
-
- private int d = D;
-
- /**
- * Counts the total length of the data being digested.
- */
- private long msgLength;
-
- /**
- * The internal buffer is {@link BLOCK_LENGTH} wide.
- */
- private final byte[] buffer = new byte[BYTE_BLOCK_LENGTH];
-
- /**
- * Default constructor.
- */
- public MD4() {
- // Do nothing
- }
-
- /**
- * Returns the digest length in bytes.
- *
- * @return the digest length in bytes.
- */
- protected int engineGetDigestLength() {
- return BYTE_DIGEST_LENGTH;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void engineUpdate(byte b) {
- int pos = (int) (msgLength % BYTE_BLOCK_LENGTH);
- buffer[pos] = b;
- msgLength++;
-
- // If buffer contains enough data then process it.
- if (pos == (BYTE_BLOCK_LENGTH - 1)) {
- process(buffer, 0);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void engineUpdate(byte[] b, int offset, int len) {
- int pos = (int) (msgLength % BYTE_BLOCK_LENGTH);
- int nbOfCharsToFillBuf = BYTE_BLOCK_LENGTH - pos;
- int blkStart = 0;
-
- msgLength += len;
-
- // Process each full block
- if (len >= nbOfCharsToFillBuf) {
- System.arraycopy(b, offset, buffer, pos, nbOfCharsToFillBuf);
- process(buffer, 0);
- for (blkStart = nbOfCharsToFillBuf; blkStart + BYTE_BLOCK_LENGTH - 1 < len; blkStart += BYTE_BLOCK_LENGTH) {
- process(b, offset + blkStart);
- }
- pos = 0;
- }
-
- // Fill buffer with the remaining data
- if (blkStart < len) {
- System.arraycopy(b, offset + blkStart, buffer, pos, len - blkStart);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected byte[] engineDigest() {
- byte[] p = pad();
- engineUpdate(p, 0, p.length);
- byte[] digest = { (byte) a, (byte) (a >>> 8), (byte) (a >>> 16), (byte) (a >>> 24), (byte) b, (byte) (b >>> 8),
- (byte) (b >>> 16), (byte) (b >>> 24), (byte) c, (byte) (c >>> 8), (byte) (c >>> 16), (byte) (c >>> 24),
- (byte) d, (byte) (d >>> 8), (byte) (d >>> 16), (byte) (d >>> 24) };
-
- engineReset();
-
- return digest;
- }
-
- /**
- * {@inheritDoc}
- */
- protected int engineDigest(byte[] buf, int offset, int len) throws DigestException {
- if (offset < 0 || offset + len >= buf.length) {
- throw new DigestException("Wrong offset or not enough space to store the digest");
- }
- int destLength = Math.min(len, BYTE_DIGEST_LENGTH);
- System.arraycopy(engineDigest(), 0, buf, offset, destLength);
- return destLength;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void engineReset() {
- a = A;
- b = B;
- c = C;
- d = D;
- msgLength = 0;
- }
-
- /**
- * Pads the buffer by appending the byte 0x80, then append as many zero
- * bytes as necessary to make the buffer length a multiple of 64 bytes.
- * The last 8 bytes will be filled with the length of the buffer in bits.
- * If there's no room to store the length in bits in the block i.e the block
- * is larger than 56 bytes then an additionnal 64-bytes block is appended.
- *
- * @see sections 3.1 & 3.2 of the RFC 1320.
- *
- * @return the pad byte array
- */
- private byte[] pad() {
- int pos = (int) (msgLength % BYTE_BLOCK_LENGTH);
- int padLength = (pos < 56) ? (64 - pos) : (128 - pos);
- byte[] pad = new byte[padLength];
-
- // First bit of the padding set to 1
- pad[0] = (byte) 0x80;
-
- long bits = msgLength << 3;
- int index = padLength - 8;
- for (int i = 0; i < 8; i++) {
- pad[index++] = (byte) (bits >>> (i << 3));
- }
-
- return pad;
- }
-
- /**
- * Process one 64-byte block. Algorithm is constituted by three rounds.
- * Note that F, G and H functions were inlined for improved performance.
- *
- * @param in the byte array to process
- * @param offset the offset at which the 64-byte block is stored
- */
- private void process(byte[] in, int offset) {
- // Save previous state.
- int aa = a;
- int bb = b;
- int cc = c;
- int dd = d;
-
- // Copy the block to process into X array
- int[] X = new int[16];
- for (int i = 0; i < 16; i++) {
- X[i] = (in[offset++] & 0xff) | (in[offset++] & 0xff) << 8 | (in[offset++] & 0xff) << 16
- | (in[offset++] & 0xff) << 24;
- }
-
- // Round 1
- a += ((b & c) | (~b & d)) + X[0];
- a = a << 3 | a >>> (32 - 3);
- d += ((a & b) | (~a & c)) + X[1];
- d = d << 7 | d >>> (32 - 7);
- c += ((d & a) | (~d & b)) + X[2];
- c = c << 11 | c >>> (32 - 11);
- b += ((c & d) | (~c & a)) + X[3];
- b = b << 19 | b >>> (32 - 19);
- a += ((b & c) | (~b & d)) + X[4];
- a = a << 3 | a >>> (32 - 3);
- d += ((a & b) | (~a & c)) + X[5];
- d = d << 7 | d >>> (32 - 7);
- c += ((d & a) | (~d & b)) + X[6];
- c = c << 11 | c >>> (32 - 11);
- b += ((c & d) | (~c & a)) + X[7];
- b = b << 19 | b >>> (32 - 19);
- a += ((b & c) | (~b & d)) + X[8];
- a = a << 3 | a >>> (32 - 3);
- d += ((a & b) | (~a & c)) + X[9];
- d = d << 7 | d >>> (32 - 7);
- c += ((d & a) | (~d & b)) + X[10];
- c = c << 11 | c >>> (32 - 11);
- b += ((c & d) | (~c & a)) + X[11];
- b = b << 19 | b >>> (32 - 19);
- a += ((b & c) | (~b & d)) + X[12];
- a = a << 3 | a >>> (32 - 3);
- d += ((a & b) | (~a & c)) + X[13];
- d = d << 7 | d >>> (32 - 7);
- c += ((d & a) | (~d & b)) + X[14];
- c = c << 11 | c >>> (32 - 11);
- b += ((c & d) | (~c & a)) + X[15];
- b = b << 19 | b >>> (32 - 19);
-
- // Round 2
- a += ((b & (c | d)) | (c & d)) + X[0] + 0x5a827999;
- a = a << 3 | a >>> (32 - 3);
- d += ((a & (b | c)) | (b & c)) + X[4] + 0x5a827999;
- d = d << 5 | d >>> (32 - 5);
- c += ((d & (a | b)) | (a & b)) + X[8] + 0x5a827999;
- c = c << 9 | c >>> (32 - 9);
- b += ((c & (d | a)) | (d & a)) + X[12] + 0x5a827999;
- b = b << 13 | b >>> (32 - 13);
- a += ((b & (c | d)) | (c & d)) + X[1] + 0x5a827999;
- a = a << 3 | a >>> (32 - 3);
- d += ((a & (b | c)) | (b & c)) + X[5] + 0x5a827999;
- d = d << 5 | d >>> (32 - 5);
- c += ((d & (a | b)) | (a & b)) + X[9] + 0x5a827999;
- c = c << 9 | c >>> (32 - 9);
- b += ((c & (d | a)) | (d & a)) + X[13] + 0x5a827999;
- b = b << 13 | b >>> (32 - 13);
- a += ((b & (c | d)) | (c & d)) + X[2] + 0x5a827999;
- a = a << 3 | a >>> (32 - 3);
- d += ((a & (b | c)) | (b & c)) + X[6] + 0x5a827999;
- d = d << 5 | d >>> (32 - 5);
- c += ((d & (a | b)) | (a & b)) + X[10] + 0x5a827999;
- c = c << 9 | c >>> (32 - 9);
- b += ((c & (d | a)) | (d & a)) + X[14] + 0x5a827999;
- b = b << 13 | b >>> (32 - 13);
- a += ((b & (c | d)) | (c & d)) + X[3] + 0x5a827999;
- a = a << 3 | a >>> (32 - 3);
- d += ((a & (b | c)) | (b & c)) + X[7] + 0x5a827999;
- d = d << 5 | d >>> (32 - 5);
- c += ((d & (a | b)) | (a & b)) + X[11] + 0x5a827999;
- c = c << 9 | c >>> (32 - 9);
- b += ((c & (d | a)) | (d & a)) + X[15] + 0x5a827999;
- b = b << 13 | b >>> (32 - 13);
-
- // Round 3
- a += (b ^ c ^ d) + X[0] + 0x6ed9eba1;
- a = a << 3 | a >>> (32 - 3);
- d += (a ^ b ^ c) + X[8] + 0x6ed9eba1;
- d = d << 9 | d >>> (32 - 9);
- c += (d ^ a ^ b) + X[4] + 0x6ed9eba1;
- c = c << 11 | c >>> (32 - 11);
- b += (c ^ d ^ a) + X[12] + 0x6ed9eba1;
- b = b << 15 | b >>> (32 - 15);
- a += (b ^ c ^ d) + X[2] + 0x6ed9eba1;
- a = a << 3 | a >>> (32 - 3);
- d += (a ^ b ^ c) + X[10] + 0x6ed9eba1;
- d = d << 9 | d >>> (32 - 9);
- c += (d ^ a ^ b) + X[6] + 0x6ed9eba1;
- c = c << 11 | c >>> (32 - 11);
- b += (c ^ d ^ a) + X[14] + 0x6ed9eba1;
- b = b << 15 | b >>> (32 - 15);
- a += (b ^ c ^ d) + X[1] + 0x6ed9eba1;
- a = a << 3 | a >>> (32 - 3);
- d += (a ^ b ^ c) + X[9] + 0x6ed9eba1;
- d = d << 9 | d >>> (32 - 9);
- c += (d ^ a ^ b) + X[5] + 0x6ed9eba1;
- c = c << 11 | c >>> (32 - 11);
- b += (c ^ d ^ a) + X[13] + 0x6ed9eba1;
- b = b << 15 | b >>> (32 - 15);
- a += (b ^ c ^ d) + X[3] + 0x6ed9eba1;
- a = a << 3 | a >>> (32 - 3);
- d += (a ^ b ^ c) + X[11] + 0x6ed9eba1;
- d = d << 9 | d >>> (32 - 9);
- c += (d ^ a ^ b) + X[7] + 0x6ed9eba1;
- c = c << 11 | c >>> (32 - 11);
- b += (c ^ d ^ a) + X[15] + 0x6ed9eba1;
- b = b << 15 | b >>> (32 - 15);
-
- //Update state.
- a += aa;
- b += bb;
- c += cc;
- d += dd;
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/9f9af070/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4Provider.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4Provider.java b/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4Provider.java
deleted file mode 100644
index cdcfa60..0000000
--- a/mina-core/src/main/java/org/apache/mina/proxy/utils/MD4Provider.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.mina.proxy.utils;
-
-import java.security.Provider;
-
-/**
- * MD4Provider.java - A security provider that only provides a MD4 implementation.
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- * @since MINA 2.0.0-M3
- */
-public class MD4Provider extends Provider {
-
- /**
- * The serial version UID.
- */
- private final static long serialVersionUID = -1616816866935565456L;
-
- /**
- * Provider name.
- */
- public final static String PROVIDER_NAME = "MINA";
-
- /**
- * Provider version.
- */
- public final static double VERSION = 1.00;
-
- /**
- * Provider information.
- */
- public final static String INFO = "MINA MD4 Provider v" + VERSION;
-
- /**
- * Default constructor that registers {@link MD4} as the <i>Service Provider
- * Interface</i> (<b>SPI</b>) of the MD4 message digest algorithm.
- */
- public MD4Provider() {
- super(PROVIDER_NAME, VERSION, INFO);
- put("MessageDigest.MD4", MD4.class.getName());
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/9f9af070/mina-core/src/test/java/org/apache/mina/proxy/MD4Test.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/proxy/MD4Test.java b/mina-core/src/test/java/org/apache/mina/proxy/MD4Test.java
deleted file mode 100644
index 78b0b6d..0000000
--- a/mina-core/src/test/java/org/apache/mina/proxy/MD4Test.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.mina.proxy;
-
-import static org.apache.mina.proxy.utils.ByteUtilities.asHex;
-import static org.junit.Assert.assertEquals;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Security;
-
-import org.apache.mina.proxy.utils.MD4Provider;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * MD4Test.java - JUnit testcase that tests the rfc 1320 test suite.
- * @see <a href="http://www.ietf.org/rfc/rfc1320.txt">RFC 1320</a>
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- * @since MINA 2.0.0-M3
- */
-public class MD4Test {
-
- /**
- * {@inheritDoc}
- */
- @Before
- public void setUp() throws Exception {
- if (Security.getProvider(MD4Provider.PROVIDER_NAME) == null) {
- System.out.print("Adding MINA provider...");
- Security.addProvider(new MD4Provider());
- //System.out.println(" [Ok]");
- }
- }
-
- /**
- * Test suite for the MD4 algorithm.
- */
- @Test
- public void testRFCVectors() throws NoSuchAlgorithmException, NoSuchProviderException {
- MessageDigest md4 = MessageDigest.getInstance("MD4", MD4Provider.PROVIDER_NAME);
- doTest(md4, "31d6cfe0d16ae931b73c59d7e0c089c0", "");
- doTest(md4, "bde52cb31de33e46245e05fbdbd6fb24", "a");
- doTest(md4, "a448017aaf21d8525fc10ae87aa6729d", "abc");
- doTest(md4, "d9130a8164549fe818874806e1c7014b", "message digest");
- doTest(md4, "d79e1c308aa5bbcdeea8ed63df412da9", "abcdefghijklmnopqrstuvwxyz");
- doTest(md4, "043f8582f241db351ce627e153e7f0e4",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
- doTest(md4, "e33b4ddc9c38f2199c3e7b164fcc0536",
- "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
- }
-
- /**
- * Original test vector found on <a href="http://en.wikipedia.org/wiki/MD4">wikipedia(en)</a>
- * and <a href="http://fr.wikipedia.org/wiki/MD4">wikipedia(fr)</a>
- */
- @Test
- public void testWikipediaVectors() throws NoSuchAlgorithmException, NoSuchProviderException {
- MessageDigest md4 = MessageDigest.getInstance("MD4", MD4Provider.PROVIDER_NAME);
- doTest(md4, "b94e66e0817dd34dc7858a0c131d4079", "Wikipedia, l'encyclopedie libre et gratuite");
- doTest(md4, "1bee69a46ba811185c194762abaeae90", "The quick brown fox jumps over the lazy dog");
- doTest(md4, "b86e130ce7028da59e672d56ad0113df", "The quick brown fox jumps over the lazy cog");
- }
-
- /**
- * Performs md4 digesting on the provided test vector and verifies that the
- * result equals to the expected result.
- *
- * @param md4 the md4 message digester
- * @param expected the expected hex formatted string
- * @param testVector the string message
- */
- private static void doTest(MessageDigest md4, String expected, String testVector) {
- String result = asHex(md4.digest(testVector.getBytes()));
- assertEquals(expected, result);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/9f9af070/mina-core/src/test/java/org/apache/mina/proxy/NTLMTest.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/proxy/NTLMTest.java b/mina-core/src/test/java/org/apache/mina/proxy/NTLMTest.java
index f3fea78..c3e2375 100644
--- a/mina-core/src/test/java/org/apache/mina/proxy/NTLMTest.java
+++ b/mina-core/src/test/java/org/apache/mina/proxy/NTLMTest.java
@@ -31,7 +31,6 @@ import java.security.Security;
import org.apache.mina.proxy.handlers.http.ntlm.NTLMResponses;
import org.apache.mina.proxy.handlers.http.ntlm.NTLMUtilities;
import org.apache.mina.proxy.utils.ByteUtilities;
-import org.apache.mina.proxy.utils.MD4Provider;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,12 +44,6 @@ import org.slf4j.LoggerFactory;
public class NTLMTest {
private final static Logger logger = LoggerFactory.getLogger(NTLMTest.class);
- static {
- if (Security.getProvider("MINA") == null) {
- Security.addProvider(new MD4Provider());
- }
- }
-
/**
* Tests bytes manipulations.
*/
@@ -243,4 +236,4 @@ public class NTLMTest {
ByteUtilities.asByteArray(targetInformation), ByteUtilities.asByteArray("0123456789abcdef"),
ByteUtilities.asByteArray("ffffff0011223344"), 1055844000000L)));
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/9f9af070/mina-example/src/test/java/org/apache/mina/example/proxy/ProxyTestClient.java
----------------------------------------------------------------------
diff --git a/mina-example/src/test/java/org/apache/mina/example/proxy/ProxyTestClient.java b/mina-example/src/test/java/org/apache/mina/example/proxy/ProxyTestClient.java
index b913dee..443165c 100644
--- a/mina-example/src/test/java/org/apache/mina/example/proxy/ProxyTestClient.java
+++ b/mina-example/src/test/java/org/apache/mina/example/proxy/ProxyTestClient.java
@@ -39,7 +39,6 @@ import org.apache.mina.proxy.handlers.http.HttpProxyRequest;
import org.apache.mina.proxy.handlers.socks.SocksProxyConstants;
import org.apache.mina.proxy.handlers.socks.SocksProxyRequest;
import org.apache.mina.proxy.session.ProxyIoSession;
-import org.apache.mina.proxy.utils.MD4Provider;
import org.apache.mina.transport.socket.nio.NioSocketConnector;
/**
@@ -80,15 +79,6 @@ public class ProxyTestClient {
private final static boolean USE_HTTP_1_1 = false;
/**
- * NTLM proxy authentication needs a JCE provider that handles MD4 hashing.
- */
- static {
- if (Security.getProvider("MINA") == null) {
- Security.addProvider(new MD4Provider());
- }
- }
-
- /**
* Creates a connection to the endpoint through a proxy server using the specified
* authentication method.
*
@@ -227,4 +217,4 @@ public class ProxyTestClient {
public static void main(String[] args) throws Exception {
new ProxyTestClient(args);
}
-}
\ No newline at end of file
+}
[2/8] git commit: Aplied the proposed modification from DIRMINA-948
Posted by je...@apache.org.
Aplied the proposed modification from DIRMINA-948
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/f72467ad
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/f72467ad
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/f72467ad
Branch: refs/heads/2.0
Commit: f72467ad34ad2573760d74e3ce8714279e71287b
Parents: 4ae142b
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Wed Oct 9 16:30:42 2013 +0200
Committer: Emmanuel Lécharny <el...@apache.org>
Committed: Wed Oct 9 16:30:42 2013 +0200
----------------------------------------------------------------------
.../core/filterchain/DefaultIoFilterChain.java | 76 ++++++++++----------
1 file changed, 38 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/f72467ad/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
index 9ba0087..e8bc73d 100644
--- a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
+++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
@@ -91,45 +91,45 @@ public class DefaultIoFilterChain implements IoFilterChain {
public Entry getEntry(String name) {
Entry e = name2entry.get(name);
-
+
if (e == null) {
return null;
}
-
+
return e;
}
public Entry getEntry(IoFilter filter) {
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
if (e.getFilter() == filter) {
return e;
}
-
+
e = e.nextEntry;
}
-
+
return null;
}
public Entry getEntry(Class<? extends IoFilter> filterType) {
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
if (filterType.isAssignableFrom(e.getFilter().getClass())) {
return e;
}
-
+
e = e.nextEntry;
}
-
+
return null;
}
public IoFilter get(String name) {
Entry e = getEntry(name);
-
+
if (e == null) {
return null;
}
@@ -139,7 +139,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
public IoFilter get(Class<? extends IoFilter> filterType) {
Entry e = getEntry(filterType);
-
+
if (e == null) {
return null;
}
@@ -149,7 +149,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
public NextFilter getNextFilter(String name) {
Entry e = getEntry(name);
-
+
if (e == null) {
return null;
}
@@ -159,7 +159,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
public NextFilter getNextFilter(IoFilter filter) {
Entry e = getEntry(filter);
-
+
if (e == null) {
return null;
}
@@ -169,7 +169,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
public NextFilter getNextFilter(Class<? extends IoFilter> filterType) {
Entry e = getEntry(filterType);
-
+
if (e == null) {
return null;
}
@@ -207,32 +207,32 @@ public class DefaultIoFilterChain implements IoFilterChain {
public synchronized void remove(IoFilter filter) {
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
if (e.getFilter() == filter) {
deregister(e);
return;
}
-
+
e = e.nextEntry;
}
-
+
throw new IllegalArgumentException("Filter not found: " + filter.getClass().getName());
}
public synchronized IoFilter remove(Class<? extends IoFilter> filterType) {
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
if (filterType.isAssignableFrom(e.getFilter().getClass())) {
IoFilter oldFilter = e.getFilter();
deregister(e);
return oldFilter;
}
-
+
e = e.nextEntry;
}
-
+
throw new IllegalArgumentException("Filter not found: " + filterType.getName());
}
@@ -240,44 +240,44 @@ public class DefaultIoFilterChain implements IoFilterChain {
EntryImpl entry = checkOldName(name);
IoFilter oldFilter = entry.getFilter();
entry.setFilter(newFilter);
-
+
return oldFilter;
}
public synchronized void replace(IoFilter oldFilter, IoFilter newFilter) {
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
if (e.getFilter() == oldFilter) {
e.setFilter(newFilter);
return;
}
-
+
e = e.nextEntry;
}
-
+
throw new IllegalArgumentException("Filter not found: " + oldFilter.getClass().getName());
}
public synchronized IoFilter replace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter) {
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
if (oldFilterType.isAssignableFrom(e.getFilter().getClass())) {
IoFilter oldFilter = e.getFilter();
e.setFilter(newFilter);
return oldFilter;
}
-
+
e = e.nextEntry;
}
-
+
throw new IllegalArgumentException("Filter not found: " + oldFilterType.getName());
}
public synchronized void clear() throws Exception {
List<IoFilterChain.Entry> l = new ArrayList<IoFilterChain.Entry>(name2entry.values());
-
+
for (IoFilterChain.Entry entry : l) {
try {
deregister((EntryImpl) entry);
@@ -344,11 +344,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
*/
private EntryImpl checkOldName(String baseName) {
EntryImpl e = (EntryImpl) name2entry.get(baseName);
-
+
if (e == null) {
throw new IllegalArgumentException("Filter not found:" + baseName);
}
-
+
return e;
}
@@ -523,7 +523,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
public List<Entry> getAll() {
List<Entry> list = new ArrayList<Entry>();
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
list.add(e);
e = e.nextEntry;
@@ -535,12 +535,12 @@ public class DefaultIoFilterChain implements IoFilterChain {
public List<Entry> getAllReversed() {
List<Entry> list = new ArrayList<Entry>();
EntryImpl e = tail.prevEntry;
-
+
while (e != head) {
list.add(e);
e = e.prevEntry;
}
-
+
return list;
}
@@ -564,7 +564,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
boolean empty = true;
EntryImpl e = head.nextEntry;
-
+
while (e != tail) {
if (!empty) {
buf.append(", ");
@@ -616,7 +616,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();
if (!s.isWriteSuspended()) {
- if (writeRequestQueue.size() == 0) {
+ if (writeRequestQueue.isEmpty(session)) {
// We can write directly the message
s.getProcessor().write(s, writeRequest);
} else {
@@ -643,7 +643,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
} finally {
// Notify the related future.
ConnectFuture future = (ConnectFuture) session.removeAttribute(SESSION_CREATED_FUTURE);
-
+
if (future != null) {
future.setSession(session);
}
@@ -658,7 +658,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
@Override
public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception {
AbstractIoSession s = (AbstractIoSession) session;
-
+
try {
s.getHandler().sessionClosed(session);
} finally {
@@ -747,7 +747,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
if (filter == null) {
throw new IllegalArgumentException("filter");
}
-
+
if (name == null) {
throw new IllegalArgumentException("name");
}
@@ -858,7 +858,7 @@ public class DefaultIoFilterChain implements IoFilterChain {
}
sb.append("')");
-
+
return sb.toString();
}
[4/8] git commit: Removed the reference to javassist,
it's already pulled by the ognl lib. Fix for DIRMINA-938
Posted by je...@apache.org.
Removed the reference to javassist, it's already pulled by the ognl lib. Fix for DIRMINA-938
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/ab618cd5
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/ab618cd5
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/ab618cd5
Branch: refs/heads/2.0
Commit: ab618cd52920640ae75d718195c95d6221a18d98
Parents: 9f9af07
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Fri Mar 15 15:59:32 2013 +0100
Committer: Jeff MAURY <je...@apache.org>
Committed: Wed Nov 27 13:23:04 2013 +0100
----------------------------------------------------------------------
mina-integration-ognl/pom.xml | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/ab618cd5/mina-integration-ognl/pom.xml
----------------------------------------------------------------------
diff --git a/mina-integration-ognl/pom.xml b/mina-integration-ognl/pom.xml
index 5bb4e7a..ac3b4b8 100644
--- a/mina-integration-ognl/pom.xml
+++ b/mina-integration-ognl/pom.xml
@@ -55,11 +55,5 @@
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
</dependency>
-
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>javassist</artifactId>
- <scope>runtime</scope>
- </dependency>
</dependencies>
</project>
[3/8] git commit: Applied the patch proposed by Jon (DIRMINA-929)
Posted by je...@apache.org.
Applied the patch proposed by Jon (DIRMINA-929)
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/f42feedc
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/f42feedc
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/f42feedc
Branch: refs/heads/2.0
Commit: f42feedcdaf8922df788fa5bde62e363cbc10c41
Parents: f72467a
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Fri Jan 11 18:02:59 2013 +0100
Committer: Jeff MAURY <je...@apache.org>
Committed: Wed Nov 27 13:23:03 2013 +0100
----------------------------------------------------------------------
.../mina/core/polling/AbstractPollingIoProcessor.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/f42feedc/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
index 0924f18..5268434 100644
--- a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
+++ b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
@@ -846,6 +846,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
if ((localWrittenBytes > 0) && ((IoBuffer) message).hasRemaining()) {
// the buffer isn't empty, we re-interest it in writing
+ writtenBytes += localWrittenBytes;
setInterestedInWrite(session, true);
return false;
}
@@ -859,6 +860,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
// return 0 indicating that we need
// to pause until writing may resume.
if ((localWrittenBytes > 0) && (((FileRegion) message).getRemainingBytes() > 0)) {
+ writtenBytes += localWrittenBytes;
setInterestedInWrite(session, true);
return false;
}
@@ -880,6 +882,10 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
scheduleFlush(session);
return false;
}
+
+ if (message instanceof IoBuffer) {
+ ((IoBuffer) message).free();
+ }
} while (writtenBytes < maxWrittenBytes);
} catch (Exception e) {
if (req != null) {
@@ -913,7 +919,9 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
} catch (IOException ioe) {
// We have had an issue while trying to send data to the
// peer : let's close the session.
+ buf.free();
session.close(true);
+ return 0;
}
}
@@ -925,8 +933,6 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
int pos = buf.position();
buf.reset();
- session.increaseScheduledWriteMessages();
-
fireMessageSent(session, req);
// And set it back to its position
[6/8] git commit: Add unit test for DIRMINA-937. Ignored for the
build not to fail
Posted by je...@apache.org.
Add unit test for DIRMINA-937. Ignored for the build not to fail
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/885ec9fa
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/885ec9fa
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/885ec9fa
Branch: refs/heads/2.0
Commit: 885ec9fa3fb9b01cf41ade4751832ca1e4397af7
Parents: ab618cd
Author: Jeff MAURY <je...@apache.org>
Authored: Tue Mar 26 00:18:43 2013 +0100
Committer: Jeff MAURY <je...@apache.org>
Committed: Wed Nov 27 13:23:05 2013 +0100
----------------------------------------------------------------------
.../mina/filter/ssl/SslDIRMINA937Test.java | 170 +++++++++++++++++++
1 file changed, 170 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/885ec9fa/mina-core/src/test/java/org/apache/mina/filter/ssl/SslDIRMINA937Test.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/filter/ssl/SslDIRMINA937Test.java b/mina-core/src/test/java/org/apache/mina/filter/ssl/SslDIRMINA937Test.java
new file mode 100644
index 0000000..0086729
--- /dev/null
+++ b/mina-core/src/test/java/org/apache/mina/filter/ssl/SslDIRMINA937Test.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.mina.filter.ssl;
+
+import static org.junit.Assert.*;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.Security;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
+import org.apache.mina.core.service.IoHandlerAdapter;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
+import org.apache.mina.transport.socket.nio.NioSocketConnector;
+import org.apache.mina.util.AvailablePortFinder;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test an SSL session where the connection cannot be established with the server due to
+ * incompatible protocols (Test for DIRMINA-937)
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class SslDIRMINA937Test {
+ /** A static port used for his test, chosen to avoid collisions */
+ private static final int port = AvailablePortFinder.getNextAvailable(5555);
+
+ private static Exception clientError = null;
+
+ /** A JVM independant KEY_MANAGER_FACTORY algorithm */
+ private static final String KEY_MANAGER_FACTORY_ALGORITHM;
+
+ static {
+ String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm");
+ if (algorithm == null) {
+ algorithm = KeyManagerFactory.getDefaultAlgorithm();
+ }
+
+ KEY_MANAGER_FACTORY_ALGORITHM = algorithm;
+ }
+
+ private static class TestHandler extends IoHandlerAdapter {
+ public void messageReceived(IoSession session, Object message) throws Exception {
+ String line = (String) message;
+
+ if (line.startsWith("hello")) {
+ System.out.println("Server got: 'hello', waiting for 'send'");
+ Thread.sleep(1500);
+ } else if (line.startsWith("send")) {
+ System.out.println("Server got: 'send', sending 'data'");
+ session.write("data");
+ }
+ }
+ }
+
+ /**
+ * Starts a Server with the SSL Filter and a simple text line
+ * protocol codec filter
+ */
+ private static void startServer() throws Exception {
+ NioSocketAcceptor acceptor = new NioSocketAcceptor();
+
+ acceptor.setReuseAddress(true);
+ DefaultIoFilterChainBuilder filters = acceptor.getFilterChain();
+
+ // Inject the SSL filter
+ SSLContext context = createSSLContext("TLSv1");
+ SslFilter sslFilter = new SslFilter(context);
+ sslFilter.setEnabledProtocols(new String[] { "TLSv1" });
+ //sslFilter.setEnabledCipherSuites(getServerCipherSuites(context.getDefaultSSLParameters().getCipherSuites()));
+ filters.addLast("sslFilter", sslFilter);
+
+ // Inject the TestLine codec filter
+ filters.addLast("text", new ProtocolCodecFilter(new TextLineCodecFactory()));
+
+ acceptor.setHandler(new TestHandler());
+ acceptor.bind(new InetSocketAddress(port));
+ }
+
+ /**
+ * Starts a client which will connect twice using SSL
+ */
+ private static void startClient(final CountDownLatch counter) throws Exception {
+ NioSocketConnector connector = new NioSocketConnector();
+
+ DefaultIoFilterChainBuilder filters = connector.getFilterChain();
+ SslFilter sslFilter = new SslFilter(createSSLContext("TLSv1.1"));
+ sslFilter.setEnabledProtocols(new String[] { "TLSv1.1" });
+ sslFilter.setUseClientMode(true);
+ //sslFilter.setEnabledCipherSuites(getClientCipherSuites());
+ filters.addLast("sslFilter", sslFilter);
+ connector.setHandler(new IoHandlerAdapter() {
+ @Override
+ public void sessionCreated(IoSession session) throws Exception {
+ session.setAttribute(SslFilter.USE_NOTIFICATION, Boolean.TRUE);
+ }
+
+ @Override
+ public void messageReceived(IoSession session, Object message) throws Exception {
+ if (message == SslFilter.SESSION_SECURED) {
+ counter.countDown();
+ }
+ }
+
+
+ });
+ connector.connect(new InetSocketAddress("localhost", port));
+ }
+
+ private static SSLContext createSSLContext(String protocol) throws IOException, GeneralSecurityException {
+ char[] passphrase = "password".toCharArray();
+
+ SSLContext ctx = SSLContext.getInstance(protocol);
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KEY_MANAGER_FACTORY_ALGORITHM);
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(KEY_MANAGER_FACTORY_ALGORITHM);
+
+ KeyStore ks = KeyStore.getInstance("JKS");
+ KeyStore ts = KeyStore.getInstance("JKS");
+
+ ks.load(SslDIRMINA937Test.class.getResourceAsStream("keystore.sslTest"), passphrase);
+ ts.load(SslDIRMINA937Test.class.getResourceAsStream("truststore.sslTest"), passphrase);
+
+ kmf.init(ks, passphrase);
+ tmf.init(ts);
+ ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+ return ctx;
+ }
+
+ /**
+ * Test is ignore as it will cause the build to fail
+ */
+ @Test
+ @Ignore
+ public void testDIRMINA937() throws Exception {
+ startServer();
+
+ final CountDownLatch counter = new CountDownLatch(1);
+ startClient(counter);
+ assertTrue(counter.await(10, TimeUnit.SECONDS));
+ }
+}