001/*
002 * Copyright 2008-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2008-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) 2008-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.controls;
037
038
039
040import com.unboundid.util.NotNull;
041import com.unboundid.util.Nullable;
042import com.unboundid.util.StaticUtils;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This enum contains the set of possible attribute-level rights that may be
050 * described for an attribute in an entry retrieved with the get effective
051 * rights control.
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.COMPLETELY_THREADSAFE)
064public enum AttributeRight
065{
066  /**
067   * The attribute right that indicates that the user has sufficient permission
068   * to perform search operations that target the associated attribute.
069   */
070  SEARCH("search"),
071
072
073
074  /**
075   * The attribute right that indicates that the user has sufficient permission
076   * to read the values of the specified attribute.
077   */
078  READ("read"),
079
080
081
082  /**
083   * The attribute right that indicates that the user has sufficient permission
084   * to make comparisons against the value of the specified attribute.
085   */
086  COMPARE("compare"),
087
088
089
090  /**
091   * The attribute right that indicates that the user has sufficient permission
092   * to alter the values of the specified attribute.
093   */
094  WRITE("write"),
095
096
097
098  /**
099   * The attribute right that indicates that the user has sufficient permission
100   * to add his or her own DN to the set of values for the specified attribute.
101   */
102  SELFWRITE_ADD("selfwrite_add"),
103
104
105
106  /**
107   * The attribute right that indicates that the user has sufficient permission
108   * to remove his or her own DN from the set of values for the specified
109   * attribute.
110   */
111  SELFWRITE_DELETE("selfwrite_delete"),
112
113
114
115  /**
116   * The attribute right that indicates that the user has sufficient permission
117   * to perform operations involving proxied authorization with the attribute.
118   */
119  PROXY("proxy");
120
121
122
123  // The name of this attribute right.
124  @NotNull private final String name;
125
126
127
128  /**
129   * Creates a new attribute right with the specified name.
130   *
131   * @param  name  The name for this attribute right.
132   */
133  AttributeRight(@NotNull final String name)
134  {
135    this.name = name;
136  }
137
138
139
140  /**
141   * Retrieves the name of this attribute right.
142   *
143   * @return  The name of this attribute right.
144   */
145  @NotNull()
146  public String getName()
147  {
148    return name;
149  }
150
151
152
153  /**
154   * Retrieves the attribute right for the specified name.
155   *
156   * @param  name  The name for which to retrieve the corresponding attribute
157   *               right.
158   *
159   * @return  The requested attribute right, or {@code null} if there is no such
160   *          right.
161   */
162  @Nullable()
163  public static AttributeRight forName(@NotNull final String name)
164  {
165    switch (StaticUtils.toLowerCase(name))
166    {
167      case "search":
168        return SEARCH;
169      case "read":
170        return READ;
171      case "compare":
172        return COMPARE;
173      case "write":
174        return WRITE;
175      case "selfwriteadd":
176      case "selfwrite-add":
177      case "selfwrite_add":
178      case "self-write-add":
179      case "self_write_add":
180        return SELFWRITE_ADD;
181      case "selfwritedelete":
182      case "selfwrite-delete":
183      case "selfwrite_delete":
184      case "self-write-delete":
185      case "self_write_delete":
186      case "selfwritedel":
187      case "selfwrite-del":
188      case "selfwrite_del":
189      case "self-write-del":
190      case "self_write_del":
191        return SELFWRITE_DELETE;
192      case "proxy":
193        return PROXY;
194      default:
195        return null;
196    }
197  }
198
199
200
201  /**
202   * Retrieves a string representation of this attribute right.
203   *
204   * @return  A string representation of this attribute right.
205   */
206  @Override()
207  @NotNull()
208  public String toString()
209  {
210    return name;
211  }
212}