1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.api.ldap.aci; 21 22 23 /** 24 * An enumeration that represents grants or denials of {@link MicroOperation}s. 25 * 26 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 27 */ 28 public enum GrantAndDenial 29 { 30 // Permissions that may be used in conjunction with any component of 31 // <tt>ProtectedItem</tt>s. 32 /** Grant for {@link MicroOperation#ADD} */ 33 GRANT_ADD(MicroOperation.ADD, 0, true), 34 35 /** Denial for {@link MicroOperation#ADD} */ 36 DENY_ADD(MicroOperation.ADD, 1, false), 37 38 /** Grant for {@link MicroOperation#DISCLOSE_ON_ERROR} */ 39 GRANT_DISCLOSE_ON_ERROR(MicroOperation.DISCLOSE_ON_ERROR, 2, true), 40 41 /** Denial for {@link MicroOperation#DISCLOSE_ON_ERROR} */ 42 DENY_DISCLOSE_ON_ERROR(MicroOperation.DISCLOSE_ON_ERROR, 3, false), 43 44 /** Grant for {@link MicroOperation#READ} */ 45 GRANT_READ(MicroOperation.READ, 4, true), 46 47 /** Denial for {@link MicroOperation#READ} */ 48 DENY_READ(MicroOperation.READ, 5, false), 49 50 /** Grant for {@link MicroOperation#REMOVE} */ 51 GRANT_REMOVE(MicroOperation.REMOVE, 6, true), 52 53 /** Denial for {@link MicroOperation#REMOVE} */ 54 DENY_REMOVE(MicroOperation.REMOVE, 7, false), 55 56 // Permissions that may be used only in conjunction with the entry 57 // component. 58 /** Grant for {@link MicroOperation#BROWSE} */ 59 GRANT_BROWSE(MicroOperation.BROWSE, 8, true), 60 61 /** Denial for {@link MicroOperation#BROWSE} */ 62 DENY_BROWSE(MicroOperation.BROWSE, 9, false), 63 64 /** Grant for {@link MicroOperation#EXPORT} */ 65 GRANT_EXPORT(MicroOperation.EXPORT, 10, true), 66 67 /** Denial for {@link MicroOperation#EXPORT} */ 68 DENY_EXPORT(MicroOperation.EXPORT, 11, false), 69 70 /** Grant for {@link MicroOperation#IMPORT} */ 71 GRANT_IMPORT(MicroOperation.IMPORT, 12, true), 72 73 /** Denial for {@link MicroOperation#IMPORT} */ 74 DENY_IMPORT(MicroOperation.IMPORT, 13, false), 75 76 /** Grant for {@link MicroOperation#MODIFY} */ 77 GRANT_MODIFY(MicroOperation.MODIFY, 14, true), 78 79 /** Denial for {@link MicroOperation#MODIFY} */ 80 DENY_MODIFY(MicroOperation.MODIFY, 15, false), 81 82 /** Grant for {@link MicroOperation#RENAME} */ 83 GRANT_RENAME(MicroOperation.RENAME, 16, true), 84 85 /** Denial for {@link MicroOperation#RENAME} */ 86 DENY_RENAME(MicroOperation.RENAME, 17, false), 87 88 /** Grant for {@link MicroOperation#RETURN_DN} */ 89 GRANT_RETURN_DN(MicroOperation.RETURN_DN, 18, true), 90 91 /** Denial for {@link MicroOperation#RETURN_DN} */ 92 DENY_RETURN_DN(MicroOperation.RETURN_DN, 19, false), 93 94 // Permissions that may be used in conjunction with any component, 95 // except entry, of <tt>ProtectedItem</tt>s. 96 /** Grant for {@link MicroOperation#COMPARE} */ 97 GRANT_COMPARE(MicroOperation.COMPARE, 20, true), 98 99 /** Deny for {@link MicroOperation#COMPARE} */ 100 DENY_COMPARE(MicroOperation.COMPARE, 21, false), 101 102 /** Grant for {@link MicroOperation#FILTER_MATCH} */ 103 GRANT_FILTER_MATCH(MicroOperation.FILTER_MATCH, 22, true), 104 105 /** Denial for {@link MicroOperation#FILTER_MATCH} */ 106 DENY_FILTER_MATCH(MicroOperation.FILTER_MATCH, 23, false), 107 108 /** Grant for {@link MicroOperation#INVOKE} */ 109 GRANT_INVOKE(MicroOperation.INVOKE, 24, true), 110 111 /** Denial for {@link MicroOperation#INVOKE} */ 112 DENY_INVOKE(MicroOperation.INVOKE, 25, false); 113 114 /** The micro operation. */ 115 private final MicroOperation microOperation; 116 117 /** The code number. */ 118 private final int code; 119 120 /** The name. */ 121 private final String name; 122 123 /** The grant flag. */ 124 private final boolean grant; 125 126 127 private GrantAndDenial( MicroOperation microOperation, int code, boolean grant ) 128 { 129 this.microOperation = microOperation; 130 this.code = code; 131 this.name = ( grant ? "grant" : "deny" ) + microOperation.getName(); 132 this.grant = grant; 133 } 134 135 136 /** 137 * Gets the {@link MicroOperation} related with this grant or denial. 138 * 139 * @return the micro operation 140 */ 141 public MicroOperation getMicroOperation() 142 { 143 return microOperation; 144 } 145 146 147 /** 148 * Gets the code number of this grant or denial. 149 * 150 * @return the code number 151 */ 152 public int getCode() 153 { 154 return code; 155 } 156 157 158 /** 159 * Gets the name of this grant or denial. 160 * 161 * @return the name 162 */ 163 public String getName() 164 { 165 return name; 166 } 167 168 169 /** 170 * Returns <tt>true</tt> if and only if this is grant. 171 * 172 * @return <tt>true</tt> if and only if this is grant 173 */ 174 public boolean isGrant() 175 { 176 return grant; 177 } 178 179 180 /** 181 * {@inheritDoc} 182 */ 183 @Override 184 public String toString() 185 { 186 return name; 187 } 188 }