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