Search in sources :

Example 1 with PermissionManager

use of org.cubeengine.libcube.service.permission.PermissionManager in project core by CubeEngine.

the class ContainerCommand method addCommand.

@Override
public boolean addCommand(CommandBase command) {
    if (!(command instanceof AliasCommand) && command.getDescriptor() instanceof CubeDescriptor) {
        PermissionManager pm = manager.getPermissionManager();
        Class owner = getDescriptor().getOwner();
        Permission basePerm = pm.getBasePermission(owner);
        Permission cmdPerm = pm.getPermission(basePerm.getId() + ".command");
        if (cmdPerm == null) {
            // TODO Description for BaseCommand Permission
            cmdPerm = pm.register(owner, "command", "Allows using all commands for this module", null);
        }
        // gets the container permission
        Permission thisPerm = getDescriptor().registerPermission(pm, cmdPerm);
        // register the added cmd permission
        ((CubeDescriptor) command.getDescriptor()).registerPermission(pm, thisPerm);
    }
    return super.addCommand(command);
}
Also used : AliasCommand(org.cubeengine.butler.alias.AliasCommand) PermissionManager(org.cubeengine.libcube.service.permission.PermissionManager) CommandPermission(org.cubeengine.libcube.service.command.annotation.CommandPermission) Permission(org.cubeengine.libcube.service.permission.Permission) RawPermission(org.cubeengine.libcube.service.command.property.RawPermission)

Aggregations

AliasCommand (org.cubeengine.butler.alias.AliasCommand)1 CommandPermission (org.cubeengine.libcube.service.command.annotation.CommandPermission)1 RawPermission (org.cubeengine.libcube.service.command.property.RawPermission)1 Permission (org.cubeengine.libcube.service.permission.Permission)1 PermissionManager (org.cubeengine.libcube.service.permission.PermissionManager)1