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.json; 037 038 039 040import java.util.List; 041import java.util.Set; 042 043import com.unboundid.ldap.sdk.ResultCode; 044import com.unboundid.ldap.sdk.unboundidds.logs.AccessLogMessageType; 045import com.unboundid.ldap.sdk.unboundidds.logs.LogException; 046import com.unboundid.ldap.sdk.unboundidds.logs.v2.BindResultAccessLogMessage; 047import com.unboundid.util.NotMutable; 048import com.unboundid.util.NotNull; 049import com.unboundid.util.Nullable; 050import com.unboundid.util.ThreadSafety; 051import com.unboundid.util.ThreadSafetyLevel; 052import com.unboundid.util.json.JSONObject; 053 054 055 056/** 057 * This class provides a data structure that holds information about a 058 * JSON-formatted bind result access log message. 059 * <BR> 060 * <BLOCKQUOTE> 061 * <B>NOTE:</B> This class, and other classes within the 062 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 063 * supported for use against Ping Identity, UnboundID, and 064 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 065 * for proprietary functionality or for external specifications that are not 066 * considered stable or mature enough to be guaranteed to work in an 067 * interoperable way with other types of LDAP servers. 068 * </BLOCKQUOTE> 069 */ 070@NotMutable() 071@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 072public final class JSONBindResultAccessLogMessage 073 extends JSONBindRequestAccessLogMessage 074 implements BindResultAccessLogMessage 075{ 076 /** 077 * The serial version UID for this serializable class. 078 */ 079 private static final long serialVersionUID = 914473873424542376L; 080 081 082 083 // Indicates whether a retired password was used for the bind operation. 084 @Nullable private final Boolean retiredPasswordUsed; 085 086 // The forward helper for this access log message. 087 @NotNull private final JSONForwardAccessLogMessageHelper forwardHelper; 088 089 // The result helper for this access log message. 090 @NotNull private final JSONResultAccessLogMessageHelper resultHelper; 091 092 // The authentication failure ID for this access log message. 093 @Nullable private final Long authenticationFailureID; 094 095 // The authentication DN for this access log message. 096 @Nullable private final String authenticationDN; 097 098 // The authentication failure message for this access log message. 099 @Nullable private final String authenticationFailureMessage; 100 101 // The authentication failure name for this access log message. 102 @Nullable private final String authenticationFailureName; 103 104 // The authorization DN for this access log message. 105 @Nullable private final String authorizationDN; 106 107 // The client connection policy name for this access log message. 108 @Nullable private final String clientConnectionPolicy; 109 110 111 112 /** 113 * Creates a new JSON bind result access log message from the provided JSON 114 * object. 115 * 116 * @param jsonObject The JSON object that contains an encoded representation 117 * of this log message. It must not be {@code null}. 118 * 119 * @throws LogException If the provided JSON object cannot be parsed as a 120 * valid log message. 121 */ 122 public JSONBindResultAccessLogMessage(@NotNull final JSONObject jsonObject) 123 throws LogException 124 { 125 super(jsonObject); 126 127 authenticationDN = 128 getString(JSONFormattedAccessLogFields.BIND_AUTHENTICATION_DN); 129 authorizationDN = 130 getString(JSONFormattedAccessLogFields.BIND_AUTHORIZATION_DN); 131 retiredPasswordUsed = getBooleanNoThrow( 132 JSONFormattedAccessLogFields.BIND_RETIRED_PASSWORD_USED); 133 clientConnectionPolicy = 134 getString(JSONFormattedAccessLogFields.CLIENT_CONNECTION_POLICY); 135 136 final JSONObject authFailureReason = jsonObject.getFieldAsObject( 137 JSONFormattedAccessLogFields.BIND_AUTHENTICATION_FAILURE_REASON. 138 getFieldName()); 139 if (authFailureReason == null) 140 { 141 authenticationFailureID = null; 142 authenticationFailureName = null; 143 authenticationFailureMessage = null; 144 } 145 else 146 { 147 authenticationFailureID = authFailureReason.getFieldAsLong( 148 JSONFormattedAccessLogFields.BIND_AUTHENTICATION_FAILURE_REASON_ID. 149 getFieldName()); 150 authenticationFailureName = authFailureReason.getFieldAsString( 151 JSONFormattedAccessLogFields.BIND_AUTHENTICATION_FAILURE_REASON_NAME. 152 getFieldName()); 153 authenticationFailureMessage = authFailureReason.getFieldAsString( 154 JSONFormattedAccessLogFields. 155 BIND_AUTHENTICATION_FAILURE_REASON_MESSAGE.getFieldName()); 156 } 157 158 resultHelper = new JSONResultAccessLogMessageHelper(this); 159 forwardHelper = new JSONForwardAccessLogMessageHelper(this); 160 } 161 162 163 164 /** 165 * {@inheritDoc} 166 */ 167 @Override() 168 @NotNull() 169 public AccessLogMessageType getMessageType() 170 { 171 return AccessLogMessageType.RESULT; 172 } 173 174 175 176 /** 177 * {@inheritDoc} 178 */ 179 @Override() 180 @Nullable() 181 public ResultCode getResultCode() 182 { 183 return resultHelper.getResultCode(); 184 } 185 186 187 188 /** 189 * {@inheritDoc} 190 */ 191 @Override() 192 @Nullable() 193 public String getDiagnosticMessage() 194 { 195 return resultHelper.getDiagnosticMessage(); 196 } 197 198 199 200 /** 201 * {@inheritDoc} 202 */ 203 @Override() 204 @Nullable() 205 public String getAdditionalInformation() 206 { 207 return resultHelper.getAdditionalInformation(); 208 } 209 210 211 212 /** 213 * {@inheritDoc} 214 */ 215 @Override() 216 @Nullable() 217 public String getMatchedDN() 218 { 219 return resultHelper.getMatchedDN(); 220 } 221 222 223 224 /** 225 * {@inheritDoc} 226 */ 227 @Override() 228 @NotNull() 229 public List<String> getReferralURLs() 230 { 231 return resultHelper.getReferralURLs(); 232 } 233 234 235 236 /** 237 * {@inheritDoc} 238 */ 239 @Override() 240 @Nullable() 241 public Double getProcessingTimeMillis() 242 { 243 return resultHelper.getProcessingTimeMillis(); 244 } 245 246 247 248 /** 249 * {@inheritDoc} 250 */ 251 @Override() 252 @Nullable() 253 public Double getWorkQueueWaitTimeMillis() 254 { 255 return resultHelper.getWorkQueueWaitTimeMillis(); 256 } 257 258 259 260 /** 261 * {@inheritDoc} 262 */ 263 @Override() 264 @NotNull() 265 public Set<String> getResponseControlOIDs() 266 { 267 return resultHelper.getResponseControlOIDs(); 268 } 269 270 271 272 /** 273 * {@inheritDoc} 274 */ 275 @Override() 276 @Nullable() 277 public Long getIntermediateResponsesReturned() 278 { 279 return resultHelper.getIntermediateResponsesReturned(); 280 } 281 282 283 284 /** 285 * {@inheritDoc} 286 */ 287 @Override() 288 @NotNull() 289 public List<String> getServersAccessed() 290 { 291 return resultHelper.getServersAccessed(); 292 } 293 294 295 296 /** 297 * {@inheritDoc} 298 */ 299 @Override() 300 @Nullable() 301 public Boolean getUncachedDataAccessed() 302 { 303 return resultHelper.getUncachedDataAccessed(); 304 } 305 306 307 308 /** 309 * {@inheritDoc} 310 */ 311 @Override() 312 @NotNull() 313 public Set<String> getUsedPrivileges() 314 { 315 return resultHelper.getUsedPrivileges(); 316 } 317 318 319 320 /** 321 * {@inheritDoc} 322 */ 323 @Override() 324 @NotNull() 325 public Set<String> getPreAuthorizationUsedPrivileges() 326 { 327 return resultHelper.getPreAuthorizationUsedPrivileges(); 328 } 329 330 331 332 /** 333 * {@inheritDoc} 334 */ 335 @Override() 336 @NotNull() 337 public Set<String> getMissingPrivileges() 338 { 339 return resultHelper.getMissingPrivileges(); 340 } 341 342 343 344 /** 345 * Retrieves information about an intermediate client response control 346 * included in the log message. 347 * 348 * @return An intermediate client response control included in the log 349 * message, or {@code null} if no intermediate client response 350 * control is available. 351 */ 352 @Nullable() 353 public JSONIntermediateClientResponseControl 354 getIntermediateClientResponseControl() 355 { 356 return resultHelper.getIntermediateClientResponseControl(); 357 } 358 359 360 361 /** 362 * {@inheritDoc} 363 */ 364 @Override() 365 @Nullable() 366 public String getTargetHost() 367 { 368 return forwardHelper.getTargetHost(); 369 } 370 371 372 373 /** 374 * {@inheritDoc} 375 */ 376 @Override() 377 @Nullable() 378 public Integer getTargetPort() 379 { 380 return forwardHelper.getTargetPort(); 381 } 382 383 384 385 /** 386 * {@inheritDoc} 387 */ 388 @Override() 389 @Nullable() 390 public String getTargetProtocol() 391 { 392 return forwardHelper.getTargetProtocol(); 393 } 394 395 396 397 /** 398 * {@inheritDoc} 399 */ 400 @Override() 401 @Nullable() 402 public String getAuthenticationDN() 403 { 404 return authenticationDN; 405 } 406 407 408 409 /** 410 * {@inheritDoc} 411 */ 412 @Override() 413 @Nullable() 414 public String getAuthorizationDN() 415 { 416 return authorizationDN; 417 } 418 419 420 421 /** 422 * {@inheritDoc} 423 */ 424 @Override() 425 @Nullable() 426 public Long getAuthenticationFailureID() 427 { 428 return authenticationFailureID; 429 } 430 431 432 433 /** 434 * {@inheritDoc} 435 */ 436 @Override() 437 @Nullable() 438 public String getAuthenticationFailureName() 439 { 440 return authenticationFailureName; 441 } 442 443 444 445 /** 446 * {@inheritDoc} 447 */ 448 @Override() 449 @Nullable() 450 public String getAuthenticationFailureMessage() 451 { 452 return authenticationFailureMessage; 453 } 454 455 456 457 /** 458 * {@inheritDoc} 459 */ 460 @Override() 461 @Nullable() 462 public Boolean getRetiredPasswordUsed() 463 { 464 return retiredPasswordUsed; 465 } 466 467 468 469 /** 470 * {@inheritDoc} 471 */ 472 @Override() 473 @Nullable() 474 public String getClientConnectionPolicy() 475 { 476 return clientConnectionPolicy; 477 } 478}