Package com.adito.policyframework

Examples of com.adito.policyframework.NoPermissionException


    public void updateResourceWithNoPermissionException() throws DuplicateResourceNameException, NoPermissionException {
        Resource resource = getDefaultResource();
       
        expect(resourceDatabase.getResourceById(resource.getResourceId())).andReturn(resource);
        policyService.checkPermission(resourceType, PolicyConstants.PERM_EDIT_AND_ASSIGN, (SessionInfo) null);
        expectLastCall().andThrow(new NoPermissionException("Failed to update resource."));
        CoreEvent changeEvent = getChangeEvent(resourceService.getEditEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
        mocksControl.replay();
       
        try {
View Full Code Here


    @Test
    public void removeResourceWithNoPermissionException() throws NoPermissionException {
        Resource resource = getDefaultResource();

        policyService.checkPermission(resourceType, PolicyConstants.PERM_DELETE, (SessionInfo) null);
        expectLastCall().andThrow(new NoPermissionException("Failed to remove resource."));
        CoreEvent deleteEvent = getDeleteEvent(resourceService.getRemoveEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(deleteEvent));
        mocksControl.replay();

        try {
View Full Code Here

                            // Check the user has the permissions to access this
                            // page
                            if (resourceType != null) {
                                if (!PolicyDatabaseFactory.getInstance().isPermitted(resourceType, permissions, currentUser, false)) {
                                    throw new NoPermissionException("Action denied for current user");
                                }
                            }

                            if (request.getSession().getAttribute(Constants.SESSION_LOCKED) == null || isIgnoreSessionLock()) {
                                if (requiresProfile()) {
View Full Code Here

        }
        if (!ok && requiresResourcesOfType != null) {
            ok = PolicyDatabaseFactory.getInstance().isPrincipalGrantedResourcesOfType(session.getUser(), requiresResourcesOfType, null);
        }
        if (!ok) {
            throw new NoPermissionException(session.getUser(), resourceType);
        }
    }
View Full Code Here

            true) && ContextHolder.getContext().isRestartAvailableMode()) {
            // Restart
            shutdownForm.setShutdownOperation(ShutdownForm.RESTART);
            shutdownForm.setShutdownType(ShutdownForm.RESTART);
        } else {
            throw new NoPermissionException("Cannot shutdown or restart.");
        }

        /*
         * Hack to prevent getting in a loop if sending and message then
         * cancelling
 
View Full Code Here

        if (!ContextHolder.getContext().isSetupMode()) {
            SessionInfo info = LogonControllerFactory.getInstance().getSessionInfo(request);
            if ((navigationContext & info.getNavigationContext()) == 0) {
                if ((navigationContext & SessionInfo.MANAGEMENT_CONSOLE_CONTEXT) != 0) {                 
                  if(!PolicyDatabaseFactory.getInstance().isAnyAccessRightAllowed(info.getUser(), true, true, false)) {
                        throw new NoPermissionException("You do not have permission to use the management console.");                   
                  }
                    info.setNavigationContext(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT);
                    CoreUtil.resetMainNavigation(request.getSession());
                } else if ((navigationContext & SessionInfo.USER_CONSOLE_CONTEXT) != 0) {
                    info.setNavigationContext(SessionInfo.USER_CONSOLE_CONTEXT);
                    CoreUtil.resetMainNavigation(request.getSession());
                } else if ((navigationContext & SessionInfo.HELP_CONTEXT) != 0) {
                    // do nothing
                } else {
                    throw new NoPermissionException("Action does not define any valid navigation contexts that it should be available in.");
                }
            }
        }
    }
View Full Code Here

       
        if(launchSession.hasPolicy()) {
          if(launchSession.isTracked()) {
            // Launch session is tracked, do not allow policy to change but allow super user to browser readonly
            if (!ResourceUtil.isManageableResource(resource, getRepository().getSession().getUser(), null)) {
              throw new NoPermissionException("You do not have permission to access this network place resource under this policy.",
                getRepository().getSession().getUser(),
                      resourceType);
            }
            readOnly = true;
          }
          else {
            // Not a tracked launch session so policy changing is allowed
            launchSession.takePolicy();
          }
        }
       
        /* If the mount has not already been set as ready only (because its tracked)
         * There check access to the mount is allowed and change the granting policy
         */
        if(!readOnly) {
          try {
            if (!(resource instanceof OwnedResource) || (resource instanceof OwnedResource && ((OwnedResource) resource).getOwnerUsername() == null)) {
              try {
                grantingPolicy = PolicyDatabaseFactory.getInstance().getGrantingPolicyForUser(launchSession.getSession().getUser(), resource);
                if(grantingPolicy == null) {
                  throw new NoPermissionException("You may not access this network place resource here.",
                    getRepository().getSession().getUser(),
                          resourceType);
                }
              } catch (NoPermissionException npe2) {
                throw npe2;
              } catch (Exception e) {
                throw new NoPermissionException("Failed to determine if network place resource is accessable.",
                  getRepository().getSession().getUser(),
                        resourceType);
              }
            } else {
              if (!(getRepository().getSession().getUser().getPrincipalName().equals(((OwnedResource) resource).getOwnerUsername()))) {
                throw new NoPermissionException("You do not have permission to access this network place resource.",
                  getRepository().getSession().getUser(),
                        resourceType);
              }
            }
          } catch (NoPermissionException npe) {
            if (!ResourceUtil.isManageableResource(resource, getRepository().getSession().getUser(), PolicyConstants.PERM_USE )) {
              throw new NoPermissionException("You do not have permission to access this network place resource.",
                getRepository().getSession().getUser(),
                      resourceType);
            }
            readOnly = true;
          } catch (Exception e) {
View Full Code Here

        }
      }
      return null;
    } catch (Exception e) {
      log.error("Failed to test if user has access to resource. Denying", e);
      throw new NoPermissionException("Permission denied.", session.getUser(), NetworkPlacePlugin.NETWORK_PLACE_RESOURCE_TYPE);
    }
  }
View Full Code Here

  protected ExtensionDescriptor getExtensionDescriptor(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                              HttpServletResponse response) throws Exception {
    try {
      PolicyUtil.checkPermission(PolicyConstants.AGENT_RESOURCE_TYPE, PolicyConstants.PERM_USE, request);
    } catch (NoPermissionException e) {
      throw new NoPermissionException("Contact your administrator to use the agent.",
              e,
              LogonControllerFactory.getInstance().getUser(request),
              PolicyConstants.AGENT_RESOURCE_TYPE);
    }
    return ExtensionStore.getInstance().getExtensionDescriptor("adito-agent");
View Full Code Here

TOP

Related Classes of com.adito.policyframework.NoPermissionException

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.