Examples of PermissionLabel


Examples of org.wso2.carbon.messagebox.PermissionLabel

     * @param messageBoxId - message box id
     * @return list of permission labels
     * @throws MessageBoxException if fails to get permission labels
     */
    public List<PermissionLabel> getAllPermissions(String messageBoxId) throws MessageBoxException {
        PermissionLabel permissionLabel;
        List<PermissionLabel> permissionList = new ArrayList<PermissionLabel>();

        String permissionLabelResourcePath = getMessageBoxResourcePath(messageBoxId);
        try {
            UserRegistry userRegistry = Utils.getUserRegistry();
            Collection messageBoxCollection = (Collection) userRegistry.get(permissionLabelResourcePath);
            for (String permissionResource : messageBoxCollection.getChildren()) {
                String[] sharedUsers = userRegistry.get(permissionResource).getProperty(
                        MessageBoxConstants.MB_REGISTRY_PROPERTY_SHARED_USERS).split(
                        "\\" + MessageBoxConstants.JMS_MESSAGE_SHARED_USER_OPERATION_SEPARATOR);

                String[] operations = userRegistry.get(permissionResource).getProperty(
                        MessageBoxConstants.MB_REGISTRY_PROPERTY_OPERATIONS).split(
                        "\\" + MessageBoxConstants.JMS_MESSAGE_SHARED_USER_OPERATION_SEPARATOR);

                String permissionLabelName = permissionResource.substring(permissionResource.
                        lastIndexOf("/") + 1);

                permissionLabel = new PermissionLabel(permissionLabelName, Arrays.asList(sharedUsers),
                                                      Arrays.asList(operations));
                permissionList.add(permissionLabel);
            }
            return permissionList;
        } catch (RegistryException e) {
View Full Code Here

Examples of org.wso2.carbon.messagebox.PermissionLabel

            String[] operations = userRegistry.get(permissionLabelResourcePath).getProperty(
                    MessageBoxConstants.MB_REGISTRY_PROPERTY_OPERATIONS).split(
                    "\\" + MessageBoxConstants.JMS_MESSAGE_SHARED_USER_OPERATION_SEPARATOR);

            return new PermissionLabel(permissionLabel, Arrays.asList(sharedUsers),
                                       Arrays.asList(operations));
        } catch (RegistryException e) {
            throw new MessageBoxException("Can not find the resource in " + permissionLabelResourcePath, e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.messagebox.PermissionLabel

        if (!registryMessageBoxHandler.isMessageBoxExists(messageBoxId)) {
            throw new MessageBoxException("AWS.SimpleQueueService.NonExistentQueue");
        }

        // Get permissions before removing from registry
        PermissionLabel removedPermissionLabel = registryMessageBoxHandler.getPermission(
                messageBoxId, permissionLabelName);
        // Remove from registry allowed permission label
        registryMessageBoxHandler.removePermission(messageBoxId, permissionLabelName);

        // Get all the permissions associated with this message box
        List<PermissionLabel> allPermissions =
                registryMessageBoxHandler.getAllPermissions(messageBoxId);

        /**
         * There may be permissions set with other permission labels, duplicate permissions
         * Before un-authorizing allowed permissions, search those permissions and add them
         * to another list of permission labels
         */
        List<PermissionLabel> otherAllowedPermissions = new ArrayList<PermissionLabel>();

        // Check for all removed users
        for (String removedSharedUser : removedPermissionLabel.getSharedUsers()) {
            // for all permissions on this message box
            for (PermissionLabel permissionLabel : allPermissions) {
                // just check if shared users contains removed user, if not no need of processing further
                if (permissionLabel.getSharedUsers().contains(removedSharedUser)) {
                    for (String removedOperation : removedPermissionLabel.getOperations()) {
                        if (permissionLabel.getOperations().contains(removedOperation)) {
                            // if removed operation is allowed in another label,
                            //  that should not be unauthorized
                            List<String> duplicatedSharedUsers = new ArrayList<String>();
                            duplicatedSharedUsers.add(removedSharedUser);
                            List<String> duplicatedOperations = new ArrayList<String>();
                            duplicatedOperations.add(removedOperation);
                            PermissionLabel duplicatedPermissions =
                                    new PermissionLabel("DuplicatedPermissions",
                                                        duplicatedSharedUsers, duplicatedOperations);

                            otherAllowedPermissions.add(duplicatedPermissions);
                        }
                    }
View Full Code Here

Examples of org.wso2.carbon.messagebox.PermissionLabel

        if (!registryMessageBoxHandler.isMessageBoxExists(messageBoxId)) {
            throw new MessageBoxException("AWS.SimpleQueueService.NonExistentQueue");
        }
        sharedUsers = registryMessageBoxHandler.getSharedUsers(sharedUsers.toArray(
                new String[sharedUsers.size()]));
        PermissionLabel permissionLabel =
                new PermissionLabel(permissionLabelName, sharedUsers, operationsList);
        // Add permission on the Registry
        registryMessageBoxHandler.addPermission(messageBoxId, permissionLabel);

        // Authorize in the Authorization Manager
        authorizationHandler.addPermission(messageBoxId, permissionLabel);

        // allow consume/publish permissions
        List<String> operationList = permissionLabel.getOperations();
        for (String sharedUser : sharedUsers) {
            QueueUserPermission queueUserPermission = new QueueUserPermission();
            setPublishPermission(operationList, queueUserPermission, true);
            setConsumePermission(operationList, queueUserPermission, true);
            queueUserPermission.setUserName(sharedUser);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.