001/*
002 * Copyright 2021-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2021-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) 2021-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.extensions;
037
038
039
040import com.unboundid.asn1.ASN1Element;
041import com.unboundid.asn1.ASN1OctetString;
042import com.unboundid.util.NotNull;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045import com.unboundid.util.Validator;
046
047
048
049/**
050 * This class provides a {@link ReplaceCertificateTrustBehavior} implementation
051 * to indicate that the server should update a specified trust manager provider.
052 * <BR>
053 * <BLOCKQUOTE>
054 *   <B>NOTE:</B>  This class, and other classes within the
055 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
056 *   supported for use against Ping Identity, UnboundID, and
057 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
058 *   for proprietary functionality or for external specifications that are not
059 *   considered stable or mature enough to be guaranteed to work in an
060 *   interoperable way with other types of LDAP servers.
061 * </BLOCKQUOTE>
062 */
063@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
064public final class TrustManagerProviderReplaceCertificateTrustBehavior
065       extends ReplaceCertificateTrustBehavior
066{
067  /**
068   * The BER type to use for the ASN.1 element containing an encoded
069   * representation of this trust behavior object.
070   */
071  static final byte TYPE_TRUST_BEHAVIOR = (byte) 0x84;
072
073
074
075  /**
076   * The serial version UID for this serializable class.
077   */
078  private static final long serialVersionUID = 6812233987373145427L;
079
080
081
082  // The name of the file-based trust manager provider to be updated with
083  // information about the new listener certificate.
084  @NotNull private final String providerName;
085
086
087
088  /**
089   * Creates a new trust manager provider trust behavior object with the
090   * provided information.
091   *
092   * @param  providerName  The name of the file-based trust manager provider
093   *                       to be updated with information about the new
094   *                       listener certificate.  It must not be {@code null}.
095   */
096  public TrustManagerProviderReplaceCertificateTrustBehavior(
097              @NotNull final String providerName)
098  {
099    Validator.ensureNotNullOrEmpty(providerName,
100         "TrustManagerProviderReplaceCertificateTrustBehavior.providerName " +
101              "must mot be null or empty.");
102
103    this.providerName = providerName;
104  }
105
106
107
108  /**
109   * Retrieves the name of the trust manager provider to be updated with
110   * information about the new listener certificate.
111   *
112   * @return  The name of the trust manager provider to be updated with
113   *          information about the new listener certificate.
114   */
115  @NotNull()
116  public String getProviderName()
117  {
118    return providerName;
119  }
120
121
122
123  /**
124   * {@inheritDoc}
125   */
126  @Override()
127  @NotNull()
128  public ASN1Element encode()
129  {
130    return new ASN1OctetString(TYPE_TRUST_BEHAVIOR, providerName);
131  }
132
133
134
135  /**
136   * {@inheritDoc}
137   */
138  @Override()
139  public void toString(@NotNull final StringBuilder buffer)
140  {
141    buffer.append("TrustManagerProviderReplaceCertificateTrustBehavior(" +
142         "providerName='");
143    buffer.append(providerName);
144    buffer.append("')");
145  }
146}