Package org.jboss.security

Examples of org.jboss.security.AuthorizationManager


    * @return
    * @throws NamingException
    */
   static AuthorizationManager newAuthorizationManager(String securityDomain)
   {
      AuthorizationManager securityMgr = null;
      try
      {
         // Create instance of securityMgrClass
         Class[] parameterTypes = {String.class, CallbackHandler.class};
         Constructor ctor = authorizationMgrClass.getConstructor(parameterTypes);
View Full Code Here


      if(map == null)
         throw new IllegalStateException("Map from the Resource is null");
   
      if(map.size() == 0)
         throw new IllegalStateException("Map from the Resource is size zero");
      AuthorizationManager am = (AuthorizationManager) map.get("authorizationManager");
      if(am == null)
         throw new IllegalStateException("Authorization Manager is null");
      if(am instanceof PolicyRegistration)
         this.policyRegistration = (PolicyRegistration) am;
      //Populate local variables from the resource
View Full Code Here

      if (methodRoles.contains(AnybodyPrincipal.ANYBODY_PRINCIPAL) == false)
      {
         // The caller is using a the caller identity
         if (callerRunAsIdentity == null)
         {
            AuthorizationManager am = (AuthorizationManager)policyRegistration;
           
            // Now actually check if the current caller has one of the required method roles
            if (am.doesUserHaveRole(ejbPrincipal, methodRoles) == false)
            {
               Set userRoles = am.getUserRoles(ejbPrincipal);
               String method = this.ejbMethod.getName();
               String msg = "Insufficient method permissions, principal=" + ejbPrincipal
                  + ", ejbName=" + this.ejbName
                  + ", method=" + method + ", interface=" + this.methodInterface
                  + ", requiredRoles=" + methodRoles + ", principalRoles=" + userRoles;
View Full Code Here

      return allowed ? AuthorizationContext.PERMIT : AuthorizationContext.DENY;
   }
  
   private int checkRoleRef()
   {
      AuthorizationManager am = (AuthorizationManager)policyRegistration;
      //Check the caller of this beans run-as identity
      if (ejbPrincipal == null && callerRunAsIdentity == null)
      {
         if(trace)
            log.trace("ejbPrincipal = null,callerRunAsIdentity = null => DENY" );
         return AuthorizationContext.DENY;
      }

      // Map the role name used by Bean Provider to the security role
      // link in the deployment descriptor. The EJB 1.1 spec requires
      // the security role refs in the descriptor but for backward
      // compability we're not enforcing this requirement.
      //
      // TODO (2.3): add a conditional check using jboss.xml <enforce-ejb-restrictions> element
      //             which will throw an exception in case no matching
      //             security ref is found.
      boolean matchFound = false;
      Iterator it = this.securityRoleReferences.iterator();
      while ( it.hasNext())
      {
         SecurityRoleRef meta = (SecurityRoleRef) it.next();
         if (meta.getName().equals(roleName))
         {
            roleName = meta.getLink();
            matchFound = true;
            break;
         }
      }

      if (!matchFound)
         log.trace("no match found for security role " + roleName +
         " in the deployment descriptor for ejb " + this.ejbName);

      HashSet set = new HashSet();
      set.add(new SimplePrincipal(roleName));

      boolean allowed = false;
      if (callerRunAsIdentity == null)
         allowed = am.doesUserHaveRole(ejbPrincipal, set);
      else
         allowed = this.callerRunAsIdentity.doesUserHaveRole(set);
     
      return allowed ? AuthorizationContext.PERMIT : AuthorizationContext.DENY;
   }
View Full Code Here

      if(map == null)
         throw new IllegalStateException("Map from the Resource is null");
   
      if(map.size() == 0)
         throw new IllegalStateException("Map from the Resource is size zero");
      AuthorizationManager am = (AuthorizationManager) map.get("authorizationManager");
      if(am == null)
         throw new IllegalStateException("Authorization Manager is null");
      if(am instanceof PolicyRegistration)
         this.policyRegistration = (PolicyRegistration) am;
      //Populate local variables from the resource
      this.callerSubject = (Subject)map.get(ResourceKeys.CALLER_SUBJECT);
      this.ejbCS = (CodeSource)map.get(ResourceKeys.EJB_CODESOURCE);
      this.ejbMethod = (Method)map.get(ResourceKeys.EJB_METHOD);
      this.ejbName = (String)map.get(ResourceKeys.EJB_NAME);
      this.methodInterface = (String)map.get(ResourceKeys.EJB_METHODINTERFACE);
      this.roleName = (String)map.get(ResourceKeys.ROLENAME);
      //Get the Security Context Roles
      if(am != null)
      {
         Principal ejbPrincipal = (Principal)map.get(ResourceKeys.EJB_PRINCIPAL);
         Set<Principal> roleset = am.getUserRoles(ejbPrincipal);
         this.securityContextRoles = getGroupFromRoleSet(roleset);
      }
      this.roleRefCheck = (Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK);
      if(this.roleRefCheck == Boolean.TRUE)
         return checkRoleRef();
View Full Code Here

    @see java.security.acl.Group;
    @see Subject#getPrincipals()
    */
   public boolean doesUserHaveRole(Principal principal, Set rolePrincipals)
   {
      AuthorizationManager am = Util.getAuthorizationManager(securityDomain);
      return am.doesUserHaveRole(principal, rolePrincipals);
   }
View Full Code Here

    @return The Set<Principal> for the application domain roles that the
    principal has been assigned.
   */
   public Set getUserRoles(Principal principal)
   {
      AuthorizationManager am = Util.getAuthorizationManager(securityDomain);
      return am.getUserRoles(principal);
   }
View Full Code Here

      if(map == null)
         throw new IllegalStateException("Map from the Resource is null");
   
      if(map.size() == 0)
         throw new IllegalStateException("Map from the Resource is size zero");
      AuthorizationManager am = (AuthorizationManager) map.get("authorizationManager");
      if(am == null)
         throw new IllegalStateException("Authorization Manager is null");
      if(am instanceof PolicyRegistration)
         this.policyRegistration = (PolicyRegistration) am;
      //Populate local variables from the resource
View Full Code Here

         // See if the security mgr supports an externalized cache policy
         setSecurityDomainCache(securityMgr, cachePolicy);
         if(deepCopySubjectMode)
            setDeepCopySubjectOption(securityMgr, true);
         //Set the Authorization Manager
         AuthorizationManager am = AuthorizationManagerService.newAuthorizationManager(securityDomain);
         sdc.setAuthorizationManager(am)
      }
      catch(Exception e2)
      {
         String msg = "Failed to create sec mgr('"+securityDomain+"'), securityMgrClass="
View Full Code Here

            }
            cache.put(key, roles);
        }

        if (!roles.contains(UNCHECKED)) {
            AuthorizationManager authorizationManager = null;
           
            try {
                authorizationManager = getAuthorizationManager(msgContext);
            } catch (ConfigurationException e) {
                logger.authorizationManagerError(e);
                throw new RuntimeException(e);
            }
            Subject subject = SecurityActions.getAuthenticatedSubject();
           
            Set<Principal> expectedRoles = rolesSet(roles);
            if (!authorizationManager.doesUserHaveRole(null, expectedRoles)) {
                SecurityContext sc = SecurityActions.getSecurityContext();
                StringBuilder builder = new StringBuilder("Authorization Failed:Subject=");
                builder.append(subject).append(":Expected Roles=").append(expectedRoles);
                SecurityContextCallbackHandler scbh = new SecurityContextCallbackHandler(sc);
                builder.append("::Actual Roles=").append(authorizationManager.getSubjectRoles(subject, scbh));
                logger.error(builder.toString());

                throw logger.jbossWSAuthorizationFailed();
            }
        }
View Full Code Here

TOP

Related Classes of org.jboss.security.AuthorizationManager

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.