1 /** 2 * Waffle (https://github.com/dblock/waffle) 3 * 4 * Copyright (c) 2010 - 2015 Application Security, Inc. 5 * 6 * All rights reserved. This program and the accompanying materials 7 * are made available under the terms of the Eclipse Public License v1.0 8 * which accompanies this distribution, and is available at 9 * http://www.eclipse.org/legal/epl-v10.html 10 * 11 * Contributors: 12 * Application Security, Inc. 13 */ 14 package waffle.util; 15 16 import javax.servlet.http.HttpServletRequest; 17 18 import com.google.common.base.Joiner; 19 20 /** 21 * The Class NtlmServletRequest. 22 * 23 * @author dblock[at]dblock[dot]org 24 */ 25 public final class NtlmServletRequest { 26 27 /** 28 * Returns a unique connection id for a given servlet request. 29 * 30 * @param request 31 * Servlet request. 32 * @return String. 33 */ 34 public static String getConnectionId(final HttpServletRequest request) { 35 return Joiner.on(":").useForNull("") 36 .join(NtlmServletRequest.getRemoteHost(request), Integer.valueOf(request.getRemotePort())); 37 } 38 39 /** 40 * Gets the remote host. 41 * 42 * @param request 43 * the request 44 * @return the remote host 45 */ 46 private static String getRemoteHost(final HttpServletRequest request) { 47 return request.getRemoteHost() == null ? request.getRemoteAddr() : request.getRemoteHost(); 48 } 49 50 /** 51 * Instantiates a new ntlm servlet request. 52 */ 53 private NtlmServletRequest() { 54 // Prevent Instantiation of object 55 } 56 57 }