Package org.jboss.test.security.resources

Examples of org.jboss.test.security.resources.TestResource


         // first retrieve the authorization manager for the acl-domain.
         InitialContext ctx = new InitialContext();
         AuthorizationManager manager = (AuthorizationManager) ctx.lookup("java:jaas/acl-domain/authorizationMgr");

         // create a resource 1 that has resource 2 as a child.
         TestResource resource1 = new TestResource(1);
         TestResource resource2 = new TestResource(2);
         Collection<Resource> childResources = new ArrayList<Resource>();
         childResources.add(resource2);
         resource1.getMap().put(ResourceKeys.CHILD_RESOURCES, childResources);
         resource2.getMap().put(ResourceKeys.PARENT_RESOURCE, resource1);

         // retrieve the identity name from the request.
         String name = request.getParameter("identity");
         Identity identity = new SimpleIdentity(name);

         // now call the getEntitlements method using created resource and identity objects.
         EntitlementHolder<EntitlementEntry> holder = manager.getEntitlements(EntitlementEntry.class, resource1,
               identity);

         // write the results in the response (resource id : permissions)
         response.setContentType("text/html");
         PrintWriter writer = response.getWriter();
         for (EntitlementEntry entry : holder.getEntitled())
         {
            TestResource resource = (TestResource) entry.getResource();
            writer.println(resource.getId() + ":" + entry.getPermission());
         }
         writer.close();
      }
      catch (Exception e)
      {
View Full Code Here


         // first retrieve the authorization manager for the acl-domain.
         InitialContext ctx = new InitialContext();
         AuthorizationManager manager = (AuthorizationManager) ctx.lookup("java:jaas/acl-domain/authorizationMgr");

         // create a resource 10 that has resource 11 as a child.
         TestResource resource10 = new TestResource(10);
         TestResource resource11 = new TestResource(11);
         Collection<Resource> childResources = new ArrayList<Resource>();
         childResources.add(resource11);
         resource10.getMap().put(ResourceKeys.CHILD_RESOURCES, childResources);
         resource11.getMap().put(ResourceKeys.PARENT_RESOURCE, resource10);

         // now call the getEntitlements method using created resource and identity objects.
         EntitlementHolder<EntitlementEntry> holder = manager.getEntitlements(EntitlementEntry.class, resource10,
               IdentityFactory.createIdentity(identity));

         // for each entitlement entry, put the resource id and associated permission in the map to be returned.
         for (EntitlementEntry entry : holder.getEntitled())
         {
            TestResource resource = (TestResource) entry.getResource();
            entitlementsMap.put(resource.getId(), entry.getPermission().toString());
         }
      }
      catch (Exception e)
      {
         throw new RuntimeException("Failed to obtain entitlements from authorization manager", e);
View Full Code Here

TOP

Related Classes of org.jboss.test.security.resources.TestResource

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.