Package org.jboss.security.authorization

Examples of org.jboss.security.authorization.AuthorizationException


      for(int i = 0; i < length; i++)
      {
         AuthorizationModule module = (AuthorizationModule)modules.get(i);
         boolean bool = module.abort();
         if(!bool)
            throw new AuthorizationException("abort on modules failed");
      }
   }
View Full Code Here


      for(int i = 0; i < length; i++)
      {
         AuthorizationModule module = (AuthorizationModule)modules.get(i);
         boolean bool = module.abort();
         if(!bool)
            throw new AuthorizationException("abort on modules failed");
      }
   }
View Full Code Here

               if(result == PERMIT)
                  invokeCommit();
               if(result == DENY)
               {
                  invokeAbort();
                  throw new AuthorizationException("Denied");
               }
               return null;
            }
         });
      }
View Full Code Here

   throws AuthorizationException
   {
      //Control Flag behavior
      boolean encounteredRequiredError = false;
      boolean encounteredOptionalError = false;
      AuthorizationException moduleException = null;
      int overallDecision = DENY;
     
      int length = modules.size();
      for(int i = 0; i < length; i++)
      {
         AuthorizationModule module = (AuthorizationModule)modules.get(i);
         ControlFlag flag = (ControlFlag)this.controlFlags.get(i);
         int decision = DENY;
         try
         {
            decision = module.authorize(resource);
         }
         catch(Exception ae)
         {
            decision = DENY;
            if(moduleException == null)
               moduleException = new AuthorizationException(ae.getMessage());
         }
        
         if(decision == PERMIT)
         {
            overallDecision =  PERMIT;
            //SUFFICIENT case
            if(flag == ControlFlag.SUFFICIENT && encounteredRequiredError == false)
               return PERMIT;
            continue; //Continue with the other modules
         }
         //Go through the failure cases
         //REQUISITE case
         if(flag == ControlFlag.REQUISITE)
         {
            if(trace)
               log.trace("REQUISITE failed for " + module);
            if(moduleException == null)
               moduleException = new AuthorizationException("Authorization failed");
            else
               throw moduleException;
         }
         //REQUIRED Case
         if(flag == ControlFlag.REQUIRED)
         {
            if(trace)
               log.trace("REQUIRED failed for " + module);
            if(encounteredRequiredError == false)
               encounteredRequiredError = true;
         }
         if(flag == ControlFlag.OPTIONAL)
            encounteredOptionalError = true;
      }
     
      //All the authorization modules have been visited.
      if(encounteredRequiredError)
         throw new AuthorizationException("Authorization Failed");
      if(overallDecision == DENY && encounteredOptionalError)
         throw new AuthorizationException("Authorization Failed");
      if(overallDecision == DENY)
         throw new AuthorizationException("Authorization Failed:No modules active.");
      return PERMIT;
   }
View Full Code Here

      for(int i = 0; i < length; i++)
      {
         AuthorizationModule module = (AuthorizationModule)modules.get(i);
         boolean bool = module.commit();
         if(!bool)
            throw new AuthorizationException("commit on modules failed");
      }
   }
View Full Code Here

      for(int i = 0; i < length; i++)
      {
         AuthorizationModule module = (AuthorizationModule)modules.get(i);
         boolean bool = module.abort();
         if(!bool)
            throw new AuthorizationException("abort on modules failed");
      }
   }
View Full Code Here

/* 124 */           if (result == 1)
/* 125 */             JBossAuthorizationContext.this.invokeCommit();
/* 126 */           if (result == -1)
/*     */           {
/* 128 */             JBossAuthorizationContext.this.invokeAbort();
/* 129 */             throw new AuthorizationException("Denied");
/*     */           }
/* 131 */           return null;
/*     */         }
/*     */       });
/*     */     }
View Full Code Here

/*     */   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;
/*     */   }
View Full Code Here

/* 246 */     for (int i = 0; i < length; i++)
/*     */     {
/* 248 */       AuthorizationModule module = (AuthorizationModule)this.modules.get(i);
/* 249 */       boolean bool = module.commit();
/* 250 */       if (!bool)
/* 251 */         throw new AuthorizationException("commit on modules failed");
/*     */     }
/*     */   }
View Full Code Here

/* 259 */     for (int i = 0; i < length; i++)
/*     */     {
/* 261 */       AuthorizationModule module = (AuthorizationModule)this.modules.get(i);
/* 262 */       boolean bool = module.abort();
/* 263 */       if (!bool)
/* 264 */         throw new AuthorizationException("abort on modules failed");
/*     */     }
/*     */   }
View Full Code Here

TOP

Related Classes of org.jboss.security.authorization.AuthorizationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.