Package org.wso2.carbon.messagebox

Examples of org.wso2.carbon.messagebox.PermissionLabel


            PrivilegedCarbonContext.endTenantFlow();
        }
    }

    private void setTenantCredentialsInCarbonContext() {
        PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        cc.setTenantId(ownerTenantId);
        cc.setTenantDomain(ownerTenantDomain);
    }
View Full Code Here


     * @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

            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

        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

        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

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here

            // Adding static subscriptions
            List<Subscription> staticSubscriptionList =
                    eventSource.getSubscriptionManager().getStaticSubscriptions();
            for (Iterator<Subscription> iterator = staticSubscriptionList.iterator();
                 iterator.hasNext();) {
                Subscription staticSubscription = iterator.next();
                OMElement staticSubElem =
                        fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                staticSubElem.addAttribute(
                        fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
                OMElement filterElem =
                        fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                filterElem.addAttribute(fac.createOMAttribute("source", nullNS,
                        (String) staticSubscription.getFilterValue()));
                filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS,
                        (String) staticSubscription.getFilterDialect()));
                staticSubElem.addChild(filterElem);
                OMElement endpointElem =
                        fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                OMElement addressElem =
                        fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                addressElem.addAttribute(
                        fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
                endpointElem.addChild(addressElem);
                staticSubElem.addChild(endpointElem);
                if (staticSubscription.getExpires() != null) {
                    OMElement expiresElem =
                            fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                    fac.createOMText(expiresElem,
                            ConverterUtil.convertToString(staticSubscription.getExpires()));
                    staticSubElem.addChild(expiresElem);
                }
                evenSourceElem.addChild(staticSubElem);
            }
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

                    .getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
            if (clazz != null) {
                String className = clazz.getAttributeValue();
                try {
                    Class subscriptionManagerClass = Class.forName(className);
                    SubscriptionManager manager =
                            (SubscriptionManager) subscriptionManagerClass.newInstance();
                    Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
                    while (itr.hasNext()) {
                        OMElement propElem = (OMElement) itr.next();
                        String propName =
                                propElem.getAttribute(new QName("name")).getAttributeValue();
                        String propValue =
                                propElem.getAttribute(new QName("value")).getAttributeValue();
                        if (propName != null && !"".equals(propName.trim()) &&
                                propValue != null && !"".equals(propValue.trim())) {

                            propName = propName.trim();
                            propValue = propValue.trim();

                            PasswordManager passwordManager =
                                    PasswordManager.getInstance();
                            String key = eventSource.getName() + "." + propName;

                            if (passwordManager.isInitialized()
                                    && passwordManager.isTokenProtected(key)) {
                                eventSource.putConfigurationProperty(propName, propValue);
                                propValue = passwordManager.resolve(propValue);
                            }

                            manager.addProperty(propName, propValue);
                        }
                    }
                    eventSource.setSubscriptionManager(manager);
                    eventSource.getSubscriptionManager()
                            .init(); // Initialise before doing further processing, required for static subscriptions
View Full Code Here

TOP

Related Classes of org.wso2.carbon.messagebox.PermissionLabel

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.