Search in sources :

Example 1 with CqActions

use of com.day.cq.security.util.CqActions in project APM by Cognifide.

the class CheckPermissions method process.

private ActionResult process(final Context context, boolean execute) {
    ActionResult actionResult = new ActionResult();
    try {
        final Authorizable authorizable = AuthorizablesUtils.getAuthorizable(context, authorizableId);
        final Set<Principal> authorizablesToCheck = getAuthorizablesToCheck(authorizable, context);
        final CqActions actions = new CqActions(context.getSession());
        final List<String> privilegesToCheck = preparePrivilegesToCheck();
        if (StringUtils.isBlank(glob)) {
            if (checkPermissionsForPath(authorizablesToCheck, actions, privilegesToCheck, path)) {
                logFailure(execute, actionResult, authorizable, path);
            } else {
                actionResult.logMessage("All required privileges are set for " + authorizable.getID() + " on " + path);
            }
        } else {
            checkPermissionsForGlob(context.getSession(), execute, actionResult, authorizable, authorizablesToCheck, actions, privilegesToCheck);
        }
    } catch (final PathNotFoundException e) {
        actionResult.logError("Path " + path + " not found");
    } catch (RepositoryException | ActionExecutionException | LoginException e) {
        actionResult.logError(MessagingUtils.createMessage(e));
    }
    return actionResult;
}
Also used : ActionResult(com.cognifide.cq.cqsm.api.actions.ActionResult) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) CqActions(com.day.cq.security.util.CqActions) LoginException(org.apache.sling.api.resource.LoginException) RepositoryException(javax.jcr.RepositoryException) PathNotFoundException(javax.jcr.PathNotFoundException) ActionExecutionException(com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException) Principal(java.security.Principal)

Example 2 with CqActions

use of com.day.cq.security.util.CqActions in project APM by Cognifide.

the class CheckPermissions method process.

private ActionResult process(final Context context, boolean execute) {
    ActionResult actionResult = context.createActionResult();
    try {
        final Authorizable authorizable = context.getAuthorizableManager().getAuthorizable(authorizableId);
        final Set<Principal> authorizablesToCheck = getAuthorizablesToCheck(authorizable, context);
        final CqActions actions = new CqActions(context.getSession());
        final List<String> privilegesToCheck = preparePrivilegesToCheck();
        if (StringUtils.isBlank(glob)) {
            if (checkPermissionsForPath(authorizablesToCheck, actions, privilegesToCheck, path)) {
                logFailure(execute, actionResult, authorizable, path);
            } else {
                actionResult.logMessage("All required privileges are set for " + authorizable.getID() + " on " + path);
            }
        } else {
            checkPermissionsForGlob(context.getSession(), execute, actionResult, authorizable, authorizablesToCheck, actions, privilegesToCheck);
        }
    } catch (final PathNotFoundException e) {
        actionResult.logError("Path " + path + " not found");
    } catch (RepositoryException | ActionExecutionException | LoginException e) {
        actionResult.logError(MessagingUtils.createMessage(e));
    }
    return actionResult;
}
Also used : ActionResult(com.cognifide.apm.api.actions.ActionResult) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) CqActions(com.day.cq.security.util.CqActions) LoginException(org.apache.sling.api.resource.LoginException) RepositoryException(javax.jcr.RepositoryException) PathNotFoundException(javax.jcr.PathNotFoundException) ActionExecutionException(com.cognifide.apm.api.exceptions.ActionExecutionException) Principal(java.security.Principal)

Aggregations

CqActions (com.day.cq.security.util.CqActions)2 Principal (java.security.Principal)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 RepositoryException (javax.jcr.RepositoryException)2 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)2 LoginException (org.apache.sling.api.resource.LoginException)2 ActionResult (com.cognifide.apm.api.actions.ActionResult)1 ActionExecutionException (com.cognifide.apm.api.exceptions.ActionExecutionException)1 ActionResult (com.cognifide.cq.cqsm.api.actions.ActionResult)1 ActionExecutionException (com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException)1