Package com.adito.policyframework

Examples of com.adito.policyframework.AccessRights


   *
   * @see com.adito.policyframework.PolicyDatabase#deleteResourcePermission(int)
   */
  public AccessRights deleteAccessRights(int id) throws Exception {
    policyCache.clear();
    AccessRights dr = getAccessRight(id);
    if (dr == null) {
      throw new Exception(
          "Cannot delete a resource permission that doesnt exist");
    }
    JDBCPreparedStatement ps = db
        .getStatement("deleteResourcePermission.delete");
    ps.startTransaction();
    ps.setInt(1, id);
    try {
      try {
        ps.execute();
        deleteResourcePermissionRelationships(ps, id);
        ps = db.getStatement(ps,
            "deleteResourcePermission.policyRelationship");
        ps.setInt(1, id);
        ps.setInt(2, dr.getResourceType().getResourceTypeId());
        ps.execute();
        ps.commit();
      } finally {
        ps.releasePreparedStatement();
      }
View Full Code Here


    String cacheKey = buf.toString();
    List<Policy> l = (List<Policy>) policyCache.retrieve(cacheKey);
    if (l == null) {
      l = new ArrayList<Policy>();
      List resourcePermissions = getAccessRights();
      AccessRights resourcePermission = null;
      AccessRight accessRight = null;
      for (Iterator i = resourcePermissions.iterator(); i.hasNext();) {
        resourcePermission = (AccessRights) i.next();
        if (isPrincipalAllowed(user, resourcePermission, true)) {
          if (permissionClass == null
              || permissionClass.equals(resourcePermission
                  .getAccessRightsClass())) {
            for (Iterator j = resourcePermission.getAccessRights()
                .iterator(); j.hasNext();) {

              accessRight = (AccessRight) j
                  .next();
              if (resourceType == null
View Full Code Here

        + user.getPrincipalName();
    List<AccessRights> l = (List<AccessRights>) policyCache.retrieve(cacheKey);
    if (l == null) {
      l = new ArrayList<AccessRights>();
      List resourcePermissions = getAccessRights();
      AccessRights resourcePermission = null;
      AccessRight accessRight = null;

      /*
             * First iterate through all of the resource permissions looking for
             * what is visible at the top level.
             */

      for (Iterator i = resourcePermissions.iterator(); i.hasNext();) {
        resourcePermission = (AccessRights) i.next();
        if (permissionClass == null
            || permissionClass.equals(resourcePermission
                .getAccessRightsClass())) {
          // Check the user is allowed
        if (isPrincipalAllowed(
                user, resourcePermission, true)) {
            // Iterator through all permissions in the resource
            for (Iterator j = resourcePermission
                .getAccessRights().iterator(); j.hasNext();) {
              accessRight = (AccessRight) j
                  .next();
              // Until the resource type matches
              if (resourceType == null
View Full Code Here

    if (n == null) {
      ArrayList<AccessRights> l = new ArrayList<AccessRights>();
      boolean superUser = LogonControllerFactory.getInstance()
          .isAdministrator(user);
      List allAccessRights = getAccessRights();
      AccessRights accessRights = null;
      AccessRight accessRight = null;

      /*
       * First iterate through all of the resource permissions looking for
       * what is visible at the top level.
       */

      for (Iterator i = allAccessRights.iterator(); i.hasNext();) {
                accessRights = (AccessRights) i.next();
                if (permissionClass == null || permissionClass.equals(accessRights.getAccessRightsClass())) {
                    // Check the user is allowed
                    if (isPrincipalAllowed(user, accessRights, true)) {

                        // Iterator through all permissions in the resource
                        for (Iterator j = accessRights.getAccessRights().iterator(); j.hasNext();) {
                            accessRight = (AccessRight) j.next();
                            // Until the resource type matches
                            if (resourceType == null || resourceType.equals(accessRight.getResourceType())) {
                                // Until at least one permission matches
                                if (permission == null || permission.getId() == accessRight.getPermission().getId()) {
View Full Code Here

        rs.getInt("policy_type_id"), c, a, rs.getInt("realm_id"));
  }
 
  List<AccessRights> buildResourcePermission(ResultSet resultSet) throws Exception {
        List<AccessRight> permissions = null;
        AccessRights accessRights = null;
        List<AccessRights> accessRightsList = new ArrayList<AccessRights>();
        int lastId = -1;
        while (resultSet.next()) {
            int resourceId = resultSet.getInt("resource_id");
            int realmID = resultSet.getInt("realm_id");
            if (resourceId != lastId) {
                permissions = new ArrayList<AccessRight>();
                Calendar dateCreated = JDBCUtil.getCalendar(resultSet, "date_created");
                Calendar dateAmended = JDBCUtil.getCalendar(resultSet, "date_amended");
                String resourceName = resultSet.getString("resource_name");
                String resourceDescription = resultSet.getString("resource_description");
                String resourceClass = resultSet.getString("resource_class");
                accessRights = new DefaultAccessRights(realmID, resourceId, resourceName, resourceDescription, permissions,
                                resourceClass, dateCreated, dateAmended);
                accessRightsList.add(accessRights);
                lastId = resourceId;
            }
            // check to see if the access right has any permissions
            if (!JDBCUtil.isNull(resultSet, "resource_type_id")) {
                int resourceTypeId = resultSet.getInt("resource_type_id");
                ResourceType resourceType = getResourceType(resourceTypeId);
                if (resourceType == null) {
                    log.warn("No resource type with Id of " + resourceTypeId + " for resource permission " + resourceId
                                    + ", ignoring");
                } else {
                    int permissionId = resultSet.getInt("permission_id");
                    Permission permission = resourceType.getPermission(permissionId);
                    if (permission == null) {
                        log.warn("No permission with Id of " + permissionId + " for resource type " + resourceTypeId
                                        + " and resource permission " + resourceId + ", ignoring");
                    } else {
                        AccessRight accessRight = new AccessRight(resourceType, permission);
                        permissions.add(accessRight);
                    }
                }
            } else {
                log.debug("Access Rights with name " + accessRights.getResourceName() + " has no permissions.");
            }
        }
        return accessRightsList;
    }
View Full Code Here

TOP

Related Classes of com.adito.policyframework.AccessRights

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.