2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf.util.messages;
11 import com.google.common.base.Optional;
12 import com.google.common.base.Preconditions;
15 * Additional header can be used with hello message to carry information about
16 * session's connection. Provided information can be reported via netconf
19 * It has pattern "[username; host-address:port; transport; session-identifier;]"
20 * username - name of account on a remote
21 * host-address - client's IP address
23 * transport - tcp, ssh
24 * session-identifier - persister, client
25 * Session-identifier is optional, others mandatory.
28 public class NetconfMessageAdditionalHeader {
30 private static final String SC = ";";
32 public static String toString(String userName, String hostAddress, String port, String transport,
33 Optional<String> sessionIdentifier) {
34 Preconditions.checkNotNull(userName);
35 Preconditions.checkNotNull(hostAddress);
36 Preconditions.checkNotNull(port);
37 Preconditions.checkNotNull(transport);
38 String identifier = sessionIdentifier.isPresent() ? sessionIdentifier.get() : "";
39 return "[" + userName + SC + hostAddress + ":" + port + SC + transport + SC + identifier + SC + "]"
40 + System.lineSeparator();