Package org.jboss.security.authorization.resources

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", "baduser"));
      er.setSecurityRoleReferences(roleRefSet);
     
      int res = pc.authorize(er, new Subject(), getRoleGroup());
      assertEquals(AuthorizationContext.DENY, res);
   }
View Full Code Here


   private EJBResource getEJBResource(PolicyRegistration policyRegistration)
   {
      HashMap<String,Object> map = new HashMap<String,Object>();
      map.put(ResourceKeys.POLICY_REGISTRATION, policyRegistration);
     
      EJBResource er = new EJBResource(map);
      er.setEjbName("StatelessSession");
      er.setEjbMethod(StatelessSession.class.getMethods()[0]);
      er.setPrincipal(p);
      return er;
   }
View Full Code Here

      EJBPolicyModuleDelegate epmd = new EJBPolicyModuleDelegate();
      
      //Create a context map
      Map<String,Object> cmap = new HashMap<String,Object>();
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
      resource.setEjbMethodRoles( getRoleGroup(new String[] {"gooduser"}) );
     
      assertEquals(AuthorizationContext.PERMIT,epmd.authorize(resource,
            new Subject(),
            getRoleGroup(new String[]{"gooduser", "validuser" })) );
   }
View Full Code Here

      EJBPolicyModuleDelegate epmd = new EJBPolicyModuleDelegate();
     
      //Create a context map
      Map<String,Object> cmap = new HashMap<String,Object>()
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
      resource.setEjbMethodRoles( getRoleGroup(new String[] {"gooduser"}) );
     
      int res = epmd.authorize(resource, new Subject(), getRoleGroup(new String[]{"baduser"}));
     
      assertEquals(AuthorizationContext.DENY, res);
   }
View Full Code Here

      EJBPolicyModuleDelegate epmd = new EJBPolicyModuleDelegate();
     
      //Create a context map
      Map<String,Object> cmap = new HashMap<String,Object>()
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
      resource.setEjbMethodRoles( getRoleGroup(new String[] {AnybodyPrincipal.ANYBODY}) );
     
      int res = epmd.authorize(resource, new Subject(), getRoleGroup(new String[]{"baduser"}));
      assertEquals(AuthorizationContext.PERMIT, res);
   }
View Full Code Here

      EJBPolicyModuleDelegate epmd = new EJBPolicyModuleDelegate();
    
      //Create a context map
      Map<String,Object> cmap = new HashMap<String,Object>()
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
     
      int res = epmd.authorize(resource, new Subject(), getRoleGroup(new String[]{"baduser"}));
      assertEquals(AuthorizationContext.DENY, res);
   }
View Full Code Here

      Map<String,Object> cmap = new HashMap<String,Object>();
     
      cmap.put(ResourceKeys.ROLEREF_PERM_CHECK, true);
      cmap.put(ResourceKeys.ROLENAME, "employee");
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
      resource.setEjbMethodRoles( getRoleGroup(new String[] {"gooduser"}) );

      Set<SecurityRoleRef> roleRefSet = new HashSet<SecurityRoleRef>();
      roleRefSet.add(new SecurityRoleRef("employee", "gooduser"));
      resource.setSecurityRoleReferences(roleRefSet);
     
      int result = epmd.authorize(resource,
            new Subject(),
            getRoleGroup(new String[]{"gooduser", "validuser" }));
     
View Full Code Here

      Map<String,Object> cmap = new HashMap<String,Object>();
     
      cmap.put(ResourceKeys.ROLEREF_PERM_CHECK, true);
      cmap.put(ResourceKeys.ROLENAME, "employee");
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
      resource.setEjbMethodRoles( getRoleGroup(new String[] {"gooduser"}) );

      Set<SecurityRoleRef> roleRefSet = new HashSet<SecurityRoleRef>();
      roleRefSet.add(new SecurityRoleRef("employee", "baduser")); //Bad user
      resource.setSecurityRoleReferences(roleRefSet);
     
      int result = epmd.authorize(resource,
            new Subject(),
            getRoleGroup(new String[]{"gooduser", "validuser" }));
     
View Full Code Here

      Map<String,Object> cmap = new HashMap<String,Object>();
     
      cmap.put(ResourceKeys.ROLEREF_PERM_CHECK, true);
      cmap.put(ResourceKeys.ROLENAME, "employee");
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
      resource.setEjbMethodRoles( getRoleGroup(new String[] {"gooduser"}) );
      resource.setEnforceEJBRestrictions(true); //Enforce EJB 1.1

      Set<SecurityRoleRef> roleRefSet = new HashSet<SecurityRoleRef>();
      roleRefSet.add(new SecurityRoleRef("employee", "gooduser"))
      resource.setSecurityRoleReferences(roleRefSet);

      int result = epmd.authorize(resource,
            new Subject(),
            getRoleGroup(new String[]{"gooduser", "validuser" }));
      assertEquals(AuthorizationContext.PERMIT, result);
View Full Code Here

      Map<String,Object> cmap = new HashMap<String,Object>();
     
      cmap.put(ResourceKeys.ROLEREF_PERM_CHECK, true);
      cmap.put(ResourceKeys.ROLENAME, "impostor");
     
      EJBResource resource = new EJBResource(cmap);
      resource.setPrincipal(new SimplePrincipal("AuthenticatedPrincipal"));
      resource.setEjbMethod(DummyClass.class.getDeclaredMethods()[0]);
      resource.setEjbName(DummyClass.class.getCanonicalName());
      resource.setEjbMethodRoles( getRoleGroup(new String[] {"gooduser"}) );
      resource.setEnforceEJBRestrictions(true); //Enforce EJB 1.1

      Set<SecurityRoleRef> roleRefSet = new HashSet<SecurityRoleRef>();
      roleRefSet.add(new SecurityRoleRef("employee", "baduser")); //Bad user
      resource.setSecurityRoleReferences(roleRefSet);
     
      try
      {
          epmd.authorize(resource,
               new Subject(),
View Full Code Here

TOP

Related Classes of org.jboss.security.authorization.resources.EJBResource

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.