001/* 002 * Copyright 2009-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2018 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.logs; 022 023 024 025import com.unboundid.util.NotMutable; 026import com.unboundid.util.ThreadSafety; 027import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031/** 032 * This class provides a data structure that holds information about a log 033 * message that may appear in the Directory Server access log about an add 034 * request forwarded to a backend server. 035 * <BR> 036 * <BLOCKQUOTE> 037 * <B>NOTE:</B> This class, and other classes within the 038 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 039 * supported for use against Ping Identity, UnboundID, and 040 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 041 * for proprietary functionality or for external specifications that are not 042 * considered stable or mature enough to be guaranteed to work in an 043 * interoperable way with other types of LDAP servers. 044 * </BLOCKQUOTE> 045 */ 046@NotMutable() 047@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 048public final class AddForwardAccessLogMessage 049 extends AddRequestAccessLogMessage 050{ 051 /** 052 * The serial version UID for this serializable class. 053 */ 054 private static final long serialVersionUID = 5311495513879603972L; 055 056 057 058 // The port of the backend server to which the request has been forwarded. 059 private final Integer targetPort; 060 061 // The address of the backend server to which the request has been forwarded. 062 private final String targetHost; 063 064 // The protocol used to forward the request to the backend server. 065 private final String targetProtocol; 066 067 068 069 /** 070 * Creates a new add forward access log message from the provided message 071 * string. 072 * 073 * @param s The string to be parsed as an add forward access log message. 074 * 075 * @throws LogException If the provided string cannot be parsed as a valid 076 * log message. 077 */ 078 public AddForwardAccessLogMessage(final String s) 079 throws LogException 080 { 081 this(new LogMessage(s)); 082 } 083 084 085 086 /** 087 * Creates a new add forward access log message from the provided log message. 088 * 089 * @param m The log message to be parsed as an add forward access log 090 * message. 091 */ 092 public AddForwardAccessLogMessage(final LogMessage m) 093 { 094 super(m); 095 096 targetHost = getNamedValue("targetHost"); 097 targetPort = getNamedValueAsInteger("targetPort"); 098 targetProtocol = getNamedValue("targetProtocol"); 099 } 100 101 102 103 /** 104 * Retrieves the address of the backend server to which the request has been 105 * forwarded. 106 * 107 * @return The address of the backend server to which the request has been 108 * forwarded, or {@code null} if it is not included in the log 109 * message. 110 */ 111 public String getTargetHost() 112 { 113 return targetHost; 114 } 115 116 117 118 /** 119 * Retrieves the port of the backend server to which the request has been 120 * forwarded. 121 * 122 * @return The port of the backend server to which the request has been 123 * forwarded, or {@code null} if it is not included in the log 124 * message. 125 */ 126 public Integer getTargetPort() 127 { 128 return targetPort; 129 } 130 131 132 133 /** 134 * Retrieves the protocol used to forward the request to the backend server. 135 * 136 * @return The protocol used to forward the request to the backend server, or 137 * {@code null} if it is not included in the log message. 138 */ 139 public String getTargetProtocol() 140 { 141 return targetProtocol; 142 } 143 144 145 146 /** 147 * {@inheritDoc} 148 */ 149 @Override() 150 public AccessLogMessageType getMessageType() 151 { 152 return AccessLogMessageType.FORWARD; 153 } 154}