Examples of EJBResource


Examples of org.jboss.security.authorization.resources.EJBResource

/*     */
/* 139 */     map.put("authorizationManager", am);
/* 140 */     map.put("roleName", roleName);
/* 141 */     map.put("roleRefPermissionCheck", Boolean.TRUE);
/*     */
/* 144 */     EJBResource ejbResource = new EJBResource(map);
/*     */
/* 146 */     RunAs callerRunAs = this.securityContext.getIncomingRunAs();
/*     */
/* 148 */     ejbResource.setEjbName(ejbName);
/* 149 */     ejbResource.setPrincipal(ejbPrincipal);
/* 150 */     ejbResource.setCallerRunAsIdentity(callerRunAs);
/* 151 */     ejbResource.setSecurityRoleReferences(securityRoleRefs);
/*     */     try
/*     */     {
/* 155 */       int check = am.authorize(ejbResource);
/* 156 */       isAuthorized = check == 1;
/*     */     }
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

/*     */   public int authorize(Resource resource)
/*     */   {
/*  83 */     if (!(resource instanceof EJBResource)) {
/*  84 */       throw new IllegalArgumentException("resource is not an EJBResource");
/*     */     }
/*  86 */     EJBResource ejbResource = (EJBResource)resource;
/*     */
/*  89 */     Map map = resource.getMap();
/*  90 */     if (map == null) {
/*  91 */       throw new IllegalStateException("Map from the Resource is null");
/*     */     }
/*  93 */     AuthorizationManager am = (AuthorizationManager)map.get("authorizationManager");
/*  94 */     if (am == null)
/*  95 */       throw new IllegalStateException("Authorization Manager is null");
/*  96 */     if ((am instanceof PolicyRegistration)) {
/*  97 */       this.policyRegistration = ((PolicyRegistration)am);
/*     */     }
/*     */
/* 107 */     this.callerSubject = ejbResource.getCallerSubject();
/* 108 */     this.ejbCS = ejbResource.getCodeSource();
/* 109 */     this.ejbMethod = ejbResource.getEjbMethod();
/* 110 */     this.ejbName = ejbResource.getEjbName();
/* 111 */     this.methodInterface = ejbResource.getEjbMethodInterface();
/*     */
/* 113 */     this.roleName = ((String)map.get("roleName"));
/*     */
/* 115 */     if (am != null)
/*     */     {
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

         log.error("Error getting Policy Registration",e);
      }
     
      map.put(ResourceKeys.POLICY_REGISTRATION, this.policyRegistration);
    
      EJBResource ejbResource = new EJBResource(map);
      ejbResource.setEjbVersion(version);
      ejbResource.setPolicyContextID(contextID);
      ejbResource.setCallerRunAsIdentity(callerRunAs);
      ejbResource.setEjbName(ejbName);
      ejbResource.setEjbMethod(ejbMethod);
      ejbResource.setPrincipal(ejbPrincipal);
      ejbResource.setEjbMethodInterface(invocationInterfaceString);
      ejbResource.setCodeSource(ejbCS);
      ejbResource.setCallerRunAsIdentity(callerRunAs);
      ejbResource.setCallerSubject(callerSubject);
      ejbResource.setEjbMethodRoles(methodRoles);
     
      SecurityContextCallbackHandler sch = new SecurityContextCallbackHandler(this.securityContext);
      RoleGroup callerRoles = am.getSubjectRoles(callerSubject, sch);
     
      boolean isAuthorized = false;
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

      map.put(ResourceKeys.POLICY_REGISTRATION, this.policyRegistration);
     
      map.put(ResourceKeys.ROLENAME, roleName);
      map.put(ResourceKeys.ROLEREF_PERM_CHECK, Boolean.TRUE);
     
      EJBResource ejbResource = new EJBResource(map);
      ejbResource.setPolicyContextID(contextID);
     
      RunAs callerRunAs = SecurityActions.getIncomingRunAs(securityContext);
     
      ejbResource.setEjbVersion(version);
      ejbResource.setEjbName(ejbName);
      ejbResource.setPrincipal(ejbPrincipal);
      ejbResource.setCallerRunAsIdentity(callerRunAs);
      ejbResource.setSecurityRoleReferences(securityRoleRefs);
      ejbResource.setEnforceEJBRestrictions(enforceEJBRestrictions);
     
      ejbResource.setCallerSubject(callerSubject);
      SecurityContextCallbackHandler sch = new SecurityContextCallbackHandler(this.securityContext);
      RoleGroup callerRoles = am.getSubjectRoles(callerSubject, sch);
     
      try
      {
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

   public int authorize(Resource resource, Subject callerSubject, RoleGroup role)
   {
      if(resource instanceof EJBResource == false)
         throw new IllegalArgumentException("resource is not an EJBResource");
     
      EJBResource ejbResource = (EJBResource) resource;
     
      //Get the context map
      Map<String,Object> map = resource.getMap();
      if(map == null)
         throw new IllegalStateException("Map from the Resource is null");

      this.policyRegistration = (PolicyRegistration) map.get(ResourceKeys.POLICY_REGISTRATION)
      if(this.policyRegistration == null)
         throw new IllegalStateException("Policy Registration passed is null");

      this.callerRunAs = ejbResource.getCallerRunAsIdentity();
      this.ejbName = ejbResource.getEjbName();
      this.ejbMethod = ejbResource.getEjbMethod();
      this.ejbPrincipal = ejbResource.getPrincipal();
      this.policyContextID = ejbResource.getPolicyContextID();
      if(policyContextID == null)
         throw new IllegalStateException("Context ID is null");
     
      this.securityRoleReferences = ejbResource.getSecurityRoleReferences();
     
      //isCallerInRole checks
      this.roleName = (String)map.get(ResourceKeys.ROLENAME);
     
      Boolean roleRefCheck = checkBooleanValue((Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK));
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

   public int authorize(Resource resource, Subject callerSubject, RoleGroup role)
   {
      if(resource instanceof EJBResource == false)
         throw new IllegalArgumentException("resource is not an EJBResource");
     
      EJBResource ejbResource = (EJBResource) resource;
     
      //Get the context map
      Map<String,Object> map = resource.getMap();
      if(map == null)
         throw new IllegalStateException("Map from the Resource is null");
     
      this.policyRegistration = (PolicyRegistration) map.get(ResourceKeys.POLICY_REGISTRATION);
     
      this.roleName = (String)map.get(ResourceKeys.ROLENAME);
      this.roleRefCheck = (Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK);
     
      this.callerRunAs = ejbResource.getCallerRunAsIdentity();
      this.ejbMethod = ejbResource.getEjbMethod();
      this.ejbName = ejbResource.getEjbName();
      this.ejbPrincipal = ejbResource.getPrincipal();
      this.methodInterface = ejbResource.getEjbMethodInterface();
      this.methodRoles = ejbResource.getEjbMethodRoles();
      this.securityRoleReferences = ejbResource.getSecurityRoleReferences();
      this.ejbRestrictions = ejbResource.isEnforceEJBRestrictions();
     
      if(this.roleRefCheck == Boolean.TRUE)
         return checkRoleRef(role);
      else
         return process(role);
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

   public int authorize(Resource resource, Subject callerSubject, RoleGroup role)
   {
      if(resource instanceof EJBResource == false)
         throw new IllegalArgumentException("resource is not an EJBResource");
     
      EJBResource ejbResource = (EJBResource) resource;
     
      //Get the context map
      Map<String,Object> map = resource.getMap();
      if(map == null)
         throw new IllegalStateException("Map from the Resource is null");

      this.policyRegistration = (PolicyRegistration) map.get(ResourceKeys.POLICY_REGISTRATION);
     
      this.ejbCS = ejbResource.getCodeSource();
      this.ejbMethod = ejbResource.getEjbMethod();
      this.ejbName = ejbResource.getEjbName();
      this.methodInterface = ejbResource.getEjbMethodInterface();
     
      //isCallerInRole checks
      this.roleName = (String)map.get(ResourceKeys.ROLENAME);
     
      this.roleRefCheck = (Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK);
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

   {
      EJBXACMLPolicyModuleDelegate pc = new EJBXACMLPolicyModuleDelegate();

      PolicyRegistration policyRegistration = new JBossPolicyRegistration();
      registerPolicy(policyRegistration);
      EJBResource er = getEJBResource(policyRegistration);
     
      er.setPolicyContextID(contextID);
      int res = pc.authorize(er, new Subject(), getRoleGroup());
      assertEquals(AuthorizationContext.PERMIT, res);
   }
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

   {
      EJBXACMLPolicyModuleDelegate pc = new EJBXACMLPolicyModuleDelegate();
     
      PolicyRegistration policyRegistration = new JBossPolicyRegistration();
      registerPolicy(policyRegistration);
      EJBResource er = getEJBResource(policyRegistration);
     
      er.setPolicyContextID(contextID);
      er.setPrincipal(new SimplePrincipal("baduser"));

      int res = pc.authorize(er, new Subject(), getRoleGroup());
      assertEquals(AuthorizationContext.DENY, res);
   }
View Full Code Here

Examples of org.jboss.security.authorization.resources.EJBResource

   {
      EJBXACMLPolicyModuleDelegate pc = new EJBXACMLPolicyModuleDelegate();
     
      PolicyRegistration policyRegistration = new JBossPolicyRegistration();
      registerPolicy(policyRegistration);
      EJBResource er = getEJBResource(policyRegistration);
     
      er.setPolicyContextID(contextID);
      er.setPrincipal(new SimplePrincipal("baduser"));
      er.getMap().put(ResourceKeys.ROLEREF_PERM_CHECK, true);
      er.getMap().put(ResourceKeys.ROLENAME, "employee");

      Set<SecurityRoleRef> roleRefSet = new HashSet<SecurityRoleRef>();
      roleRefSet.add(this.getSecurityRoleRef("employee", "ProjectUser"));
      er.setSecurityRoleReferences(roleRefSet);
     
      int res = pc.authorize(er, new Subject(), getRoleGroup());
      assertEquals(AuthorizationContext.PERMIT, res);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.