c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * CDDL HEADER START
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * The contents of this file are subject to the terms of the
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * Common Development and Distribution License, Version 1.0 only
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * (the "License"). You may not use this file except in compliance
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * with the License.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * or http://forgerock.org/license/CDDLv1.0.html.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * See the License for the specific language governing permissions
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * and limitations under the License.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * When distributing Covered Code, include this CDDL HEADER in each
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * file and include the License file at legal-notices/CDDLv1_0.txt.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * If applicable, add the following below this CDDL HEADER, with the
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * fields enclosed by brackets "[]" replaced with your own identifying
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * information:
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * Portions Copyright [yyyy] [name of copyright owner]
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * CDDL HEADER END
65e99be301d5a19db33f25841f671756e8dbb9b5ludovicp * Copyright 2008 Sun Microsystems, Inc.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * Portions Copyright 2013 ForgeRock AS
31ef6298b4179ddca52d4b1d0aad873af9d17155duganimport static org.opends.server.authorization.dseecompat.Aci.*;
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This class provides an enumeration of the allowed rights.
c9d44c649b67bea43e7549e2bf52870db9e770d0duganpublic enum EnumRight {
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "read".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_READ
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "write".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_WRITE
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "add".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_ADD
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "delete".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_DELETE
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "search".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_SEARCH
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "compare".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_COMPARE
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * "selfwrite".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_SELF
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "proxy".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_PROXY
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "import".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_IMPORT
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "export".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_EXPORT
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * This enumeration is returned when the result of the right is "all".
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac * @see Aci#ACI_ALL
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * The name of the right.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * Creates an enumeration of the right name.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * @param right The name of the right.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * Returns the string representation of the right.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * @return the string representation of the right
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * Checks if the enumeration is equal to the right name.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * @param right The name of the right to check.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * @return True if the right is equal to the enumeration's.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * Creates an enumeration of the right name.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * @param right The name of the right.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * @return An enumeration of the right or null if the name is invalid.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * Returns bit mask associated with the specified right.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * @param right The right enumeration to return the mask for.
c9d44c649b67bea43e7549e2bf52870db9e770d0dugan * @return The bit mask associated with the right.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * Return the EnumRight corresponding to the provided rightsMask.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * @param rightsMask
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * the rights mask for which to return the corresponding EnumRight
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * @return EnumRight corresponding to the provided rightsMask.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac public static Set<EnumRight> getEnumRight(int rightsMask) {
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac final EnumSet<EnumRight> results = EnumSet.noneOf(EnumRight.class);
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac // Next 3 rights are not included in ALL for historical reasons.
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac // ALL already existed when they got added. For compatibility reasons
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac // with existing deployments, they were not included in ALL.
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac // the remaining rights are already included in ALL
32543976aadb9b3f834da6eb6882b68bd661b8e5JnRouvignac if (hasRights(rightsMask, ACI_SELF)) // included in WRITE
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * Checks if the provided rights mask has the specified rights.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * @param rightsMask
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * The rights mask to look into.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * @param rights
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * The rights to check for.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * @return true if the rights mask has the specified rights, false
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac * otherwise.
0253a7dc97ec1ab462376979562c69636573904aJnRouvignac public static boolean hasRights(int rightsMask, int rights) {