Package ch.ethz.inf.vs.scandium.dtls

Examples of ch.ethz.inf.vs.scandium.dtls.HandshakeMessage


             * a HelloRequest (from server) or a ClientHello
             * (from client) => initialize appropriate
             * handshaker type
             */

            HandshakeMessage handshake = (HandshakeMessage) record.getFragment();

            switch (handshake.getMessageType()) {
            case HELLO_REQUEST:
              /*
               * Client side: server desires a re-handshake
               */
              if (session == null) {
                // create new session
                session = new DTLSSession(peerAddress, true);
                // store session according to peer address
                dtlsSessions.put(addressToKey(peerAddress), session);

                LOGGER.info("Created new session as client with peer: " + peerAddress.toString());
              }
              handshaker = new ClientHandshaker(peerAddress, null, session);
              handshakers.put(addressToKey(peerAddress), handshaker);
              LOGGER.finest("Stored re-handshaker: " + handshaker.toString() + " for " + peerAddress.toString());
              break;

            case CLIENT_HELLO:
              /*
               * Server side: server received a client hello:
               * check first if client wants to resume a
               * session (message must contain session
               * identifier) and then check if particular
               * session still available, otherwise conduct
               * full handshake with fresh session.
               */

              if (!(handshake instanceof FragmentedHandshakeMessage)) {
                // check if session identifier set
                ClientHello clientHello = (ClientHello) handshake;
                session = getSessionByIdentifier(clientHello.getSessionId().getSessionId());
              }
             
              if (session == null) {
                // create new session
                session = new DTLSSession(peerAddress, false);
                // store session according to peer address
                dtlsSessions.put(addressToKey(peerAddress), session);

                LOGGER.info("Created new session as server with peer: " + peerAddress.toString());
                handshaker = new ServerHandshaker(peerAddress, session);
              } else {
                handshaker = new ResumingServerHandshaker(peerAddress, session);
              }
              handshakers.put(addressToKey(peerAddress), handshaker);
              LOGGER.finest("Stored handshaker: " + handshaker.toString() + " for " + peerAddress.toString());
              break;

            default:
              LOGGER.severe("Received unexpected first handshake message (type="+handshake.getMessageType()+") from " + peerAddress.toString() + ":\n" + handshake.toString());
              break;
            }
          }
          flight = handshaker.processMessage(record);
          break;
View Full Code Here

TOP

Related Classes of ch.ethz.inf.vs.scandium.dtls.HandshakeMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.