/* */ private int invokeAuthorize(Resource resource)
/* */ throws AuthorizationException
/* */ {
/* 178 */ boolean encounteredRequiredError = false;
/* 179 */ boolean encounteredOptionalError = false;
/* 180 */ AuthorizationException moduleException = null;
/* 181 */ int overallDecision = -1;
/* */
/* 183 */ int length = this.modules.size();
/* 184 */ for (int i = 0; i < length; i++)
/* */ {
/* 186 */ AuthorizationModule module = (AuthorizationModule)this.modules.get(i);
/* 187 */ ControlFlag flag = (ControlFlag)this.controlFlags.get(i);
/* 188 */ int decision = -1;
/* */ try
/* */ {
/* 191 */ decision = module.authorize(resource);
/* */ }
/* */ catch (Exception ae)
/* */ {
/* 195 */ decision = -1;
/* 196 */ if (moduleException == null) {
/* 197 */ moduleException = new AuthorizationException(ae.getMessage());
/* */ }
/* */ }
/* 200 */ if (decision == 1)
/* */ {
/* 202 */ overallDecision = 1;
/* */
/* 204 */ if ((flag == ControlFlag.SUFFICIENT) && (!encounteredRequiredError)) {
/* 205 */ return 1;
/* */ }
/* */ }
/* */ else
/* */ {
/* 210 */ if (flag == ControlFlag.REQUISITE)
/* */ {
/* 212 */ if (this.trace)
/* 213 */ log.trace("REQUISITE failed for " + module);
/* 214 */ if (moduleException == null)
/* 215 */ moduleException = new AuthorizationException("Authorization failed");
/* */ else {
/* 217 */ throw moduleException;
/* */ }
/* */ }
/* 220 */ if (flag == ControlFlag.REQUIRED)
/* */ {
/* 222 */ if (this.trace)
/* 223 */ log.trace("REQUIRED failed for " + module);
/* 224 */ if (!encounteredRequiredError)
/* 225 */ encounteredRequiredError = true;
/* */ }
/* 227 */ if (flag == ControlFlag.OPTIONAL) {
/* 228 */ encounteredOptionalError = true;
/* */ }
/* */ }
/* */ }
/* 232 */ String msg = getAdditionalErrorMessage(moduleException);
/* 233 */ if (encounteredRequiredError)
/* 234 */ throw new AuthorizationException("Authorization Failed:" + msg);
/* 235 */ if ((overallDecision == -1) && (encounteredOptionalError))
/* 236 */ throw new AuthorizationException("Authorization Failed:" + msg);
/* 237 */ if (overallDecision == -1)
/* 238 */ throw new AuthorizationException("Authorization Failed:No modules active.");
/* 239 */ return 1;
/* */ }