You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2010/01/11 17:30:36 UTC
svn commit: r897928 - in
/mina/trunk/core/src/main/java/org/apache/mina/filter/ssl: SslFilter.java
SslHandler.java
Author: elecharny
Date: Mon Jan 11 16:30:36 2010
New Revision: 897928
URL: http://svn.apache.org/viewvc?rev=897928&view=rev
Log:
o Some more cleanup and improvement of the getSessionInfo method
Modified:
mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslHandler.java
Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java?rev=897928&r1=897927&r2=897928&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java Mon Jan 11 16:30:36 2010
@@ -230,7 +230,12 @@
}
- private String getSessionInfo(IoSession session) {
+ /**
+ * An extended toString() method for sessions. If the SSL handshake
+ * is not yet completed, we will print (ssl) in small caps. Once it's
+ * completed, we will use SSL capitalized.
+ */
+ /* no qualifier */ String getSessionInfo(IoSession session) {
StringBuilder sb = new StringBuilder();
if (session.getService() instanceof IoAcceptor) {
@@ -242,9 +247,11 @@
sb.append('[').append(session.getId()).append(']');
- SslHandler handler = getSslSessionHandler(session);
-
- if (isSslStarted(session)) {
+ SslHandler handler = (SslHandler) session.getAttribute(SSL_HANDLER);
+
+ if (handler == null) {
+ sb.append("(no sslEngine)");
+ } else if (isSslStarted(session)) {
if ( handler.isHandshakeComplete()) {
sb.append("(SSL)");
} else {
Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslHandler.java?rev=897928&r1=897927&r2=897928&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslHandler.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/ssl/SslHandler.java Mon Jan 11 16:30:36 2010
@@ -135,7 +135,7 @@
return;
}
- LOGGER.debug("Session[{}]: Initializing the SSL Handler", session.getId());
+ LOGGER.debug("{} Initializing the SSL Handler", sslFilter.getSessionInfo(session));
InetSocketAddress peer = (InetSocketAddress) session.getAttribute(SslFilter.PEER_ADDRESS);
@@ -185,7 +185,9 @@
firstSSLNegociation = true;
handshakeComplete = false;
- LOGGER.debug("Session[{}]: SSL Handler Initialization done.", session.getId());
+ if ( LOGGER.isDebugEnabled()) {
+ LOGGER.debug("{} SSL Handler Initialization done.", sslFilter.getSessionInfo(session));
+ }
}
@@ -331,9 +333,9 @@
/* no qualifier */ void messageReceived(NextFilter nextFilter, ByteBuffer buf) throws SSLException {
if ( LOGGER.isDebugEnabled()) {
if ( !isOutboundDone()) {
- LOGGER.debug("Session[{}](SSL): Processing the received message", session.getId());
+ LOGGER.debug("{} Processing the received message", sslFilter.getSessionInfo(session));
} else {
- LOGGER.debug("Session[{}]: Processing the received message", session.getId());
+ LOGGER.debug("{} Processing the received message", sslFilter.getSessionInfo(session));
}
}
@@ -508,7 +510,10 @@
for (;;) {
switch (handshakeStatus) {
case FINISHED:
- LOGGER.debug("Session[{}] : processing the FINISHED state", session.getId());
+ if ( LOGGER.isDebugEnabled()) {
+ LOGGER.debug("{} processing the FINISHED state", sslFilter.getSessionInfo(session));
+ }
+
session.setAttribute(SslFilter.SSL_SESSION, sslEngine.getSession());
handshakeComplete = true;
@@ -521,21 +526,26 @@
if ( LOGGER.isDebugEnabled()) {
if ( !isOutboundDone()) {
- LOGGER.debug("Session[{}] is now secured", session.getId());
+ LOGGER.debug("{} is now secured", sslFilter.getSessionInfo(session));
} else {
- LOGGER.debug("Session[{}] is not secured yet", session.getId());
+ LOGGER.debug("{} is not secured yet", sslFilter.getSessionInfo(session));
}
}
return;
case NEED_TASK:
- LOGGER.debug("Session[{}] : processing the NEED_TASK state", session.getId());
+ if ( LOGGER.isDebugEnabled()) {
+ LOGGER.debug("{} processing the NEED_TASK state", sslFilter.getSessionInfo(session));
+ }
+
handshakeStatus = doTasks();
break;
case NEED_UNWRAP:
- LOGGER.debug("Session[{}] : processing the NEED_UNWRAP state", session.getId());
+ if ( LOGGER.isDebugEnabled()) {
+ LOGGER.debug("{} processing the NEED_UNWRAP state", sslFilter.getSessionInfo(session));
+ }
// we need more data read
SSLEngineResult.Status status = unwrapHandshake(nextFilter);
@@ -548,7 +558,10 @@
break;
case NEED_WRAP:
- LOGGER.debug("Session[{}] : processing the NEED_WRAP state", session.getId());
+ if ( LOGGER.isDebugEnabled()) {
+ LOGGER.debug("{} processing the NEED_WRAP state", sslFilter.getSessionInfo(session));
+ }
+
// First make sure that the out buffer is completely empty.
// Since we
// cannot call wrap with data left on the buffer