001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.aci; 021 022 023/** 024 * An enumeration that represents grants or denials of {@link MicroOperation}s. 025 * 026 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 027 */ 028public enum GrantAndDenial 029{ 030 // Permissions that may be used in conjunction with any component of 031 // <tt>ProtectedItem</tt>s. 032 /** Grant for {@link MicroOperation#ADD} */ 033 GRANT_ADD(MicroOperation.ADD, 0, true), 034 035 /** Denial for {@link MicroOperation#ADD} */ 036 DENY_ADD(MicroOperation.ADD, 1, false), 037 038 /** Grant for {@link MicroOperation#DISCLOSE_ON_ERROR} */ 039 GRANT_DISCLOSE_ON_ERROR(MicroOperation.DISCLOSE_ON_ERROR, 2, true), 040 041 /** Denial for {@link MicroOperation#DISCLOSE_ON_ERROR} */ 042 DENY_DISCLOSE_ON_ERROR(MicroOperation.DISCLOSE_ON_ERROR, 3, false), 043 044 /** Grant for {@link MicroOperation#READ} */ 045 GRANT_READ(MicroOperation.READ, 4, true), 046 047 /** Denial for {@link MicroOperation#READ} */ 048 DENY_READ(MicroOperation.READ, 5, false), 049 050 /** Grant for {@link MicroOperation#REMOVE} */ 051 GRANT_REMOVE(MicroOperation.REMOVE, 6, true), 052 053 /** Denial for {@link MicroOperation#REMOVE} */ 054 DENY_REMOVE(MicroOperation.REMOVE, 7, false), 055 056 // Permissions that may be used only in conjunction with the entry 057 // component. 058 /** Grant for {@link MicroOperation#BROWSE} */ 059 GRANT_BROWSE(MicroOperation.BROWSE, 8, true), 060 061 /** Denial for {@link MicroOperation#BROWSE} */ 062 DENY_BROWSE(MicroOperation.BROWSE, 9, false), 063 064 /** Grant for {@link MicroOperation#EXPORT} */ 065 GRANT_EXPORT(MicroOperation.EXPORT, 10, true), 066 067 /** Denial for {@link MicroOperation#EXPORT} */ 068 DENY_EXPORT(MicroOperation.EXPORT, 11, false), 069 070 /** Grant for {@link MicroOperation#IMPORT} */ 071 GRANT_IMPORT(MicroOperation.IMPORT, 12, true), 072 073 /** Denial for {@link MicroOperation#IMPORT} */ 074 DENY_IMPORT(MicroOperation.IMPORT, 13, false), 075 076 /** Grant for {@link MicroOperation#MODIFY} */ 077 GRANT_MODIFY(MicroOperation.MODIFY, 14, true), 078 079 /** Denial for {@link MicroOperation#MODIFY} */ 080 DENY_MODIFY(MicroOperation.MODIFY, 15, false), 081 082 /** Grant for {@link MicroOperation#RENAME} */ 083 GRANT_RENAME(MicroOperation.RENAME, 16, true), 084 085 /** Denial for {@link MicroOperation#RENAME} */ 086 DENY_RENAME(MicroOperation.RENAME, 17, false), 087 088 /** Grant for {@link MicroOperation#RETURN_DN} */ 089 GRANT_RETURN_DN(MicroOperation.RETURN_DN, 18, true), 090 091 /** Denial for {@link MicroOperation#RETURN_DN} */ 092 DENY_RETURN_DN(MicroOperation.RETURN_DN, 19, false), 093 094 // Permissions that may be used in conjunction with any component, 095 // except entry, of <tt>ProtectedItem</tt>s. 096 /** Grant for {@link MicroOperation#COMPARE} */ 097 GRANT_COMPARE(MicroOperation.COMPARE, 20, true), 098 099 /** 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 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}