X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2FNetconfServerSessionNegotiator.java;fp=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2FNetconfServerSessionNegotiator.java;h=0000000000000000000000000000000000000000;hp=0dd79e2723c32034df26c79583c83bdbe117a793;hb=9ba2b4eca79bcc0e78099b133296801c8d45a6c4;hpb=b2e81149739c87f0ecc2ce7f06448d7a5d3162b8 diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java deleted file mode 100644 index 0dd79e2723..0000000000 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.impl; - -import com.google.common.base.Optional; -import io.netty.channel.Channel; -import io.netty.channel.local.LocalAddress; -import io.netty.util.Timer; -import io.netty.util.concurrent.Promise; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.util.AbstractMap; -import java.util.Map; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.NetconfServerSessionPreferences; -import org.opendaylight.controller.netconf.nettyutil.AbstractNetconfSessionNegotiator; -import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage; -import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NetconfServerSessionNegotiator - extends - AbstractNetconfSessionNegotiator { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionNegotiator.class); - - private static final String UNKNOWN = "unknown"; - - protected NetconfServerSessionNegotiator( - NetconfServerSessionPreferences sessionPreferences, - Promise promise, Channel channel, - Timer timer, NetconfServerSessionListener sessionListener, - long connectionTimeoutMillis) { - super(sessionPreferences, promise, channel, timer, sessionListener, - connectionTimeoutMillis); - } - - @Override - protected void handleMessage(NetconfHelloMessage netconfMessage) - throws NetconfDocumentedException { - NetconfServerSession session = getSessionForHelloMessage(netconfMessage); - replaceHelloMessageInboundHandler(session); - // Negotiation successful after all non hello messages were processed - negotiationSuccessful(session); - } - - @Override - protected NetconfServerSession getSession( - NetconfServerSessionListener sessionListener, Channel channel, - NetconfHelloMessage message) { - Optional additionalHeader = message - .getAdditionalHeader(); - - NetconfHelloMessageAdditionalHeader parsedHeader; - if (additionalHeader.isPresent()) { - parsedHeader = additionalHeader.get(); - } else { - - parsedHeader = new NetconfHelloMessageAdditionalHeader(UNKNOWN, - getHostName(channel.localAddress()).getValue(), - getHostName(channel.localAddress()).getKey(), "tcp", - "client"); - - } - - LOG.debug("Additional header from hello parsed as {} from {}", - parsedHeader, additionalHeader); - - return new NetconfServerSession(sessionListener, channel, - getSessionPreferences().getSessionId(), parsedHeader); - } - - /** - * @param socketAddress - * type of socket address LocalAddress, or - * InetSocketAddress, for others returns unknown - * @return Map two values - port and host of socket address - */ - protected static Map.Entry getHostName( - SocketAddress socketAddress) { - - if (socketAddress instanceof InetSocketAddress) { - - InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; - - return new AbstractMap.SimpleImmutableEntry<>( - Integer.toString(inetSocketAddress.getPort()), - inetSocketAddress.getHostString()); - - } else if (socketAddress instanceof LocalAddress) { - - return new AbstractMap.SimpleImmutableEntry<>(UNKNOWN, - ((LocalAddress) socketAddress).id()); - - } - return new AbstractMap.SimpleImmutableEntry<>(UNKNOWN, UNKNOWN); - - } - -}