001/* 002 * Copyright 2022-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2022-2024 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2022-2024 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.unboundidds.logs.v2.text; 037 038 039 040import com.unboundid.ldap.sdk.unboundidds.logs.AccessLogMessageType; 041import com.unboundid.ldap.sdk.unboundidds.logs.LogException; 042import com.unboundid.ldap.sdk.unboundidds.logs.v2.ConnectAccessLogMessage; 043import com.unboundid.util.NotMutable; 044import com.unboundid.util.NotNull; 045import com.unboundid.util.Nullable; 046import com.unboundid.util.ThreadSafety; 047import com.unboundid.util.ThreadSafetyLevel; 048 049 050 051/** 052 * This class provides a data structure that holds information about a 053 * text-formatted connect access log message. 054 * <BR> 055 * <BLOCKQUOTE> 056 * <B>NOTE:</B> This class, and other classes within the 057 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 058 * supported for use against Ping Identity, UnboundID, and 059 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 060 * for proprietary functionality or for external specifications that are not 061 * considered stable or mature enough to be guaranteed to work in an 062 * interoperable way with other types of LDAP servers. 063 * </BLOCKQUOTE> 064 */ 065@NotMutable() 066@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 067public final class TextFormattedConnectAccessLogMessage 068 extends TextFormattedAccessLogMessage 069 implements ConnectAccessLogMessage 070{ 071 /** 072 * The serial version UID for this serializable class. 073 */ 074 private static final long serialVersionUID = 5169063087516755242L; 075 076 077 078 // The source port for this log message. 079 @Nullable private final Integer sourcePort; 080 081 // The target port for this log message. 082 @Nullable private final Integer targetPort; 083 084 // The client connection policy name for this log message. 085 @Nullable private final String clientConnectionPolicyName; 086 087 // The protocol name for this log message. 088 @Nullable private final String protocolName; 089 090 // The source address for this log message. 091 @Nullable private final String sourceAddress; 092 093 // The target address for this log message. 094 @Nullable private final String targetAddress; 095 096 097 098 /** 099 * Creates a new text-formatted connect access log message from the provided 100 * message string. 101 * 102 * @param logMessageString The string representation of the log message to 103 * create. It must not be {@code null}. 104 * 105 * @throws LogException If the provided string cannot be parsed as a valid 106 * log message. 107 */ 108 public TextFormattedConnectAccessLogMessage( 109 @NotNull final String logMessageString) 110 throws LogException 111 { 112 this(new TextFormattedLogMessage(logMessageString)); 113 } 114 115 116 117 /** 118 * Creates a new text-formatted connect access log message from the provided 119 * message. 120 * 121 * @param logMessage The log message to use to create this connect access 122 * log message. It must not be {@code null}. 123 */ 124 TextFormattedConnectAccessLogMessage( 125 @NotNull final TextFormattedLogMessage logMessage) 126 { 127 super(logMessage); 128 129 sourceAddress = 130 getString(TextFormattedAccessLogFields.CONNECT_FROM_ADDRESS); 131 sourcePort = 132 getIntegerNoThrow(TextFormattedAccessLogFields.CONNECT_FROM_PORT); 133 targetAddress = 134 getString(TextFormattedAccessLogFields.CONNECT_TO_ADDRESS); 135 targetPort = 136 getIntegerNoThrow(TextFormattedAccessLogFields.CONNECT_TO_PORT); 137 protocolName = getString(TextFormattedAccessLogFields.PROTOCOL); 138 clientConnectionPolicyName = 139 getString(TextFormattedAccessLogFields.CLIENT_CONNECTION_POLICY); 140 } 141 142 143 144 /** 145 * {@inheritDoc} 146 */ 147 @Override() 148 @NotNull() 149 public AccessLogMessageType getMessageType() 150 { 151 return AccessLogMessageType.CONNECT; 152 } 153 154 155 156 /** 157 * {@inheritDoc} 158 */ 159 @Override() 160 @Nullable() 161 public String getSourceAddress() 162 { 163 return sourceAddress; 164 } 165 166 167 168 /** 169 * {@inheritDoc} 170 */ 171 @Override() 172 @Nullable() 173 public Integer getSourcePort() 174 { 175 return sourcePort; 176 } 177 178 179 180 /** 181 * {@inheritDoc} 182 */ 183 @Override() 184 @Nullable() 185 public String getTargetAddress() 186 { 187 return targetAddress; 188 } 189 190 191 192 /** 193 * {@inheritDoc} 194 */ 195 @Override() 196 @Nullable() 197 public Integer getTargetPort() 198 { 199 return targetPort; 200 } 201 202 203 204 /** 205 * {@inheritDoc} 206 */ 207 @Override() 208 @Nullable() 209 public String getProtocolName() 210 { 211 return protocolName; 212 } 213 214 215 216 /** 217 * {@inheritDoc} 218 */ 219 @Override() 220 @Nullable() 221 public String getClientConnectionPolicy() 222 { 223 return clientConnectionPolicyName; 224 } 225}