001/*
002 * Copyright 2008-2017 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2017 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.unboundidds.controls;
022
023
024
025import java.util.EnumSet;
026
027import com.unboundid.util.ThreadSafety;
028import com.unboundid.util.ThreadSafetyLevel;
029
030import static com.unboundid.util.StaticUtils.*;
031
032
033
034/**
035 * This enum contains the set of possible attribute-level rights that may be
036 * described for an attribute in an entry retrieved with the get effective
037 * rights control.
038 * <BR>
039 * <BLOCKQUOTE>
040 *   <B>NOTE:</B>  This class, and other classes within the
041 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
042 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
043 *   server products.  These classes provide support for proprietary
044 *   functionality or for external specifications that are not considered stable
045 *   or mature enough to be guaranteed to work in an interoperable way with
046 *   other types of LDAP servers.
047 * </BLOCKQUOTE>
048 */
049@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
050public enum AttributeRight
051{
052  /**
053   * The attribute right that indicates that the user has sufficient permission
054   * to perform search operations that target the associated attribute.
055   */
056  SEARCH("search"),
057
058
059
060  /**
061   * The attribute right that indicates that the user has sufficient permission
062   * to read the values of the specified attribute.
063   */
064  READ("read"),
065
066
067
068  /**
069   * The attribute right that indicates that the user has sufficient permission
070   * to make comparisons against the value of the specified attribute.
071   */
072  COMPARE("compare"),
073
074
075
076  /**
077   * The attribute right that indicates that the user has sufficient permission
078   * to alter the values of the specified attribute.
079   */
080  WRITE("write"),
081
082
083
084  /**
085   * The attribute right that indicates that the user has sufficient permission
086   * to add his or her own DN to the set of values for the specified attribute.
087   */
088  SELFWRITE_ADD("selfwrite_add"),
089
090
091
092  /**
093   * The attribute right that indicates that the user has sufficient permission
094   * to remove his or her own DN from the set of values for the specified
095   * attribute.
096   */
097  SELFWRITE_DELETE("selfwrite_delete"),
098
099
100
101  /**
102   * The attribute right that indicates that the user has sufficient permission
103   * to perform operations involving proxied authorization with the attribute.
104   */
105  PROXY("proxy");
106
107
108
109  // The name of this attribute right.
110  private final String name;
111
112
113
114  /**
115   * Creates a new attribute right with the specified name.
116   *
117   * @param  name  The name for this attribute right.
118   */
119  AttributeRight(final String name)
120  {
121    this.name = name;
122  }
123
124
125
126  /**
127   * Retrieves the name of this attribute right.
128   *
129   * @return  The name of this attribute right.
130   */
131  public String getName()
132  {
133    return name;
134  }
135
136
137
138  /**
139   * Retrieves the attribute right for the specified name.
140   *
141   * @param  name  The name for which to retrieve the corresponding attribute
142   *               right.
143   *
144   * @return  The requested attribute right, or {@code null} if there is no such
145   *          right.
146   */
147  public static AttributeRight forName(final String name)
148  {
149    final String lowerName = toLowerCase(name);
150
151    for (final AttributeRight r : EnumSet.allOf(AttributeRight.class))
152    {
153      if (r.name.equals(lowerName))
154      {
155        return r;
156      }
157    }
158
159    return null;
160  }
161
162
163
164  /**
165   * Retrieves a string representation of this attribute right.
166   *
167   * @return  A string representation of this attribute right.
168   */
169  @Override()
170  public String toString()
171  {
172    return name;
173  }
174}